可以在TIME-WAIT到期之前重新使用TCP端口吗? [英] Can a TCP port be re-used before TIME-WAIT expires?

查看:130
本文介绍了可以在TIME-WAIT到期之前重新使用TCP端口吗?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我们有一个C#FTP类,该类很好用,但是我们用尽了TCP端口,因为它们都处于TIME-WAIT状态,并且无法重用.我们可以减少注册表中的默认TIME-WAIT,但我们希望重用端口.

We have a C# FTP class which works great but we are running out of TCP ports because they are all in the TIME-WAIT state and cannot be reused. We can decrease the default TIME-WAIT in the registry but we would rather reuse the ports.

因此,鉴于以下博客: http://blogs.technet.com/b/networking/archive/2010/08/11/how-tcp-time-wait-assassination-works.aspx

So given the blog below: http://blogs.technet.com/b/networking/archive/2010/08/11/how-tcp-time-wait-assassination-works.aspx

在服务器端套接字进入TIME-WAIT状态并且客户端在2MSL(默认的TIME-WAIT时间)内重新连接到服务器的情况下,可能发生两种情况:

In a situation where the server side socket goes to a TIME-WAIT state and the client reconnects to the server within 2MSL (default TIME-WAIT time), there are 2 things that can happen:

1.由于套接字处于TIME-WAIT状态,服务器将不响应来自客户端的SYN数据包.

1.The server will not respond to the SYN packets from the client because the socket is in the TIME-WAIT state.

2.服务器可以接受来自客户端的SYN,并将套接字的状态从TIME-WAIT更改为ESTABLISHED.这被称为TIME-WAIT暗杀或先前连接的化身.

2.The server may accept the SYN from the client and change the state of the socket from TIME-WAIT to ESTABLISHED. This is known as TIME-WAIT assassination, or incarnation of a previous connection.

上面情形"2"的关键是发送的SYN的ISN(初始序列号)必须高于上一个会话中使用的最高序列号.如果ISN不符合预期,则服务器将不会响应SYN,套接字将等待2MSL,然后才能再次使用.

The key to scenario ‘2’ above is that the ISN (Initial Sequence number) of the SYN sent needs to be higher than the highest sequence number used in the previous session. If the ISN is not as expected, the server will not respond to the SYN and the socket will wait for 2MSL before being available for use again.

我正在尝试(以C#编程)找到一种方法来始终发送发送的SYN,该SYN的编号要比前一个会话中使用的最高序列号高.

I am trying (programmatically in C#) to find a way to always send a SYN sent with a higher number than the highest sequence number used in previous session.

那有可能实现吗?

推荐答案

Windows已经为您本地实现了更高的序列号,您无需执行任何特殊操作即可获得该功能. 文章您已与各州建立了尽可能多的联系:

Windows already natively implements higher sequence numbers for you, you do not have to do anything special to get that functionality. The article you linked to states as much:

Microsoft的TCP/IP实现使用此功能. ... TCP TIME-WAIT暗杀在Windows系统之间非常有效,并且在Windows与运行其他TCP/IP实现的主机进行通信时可能无法按预期工作. RFC1337,超时杀害的危害,讨论了可能的陷阱: http://tools.ietf.org/rfc/rfc1337.txt

这篇关于可以在TIME-WAIT到期之前重新使用TCP端口吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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