Advanced Computer Networks: Lecture 31. This lecture will cover the following: TCP segment header; negotiate maximum segment size (MSS); TCP state description; state transition diagram; think-pair-share; sliding window implementation; sliding window math; TCP flow control issues;...
CS716 Advanced Computer Networks By Dr. Amir Qayyum Lecture No. 31 TCP Segment Header • 16bit advertised window – Space remaining in receive window • 16bit checksum – Uses IP checksum algorithm – Computed on header, data, and pseudoheader • 16bit urgent data pointer – If URG = 1 – Index of last byte of urgent data in segment TCP Segment Format • Each connection identified with 4tuple: – (SrcPort,SrcIPAddr,DsrPort,DstIPAddr) • Sliding window + flow control – ACK, SequenceNum, AdvertisedWindow Data(SequenceNum) Receiver Sender • Flags Acknowledgment + AdvertisedWindow – SYN, FIN, RESET, PUSH, URG, ACK TCP Options – Existing & Proposed • Negotiate maximum segment size (MSS) – Each host suggests a value – Minimum of two values is chosen – Prevents IP fragmentation over first/last hops TCP Options – Existing & Proposed • Packet timestamp – Allows RTT calculation for retransmitted packets – Extends sequence number space for identification of stray packets (packets arriving very late) • Negotiate advertised window granularity – Allows larger windows – Good for routes with large bandwidthdelay products TCP State Description • • • • • • • • • • • CLOSED LISTEN SYN_RCVD SYN_SENT ESTABLISHED CLOSE_WAIT LAST_ACK FIN_WAIT_1 FIN_WAIT_2 CLOSING TIME_WAIT Disconnected Waiting for incoming connection Connection request received Connection request sent Ready for data transport Connection closed by peer Closed by peer, closed locally, await ACK Connection closed locally Closed locally and ACK’d Closed by both sides “simultaneously” Wait for network to discard related packets State Transition Diagram CLOSED Active open/SYN Passive open Close Close LISTEN SYN_RCVD SYN/SYN + ACK Send/SYN SYN/SYN + ACK ACK Close/FIN SYN + ACK/ACK ESTABLISHED Close/FIN FIN/ACK FIN_WAIT_1 ACK FIN_WAIT_2 CLOSE_WAIT AC FIN/ACK K + FI N /A CK Close/FIN CLOSING ACK FIN/ACK SYN_SENT TIME_WAIT LAST_ACK Timeout after two segment lifetimes ACK CLOSED ThinkPairShare • Describe the path taken – By a server under normal conditions, and – By a client under normal conditions, – Assuming that the client closes the connection first • Consider the TIME_WAIT state – What purpose does this state serve ? – Prove that at least one side of a connection enters this state before returning to CLOSED – Explain how both sides might enter this state Sliding Window Implementation • Sequence numbers are indices into byte stream • ACK sequence number is actually next byte expected (as opposed to last byte received) • Receiver buffers contain – Data ready for delivery to application until requested – Outoforder data out to maximum buffer capacity • Sender buffers contain – Unacknowledged data – Unsent data out to maximum buffer capacity 10 Sliding Window application • Sender side LastByteAcked Window LastByteSent max buffer size TCP LastByteWritten time – Green: sent and acknowledged – Red: sent (or can be sent) but not acknowledged – Blue: available but not within send window 11 Sliding Window • Receiver side NextByteRead application TCP NextByteExpected LastByteReceived Advertised window max buffer size time – Green: received and ready to be delivered – Red: received and buffered – Blue: received and discarded 12 Sliding Window Math Sending application Receiving application TCP TCP LastByteWritten LastByteAcked LastByteRead LastByteSent NextByteExpected • Sending side – LastByteAcked