TCP VS UDP
WHICH IS BETTER FOR REAL TIME COMMUNICATION?
Nurul Kaium EE 460
Introduction
TCP and UDP works in Transport Layer of OSI Model as well as TCP/IP Model
The function of the Transport Layer is to insure packets have no errors and
that all packets arrive and are correctly reassembled.
TCP
TCP (Transmission Control Protocol) enables two hosts to establish a
connection and exchange streams of data. TCP guarantees delivery of data and also guarantees that packets will be delivered in the same order in which they were sent. Two hosts connect before sending any data, sender lets receiver know that data is on the way; recipient acknowledges receipt of data (ACK) or denies receipt (NACK). The ACKing and NACKing is called handshaking.
It provides reliable packet delivery, packet sequencing and error
control.
Continued
TCP guarantees three things: that your data gets there, that it gets
there in order, and that it gets there without duplication. TCP does Flow Control , Congestion Control and error control.
What is Flow/Congestion/Error Control ?
Flow Control: Algorithms to prevent that the sender overruns the receiver
with information.
Congestion Control: Algorithms to prevent that the sender overloads the
network
Error Control: Algorithms to recover or conceal the effects from packet
losses
TCP in Real time communication
if we use TCP in real time communication and pocket loss occurred,
we get long delay to continue watching/listening because TCP is retransmitting lost packets and it takes time. For some real time applications, the loss of individual packets may not have a noticeable effect (e.g. video streams/audio stream/gaming/VoIP). TCP cannot conclude a transmission without all data in motion being explicitly acknowledged. That creates much latency in network . Too much latency is not suitable for real time communication.
UDP
UDP is a connectionless, unreliable Transport level service protocol. It
is primarily used for protocols that require a broadcast capability. It provides no packet sequencing, may lose packets, and does not check for duplicates.
It is used by applications that do not need a reliable transport service.
Continued
Packets may travel along different paths depending on the state of the
network. No two packets are guaranteed the same route. Each packet has a time-to-live (TTL) counter, which is updated when it is routed along to the next point in the network. When the timer expires, it will be discarded, and the recipient will not be notified. If a packet does arrive, it will always arrive intact. Packets that are corrupt or only partially delivered are discarded.
Udp in real time communication
UDP is most often used for real time applications because these
applications require less overhead(8 bytes whereas TCP has 20 bytes). They also do not need to be re-sequenced since packets that arrive late or out of order have no value. Real-time applications that demand up-to-the-second or better performance are candidates for UDP, as there are fewer delays due to error checking and flow control of TCP.
UDP does not have allocation of buffers, parameters, sequence #s.
Popular Applications That Use UDP
Real-time multimedia streaming Retransmitting lost/corrupted packets is not worthwhile By the time the packet is retransmitted, its too late E.g., telephone calls, video conferencing, gaming.
10
TCP vs. UDP Conclusion
TCP and UDP each have their place. In fact, some applications use a combination of
the two. For example, a lot of online multiplayer games use TCP for data transfer and UDP for things like a client heartbeat or to send opponent position updates. UDP is a good choice for real-time applications like VoIP to provide small jitter TCP is a good choice when we need reliability , flow control and congestion control.