Computer Networks Transport Layer CEN 5501C - Computer Networks - Spring 2007 - UF/CISE - Newman 1 Transport Layer Objectives • Goals – Deals with end host pacing, congestion control – Provides internal addresses on host (ports) • Upward multiplexing – Reliable, end-to-end data delivery • Challenges – Network reliability – lost, delayed, duplicated, out of order packets – Network delay variation (RTT estimation) CEN 5501C - Computer Networks - Spring 2007 - UF/CISE - Newman 2 Transport Layer Protocols • • • • • • • UDP (User Datagram Protocol) TCP (Transmission Control Protocol) SCTP (Stream Control Transmission Prot) DCCP (Datagram Congestion Ctl Prot) RTP (Realtime Transport Protocol) ATP (AppleTalk Transaction Protocol) NetBEUI (NetBIOS Extended User Interf.) CEN 5501C - Computer Networks - Spring 2007 - UF/CISE - Newman 3 User Datagram Protocol • “Passthrough” for IP – Upward multiplexing – No reliability guarantees at all – No congestion control • Fields (8 bytes!) – Src & Dest Port (16 bits each) – Optional checksum (16 bits) – 16-bit length (including header) • See IETF RFC 768 CEN 5501C - Computer Networks - Spring 2007 - UF/CISE - Newman 4 Transmission Control Protocol • Much more complex – Upward multiplexing – Reliable, in-order byte stream delivery – Congestion control – No timing guarantees/QoS • Session Semantics – Setup: 3-way handshake (SYN, SYN-ACK,ACK) – Use: sequence #s, ACKs – Teardown: FIN, FIN-ACK • See RFC 793, RFC2581, RFC 3168 CEN 5501C - Computer Networks - Spring 2007 - UF/CISE - Newman 5 Stream Control Transmission Protocol • Multiple Stream Service – Upward multiplexing – Reliable, in-order delivery – Congestion control – Message streams – Multihoming support • See RFC 2960 (protocol), RFC 3286 (text) CEN 5501C - Computer Networks - Spring 2007 - UF/CISE - Newman 6 Datagram Congestion Control Protocol • Intermediate between TCP and UDP – Upward multiplexing – Order, reliability not guaranteed – Congestion control – No timing guarantees/QoS • Session semantics (setup, use, teardown) • See RFC 4340 CEN 5501C - Computer Networks - Spring 2007 - UF/CISE - Newman 7 RTP • For realtime traffic – Has ports for upward multiplexing – Marker bit – Payload type – 32-bit Timestamp for delivery jitter – No congestion control – 16-bit Sequence numbers, but no order guarantee – Runs on top of UDP – See RFC 3550 CEN 5501C - Computer Networks - Spring 2007 - UF/CISE - Newman 8 AppleTalk Transaction Protocol • Part of AppleTalk self-configuration – AppleTalk addr resolution protocol (AARP) hosts automatically generate own NW addrs – Name Binding Protocol (NBP) like DNS • Proprietary • Request/Response/ACK exchanges – 1 req pkt could garner up to 8 resp pkts – Requestor sent bitmap selective ACK • At-least-once and exactly-once options CEN 5501C - Computer Networks - Spring 2007 - UF/CISE - Newman 9 AppleTalk Data Stream Protocol • Late addition to AppleTalk suite • Proprietary • TCP-like, except: – Host can reject a connection – No half-open connections • See http://en.wikipedia.org/wiki/AppleTalk CEN 5501C - Computer Networks - Spring 2007 - UF/CISE - Newman 10 NetBIOS Extended User Interface • Unrouted network-and-transport layer – Can only be used in a broadcast domain • A.k.a. NetBIOS Frame (NBF) • Uses IEEE 802.2 type 1 for name svc, datagram • Uses IEEE 802.2 type 2 for session svc. CEN 5501C - Computer Networks - Spring 2007 - UF/CISE - Newman 11 Back to TCP • Fields (20 bytes!) – Src & Dest Port (16 bits each) – 32-bit sequence #, ACK # (byte stream) – 4-bit Header Length (in 32-bit words) – Reserved (6 bits) – Flags (6 bits) – 16-bit Window size (bytes willing to Rx) – Checksum (16 bits) – Urgent pointer – Options (0 or more 32-bit words) CEN 5501C - Computer Networks - Spring 2007 - UF/CISE - Newman 12 TCP Flags • URG – Urgent pointer valid (offset in current segment) • • • • • ACK – ACK field is valid PSH – deliver immediately (don’t buffer) RST – Reset connection (abort) SYN – Synchronize (3-way handshake) FIN – Finish (normal close connection) CEN 5501C - Computer Networks - Spring 2007 - UF/CISE - Newman 13 TCP Session Initiation Host A Host B Syn, X, - Syn, ACK, Y, X+1 ACK, X+1, Y+1 Normal Three-way Handshake -Client makes connection req -Server responds (half-open Connection now) -Client confirms -Data transfer begins -Syn Flooding Attack… CEN 5501C - Computer Networks - Spring 2007 - UF/CISE - Newman 14 TCP Initiation Mishaps Host B Host A RST Call Collision Unknown/Late CEN 5501C - Computer Networks - Spring 2007 - UF/CISE - Newman 15 TCP States • • • • • • • • • • • CLOSED – no active/pending connection LISTEN – server waits for incoming call SYN RCVD – connection req received, wait for ACK SYN SENT – connection requested, wait for SYN-ACK ESTAB – normal data transfer state FIN WAIT 1 – application has said it’s done (active) FIN WAIT 2 – other side has agreed to release (active) TIMED WAIT – wait for all packets to die off (active) CLOSING – both sides closed simultaneously (active) CLOSE WAIT – other side initiated a release (passive) LAST ACK – wait for all packets to die off (passive) CEN 5501C - Computer Networks - Spring 2007 - UF/CISE - Newman 16 TCP State Machine - Open Normal Server Connect/SYN Normal Client CLOSED Unusual Close/- Listen/- SYN/SYN-ACK SYN RCVD Close/LISTEN Send/SYN RST/- SYN SENT SYN/SYN-ACK Close/FIN ACK/ESTABLISHED FIN WAIT 1 SYN-ACK/ACK CEN 5501C - Computer Networks - Spring 2007 - UF/CISE - Newman 17 TCP State Machine - Close SYN RCVD Close/FIN Close/FIN ESTABLISHED FIN/ACK [Active Close] FIN WAIT 1 FIN/ACK CLOSING ACK/- FIN WAIT 2 [Passive Close] CLOSE WAIT ACK/FIN/ACK TIMED WAIT Close/FIN LAST ACK (Timeout) ACK/- CLOSED CEN 5501C - Computer Networks - Spring 2007 - UF/CISE - Newman 18 TCP Transmission Policy • Sender not required to send as soon as application delivers data • Windows not tied directly to ACKs, but also to receive window size • Receiver may ACK when segt received, when receive window changes, etc. CEN 5501C - Computer Networks - Spring 2007 - UF/CISE - Newman 19 TCP Transmission Example Receiver’s 4K buffer 0 4K empty Appl writes 2 K bytes Sender may send up to 2 K bytes 2K Sender blocked Appl writes 3 K bytes Full Appl reads 2 K bytes 2K 1K CEN 5501C - Computer Networks - Spring 2007 - UF/CISE - Newman 2K 20 TCP Telnet Example • Interactive editor – reacts on every keystroke • Sender sends each character on arrival – 41 bytes (1 char + 20 TCP + 20 IP) • Receiver sends 40-byte ACK • Editor reads byte, Rx updates WIN (40 more) • Editor processes character, echoes it – 41 more bytes! • Total of 162 bytes in 4 datagrams per char!! CEN 5501C - Computer Networks - Spring 2007 - UF/CISE - Newman 21 TCP Solution • Delayed ACKs can alleviate this • Wait 500 ms before sending ACK • Gives time for read, echo, so only 1 DG sent – Ack timer needed, reverse flow trigger – Also trigger ACK on second segment arrival • Still inefficient (82 bytes in 2 DGs) • Nagle’s Algorithm helps further! CEN 5501C - Computer Networks - Spring 2007 - UF/CISE - Newman 22 Nagle’s Algorithm • Sender side solution • When data arrives one byte at a time, send first byte, then buffer rest until ACKed • When ACK arrives, or when MSS can be filled, or if half WIN filled, send all chars in buffer in a single segment • Huge bandwidth savings! Widely used. • Disable if using mouse, avoid jerkiness CEN 5501C - Computer Networks - Spring 2007 - UF/CISE - Newman 23 Silly Window Syndrome Receiver’s buffer Full Sender sends 1 byte Appl reads 1 byte 40 bytes ACK room for 1 byte 40 bytes hdrs 1 byte of data Full CEN 5501C - Computer Networks - Spring 2007 - UF/CISE - Newman 24 Clark’s Solution • Prevent Rx from sending window update for one byte • Rx forced to wait until WIN >= MSS, or buffer is half empty, whichever is smaller • Sender should not send tiny segments • Wait until full MSS or half receiver’s buffer size, whichever smaller CEN 5501C - Computer Networks - Spring 2007 - UF/CISE - Newman 25