The User Datagram Protocol(UDP) is called a connectionless, unreliable transport protocol. It does not add anything to the services of IP except to provide process to process communication instead of host to host communication.
UDP packets, called user datagrams, have a fixed size header of 8 bytes. The below diagram shows the format of a user datagram.
User datagram format:
Source port number: This is the port number used by the process running on the source host. It is 16 bits long, which means that the port number can range from 0 to 65,535. If the source host is the client (a client sending a request), the port number is an ephemeral port number requested by the process and chosen by the UDP software running on the source host. If the source host is the server (a server sending a response), the port number is a well-known port number.
Destination port number: This is the port number used by the process running on the destination host. It is also 16 bits long. If the destination host is the server (a client sending a request), the port number is a well-known port number. If the destination host is the client (a server sending a response), the port number is an ephemeral port number. The server copies the ephemeral port number that it has received in the request packet.
Length: This is a 16 –bit field that defines the total length of the user datagram (header plus data). The 16 bits can define a total length of 0 to 65,535 bytes.
UDP length=IP length – IP header’s length.
Checksum: This field is used to detect errors over the entire user datagram (header plus data).
The checksum includes three sections: a pseudoheader, the UDP header, and the data coming from the application layer.
The pseudoheader is the part of the header of the IP packet in which the user datagram is to be encapsulated with some fields filled with 0’s
If the checksum does not include the pseudoheader, a user...