CS551Basic TCP MechanismsBill Chenghttp://merlot.usc.edu/cs551-f121 Computer Communications - CSCI 551 Copyright © William C. ChengConnection establishment?2What Does TCP Provide? Computer Communications - CSCI 551 Copyright © William C. ChengConnectionless communication?Congestion control?Differentiated services?Duplicate packet detection?Flow control?Loss recovery?Message or record boundaries?Ordered data delivery?Out-of-order data delivery?Quality of service guarantees?Urgent data indication?Does TCP Provide...3What Does TCP Provide? Computer Communications - CSCI 551 Copyright © William C. ChengConnection establishment? YConnectionless communication? NCongestion control? YDifferentiated services? Y (sort of)Duplicate packet detection? YFlow control? YLoss recovery? YMessage or record boundaries? NOrdered data delivery? YOut-of-order data delivery? NQuality of service guarantees? NUrgent data indication? YDoes TCP Provide...file transfer/ftp, http, p2p, DNS (zone transfers), BGP,SMTP, remote login/telnetWhere: anywhere reliable communication is needed4Where And Why Is TCP Used? Computer Communications - CSCI 551 Copyright © William C. Chengconnection oriented (reliability, ordering, ...)Why?has the right features (congestion control, flow control, ...)widely deployed ⇒ interoperability, understood,exhaustively studies, pretty good implementationsdoing your own protocol is a lot of workeverywhere (60-90% of traffic is TCP)5TCP Summary Computer Communications - CSCI 551 Copyright © William C. ChengCommunication abstraction:ReliableOrderedPoint-to-pointByte-streamProtocol implemented entirely at the endsAssumes unreliable, non-sequenced deliveryFate sharingOperationsOPEN/LISTEN, CONNECT, SEND, RECEIVE, ABORT6TCP Reliability Mechanism Computer Communications - CSCI 551 Copyright © William C. ChengSender Receiverdata1234acklost ackSummary or mechanismswindow-based flowcontrolsequence numbers,3-way handshakereliability (ACK,retransmission policies)congestion controlRTT estimationcummulative ack7 Computer Communications - CSCI 551 Copyright © William C. Cheng TCP HeaderSYNFINRESETPUSHURGACK Flags:DataOptions (variable)Checksum Urgent pointerAdvertised windowFlags0Hdr lenAcknowledgementSequence numberSource port Destination port8TCP Header Computer Communications - CSCI 551 Copyright © William C. Cheng 0 1 2 3 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+| Source Port | Destination Port |+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+| Sequence Number |+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+| Acknowledgment Number |+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+| Hdr | |U|A|P|R|S|F| || Len | Reserved |R|C|S|S|Y|I| Advertised Window || | |G|K|H|T|N|N| |+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+| Checksum | Urgent Pointer |+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+| Options (variable) | Padding |+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+| || Data || |+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+Connection establishment9TCP Mechanisms Computer Communications - CSCI 551 Copyright © William C. ChengSequence number selectionConnection tear-downRound-trip estimationWindow flow controlA and B must agree on initial sequence number selection:Use 3-way handshake10Connection Establishment Computer Communications - CSCI 551 Copyright © William C. ChengMake sure other side is listeningPass window sizesSetup options (such as timestamping)A B<SEQ=x><CTL=SYN><SEQ=y><ACK=x+1><CTL=SYN+ACK><ACK=y+1><CTL=ACK>SYNACK-BSYN+ACK-ASetup initial sequence number11Connection Setup Computer Communications - CSCI 551 Copyright © William C. Cheng +---------+ ---------\ active OPEN | CLOSED | \ ----------- +---------+<---------\ \ create TCB | ^ \ \ snd SYN passive OPEN | | CLOSE \ \ ------------ | | ---------- \ \ create TCB | | delete TCB \ \ V | \ \ +---------+ CLOSE | \ | LISTEN | ---------- | | +---------+ delete TCB | | rcv SYN | | SEND | | ----------- | | ------- | V +---------+ snd SYN,ACK / \ snd SYN +---------+ | |<----------------- ------------------>| | | SYN | rcv SYN | SYN | | RCVD |<-----------------------------------------------| SENT | | | snd ACK | | | |------------------ -------------------| | +---------+ rcv ACK of SYN \ / rcv SYN,ACK +---------+ | -------------- | | ----------- | x | | snd ACK | V V | CLOSE +---------+ | ------- | ESTAB | | snd FIN +---------+ +---------+ ---------\ active OPEN | CLOSED | \ ----------- +---------+<---------\ \ create TCB | ^ \ \ snd SYN passive OPEN | | CLOSE \ \ ------------ | | ---------- \ \ create TCB | | delete TCB \ \ V | \ \
View Full Document