Skip to content

Latest commit

 

History

History
101 lines (94 loc) · 10.2 KB

README.md

File metadata and controls

101 lines (94 loc) · 10.2 KB

Testing the State-Event-Engine of TCP

Description

The following diagram from RFC 793, Section 3.2 with corrections from RFC 1122, Section 4.2.2.8 shows the TCP state-event-engine.

                                       +---------+ ---------\      active OPEN
                                       |  CLOSED |            \    -----------
                                       +---------+<---------\   \   create TCB
                                         |     ^              \   \  snd SYN
                            passive OPEN |     |   CLOSE        \   \
                            ------------ |     | ----------       \   \
                             create TCB  |     | delete TCB         \   \
                                         V     |                      \   \
                        rcv RST        +---------+            CLOSE    |    \
                 --------------------->|  LISTEN |          ---------- |     |
               /                       +---------+          delete TCB |     |
               |            rcv SYN      |     |     SEND              |     |
               |           -----------   |     |    -------            |     V
          +---------+      snd SYN,ACK  /       \   snd SYN          +---------+
          |         |<-----------------           ------------------>|         |
          |   SYN   |                    rcv SYN                     |   SYN   |
          |   RCVD  |<-----------------------------------------------|   SENT  |
          |         |                  snd SYN,ACK                   |         |
          |         |------------------           -------------------|         |
          +---------+   rcv ACK of SYN  \       /  rcv SYN,ACK       +---------+
               |        --------------   |     |   -----------
               |               x         |     |     snd ACK
               |                         V     V
        CLOSE  |                       +---------+
       ------- |                       |  ESTAB  |
       snd FIN |                       +---------+
               |                CLOSE    |     |    rcv FIN
               V               -------   |     |    -------
          +---------+          snd FIN  /       \   snd ACK          +---------+
          |  FIN    |<-----------------           ------------------>|  CLOSE  |
          | WAIT-1  |---------------------                           |   WAIT  |
          +---------+                      \   rcv FIN               +---------+
rcv ACK of FIN ||                           |  -------                    |  CLOSE 
-------------- | \                          |  snd ACK                    | -------
       x       V   ---    rcv FIN,ACK       V                             V snd FIN
          +---------+  \  -----------  +---------+                   +---------+
          |FINWAIT-2|   |   snd ACK    | CLOSING |                   | LAST-ACK|
          +---------+   \              +---------+                   +---------+
               |          --------------    |                             |
               |                         \  | rcv ACK of FIN              | rcv ACK of FIN
       rcv FIN |                          | | --------------              | --------------
       ------- |                          V V        x                    V       x
       snd ACK  \                      +---------+                   +---------+
                  -------------------->|TIME WAIT|------------------>| CLOSED  |
                                       +---------+   Timeout=2MSL    +---------+
                                                     ------------
                                                      delete TCB 

RFC 1337 describes the handling of RST segments in the TIME-WAIT state. RFC 5961 specifies an alternate handling of SYN and RST segments for improved security.

Structure

The following table shows the number of tests for handling TCP segments in the various states.

SYN SYN-ACK SYN-FIN ACK FIN FIN-ACK RST RST-ACK
CLOSED 4 4 4 4 4 4 4 4
LISTEN 4 4 8 4 4 4 4 4
SYN-SENT 4 12 8 12 4 12 4 12
SYN-RCVD x x x x x x 32 128
ESTABLISHED 16 x x x x x 16 x
CLOSE-WAIT 16 x x x x x 16 x
FIN-WAIT-1 16 x x x x x 16 x
CLOSING 16 x x x x x 16 x
LAST-ACK 16 x x x x x 16 x
FIN-WAIT-2 16 x x x x x 16 x
TIME-WAIT 16 16 32 10 10 10 16 16

Notes

  1. The condition in RFC 5961 defining outside the current receive window should read (SEG.SEQ < RCV.NXT || SEG.SEQ >= RCV.NXT + RCV.WND) instead of (SEG.SEQ <= RCV.NXT || SEG.SEQ > RCV.NXT + RCV.WND). This has been reported as Errata 4845.

Fixes

References