tcp overview
play

TCP Overview Jeff Chase Duke University These slides draw - PowerPoint PPT Presentation

TCP Overview Jeff Chase Duke University These slides draw extensively on material from Srini Seshan and Dave Andersen at CMU (mostly figures), and they also incorporate earlier material by Adolfo Rodriguez and Amin Vahdat. Some congestion


  1. TCP Overview Jeff Chase Duke University These slides draw extensively on material from Srini Seshan and Dave Andersen at CMU (mostly figures), and they also incorporate earlier material by Adolfo Rodriguez and Amin Vahdat. Some congestion control slides are from Ion Stoica.

  2. The Internet Protocol Suite Application Application Applications Presentation Presentation Presentation Session Session Session UDP TCP Transport Transport Waist Network Network Data link Data Link Data link Physical Physical Physical The waist facilitates The Hourglass Model Interoperability.

  3. UDP • User Datagram Protocol (UDP) – Thin veneer on top of IP – Data sent as individual datagrams • From a sender to a receiver: like USPS – Demultiplex receiver: (IPaddr, port) pair – No guarantees about reliability, in-order delivery – Checksum to prevent corruption of data Link-layer IP SrcPort DestPort Checksum Len Data… UDP Header

  4. TCP • Transmission Control Protocol (TCP) – Reliable in-order delivery of byte stream – Full-duplex: each endpoint may send and receive – Flow control • To ensure that sender does not overrun receiver by sending too fast – Congestion control • Keep the sender from overrunning the network • Many simultaneous connections across routers (cross traffic)

  5. A Brief Internet History 1991 WWW/HTTP 1990 1972 ARPANET TELNET 1995 dissolved RFC 318 Multi-backbone 1986 Internet NNTP 1992 1969 1984 1973 1977 1982 RFC 977 MBONE ARPANET DNS FTP MAIL TCP & IP created RFC 883 RFC 454 RFC 733 RFC 793 & 791 1970 1975 1980 1985 1990 1995

  6. SEND, RECEIVE COMPLETE TCP user TCP/IP TCP TCP implementation sender receiver drivers timer packet packet transmission arrival

  7. Some TCP Challenges • Segment byte stream into individual packets – How big should the packets/segments be? • What if packets are delivered out of order? – May take different paths through the network • What if a packet is lost? – Packets may be dropped in the network • What if a packet is corrupted in transit? – Detect error and fix it or resend • How fast should the sender send?

  8. Mechanism: Checksums • Checksum C = F(contents) • Checksum C is small, fixed-size (in essence, a hash) • Generate at sender and place in segment • Verify at receiver • If checksum matches, packet is not corrupt • Probably…

  9. Sequence Number Space • Each byte in byte stream is numbered. – 32 bit value – Wraps around – Initial values selected at start up time • Each packet/segment has a sequence number and length – Indicates where it fits in the byte stream 13450 14950 16050 17550 packet 8 packet 9 packet 10

  10. Sequence Numbers • 32 Bits, Unsigned – Circular Comparison b a a b Max 0 Max 0 b < a a < b • Why So Big? – Guard against stray packets • With IP, packets have maximum lifetime of 120s • Sequence number would wrap around in this time at 286MB/s

  11. Using the Sequence Numbers • Reassembly buffer – Packets/segments received into (kernel) memory – Sort them by sequence number – Deliver segments to application in order! – Seq(i) + Len(i) < Seq(i+1)? • Gap: defer delivery of segment i+1 • Acknowledgments – Periodically send back the sequence number of the latest (newest) byte received in order. – No ack received? Lost segment: retransmit. • How long to wait?

  12. TCP Header Format 0 4 10 16 31 SrcPort DestPort SequenceNum Acknowledgment HdrLen 0 Flags AdvertisedWindow CheckSum UrgPtr Options (variable) Data • Without options, TCP header 20 bytes – Thus, typical Internet packet minimum of 40 bytes

  13. Establishing Connection: Three-Way handshake • Each side notifies other of starting sequence number it SYN: SeqC will use for sending – Why not simply chose 0? • Must avoid overlap with earlier incarnation ACK: SeqC+1 SYN: SeqS • Security issues • Each side acknowledges ACK: SeqS+1 other’s sequence number – SYN-ACK: Acknowledge sequence number + 1 • Can combine second SYN with first ACK Client Server

  14. TCP State Diagram: Connection Setup Client CLOSED active OPEN Server create TCB passive OPEN Snd SYN CLOSE create TCB delete TCB CLOSE LISTEN delete TCB SEND rcv SYN snd SYN ACK snd SYN SYN SYN rcv SYN RCVD SENT snd ACK Rcv SYN, ACK rcv ACK of SYN Snd ACK CLOSE ESTAB Send FIN

  15. Tearing Down Connection • Either side can initiate tear down – Send FIN signal A B – “I’m not going to send any more FIN, SeqA data” • Other side can continue sending ACK, SeqA+1 data – Half open connection Data – Must continue to acknowledge ACK • Acknowledging FIN – Acknowledge last sequence FIN, SeqB number + 1 ACK, SeqB+1

  16. Reliable Transmission • How do we send a packet reliably when it can be lost? • Two mechanisms – Acks – Timeouts • Simplest reliable protocol: Stop and Wait

  17. Stop and Wait Send a packet, stop and wait until ack arrives Sender Receiver P a c k e t Timeout Time ACK

  18. Recovering From Error P P P a a a c c c k k k e e e t t t Timeout Timeout Timeout ACK ACK Time P a c k e t P P a a c c k k e e t t Timeout Timeout Timeout ACK ACK ACK ACK lost Packet lost Early timeout

  19. Problems with Stop and Wait • How to recognize a duplicate transmission? – Solution: put sequence number in packet • Performance – Unless Latency-Bandwidth product is very small, sender cannot fill the pipe – Solution: sliding window protocols

  20. Keeping the Pipe Full Bandwidth Latency • Bandwidth-Delay product measures network capacity • How much data can you put into the network before the first byte reaches receiver • 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

  21. How Do We Keep the Pipe Full? • Send multiple packets wnd = 3 RTT (Round Trip Time) without waiting for first to segment 1 be ACKed segment 2 – How many? Limited by segment 3 the “window” wnd. – Flow/congestion policies ACK 2 set wnd. ACK 3 ACK 4 • Self-clocking sliding window segment 4 – Arrival of an ack opens up segment 5 another window “slot” to segment 6 send – Ideally, first ACK arrives immediately after window is filled – Else pipeline “bubbles” waste bandwidth • Throughput = wnd/RTT [Stoica]

  22. Flow Control • Receiver devotes some buffer space to hold incoming bytes until the application consumes them. – Socket buffers • How much? Must place a bound on it. – Advertise wnd: max number of bytes to accept – Receiver returns AdvertisedWindow in TCP header of its acknowledgments back to the sender. • Sliding window – Flow window is range of bytes receiver will accept • [ack+1, ack + wnd] – Receiver drops segments/bytes outside the window – Sender stops transmitting when it fills the window • Bytes in transit <= wnd – Each side advances window as data is delivered.

  23. Window Flow Control: Send Side window Sent and acked Sent but not acked Not yet sent Next to be written Next to be sent by TCP user

  24. 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 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 Options… Options... Options… Options... App write acknowledged sent to be sent outside window

  25. Window Flow Control: Receive Side What should receiver do with an arriving segment? New duplicate out-of- order Receive buffer outside window Acked but not Not yet delivered to user acked window

  26. snd.bufsize snd.nxt snd.una complete sent but unacked not sent sends ( retransmission queue ) (posted sends) acks in data in flight flight newer data increasing acknowledged not received sequence reorder buffer numbers (pending delivery) (lazily allocated) rcv.user rcv.nxt rcv.last rcv.bufsize rcv.wnd Another fig….might be useful. If you’re interested, all of this basic data transfer is specified in RFC 793.

  27. TCP Persist • What happens if window is 0? – Application has not consumed data fast enough. – Receiver buffer exhausted: grind to halt • Must reopen window when application reads data – App reads data: opens up buffer space – Receiver sends segment with “window update” – What if this update is lost? • TCP Persist state (sender idled by closed window) – Sender periodically sends 1 byte packets – Receiver responds with ACK even if it can’t store the packet – ACK segment includes current window

  28. Performance

  29. Limits to Throughput • How fast can the app produce or consume data? • Hardware/path limitations – Wire speed – Host limitations/overhead • Efficient use of the wire – Leaving network idle – Sending duplicate data – High ratio of control to data – What causes loss of efficiency?

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