Information Technology Reference
In-Depth Information
this case, the recipient tells the originator that it will start transmitting at a sequence
number of 100. The acknowledgement number is 1000, which is the sequence number
that the recipient expects to receive next. When this is received, the originator goes into
the ESTABLISHED state.
4. The originator sends back a TCP packet with the SYN and ACK bits set and the ac-
knowledgement number is 101, which is the sequence number it expects to see next.
5. The originator transmits data with the sequence number of 1000.
Originator
Recipient
1. CLOSED
LISTEN
2. SYN-SENT
<SEQ=999><CTL=SYN>
SYN-RECEIVED
3. ESTABLISHED
<SEQ=100><ACK=1000>
<CTL=SYN,ACK>
SYN-RECEIVED
4. ESTABLISHED
<SEQ=1000><ACK=101>
<CTL=ACK>
ESTABLISHED
5. ESTABLISHED
<SEQ=1000><ACK=101>
<CTL=ACK><DATA> ESTABLISHED
Figure 24.7 TCP connection
Note that the acknowledgement number acknowledges every sequence number up to but not
including the acknowledgement number.
Figure 24.8 shows how the three-way handshake prevents old duplicate connection initia-
tions from causing confusion. In state 3, a duplicate SYN has been received, which is from a
previous connection. The recipient sends back an acknowledgement for this (4), but when
this is received by the originator, the originator sends back a RST (reset) packet. This causes
the recipient to go back into a LISTEN state. It will then receive the SYN packet sent in 2,
and after acknowledging it, a connection is made.
TCP connections are half-open if one of the TCPs has closed or aborted, and the other
end is still connected. They can also occur if the two connections have become desynchro-
nised because of a system crash. This connection is automatically reset if data is sent in ei-
ther direction. This is because the sequence numbers will be incorrect, otherwise the connec-
tion will time-out.
A connection is normally closed with the CLOSE call. A host who has closed cannot
continue to send, but can continue to RECEIVE until it is told to close by the other side. Fig-
ure 24.9 shows a typical sequence for closing a connection. Normally the application pro-
gram sends a CLOSE call for the given connection. Next, a TCP packet is sent with the FIN
bit set, the originator enters into the FIN-WAIT-1 state. When the other TCP has acknowl-
edged the FIN and sent a FIN of its own, the first TCP can ACK this FIN.
Originator
Recipient
1. CLOSED
LISTEN
2. SYN-SENT
<SEQ=999><CTL=SYN>
3. (duplicate)
<SEQ=900><CTL=SYN>
4. SYN-SENT
<SEQ=100><ACK=901> <CTL=SYN,ACK>
SYN-RECEIVED
5. SYN-SENT
<SEQ=901><CTL=RST>
LISTEN
.
( t 2 r i )
7. SYN-SENT
<SEQ=100><ACK=1000><CTL=SYN,ACK>
SYN-RECEIVED
8. ESTABLISHED
<SEQ=1000><ACK=101><CTL=ACK><DATA>
ESTABLISHED
Figure 24.8
TCP connection with duplicate connections
Search WWH ::




Custom Search