CSIE,NTUT,TAIWAN 1
User Datagram
Protocol (UDP)
Chuan-Ming Liu
CSIE,NTUT
Spring ’04,TAIWAN
CSIE,NTUT,TAIWAN 2
CONTENTS
PROCESS-TO-PROCESS COMMUNICATION
USER DATAGRAM
CHECKSUM
UDP OPERATION
USE OF UDP
UDP PACKAGE
CSIE,NTUT,TAIWAN 3
Introduction
Transport layer protocol is to
– Create a process-to-process communication
– Provide control mechanisms
– Provide a connection mechanism for the processes
CSIE,NTUT,TAIWAN 4
CSIE,NTUT,TAIWAN 5
PROCESS
TO
PROCESS
COMMUNICATION
11.1
CSIE,NTUT,TAIWAN 6Figure 11-2
UDP versus IP
CSIE,NTUT,TAIWAN 7
Port Numbers
client-server paradigm
– Process on the local host,called client,needs
services from a process on the remote host,called
server
– Both processes (client and server) have the same
name
For communication,we need to define
– Local host
– Local process
– Remote host
– Remote process
CSIE,NTUT,TAIWAN 8
Port Numbers
Local and remote hosts are defined using IP
addresses
Processes are defined by so called port number
The port number in TCP/IP are integers
between 0 to 65,535
Client process randomly selects a port number
by the UDP – ephemeral port number
TCP/IP uses universal port numbers for
servers – well-known port numbers
CSIE,NTUT,TAIWAN 9Figure 11-3
Port numbers
CSIE,NTUT,TAIWAN 10Figure 11-4
IP addresses versus port numbers
CSIE,NTUT,TAIWAN 11Figure 11-5
IANA ranges for the port numbers
CSIE,NTUT,TAIWAN 12
Socket Addresses
Combination of an IP address and a port
number is called a socket address
The socket address uniquely defines a process
IP header contains the IP addresses
UDP header includes the port numbers
CSIE,NTUT,TAIWAN 13Figure 11-6
Socket addresses
CSIE,NTUT,TAIWAN 14
USER
DATAGRAM
11.2
CSIE,NTUT,TAIWAN 15
User Datagram
UDP packets are called user datagram
Header size is fixed and of 8 bytes
CSIE,NTUT,TAIWAN 16Figure 11-7
User Datagram Format
CSIE,NTUT,TAIWAN 17
Length
16-bit field
Defines the total length of the user datagram,
including the data
Minimum length is 8 bytes
The length of data can be 0 to 65,507 bytes
CSIE,NTUT,TAIWAN 18
UDP length =
IP length - IP header’s length
CSIE,NTUT,TAIWAN 19
CHECKSUM
11.3
CSIE,NTUT,TAIWAN 20
Checksum
Includes three sections
– Pseudo-header,necessary IP information for error
checking
– UDP header
– Data
CSIE,NTUT,TAIWAN 21Figure 11-8
Pseudo-header added to the UDP datagram
CSIE,NTUT,TAIWAN 22Figure 11-9
Checksum calculation of a
simple UDP user datagram
CSIE,NTUT,TAIWAN 23
UDP
OPERATION
11.4
CSIE,NTUT,TAIWAN 24
UDP Operation
Connectionless services
– Can not send a stream of data
– Better for short message
No flow and error control
Encapsulation and decapsulation
Queuing
– Queues are associated with ports
– Queues are identified by port numbers
– When process terminates,the queues are destroyed
Multiplexing and demultiplexing
CSIE,NTUT,TAIWAN 25Figure 11-10
Encapsulation and decapsulation
CSIE,NTUT,TAIWAN 26Figure 11-11
Queues in UDP
CSIE,NTUT,TAIWAN 27Figure 11-12
Multiplexing and demultiplexing
CSIE,NTUT,TAIWAN 28
USE
OF UDP
11.5
CSIE,NTUT,TAIWAN 29
Use of UDP
process requiring simple request-response
communication with little concern for flow and
error control
process with internal flow and error-control
mechanisms
Multicasting and broadcasting
CSIE,NTUT,TAIWAN 30
UDP
PACKAGE
11.6
CSIE,NTUT,TAIWAN 31Figure 11-13
UDP package
CSIE,NTUT,TAIWAN 32
State Process ID Port Number Queue Number
-------- ------------ -------------- ------------------
IN-USE 2,345 52,010 34
IN-USE 3,422 52,011
FREE
IN-USE 4,652 52,012 38
FREE
Control-block table at the beginning
CSIE,NTUT,TAIWAN 33
Example 1
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.
CSIE,NTUT,TAIWAN 34
Example 2
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 does
not allocate a queue at this moment because
no user datagrams have arrived for this
destination
CSIE,NTUT,TAIWAN 35
State Process ID Port Number Queue Number
-------- ------------ -------------- ------------------
IN-USE 2,345 52,010 34
IN-USE 3,422 52,011
IN-USE 4,978 52,014
IN-USE 4,652 52,012 38
FREE
Modified table after Example 2
CSIE,NTUT,TAIWAN 36
Example 3
Auser 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).
CSIE,NTUT,TAIWAN 37
State Process ID Port Number Queue Number
-------- ------------ -------------- ------------------
IN-USE 2,345 52,010 34
IN-USE 3,422 52,011 43
IN-USE 4,978 52,014
IN-USE 4,652 52,012 38
FREE
Modified table after Example 3
CSIE,NTUT,TAIWAN 38
Example 4
After a few seconds,a user datagram arrives
for port 52,222,The input module checks the
table and cannot find the 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.
CSIE,NTUT,TAIWAN 39
Example 5
After a few seconds,a process needs to send
a user datagram,It delivers the data to the
output module which adds the UDP header
and sends it.