-2

i want to know if we have a simple udp packet that has a string in it how much the size of udp packet will be

for exmaple we have a udp packet that has a string in it the string is:stackoverflow.com

ok now how much the size of the udp packet will be?

i was thinking that may the size of udp packets that have a text in it be like a size of text file with the same text in packet?

so if the file have this text and the size is 1 kilobites

test

if the packet has same text will the size be same as text file?

2 Answers2

0

The size of a UDP datagram is the size of the data inside it (payload) plus the size of the UDP and IP headers. The payload can be up to 65507 bytes for IPv4 transported over IP with no additional options in the header.

It's up to you how you create the payload. "test" could be as little as 4 bytes using a single-byte character set with no terminator or length indicator. Really, it's up to you to create a payload structure that you are able to decode at your receiver.

Andy Brown
  • 8,676
  • 2
  • 30
  • 49
0

Add 8 octets for UDP header, another 12 for IPv4.

It gets a bit more complicated if you need to calculate the lower layer, e.g. ethernet frame

Kimvais
  • 34,273
  • 14
  • 100
  • 135