Multicasting big packet contain all info to multip

2019-09-17 21:24发布

问题:

I'm writing a C++ application MyMasterApp which sends information (OSC via UDP) to multiple clients (about 5-10), which are mobile devices (Android or iPhone) via wifi.

Each device is to receive unique information, of the same type. Probably about 100-200 bytes per device, and I'll be updating all devices at 30Hz.

I could send a unique data packet to each device, or I could create one big structure which contains each of the unique bits of data for each device, with the target id, multicast this to all devices, then each device only picks out the data it needs.

i.e.

  • send DATA1 to device1
  • send DATA2 to device2
  • send DATA3 to device3
  • send DATA4 to device4

vs

  • create a new DATA which contains DATA1, DATA2, DATA3 etc. multicast DATA to all devices, and each device picks the relevant data to use.

Before I attempt both approaches, are there any theoretical, or recorded practical advantages of one over the other (E.g. better performance, less collision, lost packets etc)? Or are the differences just negligible?

I have a related network performance question about the same project at Should I listen on different ports, or the same port?

回答1:

One of the major advantages of multicast is scalability so in the future if you tend to have more devices multicast will help. Better to look at multicast vs unicast performance for guidance

M. Ebrahimi, M. Daneshtalab, P. Liljeberg, and H. Tenhunen. Performance evaluation of unicast and multicast communication in three-dimensional mesh architectures. In Computer Architecture and Digital Systems (CADS), 2010 15th CSI International Symposium on, pages 161-162, sept. 2010.



回答2:

Even leaving future growth aside, your present worst cases of 200 bytes x 10 devices is already 2000 bytes, which is already too big to send via UDP. The practical maximum UDP datagram is generally held to be 576 bytes, or 534, numbers of that sort. So you don't have a choice. You must unicast.