SYN = 1
and seq = x
to Server.ack = x + 1
and seq = y
.ack = y + 1
and seq = x + 1
.FIN = 1
and seq = u
. Now Client has been disconnected.ack = u + 1
and seq = v
.FIN = 1
and seq = w
and ack = u + 1
(next seq of datagram will receive). Now Server has been disconnected.seq = u + 1
and ack = w + 1
.Duplicate Cumulative Acknowledgements
If the sender receives 3 confirmations of the same package, it will retransfer the last unconfirmed package.
Retransmission Timeout
The sender uses an estimated time as the maximum timeout for the confirmation. If the confirmation package is not received after this upper limit, the sender will retransfer the packet.
Example
seq = 1
and 1460 bytes. The receiver responds with ack = 1461
to indicate that it has fully received and requested the next message segment.seq = 1461
. The receiver responds with a TCP message segment with ack = 2921
(1461+1460) to indicate that it has fully received and requested the next message segment.Both Sender and Receiver have a window. The Receiver tells the Sender its own window size through the window field in the TCP message and the Sender sets its own window size according to this value.
The receiving window only confirm the last sequentially(按序到达) byte. For example, the byte received is {31, 34, 35}, where {31} arrives in order and {34, 35} are not, so only 31 is confirmed. After the sender received confirmation by a byte, it knows that all bytes before this byte have been received.
Receiver’s Advertised Window: The message sender(can be client or server) indicates the number of bytes can be received in the WIN
. The receiver sends up to the number of bytes allowed by WIN
.
Example:
Suppose cwnd is 1, swnd = cwnd, so the sender can only send one message. After the receiver receives the message, it will send a confirmation to the sender. After receiving the confirmation message, the sender will add cwnd to 2. (2 ⇒ 4, 4 ⇒ 8…cwnd increases exponentially)
cwnd can only be added 1 linearly. Assuming that 4 of the 24 messages are lost and after a period of time, the retransmission timer of the 4 lost messages timed out, and the sender found the congestion. ssthresh reduced to half of cwnd and cwnd is placed at 1.
The sender sends message1. After receiving the message1, the receiver will confirm message1. Before the confirmation of message1 reaches the sender, the sender can also send message2. If the sender receives 3 repeated confirmations, it immediately retransmit the message.
The TCP protocol was inefficient when packets were lost.
For example, 10,000 bytes of data are sent through 10 groups. If the first group is lost, the receiver cannot say that it has successfully received 1,000 to 9,999 bytes, but has not received the first group containing 0 to 999 bytes. Therefore, the sender may have to retransit all 10,000 bytes.