tcp overview
play

TCP Overview Application Application Applications Jeff Chase - PDF document

The Internet Protocol Suite TCP Overview Application Application Applications Jeff Chase Presentation Presentation Presentation Duke University Session Session Session UDP TCP Transport Transport Waist Network Network Data link


  1. The Internet Protocol Suite TCP Overview Application Application Applications Jeff Chase Presentation Presentation Presentation Duke University Session Session Session UDP TCP Transport Transport Waist Network Network Data link Data Link Data link Physical Physical Physical The waist facilitates These slides draw extensively on material from Srini Seshan and Dave Andersen The Hourglass Model at CMU (mostly figures), and they also incorporate earlier material by Adolfo Rodriguez and Amin Vahdat. Some congestion control slides are from Ion Stoica. Interoperability. UDP TCP • User Datagram Protocol (UDP) • Transmission Control Protocol (TCP) – Thin veneer on top of IP – Reliable in-order delivery of byte stream – Data sent as individual datagrams – Full-duplex: each endpoint may send and receive • From a sender to a receiver: like USPS – Flow control – Demultiplex receiver: (IPaddr, port) pair • To ensure that sender does not overrun receiver by sending too fast – No guarantees about reliability, in-order delivery – Congestion control – Checksum to prevent corruption of data • Keep the sender from overrunning the network • Many simultaneous connections across routers Link-layer IP SrcPort DestPort Checksum Len Data… (cross traffic) UDP Header A Brief Internet History SEND, RECEIVE COMPLETE TCP user 1991 WWW/HTTP 1990 TCP/IP 1972 TCP TCP ARPANET TELNET 1995 implementation dissolved sender receiver RFC 318 Multi-backbone 1986 Internet NNTP 1992 1969 1973 1977 1982 1984 RFC 977 MBONE ARPANET FTP MAIL TCP & IP DNS created RFC 454 RFC 733 RFC 883 RFC 793 & 791 drivers timer packet packet transmission arrival 1970 1975 1980 1985 1990 1995 1

  2. Some TCP Challenges Mechanism: Checksums • Segment byte stream into individual packets • Checksum C = F(contents) – How big should the packets/segments be? • Checksum C is small, fixed-size (in essence, a hash) • What if packets are delivered out of order? • Generate at sender and place in segment – May take different paths through the network • Verify at receiver • What if a packet is lost? • If checksum matches, packet is not corrupt – Packets may be dropped in the network • Probably… • What if a packet is corrupted in transit? – Detect error and fix it or resend • How fast should the sender send? Sequence Number Space Sequence Numbers • Each byte in byte stream is numbered. • 32 Bits, Unsigned – 32 bit value – Circular Comparison – Wraps around b – Initial values selected at start up time a • Each packet/segment has a sequence number and length a – Indicates where it fits in the byte stream b Max 0 Max 0 b < a a < b • Why So Big? 13450 14950 16050 17550 – Guard against stray packets • With IP, packets have maximum lifetime of 120s • Sequence number would wrap around in this time at 286MB/s packet 8 packet 9 packet 10 Using the Sequence Numbers TCP Header Format 0 4 10 16 31 • Reassembly buffer SrcPort DestPort – Packets/segments received into (kernel) memory SequenceNum – Sort them by sequence number – Deliver segments to application in order! Acknowledgment – Seq(i) + Len(i) < Seq(i+1)? HdrLen 0 Flags AdvertisedWindow • Gap: defer delivery of segment i+1 CheckSum UrgPtr • Acknowledgments Options (variable) – Periodically send back the sequence number of the Data latest (newest) byte received in order. – No ack received? Lost segment: retransmit. • Without options, TCP header 20 bytes • How long to wait? – Thus, typical Internet packet minimum of 40 bytes 2

  3. Establishing Connection: TCP State Diagram: Three-Way handshake Connection Setup • Each side notifies other of Client starting sequence number it CLOSED active OPEN SYN: SeqC will use for sending Server create TCB passive OPEN Snd SYN CLOSE – Why not simply chose 0? create TCB delete TCB • Must avoid overlap with ACK: SeqC+1 CLOSE earlier incarnation LISTEN SYN: SeqS delete TCB • Security issues SEND rcv SYN • Each side acknowledges snd SYN ACK snd SYN ACK: SeqS+1 other’s sequence number SYN SYN rcv SYN RCVD SENT snd ACK – SYN-ACK: Acknowledge Rcv SYN, ACK sequence number + 1 rcv ACK of SYN Snd ACK • Can combine second SYN with CLOSE first ACK Client Server ESTAB Send FIN Tearing Down Connection Reliable Transmission • Either side can initiate tear down • How do we send a packet reliably when it can be lost? – Send FIN signal A B • Two mechanisms – “I’m not going to send any more FIN, SeqA – Acks data” • Other side can continue sending – Timeouts ACK, SeqA+1 data • Simplest reliable protocol: Stop and Wait – Half open connection Data – Must continue to acknowledge ACK • Acknowledging FIN – Acknowledge last sequence FIN, SeqB number + 1 ACK, SeqB+1 Stop and Wait Recovering From Error Send a packet, stop and wait until ack arrives P P P a c a c a c k k k e t e t e t Timeout Timeout Timeout ACK ACK Sender Receiver Time P a c k e t P P P a c a c a k k c k e t e t e t Timeout Timeout Timeout Timeout Time ACK ACK ACK ACK ACK lost Packet lost Early timeout 3

  4. Problems with Stop and Wait Keeping the Pipe Full Bandwidth • How to recognize a duplicate transmission? – Solution: put sequence number in packet Latency • Performance • Bandwidth-Delay product measures network capacity – Unless Latency-Bandwidth product is very small, • How much data can you put into the network before sender cannot fill the pipe the first byte reaches receiver – Solution: sliding window protocols • Stop and Wait: 1 data packet per RTT – Ex. 1.5-Mbps link with 45-ms RTT – Stop-and-wait: 182 Kbps • Ideally, send enough packets to fill the pipe before requiring first ACK Flow Control How Do We Keep the Pipe Full? • Receiver devotes some buffer space to hold incoming bytes until • Send multiple packets wnd = 3 the application consumes them. RTT (Round Trip Time) without waiting for first to segment 1 be ACKed – Socket buffers segment 2 – How many? Limited by • How much? Must place a bound on it. segment 3 the “window” wnd. – Advertise wnd: max number of bytes to accept – Flow/congestion policies ACK 2 set wnd. – Receiver returns AdvertisedWindow in TCP header of its ACK 3 ACK 4 • Self-clocking sliding window acknowledgments back to the sender. segment 4 – Arrival of an ack opens up • Sliding window segment 5 another window “slot” to segment 6 – Flow window is range of bytes receiver will accept send – Ideally, first ACK arrives • [ack+1, ack + wnd] immediately after window – Receiver drops segments/bytes outside the window is filled – Sender stops transmitting when it fills the window – Else pipeline “bubbles” waste bandwidth • Bytes in transit <= wnd • Throughput = wnd/RTT – Each side advances window as data is delivered. [Stoica] Window Flow Control: Send Side Window Flow Control: Send Side Packet Received Packet Sent Source Port Dest. Port Source Port Dest. Port Source Port Dest. Port Source Port Dest. Port Sequence Number Sequence Number Sequence Number Sequence Number window Acknowledgment Acknowledgment Acknowledgment Acknowledgment HL/Flags Window HL/Flags Window HL/Flags Window HL/Flags Window D. Checksum Urgent Pointer D. Checksum Urgent Pointer D. Checksum Urgent Pointer D. Checksum Urgent Pointer Sent and acked Sent but not acked Not yet sent Options… Options... Options… Options... App write Next to be written Next to be sent by TCP user acknowledged sent to be sent outside window 4

Download Presentation
Download Policy: The content available on the website is offered to you 'AS IS' for your personal information and use only. It cannot be commercialized, licensed, or distributed on other websites without prior consent from the author. To download a presentation, simply click this link. If you encounter any difficulties during the download process, it's possible that the publisher has removed the file from their server.

Recommend


More recommend