C#UDP套接字问题

时间:2011-12-16 11:15:58

标签: c# sockets udp wireshark

我正在尝试将一些UDP数据包发送到服务器。我使用Wireshark来监控我的活动。当我发送数据包时,wireshark告诉我我的标头校验和不正确。

wireshark

在wireshark首选项中,“验证UDP chechsum(如果可能)”选项禁用

this.socket = new Socket(AddressFamily.InterNetwork, SocketType.Dgram, ProtocolType.Udp);
this.destination = new IPEndPoint(IPAddress.Parse("***.***.***.***"), 80);

this.socket.Connect(this.destination);
this.socket.Send(Encoding.ASCII.GetBytes("foo"));
this.socket.Shutdown(SocketShutdown.Both);
this.socket.Disconnect(true);

我忘记了什么吗?我需要设置具体选项吗?非常感谢帮助!

1 个答案:

答案 0 :(得分:3)

已知问题 - 请注意“可能由IP Checksum卸载引起”。 From the Wireshark wiki

  

大多数现代操作系统都支持某种形式的网络卸载,其中一些网络处理发生在NIC而不是CPU上   [...]
  在支持校验和卸载的系统上,在网络上传输之前,会在NIC上计算IP,TCP和UDP校验和。在Wireshark中,这些显示为标记为黑色的传出数据包,带有红色文本和注释[不正确,应该是xxxx(可能由“TCP校验和卸载”引起?)]。

该页面还列出了如何为特定操作系统禁用此功能。