Content User Datagram Protocol () Linda Wu protocol Process-to-process communication Port number assignment User datagram operation (CMPT 471 2003-3) Reference: chapter 12 Notes-8 CMPT 471 2003-3 2 Protocol Protocol (cont.) User Datagram Protocol Allows multiple application programs executing on a computer to send and receive datagrams independently Uses to transport messages between machines Unreliable, connectionless datagram delivery Application Transport Network Data link physical SMTP FTP DNS SNMP IGMP TCP ICMP Underlying LAN / WAN technology ARP BOOTP RARP Notes-8 CMPT 471 2003-3 3 Notes-8 CMPT 471 2003-3 4
Protocol (cont.) Transport protocol responsibilities Create process-to-process communication : port number Provide control mechanism at transport level : no flow control or acknowledgement for received packets; provide error control to some extent Provide connection mechanism for processes : receive data unit from process, deliver it unreliably to the receiver; the data unit must be small enough to fit in a packet Protocol (cont.) Why use? is a very simple protocol using a minimum of overhead Suitable for a process that wants to send a small message and does not care much about reliability Suitable for a process with internal flow control and error-control mechanism is used in: SNMP, R, multicasting, broadcasting Notes-8 CMPT 471 2003-3 5 Notes-8 CMPT 471 2003-3 6 Process-to-Process Communication Host-to-host communication At computer level Message is delivered to the destination machine protocol Process-to-process communication At process level Message is delivered to the appropriate process Transport protocol such as Process-to-Process Communication (cont.) Client-server paradigm for process-toprocess communication Client: process that needs services; multiple client programs can run on a local computer Server: process that provides services; multiple server programs can run in a remote computer Definitions: Local host address Local process port number Remote host address Remote process port number Notes-8 CMPT 471 2003-3 7 Notes-8 CMPT 471 2003-3 8
Process-to-Process Communication (cont.) address v.s. port number 141.14.26.7 13 141.14.26.7... address: selects the host 13 13 Port #: selects the process Port Number Assignment Port numbers in TCP/ 0 ~ 65,535 IANA ranges Well-known ports (0 ~ 1,023): assigned and controlled by IANA Registered ports (1,024 ~ 49,151): be registered with IANA to prevent duplication Dynamic ports (49,152 ~ 65,535): can be used by any process Server port number Universal port number: well-known port number Client port number Dynamic binding: not globally known, chosen randomly by the software Notes-8 CMPT 471 2003-3 9 Notes-8 CMPT 471 2003-3 10 Port Number Assignment (cont.) Well-known ports used with Port 0 7 11 13 17 19 53 67 68 Unix keyword - Echo User Daytime Quote Chargen Nameserver Bootps Bootpc Description Reserved Echo a received datagram back to the sender Active users Return the date and time Return a quote of the day Return a string of characters Domain name service Server port to download bootstrap information Client port to download bootstrap information Notes-8 CMPT 471 2003-3 11 Port Number Assignment (cont.) Port numbers in Linux File /etc/services Use IANA port assignment Gives network service names, the corresponding protocol names and port numbers Most of the well-known port numbers are assigned to both and TCP Notes-8 CMPT 471 2003-3 12
User Datagram message is called user datagram Source / destination port Message length: # of bytes in both and data area ( 8) length = length length Checksum: applies to entire datagram data area: (65,535 8 20) bytes 0 Source Port (optional) Message Length Destination Port Checksum (optional) Notes-8 CMPT 471 2003-3 13 16 DATA 31 User Datagram (cont.) Checksum calculation Checksum: an optional field All 0s: to indicate the checksum has not been computed All 1s (negative zero): computed checksum is zero pseudo- Source / destination address PROTO: to ensure the packet belongs to, not to TCP; = 17 length: length of datagram, not including pseudo- * Not transmitted with datagram Notes-8 CMPT 471 2003-3 14 User Datagram (cont.) User Datagram (cont.) Pseudo 0 ZERO 8 Source Port Source address PROTO Message Length 16 Destination address length Destination Port Checksum DATA (Add padding to make the data a multiple of 16 bits) 31 Checksum calculation at sender 1. Add pseudo- to datagram 2. Fill in the checksum field with zeros 3. Divide the total bits into 16-bits words 4. If # of bytes is not even, add 1 byte of padding (all 0s) 5. Add all 16-bit sections using one s complement arithmetic 6. Complement the result (0 1, 1 0), which is a 16-bit number, and insert it to the checksum field 7. Drop the pseudo- and any padding 8. Deliver the datagram to the software for encapsulation Notes-8 CMPT 471 2003-3 15 Notes-8 CMPT 471 2003-3 16
User Datagram (cont.) Checksum calculation at receiver 1. Add pseudo- to datagram 2. Add padding if needed 3. Divide the total bits into 16-bits sections 4. Add all 16-bit sections using one s complement arithmetic 5. Complement the result 6. If the result is all 0s, drop the pseudo and any padding and accept the the datagram; otherwise, discard the datagram User Datagram (cont.) Purpose of pseudo- To verify that the datagram has reached its correct destination ( address, port number) Pseudo- assemble Sender side: the fields values are known Receiver side: exact the corresponding fields from the of datagram that carries the datagram Notes-8 CMPT 471 2003-3 17 Notes-8 CMPT 471 2003-3 18 Operation Connectionless services Each datagram sent by is an independent datagram cannot chop a stream of data into different related user datagrams Each request must be small enough to fit into one user datagram Only processes sending short message should use Operation (cont.) Flow and error control No flow control No error control except for checksum The sender does not know whether the message has been lost When the receiver detects an error through checksum, it discards it silently The process using should provide flow and error control by itself Notes-8 CMPT 471 2003-3 19 Notes-8 CMPT 471 2003-3 20
Frame Operation (cont.) Encapsulation & decapsulation data Frame data Process Message data Frame data Frame data Process Message data Operation (cont.) Queuing Queues are opened for server / client processes 2 queues for each process Incoming queue: receive messages Outgoing queue: send messages The queues function as long as the process is running The queues are destroyed when the process terminates Encapsulation Decapsulation Notes-8 CMPT 471 2003-3 21 Notes-8 CMPT 471 2003-3 22 Operation (cont.) Operation (cont.) Outgoing queue Daytime client Port 52000 Incoming queue Outgoing queue Daytime server Port 13 Incoming queue Queues on the client side The client process requests a port number from the operating system The process opens incoming and outgoing queues with the requested port number Queues on the server side The server asks for incoming and outgoing queues using its well-known port number Notes-8 CMPT 471 2003-3 23 Notes-8 CMPT 471 2003-3 24
Operation (cont.) Outgoing queue overflow The operating system asks the server / client to wait before sending any more messages Incoming queue overflow drops the datagram and asks the ICMP protocol to send port unreachable message to the datagram sender Operation (cont.) Multiplexing & demultiplexing In a host running TCP/, there are: One Possibly several processes that want to use services Processes Processes No incoming queue created for the port number specified in the arrived datagram discards the datagram and asks the ICMP protocol to send port unreachable message to the datagram sender Multiplexer Sender Demultiplexer Receiver Notes-8 CMPT 471 2003-3 25 Notes-8 CMPT 471 2003-3 26 Operation (cont.) Multiplexing Sender side: there may be several processes that need to send user datagrams Many-to-one relationship: multiplexing accepts messages from different processes Differentiates messages by their port numbers Adds to each message Passes user datagram to Operation (cont.) Demultiplexing Receiver side: there may be several processes that can receive user datagrams One-to-many relationship: demultiplexing receives user datagram from Checks errors in user datagram Drops the Delivers the message to the appropriate process based on the port number Notes-8 CMPT 471 2003-3 27 Notes-8 CMPT 471 2003-3 28
Appendix: 1 s Complement Arithmetic All computers use 2 s complement representation 2 s complement integers Binary Dec Hex 0000 0000 0 00 0000 0001 1 01 0000 0010 2 02 0000 0011 3 03 1111 1111-1 FF 1111 1110-2 FE 1111 1101-3 FD 1 s complement integers Binary 0000 0000 0000 0001 0000 0010 0000 0011 1111 1111 1111 1110 1111 1101 1111 1100 Dec Notes-8 CMPT 471 2003-3 29 0 1 2 3-0 -1-2 -3 Hex 00 01 02 03 FF FE FD FC 1 s Complement Arithmetic (cont.) Example: -3 + 5 = 2 Using 2 s complement: FD + 05 = 01 02 Discarding the carry (01) gives the result Using 1 s complement: FC + 05 = 01 01 Adding the carry (01) to the LSB (01) gives the result: 01 + 01 = 02 * 1 s complement sum is done by summing the numbers and adding the carry (carries) to the result in the rightmost position Notes-8 CMPT 471 2003-3 30