Information Technology Reference
In-Depth Information
the right or upper edge of the receive window.
First sequence number occupied by the incoming segment.
SEG.SEQ
SEG.SEQ+SEG.LEN-1
Last sequence number occupied by the incoming segment.
24.6.2 ISN selection
The initial sequence number (ISN) is selected so that previous sockets are not confused with
new sockets. Typically, this can happen when a host application crashes and then quickly re-
establishes the connection before the other side can time-out the connection. To avoid this a
32-bit initial sequence number (ISN) generator is created when the connection is made. The
number is generated by a 32-bit clock, which is incremented approximately every 4
µ
s (giv-
ing an ISN cycle of 4.55 hours). Thus, within 4.55 hours, each ISN will be unique.
As each connection has a send and receive sequence number, these are an initial send
sequence number (ISS) and an initial receive sequence number (IRS). When establishing a
connection, the two TCPs synchronise their initial sequence numbers. This is done by ex-
changing connection establishing packets, with the SYN bit set and with the initial sequence
numbers (these packets are typically called SYNs). Thus four packets must be initially ex-
changed:
A sends to B. SYN with A SEQ .
B sends to A. ACK of the sequence number (A SEQ ).
B sends to A. SYN with B SEQ .
A sends to B. ACK of the sequence number (B SEQ ).
Note that the two intermediate steps can be combined into a single message. This is some-
times knows as a three-way handshake. This handshake is necessary as the sequence num-
bers are not tied to a global clock, only to local clocks, and has many advantages, including
the fact that old packets will be discarded as they occurred in a previous time.
To make sure that a sequence number is not duplicated, a host must wait for a maximum
segment lifetime (MSL) before starting to retransmit packets (segments) after start-up or
when recovering from a crash. An example MSL is 2 minutes. However, if it is recovering,
and it has a memory of the previous sequence numbers, it may not need to wait for the MSL,
as it can use sequence numbers which are much greater than the previously used sequence
numbers.
24.7 Opening and closing a connection
Figure 24.7 shows a basic three-way handshake. The steps are:
1. The initial state on the initiator is CLOSED and, on the recipient, it is LISTEN (the re-
cipient is waiting for a connection see figure 24.7).
2. The initiator goes into the SYN-SENT state and sends a packet with the SYN bit set and
then indicates that the starting sequence number will be 999 (the current sequence num-
ber, thus the next number sent will be 1000). When this is received the recipient goes
into the SYN-RECEIVED state.
3. The recipient sends back a TCP packet with the SYN and ACK bits set (which identifies
that it is a SYN packet and also that it is acknowledging the previous SYN packet). In
Search WWH ::




Custom Search