Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Why Does RTP use UDP instead of TCP?

I wanted to know why UDP is used in RTP rather than TCP ?. Major VoIP Tools used only UDP as i hacked some of the VoIP OSS.

like image 794
Mahesh Avatar asked Dec 12 '08 05:12

Mahesh


People also ask

Why would you use UDP instead of TCP?

TCP is a connection-oriented protocol, whereas UDP is a connectionless protocol. A key difference between TCP and UDP is speed, as TCP is comparatively slower than UDP. Overall, UDP is a much faster, simpler, and efficient protocol, however, retransmission of lost data packets is only possible with TCP.

Why is UDP used for real-time data?

UDP also boasts multicast support, unlocking capabilities such as service discovery and broadcasting. Its lack of retransmission delays makes it suitable for real-time applications such as Voice over IP (VoIP), online games, and live video streaming.

Is RTP a part of UDP?

Audio or video data blocks from the transmission side of a multimedia application are wrapped in RTP packets, and each RTP packet is wrapped in a UDP segment. This means that RTP is a protocol that works on top of UDP. The Internet Engineering Task Force (IETF) defined RTP in 1996.

Why real-time data Cannot use TCP protocol give reason?

TCP is not suitable for real-time applications as the retransmissions can lead to high delay and cause delay jitter, which significantly degrades the quality. In addition, it does not support multicast. Also, congestion control mechanisms, namely slow start, are not suitable for audio or video media transmission.


2 Answers

As DJ pointed out, TCP is about getting a reliable data stream, and will slow down transmission, and re-transmit corrupted packets, in order to achieve that.

UDP does not care about reliability of the communication, and will not slow down or re-transmit data.

If your application needs a reliable data stream, for example, to retrieve a file from a webserver, you choose TCP.

If your application doesn't care about corrupted or lost packets, and you don't need to incur the additional overhead to provide the additional reliability, you can choose UDP instead.

VOIP is not significantly improved by reliable packet transmission, and in fact, in some cases things in TCP like retransmission and exponential backoff can actually hurt VOIP quality. Therefore, UDP was a better choice.

like image 164
Stobor Avatar answered Oct 05 '22 16:10

Stobor


A lot of good answers have been given, but I'd like to point one thing out explicitly:

Basically a complete data stream is a nice thing to have for real-time audio/video, but its not strictly necessary (as others have pointed out):

The important fact is that some data that arrives too late is worthless. What good is the missing data for a frame that should have been displayed a second ago?

If you were to use TCP (which also guarantees the correct order of all data), then you wouldn't be able to get to the more up-to-date data until the old one is transmitted correctly. This is doubly bad: you have to wait for the re-transmission of the old data and the new data (which is now delayed) will probably be just as worthless.

So RTP does some kind of best-effort transmission in that it tries to transfer all available data in time, but doesn't attempt to re-transmit data that was lost/corrupted during the transfer (*). It just goes on with life and hopes that the more important current data gets there correctly.

(*) actually I don't know the specifics of RTP. Maybe it does try to re-transmit, but if it does then it won't be as aggressive as TCP is (which won't ever accept any lost data).

like image 30
Joachim Sauer Avatar answered Oct 05 '22 16:10

Joachim Sauer