1

I am new to networking and trying getting some basic concepts. I will really appreciate if someone can tell me why using TCP in real-time systems is a bad idea? What makes UDP preferable for real-time systems?

1
  • Using TCP in real-time systems is a bad idea because it adds latency, jitter, and blocking. TCP retransmits lost packets, enforces in-order delivery, and applies congestion control — all of which can pause or delay data. In real-time systems, late data is useless. UDP is preferred because it’s fast, lightweight, and non-blocking. It doesn’t retransmit, doesn’t reorder packets, and doesn’t slow down due to congestion control. You get lower and more predictable latency, even if some packets are lost. Commented yesterday

3 Answers 3

8

In short TCP is designed to achieve perfect transmission above all else. You will get exactly what has been sent, in the exact order it was sent, or you will get nothing at all.

The problem with this is that TCP will get hung up trying to re-transmit data until it is received properly, but in a real-time system, the data it's trying to re-transmit is useless because it's already out of date; AND the data you actually want has to wait for the data you don't want to clear the stack, before it can be sent.

This article explains it much more eloquently

Sign up to request clarification or add additional context in comments.

3 Comments

TCP is also much more heavily buffered. Calling send() on a TCP socket just buffers the data for transmission at TCP's discretion, so you have less control.
To add an illustration and details to the previous post: Imagine yourself using voip (voice over ip like Skype call) from the UK to someone in Japan. If for every lost packet tcp would start retransmitting you would start hearing some "words" being mixed between the newer ones and the older ones which would make the communications impossible practically speaking. It's not a problem losing some packets in Udp, they won't impact the whole communication. Typically not like a missing element in a webpage.
But... TCP can be used in a way that makes it comparable to UDP in real-time systems. I dedicated an article on Gamasutra on this. Please see this section in particular: gamasutra.com/blogs/AlessandroAlinone/20131127/205705/…
1

As stated before UDP is used over TCP for Real Time Services(RTS), mainly because of how simple a packet of UDP is compared to TCP as the latter puts more emphasis on error correction and reliability.

TCP packets are bigger compared to UDP packets and much more carefully transmitted in order to maintain their integrity, where a receiver acknowledges each and every packet of TCP that is sent which is great when sending sensitive data but it will become a bottleneck in an RTS where state is to be kept as updated as possible and usually data transmitted is 100-1000 KB/s and loosing few KBs won't wreck your service when its implemented with UDP.

Comments

0

A TCP protocol is oriented to the correct transmission of data, for this it makes a connection before sending data called ‘Three way handshake’ in which by means of three packets it makes a synchronisation and recognition between transmitter and receiver which ensures that the data path will be carried out, however this process will cause a considerable delay in the sending of data that can cause the receiver to listen to or receive data with a considerable delay and even with messages being mixed up.

However, UDP, despite skipping the connection stage and therefore ensuring a higher data transmission speed, also has the disadvantage of not guaranteeing that the data being sent will arrive correctly at its destination, which is necessary in the operation of real-time systems.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.