我想知道到达我的 updclient 的数据量,包括损坏/坏数据、数据包头等。我想使用 udp 计算吞吐量。
谢谢。
UdpClient
is a very high-level interface which doesn't provide access to raw packet data. To get such information, you will need to use some low-level API and process the packets yourself.
However, in practice, the chances of a packet getting damaged in transit are very low - most of the time, you either get the correct packet or you don't get the packet at all. The packet headers are generally of constant size (8 bytes for the UDP header and usually 20 bytes for the IP header), so you can just add this value to the size of each datagram (which is returned by UdpClient.Receive
) to get the total packet size.