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?
- 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.Aaron Gutierrez– Aaron Gutierrez2025-11-25 03:47:33 +00:00Commented yesterday
3 Answers
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
3 Comments
send() on a TCP socket just buffers the data for transmission at TCP's discretion, so you have less control.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
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.