Tuesday, September 21, 2021

CST 311 - Week 3

TCP Connection Management


While UDP essentially just provides a "send and pray" service, TCP provides a reliable data transfer service. As discussed previously, TCP initiates a connection with a three-way-handshake procedure. This is accomplished by the TCP client and TCP server sending special segments to each other. These segments contain no application-layer data, but do contain headers with bits that are used to establish, maintain, and close a connection. 

Establishment


To initiate a connection, he client sends a SYN segment with the SYN bit set to 1. This segment's header contains a random initial sequence number (client_isn) to be used by the server for acknowledgement. The server responds with a SYNACK segment with the SYN bit also set to 1. This segment contains a random initial sequence number (server_isn) and an acknowledgement number (client_isn+1), which is the sequence number of the next expected segment from the client. Finally, the client responds with a segment that contains the acknowledgement number (server_isn+1) and (usually) its first data payload. The SYN bit is set to 0 in this final acknowledgement because the connection is already established. 

Maintenance


As noted above, sequence numbers and acknowledgement numbers are used by the client and server during connection establishment. However, it would be incorrect to assume they are offset by 1 every time. During normal TCP communication, the sequence numbers are offset by the number of bytes that have been transmitted. Each sequence number identifies the byte number of the first byte in the segment's payload. The maximum segment size (MSS) is the maximum size of the data payload (NOT the data + headers) and is dependent on the maximum transmission unit (MTU) in the link layer. When sending large files, sequence numbers are offset by one MSS. By synchronizing SEQ and ACK numbers, clients can retransmit lost packets when a server fails to acknowledge a segment (through a timeout timer) or when a server sends too many duplicate acknowledgements, which also implies packet loss. The procedure also guarantees that segments arrive in the correct order. 

Closure


A connection can be closed by either a client or a server. First, the initializer sends a shutdown segment with the FIN bit set to 1 and enters the FIN_WAIT_1 state. The receiver acknowledges, sends its own shutdown segment (note two segments are sent here), and enters the CLOSE_WAIT state. The initializer receives the acknowledgement and enters FIN_WAIT_2 while waiting for the receiver's shutdown segment. When it arrives, the initializer sends one final acknowledgement and enters the TIME_WAIT state, which gives it time to resend the final acknowledgement (typically 30 seconds to 2 mins). Afterwards, the connection formally closes.

No comments:

Post a Comment

CST499 - Week 8

The End? I made it. This is my final week in the CS Online program here at CSUMB. I still have one final hurdle in the form of a mock techni...