The User Datagram Protocol: Aleksander Malinowski Bogdan M. Wilamowski
The User Datagram Protocol: Aleksander Malinowski Bogdan M. Wilamowski
The User Datagram Protocol: Aleksander Malinowski Bogdan M. Wilamowski
Bogdan M. Wilamowski
Auburn University
17.1 Introduction
User Datagram Protocol (UDP) is a part of TCP/IP protocol suite. It provides full transport layer services to applications. It belongs to the transport layer in the OSI model as shown in Figure 17.1. UDP provides a connection between two processes at both ends of the transmission. This connection is provided with minimal overhead, without flow control or acknowledgement of received data. The minimal error control is provided by ignoring (dropping) received packets that fail the checksum test.
UDP Datagram
UDP datagrams have a constant size 8-byte header prepended to the transmitted data as shown in Figure 17.3. The meaning of each header field is described below.
17-2
Transport layer TCP Network layer IGMP ICMP IP Data link layer Underlying LAN or WAN technology Physical layer ARP RARP UDP
Source Port Address this is a 16-bit field that contains a port number of the process that sends options or data in this segment. Destination Port Address this is a 16-bit field that contains a port number of the process that is supposed to receive options or data carried by this segment. Total Length this is a 16-bit field that contains the total length of the packet. Although the number could be in the range from 0 to 65,535 the minimum length is 8 bytes, which correspond to the packet with the header and no data. The maximum length is 65,507 because 20 bytes are used by the IP header and 8 bytes are used by the UDP header. Thus, this information is redundant to the packet length stored in the IP header. Checksum this 16-bit field contains the checksum. The checksum is calculated by Initially filling it with 0s. Adding a pseudoheader with information from the IP protocol as illustrated in Figure 17.4. Treating the whole segment with the pseudoheader prepended as a stream of 16-bit numbers. If the number of bytes is odd, 0 is appended at the end. Adding all 16-bit numbers using 1s complements binary arithmetic. Complementing the result. This complemented result is inserted into the checksum field.
17-3
8 bytes
Header
Data
Pseudoheader
ALL 0s
Header
Checksum verification the receiver calculates the new checksum for the received packet that includes the original checksum, after adding the so-called pseudoheader (see Figure 17.4). If the new checksum is nonzero, then the datagram is corrupt and is discarded. In case of UDP, the use of checksum is optional. If it is not calculated, then the field is filled with 0s. The receiver can determine whether checksum was calculated by inspecting the field. Even in case the checksum is 0, the field does not contain 0 as the calculated checksum is complemented at the end of the process, and negative 0 (the field filled with 1s) is stored.
17-4
TABLE 17.1
Port 7 9 11 13 17 19 37 53 67 68 69 111 123 161 162
Protocol Echo Discard Users Daytime Quote Chargen Time Nameserver Bootps Bootpc TFTP RPC NTP SNMP SNMP
are registered and controlled by Internet Assigned Numbers Authority (IANA). Registered ports are also registered by IANA to avoid possible conflicts among different applications attempting to use the same port for listening to incoming connections. Ephemeral ports are also called dynamic ports. These ports are used by outgoing connections that are typically assigned the first available port above 49,151. Some operating systems may not follow IANA recommendations and treat the registered ports range as ephemeral.
Additional Reading
[1] Comer, D., Internetworking with TCP/IP Vol.1: Principles, Protocols, and Architecture, 4th ed., Prentice-Hall, Upper Saddle River, NJ, 2000. [2] Comer, D. et al., Internetworking with TCP/IP, Vol. III: Client-Server Programming and Applications, Linux/Posix Sockets Version, Prentice-Hall, Upper Saddle River, NJ, 2000. [3] Forouzan, B.A., TCP/IP Protocol Suite, 2nd ed., McGraw-Hill, New York, 2003. [4] Hall, E.A., Internet Core Protocols: The Definitive Reference, OReilly, Sebastopol, CA, 2000. [5] Leon-Garcia, A. and I/ Widjaja, Communication Networks, McGraw-Hill, New York, 2000. [6] Peterson, L.L. and B.S. Davie, Computer Networks: A System Approach, 2nd ed., Morgan Kaufmann Publishers, San Francisco, CA, 2000.
17-5
[7] RFC0768/STD0006, Postel, J., User Datagram Protocol, August 1980, http://www.rfc-editor.org/ [8] RFC1791, Sung, T., TCP And UDP Over IPX Networks With Fixed Path MTU, April 1995, http:// www.rfc-editor.org/ [9] RFC2675, Borman, D. et al., IPv6 Jumbograms, August 1999, http://www.rfc-editor.org/ [10] STD2, Reynolds, J. and J. Postel, Assigned Numbers, October 1994, http://www.rfc-editor.org/ [11] Web Site for IANA - Internet Assigned Numbers Authority, http://www.iana.org/ [12] Web Site for RFC Editor, http://www.rfc-editor.org/