15-744 Computer Networking Outline Transport Protocols Functionality Split
Total Page:16
File Type:pdf, Size:1020Kb
Outline • Transport introduction 15-744 Computer Networking • Error recovery & flow control • TCP flow control/connection setup/data transfer Review 2 – Transport Protocols • TCP reliability • Congestion sources and collapse • Congestion control basics 2 Transport Protocols Functionality Split • Network provides best-effort delivery • Lowest level end-to- end protocol. • End-systems implement many functions • Header generated by 7 7 • Reliability sender is interpreted 6 6 • In-order delivery only by the destination 5 5 • Demultiplexing • Routers view transport • Message boundaries header as part of the Transport Transport payload • Connection abstraction IP IP IP • Not always true… • Congestion control Datalink 2 2 Datalink • Firewalls • … Physical 1 1 Physical router 3 4 1 Transport Protocols UDP: User Datagram Protocol [RFC 768] • UDP provides just integrity and demux • “No frills,” “bare bones” Why is there a UDP? • TCP adds… Internet transport protocol • No connection establishment • Connection-oriented (which can add delay) • “Best effort” service, • Reliable • Simple: no connection state UDP segments may be: at sender, receiver • Ordered • Lost • Small header • Byte-stream • Delivered out of order to • No congestion control: UDP • Full duplex app can blast away as fast as desired • Flow and congestion controlled • Connectionless: • DCCP, RTP, SCTP -- not widely used. • No handshaking between UDP sender, receiver • Each UDP segment handled independently of others 5 6 UDP, cont. UDP Checksum • Often used for streaming 32 bits Goal: detect “errors” (e.g., flipped bits) in transmitted multimedia apps Length, in Source port # Dest port # segment – optional use! • Loss tolerant bytes of UDP Length Checksum segment, Sender: Receiver: • Rate sensitive including • Treat segment contents as • Compute checksum of • Other UDP uses header sequence of 16-bit integers (why?): received segment • Checksum: addition (1’s • Check if computed checksum • DNS Application complement sum) of segment equals checksum field value: • Reliable transfer data contents (message) • Sender puts checksum value • NO - error detected over UDP into UDP checksum field • YES - no error detected • Must be at But maybe errors application layer UDP segment format nonetheless? • Application-specific error recovery 7 8 2 High-Level TCP Characteristics TCP Header • Protocol implemented entirely at the ends Source port Destination port • Fate sharing (on IP) Sequence number • Protocol has evolved over time and will continue Flags: SYN Acknowledgement to do so FIN • Nearly impossible to change the header RESET HdrLen 0 Flags Advertised window PUSH • Use options to add information to the header URG Checksum Urgent pointer ACK • Change processing at endpoints Options (variable) • Backward compatibility is what makes it TCP Data 9 10 Evolution of TCP TCP Through the 1990s 1984 1994 1975 Nagel’s algorithm 1996 T/TCP Three-way handshake to reduce overhead 1987 SACK TCP (Braden) Raymond Tomlinson of small packets; Karn’s algorithm 1990 (Floyd et al) Transaction In SIGCOMM 75 predicts congestion to better estimate 4.3BSD Reno Selective TCP collapse round-trip time fast retransmit Acknowledgement delayed ACK’s 1983 BSD Unix 4.2 1986 1988 1993 1994 1996 1996 1974 supports TCP/IP Congestion Van Jacobson’s TCP Vegas ECN Hoe FACK TCP TCP described by collapse algorithms (Brakmo et al) (Floyd) NewReno startup (Mathis et al) Vint Cerf and Bob Kahn observed congestion avoidance delay-based Explicit and loss recovery extension to SACK In IEEE Trans Comm 1982 and congestion control congestion avoidance Congestion TCP & IP (most implemented in Notification RFC 793 & 791 4.3BSD Tahoe) 1975 1980 1985 1990 1993 1994 1996 11 12 3 Outline Stop and Wait • Transport introduction • ARQ • Receiver sends acknowledgement (ACK) • Error recovery & flow control when it receives packet • Sender waits for ACK and Sender Receiver timeouts if it does not • TCP flow control/connection setup/data transfer arrive within some time period • Simplest ARQ protocol • TCP reliability • Send a packet, stop and Timeout wait until ACK arrives • Congestion sources and collapse • Performance Time • Can only send one • Congestion control basics packet per round trip 13 14 Recovering from Error How to Recognize Resends? • Use sequence numbers • both packets and acks • Sequence # in packet is finite How big should it be? Timeout Time Timeout Timeout • For stop and wait? • One bit – won’t send seq #1 until received ACK for seq #0 Timeout Timeout Timeout ACK lost Packet lost Early timeout DUPLICATE PACKETS!!! 15 16 4 How to Keep the Pipe Full? Sliding Window • Send multiple packets without • Reliable, ordered delivery waiting for first to be acked • Receiver has to hold onto a packet until all prior • Number of pkts in flight = window: Flow control packets have arrived • Reliable, unordered delivery • Why might this be difficult for just parallel stop & wait? • Several parallel stop & waits • Sender must prevent buffer overflow at receiver • Send new packet after each ack • Circular buffer at sender and receiver • Sender keeps list of unack’ed packets; resends after timeout • Packets in transit buffer size • Receiver same as stop & wait • Advance when sender and receiver agree packets at • How large a window is needed? beginning have been received • Suppose 10Mbps link, 4ms delay, 500byte pkts •1? 10? 20? • Round trip delay * bandwidth = capacity of pipe 17 18 Sender/Receiver State Sequence Numbers • How large do sequence numbers need to be? Sender Receiver • Must be able to detect wrap-around • Depends on sender/receiver window size Max ACK received Next seqnum Next expected Max acceptable • E.g. …………• Max seq = 7, send win=recv win=7 • If pkts 0..6 are sent succesfully and all acks lost Sender window Receiver window • Receiver expects 7,0..5, sender retransmits old 0..6!!! • Max sequence must be send window + recv window Sent & Acked Sent Not Acked Received & Acked Acceptable Packet OK to Send Not Usable Not Usable 19 20 5 Window Sliding – Common Case Loss Recovery • On reception of new ACK (i.e. ACK for something that was • On reception of out-of-order packet not acked earlier) • Send nothing (wait for source to timeout) • Increase sequence of max ACK received • Cumulative ACK (helps source identify loss) • Send next packet • Timeout (Go-Back-N recovery) • On reception of new in-order data packet (next expected) • Set timer upon transmission of packet • Hand packet to application • Retransmit all unacknowledged packets • Send cumulative ACK – acknowledges reception of all packets up to sequence number • Performance during loss recovery • Increase sequence of max acceptable packet • No longer have an entire window in transit • Can have much more clever loss recovery 21 22 Important Lessons Good Ideas So Far… • Transport service • Flow control • UDP mostly just IP service • Stop & wait • TCP congestion controlled, reliable, byte stream • Parallel stop & wait • Types of ARQ protocols • Sliding window • Stop-and-wait slow, simple • Loss recovery • Go-back-n can keep link utilized (except w/ losses) • Timeouts • Selective repeat efficient loss recovery -- used in SACK • Acknowledgement-driven recovery (selective repeat or • Sliding window flow control cumulative acknowledgement) • Addresses buffering issues and keeps link utilized 23 24 6 Outline More on Sequence Numbers • Transport introduction • 32 Bits, Unsigned for bytes not packets! • Error recovery & flow control • Why So Big? • For sliding window, must have • TCP flow control/connection setup/data transfer • |Sequence Space| > |Sending Window| + |Receiving Window| • TCP reliability • No problem • Also, want to guard against stray packets • Congestion sources and collapse • With IP, packets have maximum lifetime of 120s • Sequence number would wrap around in this time at 286Mbps • Congestion control basics 25 26 TCP Flow Control Window Flow Control: Send Side • TCP is a sliding window protocol • For window size n, can send up to n bytes without receiving an acknowledgement window • When the data is acknowledged then the window slides forward • Each packet advertises a window size • Indicates number of bytes the receiver has space for Sent and acked Sent but not acked Not yet sent • Original TCP always sent entire window • Congestion control now limits this Next to be sent 27 28 7 Window Flow Control: Send Side Performance Considerations Packet Sent Packet Received • The window size can be controlled by receiving Source Port Dest. Port Source Port Dest. Port application Sequence Number Sequence Number • Can change the socket buffer size from a default (e.g. 8Kbytes) to a maximum value (e.g. 64 Kbytes) Acknowledgment Acknowledgment HL/Flags Window HL/Flags Window • The window size field in the TCP header limits the D. Checksum Urgent Pointer D. Checksum Urgent Pointer window that the receiver can advertise Options… Options... • 16 bits 64 KBytes • 10 msec RTT 51 Mbit/second • 100 msec RTT 5 Mbit/second App write • TCP options to get around 64KB limit scales window size acknowledged sent to be sent outside window 29 30 Establishing Connection: Outline Three-Way handshake • Each side notifies other of • Transport introduction starting sequence number it SYN: SeqC will use for sending • Error recovery & flow control • Why not simply chose 0? • Must avoid overlap with earlier ACK: SeqC+1 incarnation SYN: SeqS • TCP flow control/connection setup/data transfer • Security issues • Each side acknowledges ACK: SeqS+1 • TCP reliability other’s sequence number