# Alternative transport protocols in UAVCAN

**URL:** <https://forum.opencyphal.org/t/alternative-transport-protocols-in-uavcan/324>\
**Category:** Development & Maintenance\
**Created:** [January 11, 2019, 8:44pm UTC](https://forum.opencyphal.org/t/alternative-transport-protocols-in-uavcan/324 "2019-01-11T20:44:36Z")\
**Posts on this page:** 1\
**Showing post:** 16

<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:** [May 11, 2020, 11:10am UTC](https://forum.opencyphal.org/t/alternative-transport-protocols-in-uavcan/324/16 "2020-05-11T11:10:03Z")

</div>

The idea of profiles was poked by Scott a few months ago: [Future Proposal: Featherweight Profile](https://forum.opencyphal.org/t/future-proposal-featherweight-profile/743). Overall I think it’s probably a sensible direction to move towards but we have not yet accumulated the critical mass of alterations to justify breaking off a profile. Scott’s proposal is actually on the opposite side of the determinism/flexibility spectrum but the idea is the same.

> [@JediJeremy](#):
>
> That means you’ve also got a situation where you need to allocate lots of state to provide the alternate transport, so much it might potentially interfere with the CAN functions.

That’s not quite true. The way you described it sounds like the resource utilization of the protocol stack is a function of the network configuration which is not something that can be robustly controlled or predicted by a given node. The protocol is intentionally designed to ensure that a properly constructed implementation (stack) can demonstrate predictable behaviors regardless of the network configuration. It is also a [featured property of Libcanard](https://github.com/UAVCAN/libcanard/blob/bec890304a2888bc516416e4ebf252f761558b92/libcanard/canard.h#L493-L511) (which is optimized for real-time systems).

The bootloader allocates a well-known set of transfer-ID counters statically and its memory footprint is not dependent on which interfaces are active or which of the tasks are being performed. Now, _your case is different_ because certain base assumptions that the Specification makes about the underlying communication system are not met in your design (it’s too dynamic).

> [@JediJeremy](#):
>
> And said to myself “Well, in that case I’ll simply set it to Zero for my implementation and I’ll document that and then I won’t have to worry about it anymore.” - again, not nice and probably not what you wanted, but if you’re going to make things optional then some of us are going to take the easy way out. 🤪

But setting the transfer-ID timeout to zero (which is related to transfer reception) does not automatically relieve you from the requirement to keep transfer-ID states for outgoing transfers. If you just used zero TID for outgoing transfers you would run into compatibility issues with third-party software and hardware. But the following approach is viable from the protocol design standpoint (the RAM issue notwithstanding):

> [@JediJeremy](#):
>
> The alternative is storing even more monotonic Transfer ID’s per session for up to 2 seconds on what could be high-traffic links (10Mbit/s over WiFi) and that could easily overflow my microcontrollers’ limited RAM.

I think you might consider removing least-recently-used TID counters automatically when the RAM resources are exhausted. It’s probably the solution that minimally departs from the Specification.

In the longer term, we should consider extending the Specification or introducing a profile (the latter is much more convoluted) based on your experiments here. We are watching you, Jeremy.

> [@JediJeremy](#):
>
> re-reading it again I still don’t see if the protocol explicitly specifies what should happen if the transfers (not frames, but complete transfers) arrive out-of-sequence. The Transfer-ID timeout seems to de-duplicate identical transfer ID’s within that interval, but non-sequential transfers seem to be totally allowed.
> 
> I suppose that implicitly means that out-of-order transfers are allowed and should be responded to in the order they arrive? And if they’re service requests it’s up to the requester to sort it out when the replies get back?

Out-of-order transfers shall be dropped. This is explicitly required by _“Reassembled transfers shall form an ordered transfer sequence.”_ If you accept a transfer with an out-of-order TID, the set of transfers will not form an ordered sequence, hence a violation. Would you like to volunteer to add a footnote to clarify this, perhaps?

> [@JediJeremy](#):
>
> I guess that’s unavoidable. If a unit starts rebooting several times a second (eg from power brownouts) you have to accept transfers where the counter’s gone back to zero, although if it’s within the 2 second window they will be discarded.

You don’t have to. Normally, in our applications, a node works non-stop until the system is shut down (if ever). See, the transfer-ID timeout has to be sized properly to suit the trade-off (section **4.1.2.4 Behaviors** , non-normative blue box):

> Low transfer-ID timeout values increase the risk of undetected transfer duplication when such transfers are significantly delayed due to network congestion, which is possible with very low-priority transfers when the network load is high.  
> High transfer-ID timeout values increase the risk of an undetected transfer loss when a remote node suffers a loss of state (e.g., due to a software reset).

> [@JediJeremy](#):
>
> In cases where a frame arrives in small fragments (say over serial links) Would you prefer that timestamp to be sampled at the _start_ of the frame or the _end_ ? I could set the timestamp to the start frame delimiter, the first actual frame byte, last byte, or the end delimiter in cases where they’re measurably different. I’d probably pick the first frame byte, since frame delimiters can be ambiguous as to which one you’re getting.

I expect this to be specified once the UAVCAN/serial made it to the spec doc. The existing [experimental implementation in PyUAVCAN](https://github.com/UAVCAN/pyuavcan/blob/5752640d7719f679bfb51cf175826d87354a5603/pyuavcan/transport/serial/_stream_parser.py#L63) timestamps by the first delimiter of the frame (the ambiguity is resolved retroactively) and I think it’s probably optimal because the delimiter is the first element of the frame. Timestamping at the end is undesirable because the payload transmission time (and its escaping, if any) would skew the timestamp.

> [@JediJeremy](#):
>
> ps: when I’m re/quoting you, what’s the bbcode to include your name header thingy?

You can select the quoted text and then click “Quote”:

 ![image](https://forum.opencyphal.org/uploads/default/original/1X/123ec7acd41194990e794477c934707f724191af.png)

---

_[View the full topic](https://forum.opencyphal.org/t/alternative-transport-protocols-in-uavcan/324)._
