Você está na página 1de 36

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

Figure 11.1

TCP/IP Protocol Suite

Position of UDP in the TCP/IP protocol suite

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

Figure 11.2

UDP versus IP

UDP (User Datagram Protocol) creates a


transport layer connection between two
processes.
A user datagram is encapsulated in an IP
datagram.

The port number identifies the process, or


running application program. So using the po
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

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

Figure 11.2

UDP versus IP

For communication, 4 pieces of info are needed:


1.local host (IP addr), 2.local process (port #),
3.remote host (IP addr), 4. 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

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

Figure 11.4

TCP/IP Protocol Suite

IP addresses versus port numbers

ICANN ranges

Well-known ports

Registered ports

0 -> 1023 (assigned and controlled by ICANN).


1024 -> 49151
Registered with ICANN to prevent duplication.

Dynamic ports

49152 -> 65535


They can be used as temporary or private port
numbers.

TCP/IP Protocol Suite

Figure 11.5

TCP/IP Protocol Suite

ICANN ranges

10

Table 11.1 Well-known ports used with UDP

Well-known port #s are < 1024.


TCP/IP Protocol Suite

11

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

12

11.2 USER DATAGRAM


UDP packets are called user datagrams and have a fixed-size header of 8
bytes.

TCP/IP Protocol Suite

13

Figure 11.7

TCP/IP Protocol Suite

User datagram format

14

Note:
UDP length =
IP length IP headers length

TCP/IP Protocol Suite

15

UDP provides a connectionless service. This


means that each user datagram sent by
UDP is an independent datagram.
There is no relationship between the
different user datagrams even if they are
coming from the same source process and
going to the same destination program.
The user datagrams are not numbered.

TCP/IP Protocol Suite

16

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

17

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

18

Figure 11.9

TCP/IP Protocol Suite

Checksum calculation of a simple UDP user datagram

19

Optional use of the


checksum

If the checksum is not calculated, the


field is filled with 0s.
If the source does calculate the
checksum and the result happens to
be all 0s, it must be complemented
(1s).

TCP/IP Protocol Suite

20

11.4 UDP OPERATION


UDP uses concepts common to the transport layer. These concepts will
be discussed here briefly, and then expanded in the next chapter on the
TCP protocol.

The topics discussed in this section include:


Connectionless Services
Flow and Error Control
Encapsulation and Decapsulation
Queuing
Multiplexing and Demultiplexing
TCP/IP Protocol Suite

21

Figure 11.10

TCP/IP Protocol Suite

Encapsulation and decapsulation

22

Figure 11.11 Queues in UDP

TCP/IP Protocol Suite

23

Multiplexing and demultiplexing


multiplexing
At the sender site, there may be several processes
that need to send user datagrams. However,
there is only one UDP. This is a many-to-one
relationship and requires multiplexing .
Demultiplexing
At the receiver site, there is only one UDP. However,
we may have many processes that can receive
user datagrams. This is a one-to-many
relationship and requires demultiplexing.

TCP/IP Protocol Suite

24

Figure 11.12

TCP/IP Protocol Suite

Multiplexing and demultiplexing

25

11.5 USE OF UDP


-UDP is suitable for a process that requires simple request-response
communication with little concern for flow and error control.
-UDP is suitable for a process with internal flow and error-control
mechanisms (TFTP).
-UDP is suitable transport protocol for multicasting.
-UDP is used for management processes such as SNMP.
-UDP is used for some route updating protocols such as RIP.

TCP/IP Protocol Suite

26

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

27

Figure 11.13

TCP/IP Protocol Suite

UDP design

28

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. When a process starts, it asks for
Port number from the operating system.
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 datagrams.

TCP/IP Protocol Suite

29

Lets 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

30

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

31

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

32

Table 11.3 Control-block table after Example 3

TCP/IP Protocol Suite

33

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

34

Table 11.4 Control-block after Example 4

TCP/IP Protocol Suite

35

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

36

Você também pode gostar