As part of the process of connection establishment, each of the two devices in a TCP connection informs the other of the sequence number it plans to use for its first data transmission by putting the preceding sequence number in the Sequence Number field of its SYN message.
The other device confirms this by incrementing that value and putting it into the Acknowledgment Number field of its ACK , telling the other device that is the sequence number it is expecting for the first data transmission.
This process is called sequence number synchronization .
The TIME-WAIT state is required for two main reasons.
The first is to provide enough time to ensure that the ACK is received by the other device, and to retransmit it if it is lost.
The second is to provide a “buffering period” between the end of this connection and any subsequent ones. If not for this period, it is possible that packets from different connections could be mixed, creating confusion.
The standard specifies that the client should wait double a particular length of time called the maximum segment lifetime (MSL) before finishing the close of the connection.
Ideally, the retransmission timer should be of value just slightly larger than the round-trip time (RTT)
How to determine RTT?
Differences in TCP Connection Distances.
Transient Delays and Variability : The amount of time it takes to send data between any two devices will vary over time due to various happenings on the internetwork: fluctuations in traffic, router loads and so on.