# Questions about the transfer-ID

**URL:** <https://forum.opencyphal.org/t/questions-about-the-transfer-id/1526>\
**Category:** Applications & Usage\
**Created:** [November 18, 2021, 12:39pm UTC](https://forum.opencyphal.org/t/questions-about-the-transfer-id/1526 "2021-11-18T12:39:15Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![xbron](https://forum.opencyphal.org/user_avatar/forum.opencyphal.org/xbron/32/985_2.png) [@xbron](https://forum.opencyphal.org/u/xbron)\
**Post date:** [November 18, 2021, 12:39pm UTC](https://forum.opencyphal.org/t/questions-about-the-transfer-id/1526/1 "2021-11-18T12:39:15Z")

</div>

Hello,  
I think that I don’t exactly understand how I should work with transfer-ID when using **Libcanard**. I have read [official repository](https://github.com/UAVCAN/libcanard), specification v1.0 and several open source libraries and repositories (like [107-Arduino-UAVCAN](https://github.com/107-systems/107-Arduino-UAVCAN)). But there is still one little question: should I create unique transfer-ID for each subject? In the official example of Libcanard one can find this comment:

```cpp
...
++my_message_transfer_id; // The transfer-ID shall be incremented after every transmission on this subject.
...

```

But in this example only one message is transferring. So suppose that if I have 3 publishing functions:

```cpp
void publishHeartbeat(CanardInstance* const canard, const uint32_t uptime);
void publishTemperature(CanardInstance* const canard, float temperature);
void publishSpeed(CanardInstance* const canard, float speed);

```

Should I create static variable for storing transfer-ID counter in each of this functions ?

Also is it correct that Libcanard takes care of the transfer-ID overflow (modulo 32)? If yes then is it necessary for user to do something like this ([ArduinoUAVCAN.cpp](https://github.com/107-systems/107-Arduino-UAVCAN/blob/master/src/ArduinoUAVCAN.cpp)):

```cpp
CanardTransferID ArduinoUAVCAN::getNextTransferId(CanardPortID const port_id)
{
  CanardTransferID const next_transfer_id = (_tx_transfer_map.count(port_id) > 0) ? ((_tx_transfer_map[port_id] + 1) % CANARD_TRANSFER_ID_MAX) : 0;
  _tx_transfer_map[port_id] = next_transfer_id;
  return next_transfer_id;
}

```

Thanks in advance.

---

<div class="post-metadata">

**Author:** ![pavel.kirienko](https://forum.opencyphal.org/user_avatar/forum.opencyphal.org/pavel.kirienko/32/9_2.png) [@pavel.kirienko](https://forum.opencyphal.org/u/pavel.kirienko)\
**Post date:** [November 18, 2021, 12:43pm UTC](https://forum.opencyphal.org/t/questions-about-the-transfer-id/1526/2 "2021-11-18T12:43:24Z")

</div>

> [@xbron](#):
>
> Should I create static variable for storing transfer-ID counter in each of this functions ?

Yes. Please find the relevant statement highlighted:

 ![image](https://forum.opencyphal.org/uploads/default/original/2X/b/b58806caf2540bd1da823966e5f102cef5746a78.png)

> [@xbron](#):
>
> Also is it correct that Libcanard takes care of the transfer-ID overflow (modulo 32)?

Yes.

> [@xbron](#):
>
> If yes then is it necessary for user to do something like this ([ArduinoUAVCAN.cpp](https://github.com/107-systems/107-Arduino-UAVCAN/blob/master/src/ArduinoUAVCAN.cpp)):

Not necessary, but it’s not an error either.

---

<div class="post-metadata">

**Author:** ![xbron](https://forum.opencyphal.org/user_avatar/forum.opencyphal.org/xbron/32/985_2.png) [@xbron](https://forum.opencyphal.org/u/xbron)\
**Post date:** [November 18, 2021, 3:21pm UTC](https://forum.opencyphal.org/t/questions-about-the-transfer-id/1526/3 "2021-11-18T15:21:52Z")

</div>

Thank you very much, Pavel!
