8.3. User Datagram Protocol (UDP)The user datagram protocol (UDP) is another transport-layer protocol that is placed on top of the network layer. UDP is a connectionless protocol, as no handshaking between sending and receiving points occurs before sending a segment. UDP does not provide a reliable service. The enhancement provided by UDP over IP is its ability to check the integrity of flowing packets. IP is capable of delivering a packet to its destination but stops delivering them to an application. UDP fills this gap by providing a mechanism to differentiate among multiple applications and deliver a packet to the desired application. UDP can perform error detection to a certain extent but not to the level that TCP can. 8.3.1. UDP SegmentThe format of the UDP segment is shown in Figure 8.4. The segment starts with the source port , followed by the destination port . These port numbers are used to identify the ports of applications at the source or the destination, respectively. The source port identifies the application that is sending the data. The destination port helps UDP to demultiplex the packet and directs it to the right application. The UDP length field indicates the length of the UDP segment, including both the header and the data. UDP checksum specifies the computed checksum when transmitting the packet from the host. If no checksum is computed, this field contains all zeroes. When this segment is received at the destination, the checksum is computed; if there is an error, the packet is discarded. Figure 8.4. User datagram protocol segmentUDP takes messages from the application process, attaches source and destination port number fields and two other fields, and makes this segment available to the network layer. The network layer encapsulates the segment into an IP datagram (packet) and finds the best path to deliver the segment to the other end host. 8.3.2. Applications of TCP and UDPAlthough TCP provides a reliable service and UDP does not, many applications fit better in the communication system by using UDP, for the following reasons:
The first category includes such applications as e-mail, the Web, remote terminal access , and file transfer . These applications run over TCP, as they all require reliable data-transfer service. The second category of applications, including DNS , RIP routing table updates , and SNMP network management, run over UDP rather than over TCP. For example, RIP updates are transmitted periodically, and reliability may not be an issue, as a more recent update can always replace a lost one. |