CS 455/555 Data Communications and Computer Networks – Fall 2005 Introduction to Transport Protocols: Transmission Control Protocol (TCP) & User Datagram Protocol (UDP) Chapters 24 & 25 Reliable Stream transport Service • Problem: If underlying protocol is unreliable, how do we guarantee efficient, reliable delivery? – Write complex applications that handle network-related error conditions – Increase the complexity of the underlying protocols to include reliable transport – Develop a general purpose protocol that guarantees reliable stream delivery and that removes reliability responsibilities from the applications and lower-layer protocols. Introduction • Internet Protocol (IP) provides “unreliable datagram service” between hosts. At the IP layer, a destination address only identifies a host computer. – For which user or application? • Transport protocols provide end-to-end delivery between endpoints of a connection, e.g., processes or programs. End-to-End Communication Introduction (continued) • IP datagram service is unreliable in that datagrams may be – Lost (usually dropped due to congestion) – Duplicated – Delivered out of order • TCP provides reliable service nevertheless • Challenge: – How to provide a reliable transport service over unreliable (conceptually) technology? Transport and Network Layers • Transport Layer Services: – – – – Reliable/Unreliable data transfer Delay guarantees Bandwidth guarantees Security • Transport protocol is built using services from Network Layer • Transport services can be constrained by the services of the underlying network layer protocol – Delay and bandwidth guarantees – Unreliable data transfer Internet Transport Layer • User Datagram Protocol (UDP) and Transmission Control Protocol (TCP) are Internet transport layer protocols • We refer to layer 4 PDU as a segment (for both UDP and TCP) • The Network Layer protocol, IP, is a besteffort delivery service (unreliable). • UDP and TCP provide application multiplexing & demultiplexing and data integrity Multiplexing/Demultiplexing Protocol software throughout the layers multiplex or demultiplex among objects at the next layer. – At the transport layer level: • Demultiplexing - delivering segments to the correct application process • Multiplexing - gathering data at the source host from different processes and encapsulation Demultiplexing Application Application Transport ICMP Application Application TCP UDP IGMP Network IP ARP Link RARP Ethernet Driver incoming frame Application Demultiplexing Details 1024-5000 FTP server 21 User process User process User process User process TCP src port ICMP UDP 17 1 IGMP 2 Others TCP dest port source addr hdr cksum type IP x0800 AppleTalk data TCP RARP x8035 Novell discard 9 server header 6 IP header protocol x0806 7 ARP dest addr TCP telnet 23 server echo server Ethernet frame type dest addr source addr data IP data (Ethernet frame types in hex, others in decimal) CRC TCP Connections • Virtual • An ordered pair of endpoints – An endpoint is an ordered pair containing • An IP address • A TCP port number • This information is kept by the OS – netstat Port Numbers FTP client, port 1184 FTP protocol FTP server, port 21 TCP TCP protocol TCP IP IP protocol IP Ethernet protocol Ethernet Driver Ethernet Driver • TCP and UDP use port numbers to identify the applications at each end of a communication. • How are these port numbers chosen? How port numbers are chosen • Port numbers are managed by the Internet Assigned Numbers Authority (IANA) – http://www.iana.org/assignments/port-numbers • Servers are known by their well-known port number e.g. FTP TCP port 21 Telnet TCP port 23 Biff UDP port 512 • Clients use ephemeral port numbers (“ephemeral” means “short-lived”) • Most (but not all) TCP/IP implementations allocate ephemeral 1024-5000 How port numbers are chosen • The port numbers are divided into three ranges: – the Well Known Ports, – the Registered Ports, – and the Dynamic and/or Private Ports. • The Well Known Ports are those from 0 through 1023. • The Registered Ports are those from 1024 through 49151 • The Dynamic and/or Private Ports are those from 49152 through 65535 Well-known port numbers • Can be found in /etc/services on Unix system [codd:~] [9:57am] -> grep telnet /etc/services telnet 23/tcp [codd:~] [9:57am] -> grep daytime /etc/services daytime 13/tcp daytime 13/udp [codd:~] [9:58am] -> grep echo /etc/services echo 7/tcp echo 7/udp • Are independent on UDP vs. TCP, but when same service is offered, same number is used Reserved Ports • On Unix systems, ports between 1 and 1023 are reserved ports • Only a superuser process can assign itself a reserved port • This fact is used by some applications (e.g. rlogin) to implement security between client and server. – not very secure however, in era of PC’s and workstations!!! Some Sample Services • There are a few standard, simple services that almost every TCP/IP implementation provides. • Three examples: TCP UDP Name port port RFC Description echo 7 7 862 server echoes what client sends discard 9 9 863 server discards what client sends daytime13 13 867 server returns time/date in ascii UDP • Adds very little to IP: – Multiplexing/demultiplexing – Error checking • Some applications are better suited for UDP because: – – – – – No connection establishment No connection state Small packet overhead Unregulated send rate Multicast Applications and Transport Protocols Application Application-Layer Protocol Underlying Transport Protocol Email SMTP TCP Remote Terminal Access Telnet TCP Web HTTP TCP File Transfer FTP TCP Remote File Server NFS Typically UDP Streaming Multimedia Proprietary Typically UDP Network Management SNMP Typically UDP Routing Protocol RIP Typically UDP Name Translation DNS Typically UDP TCP • Transmission Control Protocol (TCP) is most widely used transport protocol • Provides reliable data delivery by using IP unreliable datagram delivery • Compensates for loss, delay, duplication and similar problems in Internet components • Reliable delivery is high-level, familiar model for construction or applications TCP • TCP is protocol (rules, formats), not a piece of software • “specifies the format of data and acknowledgements that two computers exchange in order to achieve reliable transfer, as well as the procedures the computers use to ensure that data arrives correctly” • Determines how hosts should recover from errors like lost or duplicate packets • Details initiation and completion procedures for a TCP stream transfer between 2 hosts TCP Services • Characteristics of services provided to applications: – connection-oriented: • Connection state resides entirely on end system • end nodes must agree before transfer can begin – Point-to-point: • TCP uses port to identify the destination user process within a host • After port numbers are assigned on both ends, transfer may begin • Does not allow multicasting – complete reliability: no data loss or out-of-order – Provides full duplex communication: • concurrent transfer in both ways • appears as 2 independent streams – Stream interface: • data sent to or received from TCP in streams of bits, divided into octets • unstructured datastream: does not honor “structured” streams of data (like records in a file) • buffered transfer - protocol SW free to divide streams into packets regardless of how the application sends – reliable connection startup: • Virtual Circuit connection - contact made; negotiate for reliability options; inform applications of ready status – graceful connection shutdown; • all data guaramteed to be delivered before closing the connection TCP “Service” Summary • Transport layer makes data transmission transparent to the upper layers • Responsible for end-to-end delivery, segmentation and concatenation • TCP provides a service to the application layer which is: – connection-oriented: connection established before communication takes place, terminated when done, through 3-way handshakes. – byte-stream: no record boundaries, no structure, just a sequence of bytes. TCP “Service” Summary (cont.) – reliable: • • • • no loss: lost packets are retransmitted no corruption: checksums insure integrity ordered: data delivered in the order it was received no duplicates – flow controlled: fast sender will not overwhelm slow receiver, or waste bandwidth on the network, entire network cooperates to avoid congestion. – full-duplex: every connection is bi-directional.