Chapter 5 End-to-End Protocols Transport layer turns the host-to-host packet delivery service of the underlying network into a process-to-process communication channel Common properties that application processes expect a transport protocol to provide: o Guarantees message delivery o Delivers messages in the same order they were sent o Delivers at most one copy of each message o Supports arbitrarily large messages o Supports multiple application processes on each host Typical limitations of the network upon which the transport protocol operates o Drop messages o Reorder messages o Deliver duplicate copies of a given message o Limit messages to some finite size o Deliver messages after an arbitrarily long delay The challenge for transport protocols is to turn the less-thandesirable properties of the underlying network into the service required by application programs User Datagram Protocol (UDP) UDP simply extends the host-to-host delivery service of IP into a process-to-process communication service o UDP adds a level of demultiplexing which allows multiple application processes on each host to share the network
o UDP adds no other functionality to the best-effort IP service UDP provides unreliable connectionless service An application process is identified by a port on some particular host a <host, port> pair o Servers use well-known ports E.g., Port 80 for web server, port 53 for DNS server, port 25 for mail server o A port is implemented by a message queue UDP datagram format o SrcPort/DestPort indicates the port for the source/destination process o Length: number of bytes in the UDP datagram, including the header and the data o Checksum: computed over the entire UDP datagram and the pseudoheader The pseudoheader consists of source IP address, destination IP address, and protocol number from the IP header plus the UDP length field The pseudoheader is used to verify that the datagram has been delivered between the correct two endpoints UDP checksum is optional in IPv4, mandatory in IPv6. UDP checksum is set to zero if not used The Transmission Control Protocol (TCP) TCP offers a reliable, connection-oriented, byte-stream service o Reliable, in-order delivery of a stream of bytes o Two application processes must establish a TCP connection in order to communicate using TCP
o Full duplex operation: each TCP connection supports a pair of byte streams, one in each direction o A flow control mechanism keeps the sender from over-running the receiver o A congestion control mechanism keeps the sender from overloading the network TCP uses the sliding window algorithm on an end-to-end basis to provide reliable and ordered delivery. However, because TCP runs over the Internet rather than a point-to-point link, there are many important differences that complicate TCP o TCP supports logical connections between processes running on any two computers in the Internet Need explicit connection establishment and teardown o TCP connections may have widely different RTTs, and RTT may vary during a single TCP connection Need adaptive timeout mechanism o Potentially long delay in the network Need to be prepared for very old packets to suddenly show up at the receiver, potentially confusing the sliding window algorithm o Potentially different capacity at destination host Each side needs to learn how much buffer space the other side can allocate to the connection (i.e., flow control) o Network is shared by many hosts Need to be prepared for network congestion TCP is a byte-oriented protocol: the sender writes bytes into a TCP connection and the receiver reads bytes out of the TCP connection
o TCP on the source host buffers enough bytes from the sending process to fill a reasonably sized packet and then sends this packet to its peer on the destination host o TCP on the destination host then empties the contents of the packet into a receive buffer, and the receiving process reads from this buffer at its leisure o The packets exchanged between TCP peers are called segments TCP segment format o SrcPort/DstPort identify the source/destination port A TCP connection is uniquely identified by the 4-tuple <srcport, SrcIPAddr, DstPort, DstIPAddr> o SequenceNum: the sequence number for the first byte of data carried in the segment Each byte of data has a sequence number o Acknowledgement: the next sequence number expected o AdvertisedWindow: number of bytes, beginning with the sequence number indicated in the Acknowledgement field, that the receiver is able to accept o HdrLen: length of the header in 32-bit words o Flags SYN: used in connection establishment FIN: used in connection termination RESET: used when one side wants to abort the connection ACK: set when the Acknowledgement field is valid URG: indicate that this segment contains urgent data Urgent data is contained at the front of segment body, before the nonurgent data UrgPtr indicates the number of bytes in urgent data
PUSH: indicates that the sending process wants TCP to send whatever bytes it had collected to its peer o Checksum: computed over the entire TCP segment and the pseudoheader The pseudoheader consists of source IP address, destination IP address, and protocol fields from the IP header plus a TCP length field (length of the TCP header and data measured in bytes) Required in both IPv4 and IPv6. o Options: up to 40 bytes, attached after the mandatory fields