Presentation is loading. Please wait.

Presentation is loading. Please wait.

資 管 Lee Lesson 8 User Datagram Protocol (UDP). 資 管 Lee UDP TCP/IP protocol suite specifies two protocols for the transport layer:UDP and TCP ICMP IP TCP.

Similar presentations


Presentation on theme: "資 管 Lee Lesson 8 User Datagram Protocol (UDP). 資 管 Lee UDP TCP/IP protocol suite specifies two protocols for the transport layer:UDP and TCP ICMP IP TCP."— Presentation transcript:

1 資 管 Lee Lesson 8 User Datagram Protocol (UDP)

2 資 管 Lee UDP TCP/IP protocol suite specifies two protocols for the transport layer:UDP and TCP ICMP IP TCP UDP IGMP SMTPFTPTFTPDNSSNMP BOOTP Application layer Transport layer Network layer Data link layer Physical layer Underlying LAN or WAN technology RARP ARP

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

4 資 管 Lee IP header 193.14.26.7 13 UDP header Port number selects the process Processes 193.14.26.7 0 1,023 1,024 49,151 49,152 65,535 Well-known Registered Dynamic PortProtocolDescription 7EchoEchoes a received datagram back to the sender 9DiscardDiscards any datagram that is received 11UsersActive users 13DaytimeReturns the date and time 17QuoteReturns a quote of the day 19ChargenReturns a string of characters 53NameserverDomain Name Service 67BootpsServer port to downlaod bootstrap information 68BootpcClient port to download bootstrap information 69TFTPTrivial file transfer protocol 111RPCRemote Procedure Call 123NTPNetwork time protocol 161SNMPSimple network management protocol 162SNMPSimple network management protocol (trap) 193.14.26.7 13 Socket address

5 資 管 Lee UDP packet-User Datagram Source port number (16 bits) Destination port number (16 bits) Total length 16 bits Checksum 16 bits HeaderData UDP datagram format Source port, Dest. Port: range from 0 to 65,535. Length: total length of the user datagram(UDP), header plus data. Why this field exist? Checksum: contains three sections, a pseudoheader, the UDP header, and the data.

6 資 管 Lee Checksum field in UDP packet 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) TE: 5 4 4 5 ST: 5 3 5 4 IN: 4 9 4 E G0: 4 7 0 0 pseudoheader 153.18.8.105 171.2.14.10 All 0s1715 108713 15All 0s TEST ING Only used in the checksum Calculation Optional use of the Checksum: If the checksum is not calculated, the field is filled with 0s.

7 資 管 Lee UDP Operation Message from process UDP header UDP data IP header IP data Frame header Frame data Process a. Encapsulation b. Decapsulation Message from process UDP header UDP data IP header IP data Frame header Frame data Process 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. Process which uses UDP must provide for these mechanisms.

8 資 管 Lee UDP Operation UDP Daytime client Port 52000 Incoming queue Outgoing queue UDP Daytime server Port 13 Incoming queue Outgoing queue 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.

9 資 管 Lee UDP Design Input module Process Queues Output module 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. Process Control-block module …… Control-block table Data Processes (when started) UDP User datagram IP UDP

10 資 管 Lee 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.

11 資 管 Lee Examples StateProcess IDPort NumberQueue Number IN-USE2,34552,01034 IN-USE3,42252,011 FREE IN-USE4,65252,01238 FREE Example 1: arrival of a user datagram with destination port number 52,012. Ans: Example 2: After a few seconds, a process starts. Get port number 52,014 from OS. The control-block table at the beginning of examples StateProcess IDPort NumberQueue Number IN-USE2,34552,01034 IN-USE3,42252,011 FREE IN-USE4,65252,01238 FREE

12 資 管 Lee StateProcess IDPort NumberQueue Number IN-USE2,34552,01034 IN-USE3,42252,011 FREE IN-USE4,65252,01238 FREE Example 3: A user datagram now arrives for port 52,011. Example 4: A user datagram now arrives for port 52,223. Example 5: A process needs to send a user datagram: StateProcess IDPort NumberQueue Number IN-USE2,34552,01034 IN-USE3,42252,011 FREE IN-USE4,65252,01238 FREE

13 資 管 Lee Practice set If the outgoing queue of a UDP client overflows, a. the user data grams are discarded and a port unreachable message is sent. b. the operating system asks the server to wait before any more messages are sent c. new queues are initiated d. the operating system asks the client process to wait before any more messages are sent. If the incoming queue of a UDP client overflows, If the incoming queue of a UDP server overflows, Which component in our UDP package allocates the queus? a. control-block module b.. control-block table c. input module d. output module Which component in our UDP package communicates with the ICMP software? The following is a dump of a UDP header in hexadecimal format. 06 32 00 0D 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 data? e. is the packet directed from a client to a server or vice versa?

14 資 管 Lee 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.

15 資 管 Lee TFTP, a protocol quickly copies(writes) the files. used in bootstrap or DHCP. Operation: ◦ Reading: copy a file from the server site to the client. ◦ Writing: copy a file from the client site to the server site. TFTP uses the services of UDP on the well-known port 69. Five types of message, RRQ, WRQ, DATA, ACK, and ERROR

16 資 管 Lee RRQ- read request message OPcode =1 File nameAll 0sModeAll 0s 2 bytes Variable 1 byte Variable (netascii, (ASCII )or octet (binary file) RRQ message format (the client establish a connection for reading data from the server.) OPcode =2 File nameAll 0sModeAll 0s 2 bytes Variable 1 byte Variable (netascii, (ASCII )or octet (binary file) WRQ message format (the client establish a connection for writing data to the server.)

17 資 管 Lee OPcode =3 Block number Data 2 bytes DATA message format (Server or client send blocks of data) 2 bytes 0~512 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. OPcode =4 Block number 2 bytes ACK message format 2 bytes

18 資 管 Lee OPcode =5 Error number DataAll 0s 2 bytes ERROR message format Variable 2 bytes 1 byte NumberMeaning 0Not defined 1File not found 2Access violation 3Disk full or quota on disk exceeded 4Illegal operation 5Unknown port number 6File already exists 7No such user 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.

19 資 管 Lee 資 管 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.

20 資 管 Lee 資 管 Connection asciifile11 31 First block of data 5 Error data ERROR OR Server Client asciifile12 41 5 Error data ERROR Server Client RRQ DATA WRQ ACK OR 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.

21 資 管 Lee examples Assume a client claim a file of 1356 bytes from the servers. (assume: the file name size is 20 bytes) 1.How many data messages is required? 2.List the IP datagram sizes for each data message? 3.(assume no error exists): list all the messages for both client and server operation and the IP datagram sizes for each messages?

22 資 管 Lee 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. 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. Flow 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. Error Control

23 資 管 Lee Error Control is needed in four situations: damaged message, lost message, lost ack, or Duplicated message. Damaged message: Receiver: If a block of data is damaged, it will detected by the receiver and the Block is discarded. The checksum field in the UDP provide the damaged check for the message. Sender waits for the ACK and does not receive it within the time-out period. 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.

24 資 管 Lee Sorcerer’s Apprentice Bug( 魔法師學徒蟲 ) Server Client Block 5 ack 5 Block 5 ack 5 Block 6 ack 5 ack 6 Block 7 Situation occurs when the ACK message for a message is not lost, but delayed. 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.

25 資 管 Lee UDP ports Server 69 Client Passive open Server 69 Client 50032 Active open Server 69 Client 50032 a. Passive open by server 62001 b. Active open by client a. Rest of Communication

26 資 管 Lee TFTP Example asciifile11 31 Block 1: 512 bytes Server Client RRQ 14 32 Block 2: 512 bytes Lost 32 Block 2: 512 bytes 24 24 Damaged 33 Block 3: 312 bytes 34   The client wants to retrieve the content of a 1336-byte file called file1. Step 1: the client sends an RRQ message. Step 2:The server sends the first block with 512 byte. Step 3: ACK Step 4: lost DATA of block 2 Step 5: time-out then resend DATA of block 2. Step 6: ACK to block 2 {damaged} Step 7: time-out, resend the ACK …

27 資 管 Lee Security ClientServer TELNET client TFTP server TFTP client TELNET server 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.

28 資 管 Lee 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 I conjunction with the BOOTP or DHCP protocols. It can easily be configured into ROM. When the station is powered on, TFTP will be Connected to a server and can download the config. Files from there. BOOTP { get the config. File} TFTP { get the content of the config. File}

29 資 管 Lee Practice set The ERROR message can follow a ? Message. a. PRQ b. WRQ c. DATA d. all The flow-control mechanism in TFTP is called. a. stop-and-wait b. sliding window c. is nonexist d. depends on the TFTP Describe the connection establishment in TFTP? Describe the connection termination in TFTP? Describe the flow control in TFTP? Describe the error control in TFTP?

30 資 管 Lee PortTCPUDPDescriptionStatus 0TCPUDPReservedOfficial 1TCPUDPTCP Port Service MultiplexerOfficial 2TCPUDPManagement UtilityOfficial 3TCPUDPCompression ProcessOfficial 4TCPUDPUnassignedOfficial 5TCPUDPRemote Job EntryOfficial 6TCPUDPUnassignedOfficial 7TCPUDPEchoOfficial 8TCPUDPUnassignedOfficial 9TCPUDPDiscardOfficial 10TCPUDPUnassignedOfficial 11TCPUDPActive UsersOfficial 12TCPUDPUnassignedOfficial 13TCPUDPDAYTIMEDAYTIME – (RFC 867)RFC 867Official 14TCPUDPUnassignedOfficial 16TCPUDPUnassignedOfficial 17TCPUDPQuote of the DayOfficial 18TCPUDPMessage Send ProtocolOfficial 19TCPUDPCharacter GeneratorOfficial 20TCPFTPFTP – dataOfficial 21TCPFTPFTP – control (command)Official 22TCPUDP Secure ShellSecure Shell (SSH)—used for secure logins, file transfers (scp, sftp) and port forwardingfile transfersscpsftp Official 23TCP TelnetTelnet protocol—unencrypted text communications Official USA only 24TCPUDPPriv-mail : any private mail system.Official 25TCP Simple Mail Transfer ProtocolSimple Mail Transfer Protocol (SMTP)— used for e-mail routing between mail servers Official 34TCPUDP Remote File (RF)—used to transfer files between machines Unofficial 35TCPUDPAny private printer server protocolprinter serverOfficial 37TCPUDPTIME protocolOfficial 39TCPUDP Resource Location Protocol [2] (RLP)—used for determining the location of higher level services from hosts on a network [2]serviceshostsnetwork Official 41TCPUDPGraphicsOfficial 42TCPUDP nameserver, ARPA Host Name Server ProtocolARPAHost Name Server Protocol Official 42TCPUDPWINSUnofficial 43TCPWHOISWHOIS protocolOfficial 47TCPGREGRE protocolOfficial 49TCPUDPTACACSTACACS Login Host protocolOfficial 50TCPUDPEncapsulating Security PayloadEncapsulating Security Payload (ESP)Official 51TCPUDPAuthentication HeaderAuthentication Header (AH)Official 52TCPUDP XNS (Xerox Network Systems) Time ProtocolXerox Network Systems Official 53TCPUDPDomain Name SystemDomain Name System (DNS)Official 54TCPUDP XNS (Xerox Network Systems) ClearinghouseXerox Network Systems Official 55TCPUDPISI Graphics LanguageISI Graphics Language (ISI-GL)Unofficial 56TCPUDP XNS (Xerox Network Systems) AuthenticationXerox Network Systems Official 56TCPUDPRoute Access Protocol (RAP) [3] [3] Unofficial 57TCPMail Transfer ProtocolMail Transfer Protocol (MTP)Unofficial 58TCPUDPXNS (Xerox Network Systems) MailXerox Network SystemsOfficial 67UDP Bootstrap ProtocolBootstrap Protocol (BOOTP) Server; also used by Dynamic Host Configuration Protocol (DHCP)Dynamic Host Configuration Protocol Official 68UDP Bootstrap ProtocolBootstrap Protocol (BOOTP) Client; also used by Dynamic Host Configuration Protocol (DHCP)Dynamic Host Configuration Protocol Official 69UDPTrivial File Transfer ProtocolTrivial File Transfer Protocol (TFTP)Official 70TCPGopherGopher protocolOfficial 79TCPFinger protocolOfficial 80TCPUDPHypertext Transfer ProtocolHypertext Transfer Protocol (HTTP)Official 81TCPTorparkTorpark—Onion routingOnion routingUnofficial 82UDPTorparkTorpark—ControlUnofficial 83TCPMIT ML DeviceOfficial


Download ppt "資 管 Lee Lesson 8 User Datagram Protocol (UDP). 資 管 Lee UDP TCP/IP protocol suite specifies two protocols for the transport layer:UDP and TCP ICMP IP TCP."

Similar presentations


Ads by Google