Chapter 11 User Datagram Protocol (UDP)
Total Page:16
File Type:pdf, Size:1020Kb
Chapter 11 User Datagram Protocol (UDP) PDF created with FinePrint pdfFactory Pro trial version www.pdffactory.com Outline o Process-to-process communication o User datagram o Checksum o UDP operation o Use of UDP o UDP packet PDF created with FinePrint pdfFactory Pro trial version www.pdffactory.com Figure 11-1 Position of UDP in the TCP/IP Protocol Suite The McGraw-Hill Companies, Inc., 2000 PDF created with FinePrint pdfFactory Pro trial version www.pdffactory.com Introduction o A transport layer protocol usually has two responsibilities n Create a process-to-process communications n Provide control mechanism at the transport layer o UDP does this task at a very minimal level o It only provides error control to some extent PDF created with FinePrint pdfFactory Pro trial version www.pdffactory.com Introduction (Cont.) o Thus, UDP is a connectionless, unreliable transport protocol n Only add process-to-process to the IP n And perform very limited error checking o Advantages n UDP is very simple protocol using a minimum of overhead PDF created with FinePrint pdfFactory Pro trial version www.pdffactory.com 1111.1.1 PROCESS TO PROCESS COMMUNICATION The McGraw-Hill Companies, Inc., 2000 PDF created with FinePrint pdfFactory Pro trial version www.pdffactory.com Process-to-Process Communication o Host-to-host communication n Network layer protocol: IP n Deliver the message only to the destination computer o Process-to-process communication n Transport layer protocol: UDP and TCP n Deliver the message to the appropriate process PDF created with FinePrint pdfFactory Pro trial version www.pdffactory.com Figure 11-2 UDP Versus IP The McGraw-Hill Companies, Inc., 2000 PDF created with FinePrint pdfFactory Pro trial version www.pdffactory.com Port Numbers o Used to define the process o 0~65535 o Well-known port numbers n Some serves needs to be assign a universal port number o However, client’s port number can be defined randomly n Ephemeral port number PDF created with FinePrint pdfFactory Pro trial version www.pdffactory.com Figure 11-3 Port Numbers The McGraw-Hill Companies, Inc., 2000 PDF created with FinePrint pdfFactory Pro trial version www.pdffactory.com Figure 11-4 IP Addresses Versus Port Numbers The McGraw-Hill Companies, Inc., 2000 PDF created with FinePrint pdfFactory Pro trial version www.pdffactory.com IANA Ranges o The IANA divides the port numbers into three ranges n Well-known: assigned and controlled by IANA o 0~1,023 n Registered: not assigned or controlled by IANA o 1,024~49,151 o Can only be registered with IANA to prevent duplication n Dynamic (or private): neither controlled nor registered o 49152~65535 o Ephemeral ports and can by used by any process PDF created with FinePrint pdfFactory Pro trial version www.pdffactory.com Figure 11-5 IANA Ranges The McGraw-Hill Companies, Inc., 2000 PDF created with FinePrint pdfFactory Pro trial version www.pdffactory.com Well-Known Ports for UDP 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 Return the data and the time 17 Quote Returns a quote of a day 19 Chargen Return a string of characters 53 Nameserver Domain Name Service 67 Bootps Server port to download bootstrap information 68 Bootpc Client port to download bootstrap information PDF created with FinePrint pdfFactory Pro trial version www.pdffactory.com Well-Known Ports for UDP (Cont.) Port Protocol Description 69 TFTP Trivial File Transfer Protocol 111 RPC Remote Procedure Call 123 NTP Network Time Protocol 161 SNMP Simple Network Management Protocol 162 SNMP Simple Network Management Protocol (trap) PDF created with FinePrint pdfFactory Pro trial version www.pdffactory.com Socket Addresses o UDP needs two identifiers n The IP address n The port number o Socket address n The combination of an IP address and a port number PDF created with FinePrint pdfFactory Pro trial version www.pdffactory.com Figure 11-6 Socket Addresses The McGraw-Hill Companies, Inc., 2000 PDF created with FinePrint pdfFactory Pro trial version www.pdffactory.com 1111.2.2 USER DATAGRAM The McGraw-Hill Companies, Inc., 2000 PDF created with FinePrint pdfFactory Pro trial version www.pdffactory.com User Datagram o UDP packets: called user datagrams n Have a fixed-size header of 8 bytes o The fields are n Source port number: 16-bits: 0~65535 o Usually chosen by the UDP software n Destination port number: 16-bits: 0~65535 n Length: 16 bits: o Total length (header plus data) of the user datagram o Minimum length must be 8 bytes (contains only header) n Checksum: 16 bits o Detect errors over the entire user datagram (header plus data) PDF created with FinePrint pdfFactory Pro trial version www.pdffactory.com Figure 11-7 User Datagram Format The McGraw-Hill Companies, Inc., 2000 PDF created with FinePrint pdfFactory Pro trial version www.pdffactory.com User Datagram (Cont.) o However, the UDP length can also be derived from the IP header n UDP length = IP length – IP header’s length o Thus, theoretically, the length field in a UDP datagram is not necessary n However, it is more efficient to derive the length of a UDP packet by the UDP package itself o Ask the IP layer is time consuming PDF created with FinePrint pdfFactory Pro trial version www.pdffactory.com UDUDPP lelennggtthh == IIPP lelennggtthh -- IIPP hheeadaderer’’ss lelennggthth The McGraw-Hill Companies, Inc., 2000 PDF created with FinePrint pdfFactory Pro trial version www.pdffactory.com 1111.3.3 CHECKSUM The McGraw-Hill Companies, Inc., 2000 PDF created with FinePrint pdfFactory Pro trial version www.pdffactory.com Checksum o UDP checksum calculation is different from the one for IP and ICMP o The checksum includes three sections n The Pseudoheader o However, it will not appear in the UDP datagram n The UDP header n The data coming from the application layer PDF created with FinePrint pdfFactory Pro trial version www.pdffactory.com Pseudoheader o Some part of the header of the IP packet n With some fields are filled with 0s o Fields n 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 Protocol o To prevent the packet to deliver to the TCP o UDP has the value of 17 PDF created with FinePrint pdfFactory Pro trial version www.pdffactory.com PseudoheaderAdded to the UDP Datagram PDF created with FinePrint pdfFactory Pro trial version www.pdffactory.com Checksum Calculation at Sender o Add the pseudoheaderto the UDP datagram o Fill the checksum field with zeros o Divide the total bits into 16-bits words o 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 arithmetic o Complement the result and insert it in the checksum field o Drop the pesudoheaderand any added padding o Deliver the UDP datagram to the IP software PDF created with FinePrint pdfFactory Pro trial version www.pdffactory.com Checksum Calculation at Receiver o Add the pseudoheaderto the UDP user datagram o Add padding if needed o Divide the total bits into 16-bit sections o Add all 16-bit sections using one’s complement arithmetic o Complement the result o If the result is all 0s n Drop the pseudoheaderand any added padding n Accept the user datagram o Otherwise n Discard the user datagram PDF created with FinePrint pdfFactory Pro trial version www.pdffactory.com Figure 11-9 Checksum Calculation of a Simple UDP User Datagram The McGraw-Hill Companies, Inc., 2000 PDF created with FinePrint pdfFactory Pro trial version www.pdffactory.com Optional Use of the Checksum o The calculation of the checksum in UDP is optional o If the checksum is not calculated n The field is filled with 0s PDF created with FinePrint pdfFactory Pro trial version www.pdffactory.com 1111.4.4 UDP OPERATION The McGraw-Hill Companies, Inc., 2000 PDF created with FinePrint pdfFactory Pro trial version www.pdffactory.com UDP Operation o Connectionless Services o Flow and Error Control o Encapsulation and Decapsulation o Queuing PDF created with FinePrint pdfFactory Pro trial version www.pdffactory.com Connectionless Services o Each user datagram is an independent datagram n Even coming from the same source process o The user datagram is not numbered o No connection establishment and no connection termination PDF created with FinePrint pdfFactory Pro trial version www.pdffactory.com Flow and Error Control o No flow control n The receiver may overflow with incoming messages o No error control except for the checksum n The sender does not know if a message has been lost or duplicated PDF created with FinePrint pdfFactory Pro trial version www.pdffactory.com Figure 11-10 Encapsulation and Decapsulation The McGraw-Hill Companies, Inc., 2000 PDF created with FinePrint pdfFactory Pro trial version www.pdffactory.com Figure 11-11 Queues in UDP The McGraw-Hill Companies, Inc., 2000 PDF created with FinePrint pdfFactory Pro trial version www.pdffactory.com Figure 11-12 Multiplexing and Demultiplexing The McGraw-Hill Companies, Inc., 2000 PDF created with FinePrint pdfFactory Pro trial version www.pdffactory.com 1111.5.5 USE OF UDP The McGraw-Hill Companies, Inc., 2000 PDF created with FinePrint pdfFactory Pro trial version www.pdffactory.com Uses of UDP o 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 muticastingand broadcasting n Embedded