3.3 Connectionless Transport: UDP
💡 Aside from the multiplexing/demultiplexing function and some light error checking, UDP adds nothing to IP.
UDP transport proticol only adds source, dest port number and two other small fields. Since there is no handshaking, it is called *connectionless.*
DNS is example of application layer protocol which uses UDP.
- DNS query → UDP → Add header → Network Layer → datagram encapsulation → DNS name server
UDP may resend if there is no reply.
Benefits of UDP
- Finer application-level control over what data is sent, and when → Real time applications require minimum sending rate. Therefore reducing delay is important and can tolerate some data loss. Such applications can use UDP and implement additional funcitons on its own.
- No Connection establishment → No delay from handshaking. Chrome browser uses UDP based transport protocol, QUIC (Quick UDP Internet Connection), and implements reliablity on application-layer protocol .
- No Connection State → Since server with UDP does not record state, it can support more clients when compared to running on TCP.
- Small Packet header overhead → UDP has 8 byte, TCP has 20 byte.
However, lack of congestion control of UDP can block TCP sessions.
So application with reliablity built in and using UDP, can have the best of both world.
3.3.1 UDP Segment Structure
Source, Dest port for target process. Length for different data segments, checksum for receiving host for error checking. IP header in network layer also has checksum header.
3.3.2 UDP Checksum
- UDP Sender calculates 1s complement of sum of 16bit words in the segment
- Result in checksum field.
- Receiver adds all 16bits plus the complement.
- If normal, it should be all 11111111111. Inclusion of 0 means error.
UDP checks but doesn’t do any recover. May discard message or pass data with warning.
End-End Principle : When a functionality(like error detection) is implemented on end-end basis, “functions placed at lower levels may be redundant or of little value when compared to cost of providing them at higher level”.