Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

If UDP is unreliable why is it used at transport layer

Sorry for what is a stupid question.

Function of transport layer is reliable delivery of messages. UDP is inherently unreliable, why do we use it at Transport layer then?

Thanks

EDIT: Just to clarify, I have read the Wiki and other sources. My question is

UDP is Unreliable (I know why and the advantages and where it is used etc.) , why not use it(UDP) at some other layer, rather than Transport layer which implies reliability.

like image 369
Anon Avatar asked Aug 14 '12 02:08

Anon


2 Answers

Sometimes it is more important that the data be sent quickly and without pauses than that the stream be reliable. DNS uses UDP because the transaction between a DNS server and client consists of only one packet each way. If the packet is lost, it will be re transmitted at the request of the client.

Similarly, streaming video often uses UDP as a transport protocol because the occasional loss of a packet is acceptable. It is preferable that the image quality suffer as a result of lost packets, rather than the video stream suffer jitter or pauses (lag) as a result of TCP synchronization.

Games also often use UDP, sacrificing engine accuracy for improved speed/user experience.

These and more examples can be found in the relevant portions of the wikipedia article.

EDIT

UDP is used at the transport layer because it is a transport layer protocol. It provides "provides end-to-end communication services for applications" (RFC1122).

Reliability services are optional for transport layer protocols.

like image 147
Michael Graczyk Avatar answered Oct 01 '22 18:10

Michael Graczyk


... rather than Transport layer which implies reliability

There's more than one dimension within "reliability." It's interesting to note that UDP is reliable in that it provides a checksum to prevent against corruption.

Stream protocols like TCP create problems for latency-sensitive applications. For latency-sensitive apps, UDP's natural limitation (to shed traffic during congestion) is a huge boon.

why not use it(UDP) at some other layer

IP datagrams are designed to be small enough to make the next hop transit. UDP datagrams can span IP datagrams, so there's some value added there. But if TCP were a layer above UDP, it would be limited by UDP's semantics (TCP ports are bound to a connection, UDP datagrams are not).

like image 24
Brian Cain Avatar answered Oct 01 '22 18:10

Brian Cain