240 likes | 458 Views
User Datagram Protocol (UDP). Chapter 11. Know TCP/IP transfers datagrams around Forwarded based on destination’s IP address At IP layer, destination address identifies host Made no further distinction about which application on the host gets the datagram
E N D
User Datagram Protocol (UDP) Chapter 11
Know TCP/IP transfers datagrams around • Forwarded based on destination’s IP address • At IP layer, destination address identifies host • Made no further distinction about which application on the host gets the datagram • This chapter extends TCP/IP protocol suite • Adds mechanism to distinguish among hosts • Multiple applications on a given computer can send and receive datagrams independently
The Ultimate Destination • Most OSs support multiprogramming • Multiple applications execute simultaneously • In OS terms, each executing program is a process, task, application program, or user level process • Systems are called multitasking systems
Is a process the ultimate destination? • Seems natural; but is a bit misleading • Processes are created and destroyed dynamically • Want to replace processes without notifying senders • Want to identify destinations by function • Not by process that implements them • Single process may handle multiple functions • Want process to decide which function the sender wants • So, we will abstract the problem • Imagine each machine has a set of protocol ports • Each port identified by a positive integer • Local OS provides means to specify or access a port
Most OS’s provide synchronous port access • Computation stops during port access operation • Block process extracting data if no data there • Most ports are buffered • Puts waiting data in a finite queue • To communicate with a foreign port • Sender must know IP address & protocol port # • Messages must carry • Destination port on the machine receiving the msg • Source port on the machine sending the msg
User Datagram Protocol (UDP) • Provides primary mechanism for application programs to swap datagrams • Provides protocol ports to distinguish among multiple executing programs • Uses IP to transport messages between machines • Provides same unreliable, connectionless image • No acknowledgements; no ordering of incoming msgs • No feedback for rate control; can lose messages
Application programs have full responsibility for: • Reliability • Message loss • Duplication • Out-of-order delivery • Loss of connectivity • Unfortunately, most application programmers ignore this responsibility • Testing is usually done in controlled, reliable LANs • Fail dramatically when used in TCP/IP internet
Format of UDP Messages • Each UDP message is a user datagram • Has a header and data area
UDP Pseudo-Header • Checksum can cover data in datagram • Need to ensure more than that • Datagram only has protocol port number • Correct destination includes specific machine • Want to compute checksum on destination IP as well as UDP datagram • Constructs pseudo-header and includes in checksum computation
Pseudo-header • Sender computes checksum over pseudo-header and datagram • Only datagram gets sent • Receiver reconstructs pseudo-header by extracting fields from the IP header UDP datagram
UDP Encapsulation & Protocol Layering • UDP is our first transport protocol example
Layering above UDP means complete UDP message (header and data) is encapsulated in an IP datagram • UDP datagram in IP datagram data area • IP datagram in frame data area • Layering provides division of duties • IP layer identifies source & destination hosts • UDP layer identifies source or destination ports within a host
Layering & UDP Checksum • Violation of layering rules with checksum • Pseudo-header needs source & dest IP address • UDP must interact with IP layer to get these • Regardless of method, still interacts • Violates separation of functionality by layering • UDP is tightly integrated with IP • Compromise made for practical reasons
UDP Multiplexing, Demultiplexing, & Ports • Thru the layers, SW must mux and demux among multiple objects at next layer • UDP provides another example of this • Accepts UDP datagrams from many application programs • Passes to IP for transmission • Takes arriving datagrams • Passes each to appropriate application program
Conceptually, mux & demux occurs at ports • In practice, little more involved • Applications negotiate with OS to obtain a port protocol and associated port number • One assigned, application puts the port number in all outgoing UDP datagrams • Think of ports as queues • OS creates internal queue when provides port • UDP receives datagram, see if port # matches one • If not, sends port unreachable ICMP error msg, discards • If is, enqueues datagram at port for application program • If port full, get error and datagram discarded
Reserved & Available Ports • How should port numbers be assigned? • Two computers must agree on port numbers • A wants file from B; needs to know what port the file transfer program on B uses • Two fundamental approaches • Central authority • Dynamic binding
Central Authority • Everyone agrees that central authority assigns • List of assignments will be published • All software will be built according to the list • Also called universal assignment • Called well-known port assignments • Dynamic Binding • Ports not globally known • Software assigns ports when needed • Must send request to computer to learn of assignments • Target machine replies with the port number to use
TCP/IP uses hybrid approach • Some ports globally assigned a priori • Many left available for local sites or applications • Low values going up are assigned • Higher values left open
Summary • Can have multiple applications executing • UDP distinguishes among these processes • Uses two 16-bit integers for port numbers • Some are pre-assigned (well-known) • Some available for arbitrary use
UDP is a thin protocol • Not add significantly to semantics of IP • Provides way for applications to use IP to communicate • Unreliable, connectionless • UDP lies in transport layer • Conceptual independence between it and internet layer is somewhat violated