13: Transport Layer3b-17: TCPLast Modified: 2/25/2003 8:15:19 PM3: Transport Layer3b-2TCP: Overview RFCs: 793, 1122, 1323, 2018, 2581❒full duplex data:❍ bi-directional data flow in same connection❍ MSS: maximum segment size❒connection-oriented:❍ handshaking (exchange of control msgs) init’ssender, receiver state before data exchange❒flow and congestion controlled:❍ sender will not overwhelm receiver or network❒point-to-point:❍ one sender, one receiver❒reliable, in-order byte steam:❍ no “message boundaries” like with UDP datagrams❒pipelined:❍ TCP congestion and flow control set window size❒send & receive bufferssocketdoorTCPsend bufferTCPreceive buffersocketdoorsegmentapplicationwrites dataapplicationreads data3: Transport Layer3b-3Roadmap❒ TCP header and segment format❒ Connection establishment and termination❒ Normal Data flow3: Transport Layer3b-4TCP segment structuresource port #dest port #32 bitsapplicationdata (variable length)sequence numberacknowledgement numberrcvr window sizeptr urgent datachecksumFSRPAUheadlennotusedOptions (variable length)URG: urgent data (generally not used)ACK: ACK #validPSH: push data now(generally not used)RST, SYN, FIN:connection estab(setup, teardowncommands)# bytes rcvr willingto acceptcountingby bytes of data(not segments!)Internetchecksum(as in UDP)3: Transport Layer3b-5TCP Headers: like UDP?❒ Source and destination port numbers❒ Checksum❒ Data length? Rely on length in IP header?3: Transport Layer3b-6TCP Headers: Familiar?❒ Sequence Number field ( 32 bit)❍ Sequence Number field indicates number of first byte in the packet❒Receiver Window Size (16 bit)❍ Window like for GBN or selective repeat, but window size not fixed – variable based on receiver feedback❒Acknowledgment Field (32 bit)❍ The acknowledgement field contains the next sequence number it is expecting thus implicitly acknowledging all previous segments.❍ Cumulative acks not individual acks or negative acks23: Transport Layer3b-7TCP seq. #’s and ACKsSeq. #’s:❍ byte stream “number” of first byte in segment’s dataACKs:❍ seq # of next byte expected from other side❍ cumulative ACKQ: how receiver handles out-of-order segments❍ A: TCP spec doesn’t say, - up to implementor❍ Can buffer or not, in either case still ACK next in order byte expectedHost AHost BSeq=42, ACK=79, data = ‘C’Seq=79, ACK=43, data = ‘C’Seq=43, ACK=80Usertypes‘C’host ACKsreceipt of echoed‘C’host ACKsreceipt of‘C’, echoesback ‘C’timesimple telnet scenario3: Transport Layer3b-8TCP Header: Header Length❒ Header Length (4 bits)❍ needed because options field make header variable length❍ Expressed in number of 32 bit words = 4 bytes❍ 4 bits field => 4 bytes*24= 60 bytes; 20 bytes of required header gives 40 bytes possible of options❍ Recall UDP header was 8 bytes 3: Transport Layer3b-9Implications of Field Length❒ 32 bits for sequence number (and acknowledgement) ; 16 bits for advertised window size❒ Implication for maximum window size? Window size <= ½ SequenceNumberSpace❍ Requirement easily satisfied because receiver advertised window field is 16 bits•232>> 2* 216• Even if increase possible advertised window to 231 that would still be ok3: Transport Layer3b-10Implications of Field Length (cont)❒ Advertised Window is 16 bit field => maximum window is 64 KB ❍ Is this enough to fill the pipeline? Not always❍ Pipeline = delay*BW product❍ 100 ms roundtrip and 100 Mbps => 1.19 MB❒Sequence Number is 32 bit field => 4 GB❍ Wrap –around?❍ Maximum Segment Lifetime of 120 seconds❍ Will this ever wrap too soon? Yes it might• 4 GB/120 sec = 273 Mbps• Gigabit Ethernet? STS-12 at 622 Mbps?3: Transport Layer3b-11TCP Header: Common Options❒ Options used to extend and test TCP❒ Each option is:❍ 1 byte of option kind❍ 1 byte of option length (except for kind = 0 for end of options and kind =1 for no operation)❒Examples ❍ window scale factor: if don’t want to be limited to 216bytes in receiver advertised window❍ timestamp option: if 32 bit sequence number space will wrap in MSL; add 32 bit timestamp to distinguish between two segments with the same sequence number❍ Maximum Segment Size can be set in SYN packets3: Transport Layer3b-12TCP Header: Flags (6 bits) ❒ Connection establishment/termination❍ SYN – establish; sequence number field contains valid initial sequence number❍ FIN - terminate❒RESET - abort connection because one side received something unexpected❒ PUSH - sender invoked push to send❒ URG – indicated urgent pointer field is valid; special data - record boundary❒ ACK - indicates Acknowledgement field is valid33: Transport Layer3b-13TCP Header: ACK flag❒ ACK flag – if on then acknowledgement field valid❒ Once connection established no reason to turn off ❍ Acknowledgment field is always in header so acknowledgements are free to send along with data 3: Transport Layer3b-14TCP Header: URG❒ If URG flag on, then URG pointer contains a positive offset to be added to the sequence number field to indicate the last byte of urgent data❒ No way to tell where urgent data starts –left to application❒ TCP layer informs receiving process that there is urgent data 3: Transport Layer3b-15Out-of-band data❒ URG is not really out-of-band data; Receiver must continue to read byte stream till reach end of urgent data❒ If multiple urgent segments received, first urgent mark is lost; just one urgent pointer❒ How to get out-of-band data if need it?❍ Separate TCP connection?3: Transport Layer3b-16URG❒ How helpful is this?❒ Telnet and Rlogin use URG when user types the interrupt key; FTP uses when user aborts a file transfer❒ Is this worth a whole header field and a flag?❒ Doesn’t help that implementations vary in how they interpret the urgent pointer (point to last byte in urgent data or byte just past the last byte of urgent data)3: Transport Layer3b-17TCP Header: PSH❒ Intention: use to indicate not to leave the data in a TCP buffer waiting for more data before it is sent❍ In practice, programming interface rarely allows application to specify❍ Instead TCP will set if this segment used all the data in its send buffer❒Receiver is supposed to interpret as deliver to application immediately; most TCP/IP implementations don’t delay delivery in the first place though3: Transport Layer3b-18TCP Header: Data boundaries?❒ In general
View Full Document