Basics of networking
10. Task of the transport layer
10.3. UDP protocol
Another protocol that implements some transport layer functions is the UDP protocol. However, in this case it is much simpler, as the protocol does not implement any mechanism to guarantee reliability of data delivery or flow control.
The UDP protocol is a simple connectionless protocol and its greatest advantage is the low overhead of control data added during the encapsulation process. UDP only adds 8 bytes of control data in the datagram. The header of a UDP datagram looks like this:
BIT (0) |
BIT (15) BIT (16) |
BIT (31) |
Source port (16) |
Destination port (16) |
|
Length (16) |
Checksum (16) |
|
Length of application layer (variable length) |
· Source port - specifies the application port from which data is to be sent.
· Destination port - specifies the application port to which data is sent.
· Length - 16-bit field specifying the length of the entire UDP datagram
· Checksum - a 16-bit field used to validate the data being sent.
Connectionless UDP means that the source host does not send any information to establish a connection with the destination host before the communication process starts. The general rule is that if a source device wants to start a transfer, it wants to send the data it has just completed without prior agreement.
Applications or services that use this transport protocol include DNS, DHCP, VoIP telephony and video streaming. These applications value speed over reliability of communication, or rather the need to receive all the data being transmitted. Imagine a situation where we are watching a video broadcast or playing a game with friends, like CS. It is difficult to compete in the game or watch anything when packets are late.
Why the delay? TCP segments, for example, are much larger than UDP datagrams, and TCP has to acknowledge the data delivered, so they are sent across the network in large volumes, more than in UDP.
For applications using this particular protocol, it can be tolerated, that occasionally packets may be lost or corrupted. For DNS services, if a datagram is lost, the query is simply resent to the DNS server. For applications using the TCP protocol, loss or confusion is no longer acceptable. Datagrams are received in the order in which they are received, and if there are multiple datagrams, it is the responsibility of the specific application to ensure that they are correctly assembled.