Cumulative ACKs: ACK N acknowledges all packets up to N-1 cumulatively. An acknowledgment (ACK) for a packet means that the sender can send the next packet.
Timeouts: Helps manage retransmissions when packets are lost.
Pipelining: Essential for effective flow control using window size.
Connection-oriented: TCP establishes a connection through a handshake.
Flow controlled: Ensures that the sender does not overwhelm the receiver.
Point-to-point: Involves one sender and one receiver.
Reliable, in-order byte stream: Ensures data integrity and order; there are no message boundaries.
Full duplex data: Allows bi-directional data flow within the same connection.
MSS: Maximum Segment Size, specifies the largest segment of data that the TCP layer can send.
TCP Segment Structure
32 bits: Contains various fields including:
Source Port Number and Destination Port Number
Sequence Number: Number of the first byte in the data segment.
Acknowledgment Number: Expected next byte from the other side.
Checksum: For error checking.
Urgent data pointer: Indicates if urgent data is in the segment.
Options: Can vary in length, include congestion notification, and management flags (RST, SYN, FIN).
TCP Sequence Numbers and ACKs
Sequence numbers track the order of bytes and ensure reliable data transfer.
ACKs inform the sender of the next expected byte, indicating data has been received successfully.
TCP Timeouts
Determining Timeout Value:
Timeout value must balance between being too short (premature timeouts) and too long (sluggish retries).
Typically, it should be longer than the RTT (Round-Trip Time).
TCP uses an Exponential Weighted Moving Average (EWMA) for estimating RTT, factoring in sample RTT measurements with a safety margin.
TCP Retransmissions
Scenarios for retransmissions include:
Lost ACK: If an ACK is not received, the sender may time out and retransmit.
Cumulative ACK: ACKs can cumulatively acknowledge previously received data, facilitating more efficient recovery.
Fast Retransmit: Triggered by three duplicate ACKs, allowing immediate retransmission without waiting for a timeout. This indicates that packets subsequent to the lost one have been received, suggesting packet loss.
TCP Flow Control
Prevents the sender from overwhelming the receiver's buffer.
Receive Window (rwnd): The amount of data the receiver can currently accept, as advertised in the TCP header.
Properly managing in-flight packets ensures that data flow remains smooth without packet loss due to buffer overflow.
TCP Connection Management
Establishing a Connection:
TCP uses a 3-way handshake for connection management:
Client sends a SYN message.
Server responds with a SYN-ACK.
Client sends an ACK to confirm.
Closing a Connection: Involves sending a FIN segment, which can be acknowledged and might be combined with a FIN from the other side, thus allowing a clean disconnection.
Simultaneous FIN exchanges are managed to avoid half-open connections.
Handshake Comparison
Human 3-Way Handshake: Analogous to confirming readiness in climbing—"On belay? Belay on. Climbing."