简体   繁体   中英

Choosing Network protocol TCP or UDP for remote desktop application?

I want to create teamviewer like application in C#. Which protocol is better TCP or UDP in terms of performance?

UDP simply sends network messages without enforcing the order, eg they can come in out of order, and without checking that the messages got through.

TCP enforces packet ordering, and has a method of checking is messages actually got through. So it is more reliable.

In terms of throughput - eg amount of data transferred in a given time - they will in practice be about the same.

The advantage of UDP is lower latency. Because it doesn't check for ordering or confirm receipt of packets - your program receives the packets as they arrive. No waiting confirmations.

You want to use UDP when low latency is critical and the messages are small, and your program is tolerant to missing packets and out of order packets. I've only ever seen it used in video games ( like shooters ) for sending user input.

"teamviewer" to me implies video - large amounts of data - so use TCP.

UDP will almost always provide better performance than TCP, at the cost of reliability.


The "reliability" problem of UDP nowdays is basically a formality, it will always go through, unless you literally have connection problems. In a teamviewer-like application, missing a packet won't have much impact, since all it sends are inputs from one side and "pictures" from the other.

Teamviewer used UDP as their primary protocol for establishing connection to the remote computer. They use TCP only when UDP fails... and I did not find any problem with their UDP connections with respect to accessibility.. If there was any issue with UDP, they would have not made it as their primary protocol.. What we need to find is how they managed to optimize their UDP connections..

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM