UDP gurus? Trying to figure out total packet size.

BlitzMax Forums/BlitzMax Programming/UDP gurus? Trying to figure out total packet size.

The forum is locked. These are the original blitzbasic.com forums, kept so they can still be read. No new topics, replies or edits can be made here. To join in, head over to the Blitz3D+ forums.

In short: no, there's no (reasonable) way to know the exact amount of data. But you can make educated guesses. Like FlameDuck mentions, have a look at the OSI model.

Example: UDP over IPv4 over Ethernet
Total packet size >= UDP data + UDP header + IPv4 header + MAC frame header

Why >=? Because the headers contain optional fields; for example, IP can have DiffServ fields as well, which will increase the size.

Also, to complicate things further, you can never just assume that a typical set of stacked protocols are being used; UDP with IPv4 and Ethernet is probably most common, but things change depending on the uplink. For example, a WLAN uplink would have additional headers. DSL would also introduce additional layer 2 protocols. (Although that's not visible for client computers connecting to a modem.)

If you want to know the exact amount of data you -can- add a traffic sniffer to analyze the traffic and match incoming/outgoing data (and its complete frame sizes) with your known received data. But that's not reasonable. Instead, you can make a rough estimate since you know that each packet must -at least- have an IPv4 header and a MAC frame header. You can safely add that static number, and get a sliightly better number.