简体   繁体   English

C#UDP套接字问题

[英]C# UDP socket problems

I'm trying to send some UDP packets to a server. 我正在尝试将一些UDP数据包发送到服务器。 I use Wireshark to monitor my activity. 我使用Wireshark监视我的活动。 When I send a packet, wireshark tells me my header checksum is incorrect. 当我发送数据包时,wireshark告诉我我的报头校验和不正确。

Wireshark

At the wireshark preferences the option " Validate the UDP chechsum if possible " is disabled . 在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);

Did I forgot something? 我忘了什么吗? Do I need to set specific options? 我需要设置特定的选项吗? Help is much appreciated! 非常感谢帮助!

Known issue - note the "maybe caused by IP Checksum offload". 已知问题-注意“可能是IP Checksum卸载引起的”。 From the Wireshark wiki : 从Wireshark Wiki

Most modern operating systems support some form of network offloading, where some network processing happens on the NIC instead of the CPU. 大多数现代操作系统都支持某种形式的网络卸载,其中某些网络处理发生在NIC而不是CPU上。
[...] [...]
On systems that support checksum offloading, IP, TCP, and UDP checksums are calculated on the NIC just before they're transmitted on the wire. 在支持校验和卸载的系统上,IP,TCP和UDP校验和在通过网络传输之前就在NIC上进行计算。 In Wireshark these show up as outgoing packets marked black with red Text and the note [incorrect, should be xxxx (maybe caused by "TCP checksum offload"?)]. 在Wireshark中,这些将显示为以红色标记为黑色的传出数据包,文本和注释[不正确,应为xxxx(可能由“ TCP校验和卸载”引起)?)。

The page also lists how to disable this feature for your specific OS. 该页面还列出了如何针对您的特定操作系统禁用此功能。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM