0

我在 C# 中使用 TcpClient 与服务器通信。

当我在 Wireshark 中查看第一个 SYN 请求时,我看到 12 个字节按以下顺序指定了 6 个 TCP 选项:

-最大段大小
-NOP -
窗口比例
-NOP
-NOP
-SACK 允许

TCP_Options <<< Wireshark 捕获的屏幕截图

我正在使用传递给函数的 TcpClient 对象的默认构造函数。

我相信有一种方法可以使用 Socket.SetSocketOption 方法(在此处描述)来指定选项,但是,我希望删除这些选项以验证服务器不需要它们建立连接。

是否可以删除(或修改)我在 Wireshark 中看到的选项?

这是我如何使用 TcpClient 的一个小示例(使用默认值实例化):

public static IPStatus PingThenConnect(TcpClient tcpClient, IPEndPoint serverEndpoint)
{
  IPStatus ipStatus = IPStatus.Unknown;

  // Ping the given IP Address
  ipStatus = Network.PingIP(serverEndpoint.Address);

  if (ipStatus == IPStatus.Success)
  {
    // Connect TcpClient to given endpoint.
    tcpClient.Connect(serverEndpoint.Address, serverEndpoint.Port);
    tcpClient.LingerState = new LingerOption(true, 10);
  }

  return ipStatus;
}
4

0 回答 0