Chapter 11
User Datagram
Protocol
CONTENTS
CONTENTS
• PROCESS-TO-PROCESS COMMUNICATION • USER DATAGRAM
• CHECKSUM
• UDP OPERATION • USE OF UDP
Figure 11-1
PROCESS
TO
PROCESS
COMMUNICATION
Process to Process
Communication
• UDP is responsible for delivery of the message to the appropriate process
Port Numbers
• Process to Process Communication is achieved through the client server
• Process on local host called client, needs services from the remote host is called
Figure 11-2
Process to Process
Communication
For communication we must define • Local host
• Local Process • Remote Host
• Remote Process
• Local and Remote process are identified using port numbers
Port Numbers
• Client program defines itself with a port number called the ephemeral port number
• Recommended to be greater than 1023 for some client server programs to work properly
Figure 11-3
Figure 11-4
Figure 11-5
• Well known ports: Controlled by ICANN. Well know port numbers are less than 1024
• Registered Ports: Not Controlled by
ICANN but they can only register with ICANN to prevent duplication
• Dynamic Ports: Used Temporary or
Well Known Ports
• Port Protocol 7 Echo
9 Discard 13 DayTime 67 Bootps 68 Bootpc 60 TFTP .
Figure 11-6
Socket Addresses
• UDP needs two identifiers IP address and port number at each end to make a connection
• Combination of IP address and a port number is called a socket address
• Client socket address defines the client process uniquely just as the server socket address defines the server process uniquely
USER
DATAGRAM
Figure 11-7
User Datagram
• Source Port Number: Port number used by the process running on the source host.
• 16 bits long, source port number ranges from 0 to 65,535 • Source host is the client- ephemeral port number
• Source host is the server-Well known port number
• Destination Port Number : Port number used by the process running on the destination host
• 16 bits long ,Destination host is the client – Ephemeral port number
• Destination host is the server-Well known port number
• Length – 16 bit field that defines the total length of the user datagram plus data. 16 bits can define a total length of 0 to 65,535 bytes
UDP length
UDP length
IP length
CHECKSUM
• Checksum includes three secttions: pseudoheader, UDP header and the data coming from the application layer
• Pseudoheader is the part of the header of the IP packet in which the user datagram is encapsulated with some fields filled with 0s • Protocol field is added to ensure that the
Checksum
Sender:
1. Add the pseudo header to the UDP user datagram 2. Fill the checksum field with 0’s
3. Divide the total bits into 16 bit words
4. If the total number of bytes is not even add 1 byte of padding(all 0’s)
5. Add all 16 bit sections using 1’s complement arithmetic 6. Complement the result and insert it in the checksum
field
7. Drop the pseudo header and any padding
Checksum
• Receiver:
1. Add the pseudo header to the UDP user datagram
2. Add padding if needed
3. Divide the total bits into 16 bit sections
4. Add all 16 bit sections using one’s complement arithmetic
5. Complement the result
Figure 11-8
Figure 11-9
UDP
OPERATION
UDP OPERATION
• Connectionless Services
• Each user datagram sent by UDP will be an independent Datagram
• User datagrams are not numbered
• No Connection Establishment and Connection Termination
• Each user datagram can travel on a different path
Flow and Error Control
• UDP is a simple, unreliable transport protocol
• No Flow control and no window mechanism. Receiver may overflow with incoming messages
• No error control mechanism in UDP except checksum
Figure 11-10
Figure 11-11
Queues in UDP
• If a process wants to communicate with multiple processes it obtains only one port number one outgoing queue and one incoming queue
• Queues opened by the client can be identified by ephemeral port numbers
• Client process can send messages to the outgoing queue by using the source port number specified in the request
• UDP removes messages one by one and after adding UDP header delivers them to IP
Queues in UDP
• Server asks for incoming and outgoing queue using well known port when it starts running
• When a message arrives for server UDP checks to see if an incoming queue has been created for the port number specified in the destination port field
Figure 11-12
• Multiplexing :
• UDP accepts messages from different processes differentiated by their assigned port numbers
• Demultiplexing:
USE
OF UDP
USE of UDP
• Suitable for a process that requires simple request response communication
• Suitable for a process with internal flow and error control mechanisms
• Suitable transport protocol for multicasting
• Used for management processes such as SNMP
UDP
PACKAGE
Figure 11-13
State
State Process IDProcess ID Port NumberPort Number Queue NumberQueue Number
--- ------ ------ ---
---IN-USE 2,345 52,010 34
IN-USE 3,422 52,011 FREE
IN-USE 4,652 52,012 38
FREE
Example 1
Example 1
Example 2
Example 2
State
State Process IDProcess ID Port NumberPort Number Queue NumberQueue 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
Example 3
Example 3
State
State Process IDProcess ID Port NumberPort Number Queue NumberQueue 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
Example 4
Example 4
Example 5
Example 5