TCP序列号最大值

Won*_*Lee 5 tcp iptables packet

我正在尝试捕获数据包并重新组织数据包以获取原始 HTTP 请求。

我正在通过 IPQUEUE(通过 iptables 规则)捕获数据包,我发现数据包没有按顺序捕获。

我已经知道在 TCP 协议中,数据包必须重新排序,所以我试图按序列号重新排序数据包。

根据维基百科,TCP 的序列号是 32 位数字。那么,如果序列号达到 MAX 32bits 数会发生什么?

因为SYN包的序列号是随机数,我觉得这个限制可以很快达到。

如果有人对此表示赞赏,或者有一些有用的链接,请给我一个答案。

a.m*_*.m. 7

来自RFC-1185

  Avoiding reuse of sequence numbers within the same connection is
  simple in principle: enforce a segment lifetime shorter than the
  time it takes to cycle the sequence space, whose size is
  effectively 2**31.

  If the maximum effective bandwidth at which TCP
  is able to transmit over a particular path is B bytes per second,
  then the following constraint must be satisfied for error-free 
  operation:
      2**31 / B  > MSL (secs)  
Run Code Online (Sandbox Code Playgroud)

简而言之,TCP 会处理好它。除了此条件之外,TCP 还具有时间戳的概念来处理序列号环绕条件。来自上述 RFC

  Timestamps carried from sender to receiver in TCP Echo options can
  also be used to prevent data corruption caused by sequence number
  wrap-around, as this section describes.
Run Code Online (Sandbox Code Playgroud)

具体来说,TCP 使用 PAWS 机制来处理 TCP 环绕情况。您可以在RFC-1323中找到有关 PAWS 的更多信息


Jos*_*phH 1

RFC793 第 3.3 节:

重要的是要记住,实际的序列号空间虽然很大,但却是有限的。该空间的范围为 0 到 2* 32 - 1。由于空间是有限的,因此所有处理序列号的算术都必须以 2 * 32 为模进行执行。当序列号再次从 2**32 - 1 循环到 0 时,此无符号算术保留了序列号的关系。计算机模运算有一些微妙之处,因此在编程比较这些值时应格外小心。

对序列号进行的任何算术运算均以 2^32 为模