TCP vs UDP

214 views
Skip to first unread message

Dieter Van de Walle

unread,
Apr 4, 2023, 8:48:06 AM4/4/23
to MAVLink
Hi all,

I'm wondering what the drawbacks are for using TCP vs UDP for the connection between the flight controller (via mavlink-router) and GCS over a semi-reliable connection (4G)?

Is there any difference in behaviour for TCP vs UDP?
For example when a connection interruption occurs:
- In the case of UDP I assume packets will just get discarded
- and TCP will try to retransmit as long as the connection is established

I assume TCP might be annoying when sending control commands and retransmissions occur? Ie. commands "batched up" and processed when the connection is re-established. Or does the MAVlink protocol have some kind of features to deal with this?
(Still studying up on mavlink, forgive my ignorance!)

In general, I am looking for any advice or experiences on using TCP vs UDP for the mavlink connection between device and GCS.
In my specific case I'm dealing with a network that is not UDP friendly, so I wonder if I can simply switch to TCP, or if I should invest in changing the network setup.

Best regards,

Dieter Van de Walle

Hamish Willee

unread,
Apr 4, 2023, 9:14:46 PM4/4/23
to MAVLink
Hi Dieter,

My understanding is that almost all current systems send the packets over UDP on IP connections, and that this is because TCP/IP is more costly to no additional benefit in the MAVLink context. 

MAVLink itself doesn't know what protocol you run it over - most of what we define is an "over the wire" serial format. I think that if you run over UDP or TCP/IP then MAVLink just gets inefficiently packed into IP packets and sent. MAVLink packets have a sequence number and recipients should dump any duplicates they have already received.

So while I'm not an expert on any of this, I think MAVLink is robust enough to cope with using either underlying protocol, but for efficiency reasons UDP is preferred.

Perhaps someone else on this channel will chime in if I am incorrect.

Regards
Hamish

 PS I don't understand how a network could be TCP/IP but not UDP friendly, but that is perhaps my ignorance. I think you might bet more informed discussions asking this kind of question on a flight-stack specific forum, where people are trying this out.
Reply all
Reply to author
Forward
0 new messages