1

Is there any benifit to combining several UDP packets into one as opposed to sending them all one right after the other? I know that if the large packet gets courrupted then i loose all of them, but is there possibly some upside to sending them all in one? such as a lower chance of the large one being lost?

Lauer
  • 517
  • 1
  • 6
  • 11
  • 1
    udp is a "best effort" protocol. busy routers may opt to drop a large udp packet while a small one may be able to slip through a break in traffic. no guarantees either way. – Marc B Oct 09 '12 at 16:57
  • I would give this best answer if it were not a comment – Lauer Oct 09 '12 at 19:59

4 Answers4

0

That would be at the discretion of the sending application.

Note that your large packet is limited by the MTU of the underlying network. e.g. the theoretical size of a UDP packet is 64k, but an ethernet frame is only ~1500 bytes. So I suspect this is not a practical feature.

Brian Agnew
  • 268,207
  • 37
  • 334
  • 440
  • The theoretical maximum size of an IPv4 UDP packet payload is 65535-20-8, subtracting first the IP header then the UDP header, giving 65509 bytes. – user207421 Oct 11 '12 at 08:32
0

Generally networking channels will be limited on the rate of packets that can be sent per second. Thus if you want to send millions of messages per second you generally want to combine into a smaller number of packets to run without major packet loss.

As an over generalisation, Windows doesn't like > 10,000 packets per second for UDP, but you can saturate a gigabit network with large MTU packets.

Steve-o
  • 12,678
  • 2
  • 41
  • 60
0

Is there any benifit to combining several UDP packets into one as opposed to sending them all one right after the other?

One can save on UDP header which is 8 bytes per datagram hence reducing the amount of data sent over the wire. Just make sure you don't send more then MTU sans IP and UDP header sizes to avoid fragmenting on IP layer.

Also, the standard POSIX socket API requires one send/sendto/sendmsg() system call to send or receive one datagram, so by sending fewer datagrams one does fewer system call reducing the overall latency (an order of a few microseconds per call). Linux kernels starting from 3.0 provide sendmsg() and recvmmsg() functions to send and receive multiple datagrams in one system call.

I know that if the large packet gets courrupted then i loose all of the

True. However, if the protocol can't cope with UDP datagram loss at all it may not matter that much - as soon as one datagram is lost it's broken anyway.

Maxim Egorushkin
  • 131,725
  • 17
  • 180
  • 271
0

It is important for situations where packet size is small (less than 100 byte). The IP/UDP header is at least 28 bytes.

Imagine you have streaming connection to a server, each packet contains 50 bytes and your software sends packets with rate 1000 packet per second.

The actual payload is 1000 * 50 bytes = 50000 bytes. Headers overhead 1000 * 28 = 28000 bytes Total bytes : 50000 + 28000 = 87000 ==> 87 KBps

Imagine you can combine each 3 UDP packets into one packet:

Headers overhead 1000 / 3 * 28 = 9333 Total bytes : 50000 + 9333 ===> 60 KBps

This -in some applications- saves good portion of the bandwidth.

ItsMe
  • 373
  • 2
  • 15