What Can IP Do? Deliver datagrams to hosts – The IP address in a datagram header identify a host IP treats a computer as an endpoint of communication Best effort delivery -- no guarantees
What Do Your Applications Need? Individual packets go to their own applications – Your machine may run multiple applications simultaneously Outlook, Firefox, Windows Media Player. Different levels of services – Every bit of information should be received correctly. – Can tolerate some information loss Streamed media
Transport Layer Services Transport layer provides end-to-end connectivity across the network – Virtual communications via TCP software
Endpoint Identification with Protocol Port Numbers Port numbers – Independent of the OS All computers running TCP and UDP recognize the standard protocol port numbers TCP and UDP must provide a mapping between protocol port numbers and the program identifiers that the OS uses
Well-Known Port Numbers 22: SSH 25: SMTP 80: HTTP _UDP_port_numbers _UDP_port_numbers
Layer 4 Packet: Segment Segments carry application data across the network Segments are carried within IP datagrams within frames App, e.g., HTTPIPTCP Frame Segment Datagram
Transport Layer Services TCP/IP suite contains two transport protocols. – User Datagram Protocol (UDP) – Transmission Control Protocol (TCP) UnreliableReliable MessagesUDP? Stream?TCP
Comparison of Transport Protocols TCP is full-featured, UDP is a glorified packet TCP (Stream)UDP (Message) ConnectionsConnectionless Point-to-point communicationArbitrary Interaction Bytes are delivered once, reliably, and in order Message may be lost, reordered, duplicated Arbitrary length contentLimited message size Flow control matches sender to receiver Can send regardless of receiver state Congestion control matches sender to network Can send regardless of network state
UDP: User Datagram Protocol
User Datagram Protocol Used by apps that don’t want reliability or stream service – Voice-over-IP (unreliable) – DNS, RPC (message-oriented) – DHCP (bootstrapping, multicast) Arbitrary Interaction – 1 1; 1 N; N 1; or N M Best-effort delivery via IP – Lost, duplicated, delayed, delivered out-of order, corrupted
User Datagram Protocol Places the data in a single message for transmission – In practice, choose message size that fits in a standard MTU (e.g., 1500 bytes) 1400 or 1450 to leave space for IP and UDP headers Pros: – Applications preserve data boundaries Cons: – Each UDP message must fit into a single IP datagram – UDP message size can lead to inefficient use of the network
UDP Datagram Format Each UDP message is called a user datagram and consists of two parts: – a short header that specifies the sending and receiving application – a payload that carries the data being sent
UDP Checksum and Pseudo Header Checksum: An optional, 16-bit field may be used by the destination host to verify whether the message reaches the correct destination. – All bits set to 0 if unused When computing the checksum, UDP software includes a pseudo header:
Using the Pseudo Header The destination host must obtain the UDP length, and the source, destination, and type field from the IP datagram to verify the checksum value. The pseudo header is NOT part of the UDP datagram and NOT transmitted with the datagram.
TCP: Reliable Transport Service
Challenges To achieve efficient, reliable data transmission, a transport protocol must face several major problems: – Unreliable underlying IP service – End system reboot – Heterogeneous end systems – Congestion
Sequencing Handle Duplicates and Out-of- Order Delivery Each packet has a sequence number. The receiver stores both the sequence number of the last packet received in order and packets arriving out of order The receiver examines the sequence number – Expected packet – Packet out of order – Duplicated
TCP Last packet # in order: Packets out of order: 7 23 Application
Retransmissions Handle Lost Packets Whenever a frame arrives intact, the receiver sends a small ACK message that reports successful reception The sender ensures that each packet is transferred successfully – Whenever it sends a packet, the sender starts a timer ACK
Connection Establishment Both sender and receiver must be ready before we start the data transfer Three-Way Handshake: To establish connections reliably, TCP exchanges three messages to ensure unambiguous agreement. – SYNs are retransmitted if lost
Connection Establishment Sequencing: To establish connection, TCP requires each side to probe the other with a fresh Initial Sequence Number – A randomly generated 32-bit number
Connection Establishment Three steps: – Host 1 sends SYN(x) – Host 2 replies with ACK(x+1) + SYN(y) – Host 1 replies with ACK(y+1)
Connection Establishment Q: Why choose a random number as the Initial Sequence Number for each connection, instead of using “1”? 1.Two computers agree to communicate at 1 PM 2.One computer sends a sequence of 10 packets to the other 3.A hardware problem causes packet 3 to be delayed 4.Routes change to avoid the hardware problem 5.Protocol software on the sending computer retransmits packet 3 and sends the remaining packets without error 6.At 1:05 PM the two computers agree to communicate again 7.After the second packet arrives, the delayed copy of packet 3 arrives from the earlier conversation 8.Packet 3 arrives from the second conversation Extraordinarily long delay Replay Error!
Connection Termination The three-way handshake used to close a connection uses FIN segments.