简体   繁体   中英

How do i know how much udp data i received(including bad data) in c#

I want to know the amount of data arrived at my updclient including damaged/bad data, packet header etc. i want to calculate throughput using udp.

Thanks.

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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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