chapter 11 user datagram protocol (udp) -...

Post on 10-Apr-2019

222 Views

Category:

Documents

1 Downloads

Preview:

Click to see full reader

TRANSCRIPT

Chapter 11

User Datagram Protocol (UDP)

Outlineo Process-to-process communicationo User datagramo Checksumo UDP operationo Use of UDPo UDP package

Figure 11-1

Position of UDP in the TCP/IP Protocol Suite

The McGraw-Hill Companies, Inc., 2000

Introductiono A transport layer protocol usually has two

responsibilitiesn Create a process-to-process communicationsn Provide control mechanism at the transport layer

o UDP does this task at a very minimal levelo It only provides error control to some extent

Introduction (Cont.)o Thus, UDP is a connectionless, unreliable

transport protocoln Only add process-to-process to the IPn And perform very limited error checking

o Advantagesn UDP is very simple protocol using a minimum of

overhead

PROCESS TO

PROCESSCOMMUNICATION

11.111.1

The McGraw-Hill Companies, Inc., 2000

Process-to-Process Communicationo Host-to-host communicationn Network layer protocol: IPn Deliver the message only to the destination

computero Process-to-process communicationn Transport layer protocol: UDP and TCPn Deliver the message to the appropriate process

Figure 11-2

UDP Versus IP

The McGraw-Hill Companies, Inc., 2000

Port Numberso Used to define the processo 0~65535o Well-known port numbersn Some servers needs to be assign a universal port

numbero However, client’s port number can be defined

randomlyn Ephemeral port number

Figure 11-3

Port Numbers

The McGraw-Hill Companies, Inc., 2000

Figure 11-4

IP Addresses Versus Port Numbers

The McGraw-Hill Companies, Inc., 2000

IANA Rangeso The IANA divides the port numbers into three ranges

n Well-known: assigned and controlled by IANAo 0~1,023

n Registered: not assigned or controlled by IANAo 1,024~49,151o Can only be registered with IANA to prevent duplication

n Dynamic (or private): neither controlled nor registeredo 49152~65535o Ephemeral ports and can by used by any process

Figure 11-5

IANA Ranges

The McGraw-Hill Companies, Inc., 2000

Well-Known Ports for UDP

Server port to download bootstrap informationBootps67Domain Name ServiceNameserver53

Client port to download bootstrap informationBootpc68

Return a string of charactersChargen19Returns a quote of a dayQuote 17Return the data and the timeDaytime13Active usersUsers11Discards any datagram that is receivedDiscard9Echoes a received datagram back to the senderEcho7DescriptionProtocolPort

Well-Known Ports for UDP (Cont.)

Simple Network Management Protocol (trap)SNMP162Simple Network Management ProtocolSNMP161Network Time ProtocolNTP 123Remote Procedure CallRPC111Trivial File Transfer ProtocolTFTP69DescriptionProtocolPort

Socket Addresseso UDP needs two identifiersn The IP addressn The port number

o Socket addressn The combination of an IP address and a port

number

Figure 11-6

Socket Addresses

The McGraw-Hill Companies, Inc., 2000

USER DATAGRAM

11.211.2

The McGraw-Hill Companies, Inc., 2000

User Datagramo UDP packets: called user datagrams

n Have a fixed-size header of 8 byteso The fields are

n Source port number: 16-bits: 0~65535o Usually chosen by the UDP software

n Destination port number: 16-bits: 0~65535n Length: 16 bits:

o Total length (header plus data) of the user datagramo Minimum length must be 8 bytes (contains only header)

n Checksum: 16 bitso Detect errors over the entire user datagram (header plus data)

Figure 11-7

User Datagram Format

The McGraw-Hill Companies, Inc., 2000

User Datagram (Cont.)o However, the UDP length can also be derived

from the IP headern UDP length = IP length – IP header’s length

o Thus, theoretically, the length field in a UDP datagram is not necessaryn However, it is more efficient to derive the length

of a UDP packet by the UDP package itselfo Ask the IP layer is time consuming

UDP length UDP length ==IP length IP length −− IP headerIP header’’s lengths length

The McGraw-Hill Companies, Inc., 2000

CHECKSUM

11.311.3

The McGraw-Hill Companies, Inc., 2000

Checksumo UDP checksum calculation is different from

the one for IP and ICMPo The checksum includes three sectionsn The Pseudoheader

o However, it will not appear in the UDP datagramn The UDP headern The data coming from the application layer

Pseudoheadero Some part of the header of the IP packet with

some fields are filled with 0so Fieldsn Source and destination IP address

o To prevent that UDP datagram is correct but IP header is corrupted and be delivered to the wrong host

n Protocolo To prevent the packet to deliver to the TCPo UDP has the value of 17

Pseudoheader (Cont.)o At the time TCP was created (1976),

n There was significant concern that there might not be proper “end-to-end” checking of the delivery of datagramsat the IP level

n Guarantee end-to-end encrypted TCP semanticso Consider SA, DA…should be shared between IP/TCP, UDP

o However, in the context of today's high-speed, highly-reliable networksn The use of the pseudo header sometimes seems

unnecessary

Pseudoheader Added to the UDP Datagram

Checksum Calculation at Sendero Add the pseudoheader to the UDP datagramo Fill the checksum field with zeroso Divide the total bits into 16-bits wordso If the total number of bytes is not even

n Add 1 byte of padding (all 0s)o Add all 16-bit section using one’s complement arithmetico Complement the result and insert it in the checksum fieldo Drop the pesudoheader and any added paddingo Deliver the UDP datagram to the IP software

Checksum Calculation at Receivero Add the pseudoheader to the UDP user datagramo Add padding if neededo Divide the total bits into 16-bit sectionso Add all 16-bit sections using one’s complement

arithmetico Complement the resulto If the result is all 0s

n Drop the pseudoheader and any added paddingn Accept the user datagram

o Otherwisen Discard the user datagram

Figure 11-9

Checksum Calculation of a Simple UDP User Datagram

The McGraw-Hill Companies, Inc., 2000

Optional Use of the Checksumo The calculation of the checksum in UDP is

optional

o If the checksum is not calculatedn The field is filled with 0s

UDP OPERATION

11.411.4

The McGraw-Hill Companies, Inc., 2000

UDP Operationo Connectionless Services

o Flow and Error Control

o Encapsulation and Decapsulation

o Queuing

Connectionless Serviceso Each user datagram is an independent

datagramn Even coming from the same source process

o The user datagram is not numbered

o No connection establishment and no connection termination

Flow and Error Controlo No flow controln The receiver may overflow with incoming

messages

o No error control except for the checksumn The sender does not know if a message has been

lost or duplicated

Figure 11-10

Encapsulation and Decapsulation

The McGraw-Hill Companies, Inc., 2000

Figure 11-11

Queues in UDP

The McGraw-Hill Companies, Inc., 2000

Figure 11-12

Multiplexing and Demultiplexing

The McGraw-Hill Companies, Inc., 2000

USE OF UDP

11.511.5

The McGraw-Hill Companies, Inc., 2000

Uses of UDPo For a process that require simple request-response

communication with little concern for flow and error control

o For a process with internal flow and error-control n TFTP (Trivial File Transfer Protocol)

o For muticasting and broadcastingn Embedded in UDP but not in the TCP software

o For some management processeso For some route updating protocol

n RIP (Routing Information Protocol)

UDPPACKAGE

11.611.6

The McGraw-Hill Companies, Inc., 2000

UDP Packageo Five componentsn A control-block tablen Input queuesn A control-block modulen An input modulen An output module

Figure 11-13

UDP Package

The McGraw-Hill Companies, Inc., 2000

Control-Block Tableo Keep track of the open portso Each entry has a minimum of four fieldsn State: FREE or IN-USEn Process IDn Port numbern Corresponding queue number

Input Queueso A set of input queuesn One for each process

o In the book’s designn They do not use output queues

Control-Block Moduleo Manage the control-block tableo Pseudo coden Receive: a process ID and a port numbern Search the control block table for a FREE entry

o If (not found)n Delete an entry using a predefined strategy

o Create a new entry with the state IN-USEo Enter the process ID and the port number

n Return

Input Moduleo Receive: a user datagram from IPo Look for the corresponding entry in the control-

block tablen If (found)

o Check the queue field to see if a queue is allocatedo If (no)

n Allocate a queueo Enqueue the data in the corresponding queue

n If (not found)o Ask the ICMP module to send an “unreachable port” messageo Discard the user datagram

o Return

Output Moduleo Receive: data and information from a processo Create a UDP data datagramo Send the user datagramo Return

Example: Control-Block Table at the Beginning

StateState 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

o The first activity is the arrival of a user datagram with destination port number 52,012

o The input module searches for this port number and finds it

o Queue number 38 has been assigned to this portn The port has been previously used

o The input module sends the data to queue 38o The control-block table does not change

Example 1Example 1

o After a few seconds, a process startso It asks the operating system for a port number and is

granted port number 52,014o Now the process sends its ID (4,978) and the port

number to the control-block module to create an entry in the table

o The module does not allocate a queue at this momentn because no user datagrams have arrived for this

destination

Example 2Example 2

Modified Table After Example 2StateState 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

o A user datagram now arrives for port 52,011o The input module checks the table and finds

that no queue has been allocated for this destinationn This is the first time a user datagram has arrived

for this destinationo The module creates a queue and gives it a

number (43)

Example 3Example 3

Modified Table After Example 3StateState 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

o After a few seconds, a user datagram arrives for port 52,222

o The input module checks the tablen Cannot find the entry for this destination

o The user datagram is droppedo A request is made to ICMP to send an

“unreachable port” message to the source

Example 4Example 4

o After a few seconds, a process needs to send a user datagramn It delivers the data to the output module which

adds the UDP header and sends it

Example 5Example 5

top related