UDP

Chapter 11
User Datagram
Protocol
Objectives
Upon completion you will be able to:
• Be able to explain process-to-process communication
• Know the format of a UDP user datagram
• Be able to calculate a UDP checksum
• Understand the operation of UDP
• Know when it is appropriate to use UDP
• Understand the modules in a UDP package
TCP/IP Protocol Suite
1
Figure 11.1 Position of UDP in the TCP/IP protocol suite
TCP/IP Protocol Suite
2
11.1 PROCESS-TO-PROCESS
COMMUNICATION
Before we examine UDP, we must first understand host-to-host
communication and process-to-process communication and the
difference between them.
The topics discussed in this section include:
Port Numbers
Socket Addresses
TCP/IP Protocol Suite
3
Figure 11.2 UDP versus IP
UDP (User Datagram Protocol) creates a
transport layer connection between two
processes.
The port number identifies the process, or
running application program. So using the port
number, UDP directs the packet to the correct
location.
UDP does little else. No flow control. No ack
of received packets. Only error control is if
a checksum error is detected, it quietly drops
the packet.
TCP/IP Protocol Suite
4
Figure 11.2 UDP versus IP
UDP is a connectionless, unreliable transport
protocol.
It does not add anything to the services of IP
except for providing process-to-process
communication, instead of host-to-host.
Advantages? Minimal overhead; faster
UDP works well with apps that have their own
error and flow control; works well with
multicasting, SNMP, TFTP (trivial FTP),
(but not FTP), and RIP.
TCP/IP Protocol Suite
5
Figure 11.2 UDP versus IP
Need 4 pieces of info: local host (IP addr), local process
(port #), remote host (IP addr), remote process (port #).
Local process port # can be just about any number
(between 0 and 65,535), but remote process port # has
to be fixed, otherwise who would know what it is?
TCP/IP Protocol Suite
6
Figure 11.3 Port numbers
Example: a user wants to know the day and time from
a remote machine. Daytime client port # = 52000,
but Daytime server port # = 13.
TCP/IP Protocol Suite
7
Table 11.1 Well-known ports used with UDP
Well-known port #s are < 1024.
TCP/IP Protocol Suite
8
Figure 11.6 Socket address
In Unix, the socket address is the combination of
IP address and UDP/TCP port number.
TCP/IP Protocol Suite
9
Figure 11.7 User datagram format
TCP/IP Protocol Suite
10
11.3 CHECKSUM
UDP checksum calculation is different from the one for IP and ICMP.
Here the checksum includes three sections: a pseudoheader, the UDP
header, and the data coming from the application layer.
The topics discussed in this section include:
Checksum Calculation at Sender
Checksum Calculation at Receiver
Optional Use of the Checksum
TCP/IP Protocol Suite
11
Figure 11.8 Pseudoheader for checksum calculation
Psuedoheader and padding are only used to calculate
checksum. After checksum is calculated, they are
dropped.
TCP/IP Protocol Suite
12
Figure 11.9 Checksum calculation of a simple UDP user datagram
TCP/IP Protocol Suite
13
Figure 11.9 Practice calculation of a UDP user datagram
The following info is given:
Source port = 1087
Destination port = 17
UDP data field = hello
Total length of user datagram =13
IP source address = 153.18.8.105
IP destination address = 171.2.14.10
Create the IP packet (and UDP datagram)
that will contain this UDP datagram
TCP/IP Protocol Suite
14
11.6 UDP PACKAGE
To show how UDP handles the sending and receiving of UDP packets,
we present a simple version of the UDP package. The UDP package
involves five components: a control-block table, input queues, a controlblock module, an input module, and an output module.
The topics discussed in this section include:
Control-Block Table
Input Queues
Control-Block Module
Input Module
Output Module
TCP/IP Protocol Suite
15
Figure 11.13 UDP design
TCP/IP Protocol Suite
16
Figure 11.13 UDP design
Control-block table - keeps track of the open ports.
Table entries include state (free or in-use), process
ID, port number, and corresponding queue number.
Control-block module - manages the entries in the
control-block table.
Input module - accepts a user datagram from the IP
and checks to see if there is an existing port entry
in table. If yes, queue request; if no, generate
ICMP error message.
Output module - creates and sends user datagram
TCP/IP Protocol Suite
17
Let’s look at some examples. Below is the control-block
table before the examples.
Table 11.2 The control-block table at the beginning of examples
TCP/IP Protocol Suite
18
Example 2
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.
TCP/IP Protocol Suite
19
Example 3
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 11.3).
See Next Slide
TCP/IP Protocol Suite
20
Table 11.3 Control-block table after Example 3
TCP/IP Protocol Suite
21
Example 4
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 11.4.
See Next Slide
TCP/IP Protocol Suite
22
Table 11.4 Control-block after Example 4
TCP/IP Protocol Suite
23
Example 5
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.
TCP/IP Protocol Suite
24