Reputation: 425
I have data 1245 MB for trasmission via UDP over IPv4. For calculation of expected number of packet transmission from A to B then B relay to C, if the data transmitted in blocks of size 320bytes (i.e; payload = 320bytes), and header is 20 bytes, do we minus 20 from 320 or add in?
For instance,
1245MB = 1305477120 bytes
Total UDP Payload = 320 - 20 or 320 + 20?
Upvotes: 2
Views: 11150
Reputation: 671
For calculating the number of packets you don't need to take into account the size of the transport or network layer headers. You specified a payload size of 320 bytes, which is well within the maximum size of a UDP payload without fragmentation.
Each time you call send() or sendto(), this will create a datagram (packet), so the math is simply dividing the total size by your 320 byte chunks:
1305477120 / 320 = 4079616 packets
As a side point, if you were to make your UDP payload larger, that would reduce the total number of packets. On a lot of networks, the MTU is 1500 bytes, so you can send:
1500 bytes - IP header (20 bytes) - UDP header (8) bytes = 1472 bytes for payload
As a second side point, if your UDP payload is too big, i.e. payload + IP/UDP headers exceeds the MTU, then your single call to send() would result in multiple IP fragment packets.
Upvotes: 1
Reputation: 310840
The packet consists of:
Total: 348 bytes.
Upvotes: 3