0

I need to measure as precisely as possible how much of cell service provider's data limit my application uses up.

Is it possible to get the volume of data transferred by a .Net UDP Socket over the network interface (including overhead of UDP and IP)?

The application is a server communicating with a great number of embedded devices, each of which is connected to the internet using GPRS with a very low data limit (several megabytes per month at best, so even a few bytes here and there matter). I know the devices don't open connections with any other servers, so measuring the traffic server-side should be enough.

I know I can't get 100% accurate number (I have no idea what traffic the service provider charges), but I would like to get as close as possible.

Matěj Zábský
  • 16,909
  • 15
  • 69
  • 114

1 Answers1

0

Assuming this is IPv4, you could add 28 bytes to every data you transfer but your problem is going to be detecting packet loss and potentially fragmentation. You could add some meta data to your communication to detect packet loss (e.g. sequence numbers, acknowledgments and so on) but that would add more overhead of course which you might not want. Maybe a percentage of expected package loss could help. As for fragmentation again you could compensate when the size of your message is greater than the MTU size (which I believe could be quite small, like 296 bytes, not too sure though, maybe check with your mobile provider)

Another somewhat non-intrusive option could be reading network performance counters of your process or restrict your communication into a separate AppDomain.

Community
  • 1
  • 1
Kurn Mogh
  • 84
  • 3