tcpip 3次握手 [英] tcpip 3-way handshake

查看:34
本文介绍了tcpip 3次握手的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

为什么在 TCP 3 次握手的第三部分没有传输数据?例如

(A 到 B)同步

(B 到 A)ACK+SYN

(A to B) ACK……为什么数据不能和这个ACK一起传输?

解决方案

我一直认为是将会话建立阶段与数据传输阶段分开,这样没有真正的数据被传输直到会话的两端就序列号和会话选项达成一致,特别是因为到达的数据包可能来自完全不同的先前会话,而这些会话恰好具有相同的端点.

但是,经过进一步调查,我并不完全确定不允许使用握手数据包传输数据.我的Internetworking with TCP/IP1 书中关于 TCP 连接建立的部分包含以下片段:

<块引用>

由于协议设计,可以在握手段中随初始序列号一起发送数据.在这种情况下,TCP 软件必须保持数据直到握手完成.一旦建立连接,TCP 软件就可以释放保存的数据,并迅速将其传递给等待的应用程序.

因为使用SYN(或ACK)数据构建TCP数据包当然是可能的,所以这很可能被允许.我从未在野外看到过这种情况,但话说回来,我也从未在野外看到过毛耳侏儒狐猴,尽管我确信它们存在.

可能是套接字软件在会话完全建立之前阻止数据流出,但 TCP 似乎认为它有效.看起来您可以使用 SYN-ACK 数据包发送数据(连接建立的第 2 阶段),因为您拥有另一端的序列号和选项.同样,使用第 3 阶段 ACK 数据包发送数据似乎也是可能的.

TCP 软件一直保留数据直到握手完全完成的原因可能是由于上面提到的原因 - 只有当两端都同意序列号后才能确定数据不是来自以前的会议.

<小时>

1 Internetworking with TCP/IP Volume 1 原则、协议和架构,第 3 版,Douglas E. Comer,ISBN 0-13-216987-8.>

Why is data not transferred during the 3rd part of TCP 3-way handshake? e.g.

(A to B)SYN

(B to A)ACK+SYN

(A to B) ACK.... why cant data be transferred along with this ACK?

解决方案

I've always believed it was to keep the session establishment phase separate from the data transfer phase so that no real data is transferred until both ends of the session have agreed on the sequence numbers and session options, especially since packets arriving may be from a totally different, previous, session that just happens to have the same endpoints.

However, on further investigation, I'm not entirely certain that transmitting data with the handshake packets is disallowed. The section on TCP connection establishment in my Internetworking with TCP/IP1 book contains the following snippet:

Because of the protocol design, it is possible to send data along with the initial sequence numbers in the handshake segments. In such cases, the TCP software must hold the data until the handshake completes. Once a connection has been established, the TCP software can release data being held and deliver it to a waiting application program quickly.

Since it's certainly possible to construct a TCP packet with SYN (or ACK) and data, this may well be allowed. I've never seen it happen in the wild but, then again, I've never seen a hairy-eared dwarf lemur in the wild either, though I'm assured they exist.

It may be that it's the sockets software that prevents data going out before the session is fully established but TCP appears to consider it valid. It appears you can send data with a SYN-ACK packet (phase 2 of the connection establishment) since you have the other end's sequence number and options. Likewise, sending data with the phase 3 ACK packet appears to be possible as well.

The reason the TCP software holds on to the data until the handshake is fully complete is probably due to the reason mentioned above - only once both ends have agreed on the sequence numbers can you be sure that the data is not from a previous session.


1 Internetworking with TCP/IP Volume 1 Principles, Protocols and Architecture, 3rd edition, Douglas E. Comer, ISBN 0-13-216987-8.

这篇关于tcpip 3次握手的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆