Meanwhile series 03- TCP connection management -2, TCP connection open and close at the same time

====================================================||

Welcome to the discussion of technology can add another micro letter: windgs (please note csdn + xx occupation)

====================================================||

table of Contents

First, while opening the connection

Second, the connection is closed

Third, examples

1.tcp with open due to the linux implementation does not support simultaneous active open TCP connection, so RFC793 schematic diagram of an example we take to

2.tcp off with

3.tcp packet switched off by three connection

Supplement


In the previous content we introduced the TCP connection management is the most common way and three-way handshake waved four ways. It is possible that both ends A and B are simultaneously connected to each other and an active open or close the connection active simultaneously performed (although the possibility is relatively low on this happens), this time on a slightly different process. Here we were to open simultaneously (simultaneous open) connections and simultaneously closed (simultaneous) connections in both cases were introduced.

First, while opening the connection

        At the same time open the connection is a communication between the parties prior to receiving each other's SYN packet, we have been actively open operation and issued its own SYN packet. As you said before a four-tuple identifies a TCP connection, so if a TCP connection is opened at the same time need to communicate both know each other's IP and port information for the job, this scenario rarely happens in reality (NAT penetration in might be a little more). FIG simultaneously open process is as follows

        We do not process specific messages are introduced one by one. Note that the figure above, the main difference between TCP connections open at the same time with the three-way handshake is as follows

  • We also call A and B for the Client, they can do an active open operation (Active Opener).
  • State change while the ends are ESTABLISHED CLOSED-> SYN_SENT-> SYN_RCVD->.
  • Connection is established when the need to exchange four packets, and each packet carries both SYN identifier until it receives the SYN ACK up

 

Second, the connection is closed

        At the same time we have said with respect to close four-way handshake process is basically similar Note the difference between state transitions, while close by ESTABLISHED-> FIN_WAIT_1-> CLOSING-> TIME_WAIT-> CLOSED. While closing process is as follows, do not do the extra explanation.

 

 

 

Third, examples

1.tcp with open
due to the linux implementation does not support simultaneous active open TCP connection, so RFC793 schematic diagram of an example we take to

 

 

 

      TCP A                                            TCP B

  1.  CLOSED                                           CLOSED

  2.  SYN-SENT     --> <SEQ=100><CTL=SYN>              ...

  3.  SYN-RECEIVED <-- <SEQ=300><CTL=SYN>              <-- SYN-SENT

  4.               ... <SEQ=100><CTL=SYN>              --> SYN-RECEIVED

  5.  SYN-RECEIVED --> <SEQ=100><ACK=301><CTL=SYN,ACK> ...

  6.  ESTABLISHED  <-- <SEQ=300><ACK=101><CTL=SYN,ACK> <-- SYN-RECEIVED

  7.               ... <SEQ=101><ACK=301><CTL=ACK>     --> ESTABLISHED

                Simultaneous Connection Synchronization

 RFC793对示意图中的相关符号说明如下,大家对照下面的说明仔细观察一下上面RFC的文字示例图,有没有发现什么问题呢?(参看补充说明部分第2点)
                                      Right arrows (-->) indicate
  departure of a TCP segment from TCP A to TCP B, or arrival of a
  segment at B from A.  Left arrows (<--), indicate the reverse.
  Ellipsis (...) indicates a segment which is still in the network
  (delayed).

下面看一下wireshark实际抓包

2.tcp同关

linux本身也是支持TCP同时关闭连接的,wireshark抓包如下

 

3.tcp通过三次数据包交换关闭连接

还有一种场景是TCP通过三次数据包交换来关闭连接,这种场景同样很少遇到,我们不做过多介绍,以一个wireshark实例来看一下相关的系列号seq和ack number的关系

 

补充说明

1、RFC793给的同时打开TCP连接的示意图中,TCP B进入ESTABLISHED状态前收到的包应该是<SEQ=100><ACK=301><CTL=SYN,ACK>。想借此提醒不要仅仅看协议本身,还要记得看协议是否由对应的勘误表(errata)。原始的RFC793协议有很多

2、本篇文章给出的同时关闭时的tcp包时序图是与RFC793一致的,但是注意一些资料包括我所参考的第二版 tcpip详解,给的同时关闭的示意图中最后两条消息的系列号seq是错误的,或者干脆没有给出系列号seq的值

Guess you like

Origin blog.csdn.net/Windgs_YF/article/details/94740184