UDP packets to multiple IPs


i'm trying send udp packets multiple ip addresses single arduino uno ethernet shield. 

sending single address works great, see 0 - 2ms between received messages (which i'm assuming network latency).

calling udp.beginpacket/endpacket twice in loop, however, gives me ~400ms between received messages.  speed ~5ms second or two, drop 400ms.

the code i'm pasting uses osc library, same results without osc, using udp.write.

i'm having hard time understanding might going on here...any insight appreciated!

code: [select]

#include <oscmessage.h>
#include <ethernet.h>
#include <ethernetudp.h>
#include <spi.h>   
#include <oscmessage.h>
ethernetudp udp;

//the arduino's ip
ipaddress ip(192, 168, 1, 9);

//destination ips
ipaddress ip1(192, 168, 1, 2);
ipaddress ip2(192, 168, 1, 17);
const unsigned int outport = 9999;

 byte mac[] = {0xde, 0xad, 0xbe, 0xef, 0xfe, 0xee };
 
void setup() {
  ethernet.begin(mac,ip);
  udp.begin(8888);
}

void loop(){
 
    oscmessage msg("/analog/0");
    msg.add((int32_t)analogread(0));
   
    udp.beginpacket(ip1, outport);
    msg.send(udp);
    udp.endpacket();
 
    udp.beginpacket(ip2, outport);
    msg.send(udp);
    udp.endpacket();
    msg.empty();
}

i haven't tried sending 2 devices using udp. can tell in code 400ms delay happening?

i recommend starting serial port @ high baud rate, 115200, , sending character determine program is. used numbers 1 , 2 followed asterisk determine delay happening. 400ms delay should pretty obvious.
code: [select]
void loop(){
 
    oscmessage msg("/analog/0");
    msg.add((int32_t)analogread(0));
   
    serial.print("1");
    udp.beginpacket(ip1, outport);
    msg.send(udp);
    serial.print("*");
    udp.endpacket();
    serial.print("*");
 
    serial.print("2");
    udp.beginpacket(ip2, outport);
    msg.send(udp);
    serial.print("*");
    udp.endpacket();
    serial.println("*");
    msg.empty();
}

you should output. delay between characters?
1**2**
1**2**

edit: 2 receiving devices? arduinos or pcs?


Arduino Forum > Using Arduino > Networking, Protocols, and Devices (Moderator: fabioc84) > UDP packets to multiple IPs


arduino

Comments