Announcements Sukun is away this week Dilip will cover his section and office hours Dilip s office has moved to 751 Soda alcove His office hours remain Fri 11 12 TCP Reliable In Order Delivery Today is the deadline for requesting discussion possible regarding of midterm questions Send email to do so EE 122 Intro to Communication Networks Fall 2006 MW 4 5 30 in Donner 155 Vern Paxson Project 3 out on Wednesday TAs Dilip Antony Joseph and Sukun Kim Can do individual or in a team of 2 people First phase due November 16 no slip days Exercise good better time management http inst eecs berkeley edu ee122 Materials with thanks to Jennifer Rexford Ion Stoica and colleagues at Princeton and UC Berkeley 1 TCP Service Model Today s Lecture How does TCP achieve correct operation Reliable in order byte stream delivery Reliability in the face of IP s meager best effort service and with good performance Challenges the network can 3 way handshake to establish connections drop packets 3 way or 4 way handshake to terminate conn delay packets Retransmission to recover from loss deliver packets out of order replicate packets corrupt packets What s missing We ll only look at timeout based retransmission today State diagrams as a tool for understanding complex protocol operation 3 TCP Support for Reliable Delivery Even perhaps for many seconds Follows from possibility of arbitrary delay Weird but it does sometimes happen 4 TCP Header Used to detect corrupted data at the receiver leading the receiver to drop the packet Source port Acknowledgment Used to detect missing data and for putting the data back in order HdrLen 0 Flags Advertised window Checksum Retransmission Destination port Sequence number Sequence numbers Even perhaps a large number Checksum 2 Urgent pointer Options variable Sender retransmits lost or corrupted data Timeout based on estimates of round trip time Fast retransmit algorithm for rapid retransmission Data 5 6 1 TCP Header TCP Header Source port These should be familiar Destination port Starting sequence number byte offset of data carried in this segment Sequence number Acknowledgment HdrLen 0 Flags Advertised window Checksum Urgent pointer Source port Destination port Sequence number Acknowledgment HdrLen 0 Flags Advertised window Checksum Options variable Urgent pointer Options variable Data Data 7 TCP Header TCP Header Source port Acknowledgment gives seq just beyond highest seq received in order 8 Destination port Source port Sequence number Number of 4 byte words in TCP header 5 no options Acknowledgment HdrLen 0 Flags Advertised window Checksum If sender sends N in order bytes starting at seq S then ack for it will be S N Destination port Sequence number Urgent pointer Acknowledgment HdrLen 0 Flags Advertised window Checksum Options variable Urgent pointer Options variable Data Data 9 TCP Header 10 TCP Header Source port Destination port Source port Sequence number Must Be Zero 6 bits reserved We will get to these shortly Acknowledgment HdrLen 0 Flags Advertised window Checksum Destination port Sequence number Acknowledgment HdrLen 0 Urgent pointer Flags Advertised window Checksum Options variable Urgent pointer Options variable Data Data 11 12 2 TCP Header TCP Header Source port Destination port Source port Sequence number Buffer space available for receiving data Used for TCP s sliding window Used with URG flag to indicate urgent data not discussed further Acknowledgment HdrLen 0 Flags Advertised window Checksum Urgent pointer Acknowledgment HdrLen 0 Flags Advertised window Checksum Options variable Interpreted as offset beyond Acknowledgment field s value Destination port Sequence number Urgent pointer Options variable Data Data 13 14 TCP Stream of Bytes Service Provided Using TCP Segments Host A Host A Byte 80 Byte 3 Byte 2 Byte 1 Byte 0 Byte 80 Byte 3 Byte 2 Byte 1 Byte 0 Segment sent when TCP Data Host B 1 Segment full Max Segment Size 2 Not full but times out or 3 Pushed by application TCP Data Host B Byte 80 Byte 3 Byte 2 Byte 1 Byte 0 Byte 80 Byte 3 Byte 2 Byte 1 Byte 0 15 TCP Segment 16 Sequence Numbers IP Data TCP Data segment TCP Hdr Host A IP Hdr ISN initial sequence number IP packet No bigger than Maximum Transmission Unit MTU E g up to 1 500 bytes on an Ethernet Sequence number 1st byte TCP packet IP packet with a TCP header and data inside TCP header 20 bytes long Host B TCP segment TCP Data TCP HDR TCP Data ACK sequence number next expected byte TCP HDR No more than Maximum Segment Size MSS bytes E g up to 1460 consecutive bytes from the stream 17 18 3 Initial Sequence Number ISN Sequence number for the very first byte E g Why not just use ISN 0 Practical issue Connection Establishment TCP s Three Way Handshake IP addresses and port s uniquely identify a connection Eventually though these port s do get used again a chance an old packet is still in flight and might be associated with new connection TCP requires RFC793 changing ISN over time Set from 32 bit clock that ticks every 4 microseconds only wraps around once every 4 55 hours To establish a connection hosts exchange ISNs Establishing a TCP Connection A 20 19 TCP Header B SYN Source port CK SYN A Each host tells its ISN to the other host ACK Data Data Flags SYN ACK FIN RST PSH URG Acknowledgment HdrLen 0 Flags 21 See usr include netinet tcp h on Unix Systems B s port B s port Flags Checksum A s port B s Initial Sequence Number Flags SYN ACK FIN RST PSH URG Irrelevant since ACK not set 5 20B 0 22 Step 2 B s SYN ACK Packet A s Initial Sequence Number Flags SYN ACK FIN RST PSH URG Urgent pointer Options variable Data Step 1 A s Initial SYN Packet A s port Advertised window Checksum Three way handshake to establish connection Host A sends a SYN open synchronize sequence numbers to host B Host B returns a SYN acknowledgment SYN ACK Host A sends an ACK to acknowledge the SYN ACK Destination port Sequence number Advertised window Urgent pointer Options variable A tells B it wants to open a connection ACK A s ISN plus 1 20B 0 Flags Checksum Advertised window Urgent pointer Options variable B tells A it accepts and is ready to hear the next byte 23 upon receiving this packet A can start sending data 24 4 Step 3 A s ACK of the SYN ACK A s port Timing Diagram 3 Way Handshaking Passive Open B s port Active Open Server A s Initial Sequence Number Flags SYN ACK FIN RST PSH URG B s ISN plus 1 20B Flags 0 Checksum listen Client initiator connect Advertised window SYN Seq Urgent pointer SYN ACK Options variable Num x y
View Full Document