11 
User Datagram 
Protocol 
(UDP)
UDP is a communications protocol that offers a limited amount of service 
when messages are exchanged between computers in a network that 
uses the Internet Protocol (IP). UDP is an alternative to the 
Transmission Control Protocol (TCP) and, together with IP, is sometimes 
referred to as UDP/IP. Like the Transmission Control Protocol, UDP uses 
the Internet Protocol to actually get a data unit (called a datagram) from 
one computer to another. 
22 
Unlike TCP, however, UDP does not provide the service of 
dividing a message into packets (datagrams) and reassembling it at the 
other end. Specifically, UDP doesn't provide sequencing of the packets 
that the data arrives in. This means that the application program that 
uses UDP must be able to make sure that the entire message has arrived 
and is in the right order. Network applications that want to save 
processing time because they have very small data units to exchange 
(and therefore very little message reassembling to do) may prefer UDP 
to TCP. The Trivial File Transfer Protocol (TFTP) uses UDP instead of 
TCP.
The User Datagram Protocol (UDP) is one of the 
core members of the Internet protocol suite (the set 
of network protocols used for the Internet). With 
UDP, computer applications can send messages, in 
this case referred to as datagrams , to other hosts 
on an Internet Protocol (IP) network without prior 
communications to set up special transmission 
channels or data paths. The protocol was designed 
by David P. Reed in 1980 and formally defined in 
RFC 768. 
33
4
5
UDP is located between the application layer 
and the IP layer, and serves as the intermediary 
between the application programs and the 
network operations. 
66
77 
Figure 14.1 Position of UDP in the TCP/IP protocol suite
Applications 
Numerous key Internet applications use UDP, including: the 
Domain Name System (DNS), where queries must be fast and 
only consist of a single request followed by a single reply 
packet, the Simple Network Management Protocol (SNMP), 
the Routing Information Protocol (RIP)[2] and the Dynamic Host 
Configuration Protocol (DHCP). 
Voice and video traffic is generally transmitted using UDP 
many businesses are finding that a recent increase in UDP 
traffic from these real-time applications is hindering the 
performance of applications using TCP, such as point of sale, 
accounting, and database systems. When TCP detects packet 
loss, 
88
99 
USER DATAGRAM 
UDP packets, called user datagrams, have a 
fixed-size header of 8 bytes.
Example 
The following is a dump of a UDP header in 
hexadecimal format. 
1100 
a. What is the source port number? 
b. What is the destination port number? 
c. What is the total length of the user datagram? 
d. What is the length of the data? 
f. What is the client process?
Solution 
a. The source port number is the first four 
hexadecimal digits (CB84)16 or 52100. 
b. The destination port number is the second four 
hexadecimal digits (000D)16 or 13. 
c. The third four hexadecimal digits (001C)16 define 
the length of the whole UDP packet as 28 bytes. 
d. The length of the data is the length of the whole 
packet 
minus the length of the header, or 28 – 8 = 20 
bytes. 
f. The client process is the Daytime (see Table 14.1). 
1111
1122
1133 
Encapsulation and decapsulation
1144 
Queues in UDP
Multiplexing and demultiplexing 
TCP/IIPP PPrroottooccooll SSuuiittee 1155
1166 
UDP is an example of the 
Note 
connectionless simple protocol with the 
exception of an optional checksum 
added to packets for error detection.
A client-server application such as DNS uses the 
services of UDP because a client needs to send a 
short request to a server and to receive a quick 
response from it. The request and response can each 
fit in one user datagram. Since only one message is 
exchanged in each direction, the connectionless 
feature is not an issue; the client or server does not 
worry that messages are delivered out of order. 
1177 
Why UDP?
A client-server application such as SMTP which is 
used in electronic mail, cannot use the services of 
UDP because a user can send a long e-mail 
message, which may include multimedia (images, 
audio, or video). If the application uses UDP and the 
message does not fit in one single user datagram, the 
message must be split by the application into 
different user datagrams. Here the connectionless 
service may create problems. The user datagrams 
may arrive and be delivered to the receiver 
application out of order. The receiver application may 
not be able to reorder the pieces. This means the 
connectionless service has a disadvantage for an 
application program that sends long messages. 
1188
Assume we are downloading a very large text file 
from the Internet. We definitely need to use a 
transport layer that provides reliable service. We 
don’t want part of the file to be missing or corrupted 
when we open the file. The delay created between 
the delivery of the parts are not an overriding 
concern for us; we wait until the whole file is 
composed before looking at it. In this case, UDP is 
not a suitable transport layer. 
1199
2200 
UDP PACKAGE 
To show how UDP handles the sending and 
receiving of UDP packets, we present a 
simple version of the UDP package. 
We can say that the UDP package 
involves five components: a control-block 
table, input queues, a control-block module, 
an input module, and an output module.
UDP design 
TCP/IIPP PPrroottooccooll SSuuiittee 2211
2222
2233
2244
2255
The first activity is the arrival of a user datagram with destination port number 
52,012. The input module searches for this port number and finds it. Queue 
number 38 has been assigned to this port, which means that the port has been 
previously used. The input module sends the data to queue 38. The control-block 
table does not change. 
After a few seconds, a process starts. It asks the operating system for a port 
number and is granted port number 52,014. Now the process sends its ID 
(4,978) and the port number to the control-block module to create an entry in 
the table. The module takes the first FREE entry and inserts the information 
received. The module does not allocate a queue at this moment because no 
user datagrams have arrived for this destination (see Table 14.6). 
A user datagram now arrives for port 52,011. The input module checks 
the table and finds that no queue has been allocated for this 
destination since this is the first time a user datagram has arrived for 
this destination. The module creates a queue and gives it a number 
(43). See Table 14.7. 
After a few seconds, a user datagram arrives for port 52,222. The 
input module checks the table and cannot find an entry for this 
destination. The user datagram is dropped and a request is made 
to ICMP to send an unreachable port message to the source. 
2266
2277
2288 
Reliability and congestion control solutions 
Lacking reliability, UDP applications must generally be willing 
to accept some loss, errors or duplication. Some applications, 
such as TFTP, may add rudimentary reliability mechanisms 
into the application layer as needed. 
Most often, UDP applications do not employ reliability 
mechanisms and may even be hindered by them. Streaming 
media, real-time multiplayer games and voice over IP (VoIP) 
are examples of applications that often use UDP. In these 
particular applications, loss of packets is not usually a fatal 
problem. If an application requires a high degree of reliability, 
a protocol such as the Transmission Control Protocol may be 
used instead.
2299
3300 
Thanvi

User Datagram protocol For Msc CS

  • 1.
    11 User Datagram Protocol (UDP)
  • 2.
    UDP is acommunications protocol that offers a limited amount of service when messages are exchanged between computers in a network that uses the Internet Protocol (IP). UDP is an alternative to the Transmission Control Protocol (TCP) and, together with IP, is sometimes referred to as UDP/IP. Like the Transmission Control Protocol, UDP uses the Internet Protocol to actually get a data unit (called a datagram) from one computer to another. 22 Unlike TCP, however, UDP does not provide the service of dividing a message into packets (datagrams) and reassembling it at the other end. Specifically, UDP doesn't provide sequencing of the packets that the data arrives in. This means that the application program that uses UDP must be able to make sure that the entire message has arrived and is in the right order. Network applications that want to save processing time because they have very small data units to exchange (and therefore very little message reassembling to do) may prefer UDP to TCP. The Trivial File Transfer Protocol (TFTP) uses UDP instead of TCP.
  • 3.
    The User DatagramProtocol (UDP) is one of the core members of the Internet protocol suite (the set of network protocols used for the Internet). With UDP, computer applications can send messages, in this case referred to as datagrams , to other hosts on an Internet Protocol (IP) network without prior communications to set up special transmission channels or data paths. The protocol was designed by David P. Reed in 1980 and formally defined in RFC 768. 33
  • 4.
  • 5.
  • 6.
    UDP is locatedbetween the application layer and the IP layer, and serves as the intermediary between the application programs and the network operations. 66
  • 7.
    77 Figure 14.1Position of UDP in the TCP/IP protocol suite
  • 8.
    Applications Numerous keyInternet applications use UDP, including: the Domain Name System (DNS), where queries must be fast and only consist of a single request followed by a single reply packet, the Simple Network Management Protocol (SNMP), the Routing Information Protocol (RIP)[2] and the Dynamic Host Configuration Protocol (DHCP). Voice and video traffic is generally transmitted using UDP many businesses are finding that a recent increase in UDP traffic from these real-time applications is hindering the performance of applications using TCP, such as point of sale, accounting, and database systems. When TCP detects packet loss, 88
  • 9.
    99 USER DATAGRAM UDP packets, called user datagrams, have a fixed-size header of 8 bytes.
  • 10.
    Example The followingis a dump of a UDP header in hexadecimal format. 1100 a. What is the source port number? b. What is the destination port number? c. What is the total length of the user datagram? d. What is the length of the data? f. What is the client process?
  • 11.
    Solution a. Thesource port number is the first four hexadecimal digits (CB84)16 or 52100. b. The destination port number is the second four hexadecimal digits (000D)16 or 13. c. The third four hexadecimal digits (001C)16 define the length of the whole UDP packet as 28 bytes. d. The length of the data is the length of the whole packet minus the length of the header, or 28 – 8 = 20 bytes. f. The client process is the Daytime (see Table 14.1). 1111
  • 12.
  • 13.
  • 14.
  • 15.
    Multiplexing and demultiplexing TCP/IIPP PPrroottooccooll SSuuiittee 1155
  • 16.
    1166 UDP isan example of the Note connectionless simple protocol with the exception of an optional checksum added to packets for error detection.
  • 17.
    A client-server applicationsuch as DNS uses the services of UDP because a client needs to send a short request to a server and to receive a quick response from it. The request and response can each fit in one user datagram. Since only one message is exchanged in each direction, the connectionless feature is not an issue; the client or server does not worry that messages are delivered out of order. 1177 Why UDP?
  • 18.
    A client-server applicationsuch as SMTP which is used in electronic mail, cannot use the services of UDP because a user can send a long e-mail message, which may include multimedia (images, audio, or video). If the application uses UDP and the message does not fit in one single user datagram, the message must be split by the application into different user datagrams. Here the connectionless service may create problems. The user datagrams may arrive and be delivered to the receiver application out of order. The receiver application may not be able to reorder the pieces. This means the connectionless service has a disadvantage for an application program that sends long messages. 1188
  • 19.
    Assume we aredownloading a very large text file from the Internet. We definitely need to use a transport layer that provides reliable service. We don’t want part of the file to be missing or corrupted when we open the file. The delay created between the delivery of the parts are not an overriding concern for us; we wait until the whole file is composed before looking at it. In this case, UDP is not a suitable transport layer. 1199
  • 20.
    2200 UDP PACKAGE To show how UDP handles the sending and receiving of UDP packets, we present a simple version of the UDP package. We can say that the UDP package involves five components: a control-block table, input queues, a control-block module, an input module, and an output module.
  • 21.
    UDP design TCP/IIPPPPrroottooccooll SSuuiittee 2211
  • 22.
  • 23.
  • 24.
  • 25.
  • 26.
    The first activityis the arrival of a user datagram with destination port number 52,012. The input module searches for this port number and finds it. Queue number 38 has been assigned to this port, which means that the port has been previously used. The input module sends the data to queue 38. The control-block table does not change. After a few seconds, a process starts. It asks the operating system for a port number and is granted port number 52,014. Now the process sends its ID (4,978) and the port number to the control-block module to create an entry in the table. The module takes the first FREE entry and inserts the information received. The module does not allocate a queue at this moment because no user datagrams have arrived for this destination (see Table 14.6). A user datagram now arrives for port 52,011. The input module checks the table and finds that no queue has been allocated for this destination since this is the first time a user datagram has arrived for this destination. The module creates a queue and gives it a number (43). See Table 14.7. After a few seconds, a user datagram arrives for port 52,222. The input module checks the table and cannot find an entry for this destination. The user datagram is dropped and a request is made to ICMP to send an unreachable port message to the source. 2266
  • 27.
  • 28.
    2288 Reliability andcongestion control solutions Lacking reliability, UDP applications must generally be willing to accept some loss, errors or duplication. Some applications, such as TFTP, may add rudimentary reliability mechanisms into the application layer as needed. Most often, UDP applications do not employ reliability mechanisms and may even be hindered by them. Streaming media, real-time multiplayer games and voice over IP (VoIP) are examples of applications that often use UDP. In these particular applications, loss of packets is not usually a fatal problem. If an application requires a high degree of reliability, a protocol such as the Transmission Control Protocol may be used instead.
  • 29.
  • 30.