Presentation is loading. Please wait.

Presentation is loading. Please wait.

User Datagram Protocol (UDP)

Similar presentations


Presentation on theme: "User Datagram Protocol (UDP)"— Presentation transcript:

1 User Datagram Protocol (UDP)
Lesson 8 User Datagram Protocol (UDP)

2 UDP TCP/IP protocol suite specifies two protocols for the transport layer:UDP and TCP Application layer SMTP FTP TFTP DNS SNMP BOOTP TCP UDP Transport layer IGMP ICMP IPv4 Network layer ARP RARP Data link layer Underlying LAN or WAN technology Physical layer

3 (Running application program) Process (Running application program)
Port Numbers are integers between 0 and 65,535 Domain of UDP protocol Process (Running application program) Process (Running application program) Domain of IP protocol Internet

4 Registered Processes 49,152 65,535 1,023 1,024 49,151 Well-known
1,024 49,151 Well-known Dynamic 13 Port Protocol Description 7 Echo Echoes a received datagram back to the sender 9 Discard Discards any datagram that is received 11 Users Active users 13 Daytime Returns the date and time 17 Quote Returns a quote of the day 19 Chargen Returns a string of characters 53 Nameserver Domain Name Service 67 Bootps Server port to downlaod bootstrap information 68 Bootpc Client port to download bootstrap information 69 TFTP Trivial file transfer protocol 111 RPC Remote Procedure Call 123 NTP Network time protocol 161 SNMP Simple network management protocol 162 Simple network management protocol (trap) Port number selects the process 13 IP header UDP header 13 Socket address

5 Port Application Status 20/TCP FTP - data Official 21/TCP FTP—control (command) 22/TCP,UDP Secure Shell (SSH)—used for secure logins, file transfers (scp, sftp) and port forwarding 23/TCP Telnet protocol—unencrypted text communications 25/TCP Simple Mail Transfer Protocol (SMTP) 42/TCP,UDP nameserver, ARPA Host Name Server Protocol WINS Unofficial 43/TCP WHOIS protocol 49/TCP,UDP TACACS Login Host protocol 52/TCP,UDP XNS (Xerox Network Services) Time Protocol 53/TCP,UDP Domain Name System (DNS) 54/TCP,UDP XNS (Xerox Network Services) Clearinghouse 56/TCP,UDP XNS (Xerox Network Services) Authentication RAP (Route Access Protocol)[4] 57/TCP MTP, Mail Transfer Protocol 58/TCP,UDP XNS (Xerox Network Services) Mail 67/UDP Bootstrap Protocol (BOOTP) Server; also used by Dynamic Host Configuration Protocol (DHCP) 68/UDP Bootstrap Protocol (BOOTP) Client; also used by Dynamic Host Configuration Protocol (DHCP) 69/UDP Trivial File Transfer Protocol (TFTP) 70/TCP Gopher protocol 79/TCP Finger protocol 80/TCP Hypertext Transfer Protocol (HTTP)

6 UDP packet-User Datagram
UDP datagram format Header Data Source port number (16 bits) Destination port number (16 bits) Total length 16 bits Checksum 16 bits Source port, Dest. Port: range from 0 to 65,535. Length: total length of the user datagram, header plus data. Checksum: contains three sections, a pseudoheader, the UDP header, and the data.

7 Checksum field in UDP packet
pseudoheader 32-bit source IP address 32-bit destination IP address All 0s 8-bit protocol (17) 16-bit UDP total length Source port address (16 bits) Dest. port address (16 bits) UDP total length (16 bits) Checksum (16 bits) Data (padding must be added to make the data a multiple of 16 bits) All 0s 17 15 1087 13 T E S I N G Only used in the checksum Calculation TE: ST: IN: E G0: Optional use of the Checksum: If the checksum is not calculated, the field is filled with 0s.

8 UDP Operation Process Process a. Encapsulation b. Decapsulation
Message from process Message from process UDP header UDP data UDP header UDP data IP header IP data IP header IP data Frame header Frame data Frame header Frame data a. Encapsulation b. Decapsulation UDP is connectionless services, this means that each user datagram sent by UDP is an independent datagram. So a process that uses UDP cannot send a stream Of data to UDP and expect UDP to chop them into different related user datagrams. Instead each request must be small enough to fit into one user datagram. No flow control means the receive may overflow with incoming messages. No error control in UDP except for the checksum. This means that the sender does not Know if a message has been lost or duplicated. When the receiver detects an error using The checksum, the user datagram is silently discarded. So process which uses UDP must provide for these mechanisms.

9 UDP Operation c. Queuing Outgoing queue Outgoing queue Incoming queue
Daytime client Daytime server Outgoing queue Incoming queue Outgoing queue Incoming queue UDP UDP Port 52000 Port 13 Queuing: In UDP, queues are associated with ports. At the client site, when a process starts, it requests a port number from the operating system. Some implementations create both an incoming and an outgoing queue associated with each process. If a process wants communicate with multiple processes, it obtains only one port number and eventually one outgoing and one incoming queue. When a message arrives for a client, UDP checks to see if an incoming queue has been created for the port number . If yes, put into the queue, if not, send ICMP a port unreachable.

10 UDP Operation d. Multiplexing and Demultiplexing UDP (Multiplexer) UDP
Processes Processes UDP (Multiplexer) UDP (Demultiplexer) IP IP Only one UDP but possibly several processes that may want to use the services of UDP. 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, t here may be several processes that need to reveive user datagrams.. This is a one-to-many relationship and requires demultiplexing.

11 Use of UDP UDP is suitable for a process that requires simple request- response communication and with little concern for flow and error control. Not usually for a protocol that needs to send bulk data, such as FTP. UDP is suitable for a process with internal flow and error- control mechanisms. For example, the Trivial File Transfer Protocol(TFTP). UDP is a suitable transport protocol for multicasting and broadcasting. UDP is used for management processes such as SNMP. UDP is used for some route updating protocols such as RIP.

12 UDP IP UDP Design Processes (when started) Data Queues
Control-block module Input module Output module Control-block table UDP User datagram IP UDP User datagram Five components: (two data-structures plus three modules) Control-block table: keep tracks of the open ports. Four fields: the state, the Process ID, the port number, and the corresponding queue number. Input Queues: s set of input queues, one for each process.

13 Control-Block Module operation
Receive: a process ID and a port number 1. Search the control block table for a FREE entry 1) If (not found), Delete an entry using a predefined strategy. 2) Create a new entry with the state IN_USE. 3) Enter the process ID and the port number. 2. Return. Input Module operation Receive: a user datagram from IP 1. Look for the corresponding entry in the control-block table. 1) If (found), check the queue field to see if a queue is allocated If (no) , allocate a queue, then enqueue the data. 2) if (not found) ask the ICMP module to send an “unreachable port” message. discard the user datagram. 2. Return. Output Module operation Receive: data and information from a process 1. Create a UDP user datagram. 2. Send the user datagram. 3. Return.

14 Examples The control-block table at the beginning of examples State Process ID Port Number Queue Number IN-USE 2,345 52,010 34 3,422 52,011 FREE 4,652 52,012 38 Example 1: arrival of a user datagram with destination port number 52,012. Ans: the input module searches for this port number and finds that Queue number 38 has been assigned to this port. The input module sends the data to Queue 38. Example 2: After a few seconds, a process ID: 4,978 starts. Get port number 52,014 from OS. Ans: Now the process sends its ID 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.

15 Examples Example 3: A user datagram now arrives for port 52,011.
The control-block table at the beginning of examples State Process ID Port Number Queue Number IN-USE 2,345 52,010 34 3,422 52,011 4,978 52,014 4,652 52,012 38 FREE Example 3: A user datagram now arrives for port 52,011. Ans: the input module searches for this port number and finds that No Queue number has been assigned. The input module creates a queue and gives it a number (43). Example 4: A user datagram now arrives for port 52,223. Ans: the input module searches for this port number and finds that No entry for this port number. The user datagram is dropped and a request is made to ICMP to send an “unreachable port” message to the source. Example 5: A process needs to send a user datagram: Ans: It delivers the data to the output module which adds the UDP header and sends it.

16 Practice Quiz for UDP: UDP is acronym for?
What is the maximum and minimum size of a UDP datagram? And what is the practice size of a UDP datagram? What is the maximum and minimum size of the process data that can be encapsulated in a UDP datagram? The following is a dump of a UDP header in hexadecimal format D 00 1C E2 17 a) what is the source port number? b) What is the destination port number? c) What is the total length of the user datagram? d) What is the length of the process data? e) Is the packet directed from a client to a server or vice versa?

17 UDP Application – Trivial File Transfer protocol (TFTP)
There are occasions when we need to simply copy a file without the need for all of the functions of the FTP protocol.

18 TFTP, a protocol quickly copies(writes) the files
TFTP, a protocol quickly copies(writes) the files. used in bootstrap or DHCP. Reading means copying a file from the server site to the client. Writing means copying a file from the client site to the server site. TFTP uses the services of UDP on the well-known port 69. TFTP has five types of message, RRQ, WRQ, DATA, ACK, and ERROR

19 RRQ- read request message
RRQ message format (the client establish a connection for reading data from the server.) OPcode =1 File name All 0s Mode 2 bytes Variable 1 byte 1 byte Variable (netascii, (ASCII )or octet (binary file) WRQ message format (the client establish a connection for writing data to the server.) OPcode =2 File name All 0s Mode 2 bytes Variable 1 byte 1 byte Variable (netascii, (ASCII )or octet (binary file)

20 DATA message format (Server or client send blocks of data)
OPcode =3 Block number Data 2 bytes 0~512 bytes 2 bytes Block number. The sender of the data (server or client) uses this field for sequencing. the block number is necessary for acknowledgement. Data: this block must be exactly 512 bytes in all DATA messages except the last block which must be between 0 and 511 bytes. ACK message format OPcode =4 Block number 2 bytes 2 bytes

21 OPcode =5 Error number Data All 0s Number Meaning 1 2 3 4 5 6 7
ERROR message format: is used when a connection can not be established or when there is a problem during data transmission. It can e sent as a negative response to PRQ or WRQ. It Can also be used if the next block can not be transferred during the actual data transfer phase. ERROR message format OPcode =5 Error number Data All 0s 2 bytes Variable 2 bytes 1 byte Number Meaning Not defined 1 File not found 2 Access violation 3 Disk full or quota on disk exceeded 4 Illegal operation 5 Unknown port number 6 File already exists 7 No such user

22 TFTP messages encapsulation
TFTP Process TFTP Process Message from TFTP Message from TFTP UDP header UDP data UDP header UDP data IP header IP data IP header IP data Frame header Frame data Frame header Frame data a. Encapsulation b. Decapsulation TFTP’s five types of message are encapsulated in UDP packet. This means TFTP message delivery is unreliable. So within TFTP, there must have its own mechanism to handle flow control and error control.

23 Connection TFTP uses UDP services. There is no provision for connection establishment and termination in UDP. In TFTP, we may transfer blocks of data as they all belong to the same file. TFTP uses RRQ, WRQ, ACK and ERROR messages To establish connection. It uses the DATA message with a block of data fewer than 512 bytes (0~511) to terminate connection. READING: TFTP client sends the RRQ message to server. 1) RRQ include the file and the transmission mode. if permits, the server responds positively with a DATA message containing the first block of data. Others, the server responds negatively by sending an ERROR message. WRITING: TFTP client sends the WRQ message to server. 1) RRQ include the file and the transmission mode. if permits, the server responds positively with a ACK message. Others, the server responds negatively by sending an ERROR message. Connection Termination: termination is accomplished by sending the last block of data, which should be fewer than 512 bytes.

24 Connection OR OR Connection for reading Connection for writing ascii
Client Server Client Server RRQ WRQ ascii file1 1 ascii file1 2 DATA ACK 3 1 First block of data 4 1 OR OR ERROR ERROR 5 Error data 5 Error data Connection for reading Connection for writing Connection Termination: termination is accomplished by sending the last block of data, which should be fewer than 512 bytes.

25 Data Transfer Data Transfer phase occurs between connection.
The file is divided into blocks of data, in which each block except the last one is exactly 512 bytes. TFTP has to creates a flow-and error-control mechanism to transfer a file. Flow Control TFTP sends a block of data using the DATA message and waits for an ACK message. If the sender receives an acknowledge before the time-out, it sends the next block. Thus, flow control is achieved by numbering the data blocks and waiting for an ACK before the next data block is send. Error Control Both the sender and the receiver use time-outs. The sender uses a time-out for data messages; the receives uses a time-out for acknowledge messages. If a data message is lost, the sender retransmits it after time-out expiration. So is the same as the receiver.

26 Error Control: is needed in four situations: damaged message, lost message, lost ack, or
Duplicated message. Damaged message: If a block of data is damaged, it will detected by the receiver and the Block is discarded. The sender waits for the ACK and does not receive it within the time-out period. The checksum field in the UDP provide the damaged check for the message. Lost message: If a block is lost, it never reaches the receiver and no ACK is sent. The sender resends.The block after the time-out. Lost ACK: Two situations can happen. If the timer of the receiver matures before the timer of the sender, the receiver retransmits the ACK; otherwise, the sender retransmits the data. Duplicate message: Duplication of blocks can be detected by the receiver through block number. If a block is duplicated, it is simply discarded by the receiver.

27 Sorcerer’s Apprentice Bug(魔法師學徒蟲)
Situation occurs when the ACK message for a message is not lost, but delayed. Client Server Block 5 In this figure, ack 5 is delayed. After the time-out, the sender retransmits the fifth block, which will be acknowledged by the receiver again. The sender receives the two ack 5, which triggers it to send the sixth block twice. ack 5 Block 5 ack 5 ack 5 Block 6 Block 6 ack 6 ack 6 Block 7 Block 7

28 UDP ports Server Client Server Client Server Client
a. Passive open by server Passive open Client Server 69 b. Active open by client Active open Client Server 50032 69 a. Rest of Communication 69 Server Client 50032 62001

29 TFTP Example Damaged ascii file1 1 3 1 1 4 3 2 3 2 2 4 2 4 3 3 4
Client Server The client wants to retrieve the content of a 1336-byte file called file1. the client sends an RRQ message. The server sends the first block with 512 byte. RRQ ascii file1 1 3 1 Block 1: 512 bytes 1 4 Lost 3 2 Block 2: 512 bytes 3 2 Block 2: 512 bytes 2 4 Damaged 2 4 3 Block 3: 312 bytes 3 4

30 Security Client Server TELNETclient TFTP server TFTP client TELNETserver Security in TFTP must combined with other protocol such as TELNET. The user must first access TELNET. TELNET checks whether the user Has the right to access the system and the corresponding file. It then calls The TFTP client and passes the file name to the client. The client then makes the TFTP connection to TFTP server at the user site.

31 Applications Client Server TFTP client BOOTP client BOOTP server TFTP server 1 2 4 5 3 TFTP is very useful for basic file transfer where security is not a big issue. It can be used to initialize devices such as bridges or routers. Its main application Is in conjunction with the BOOTP or DHCP protocols. TFTP requires only a small amount of memory and uses the services of UDP and IP. It can easily be configured into ROM. When the station is powered on, TFTP will be Connected to a server ad can download the configuration files from there. As the figure above shows the powered-on station uses the BOOTP (or DHCP) client to get the name of the configuration file from BOOTP server. The station then passes the name of the file to the TFTP client to get the contents of the configuration file from the TFTP sever.

32 Practice Quiz for TFTP:
Show the encapsulation of a WRQ message in a UDP user datagram. Assume the file name is REPORT and the mode is ASCII. What is the size of the UDP datagram? Show the encapsulation of a TFTP data message, carrying block number 7, in a UDP user datagram. What is the total size of the user datagram? Host A uses TFTP to read 2,150 bytes of data from host. Show all the TFTP commands including commands needed for connection establishment and termination. Assume one ACK error.


Download ppt "User Datagram Protocol (UDP)"

Similar presentations


Ads by Google