ReflectedLight
New member
If I send a UDP packet to a device that is not online, there is an approximately 1.6 second timeout delay. This appears to be 8 retries with 200ms timeouts. This is happening in sendUDP() called from endPacket(). Since UDP is a connectionless protocol, I imagine it should be "Fire & Forget" and there shouldn't be a penalty for sending a packet to non-existent device. Even waiting around for a success result seems odd.
I am trying to send 8 bytes with UDP every 10ms to 6 devices on a local area network. Occasionally one or more of those devices will be absent from the net. Any delay or blocking with throw off my data distribution... I am working with teensy 3.2 & the Wiz820io/SD card combo.
Btw. Is there anyway to do UDP multicast on the W5200 in Teensyduino?
In the following example, change IPAddress "target" & "ip" to suit. Then take "target" offline.
My output when target is absent:
Reading MAC from hardware...
MAC: 04:E9:E5:01:9E:EA
Sent:beginPacket 0 ms : write 0 ms : endPacket 1602
Sent:beginPacket 0 ms : write 0 ms : endPacket 1602
Sent:beginPacket 0 ms : write 0 ms : endPacket 1602
....
My output when target is present:
Reading MAC from hardware...
MAC: 04:E9:E5:01:9E:EA
Sent:beginPacket 0 ms : write 0 ms : endPacket 1602
Sent:beginPacket 0 ms : write 0 ms : endPacket 0
Sent:beginPacket 0 ms : write 0 ms : endPacket 0
Sent:beginPacket 0 ms : write 0 ms : endPacket 0
.....
Thanks for your attention!
I am trying to send 8 bytes with UDP every 10ms to 6 devices on a local area network. Occasionally one or more of those devices will be absent from the net. Any delay or blocking with throw off my data distribution... I am working with teensy 3.2 & the Wiz820io/SD card combo.
Btw. Is there anyway to do UDP multicast on the W5200 in Teensyduino?
In the following example, change IPAddress "target" & "ip" to suit. Then take "target" offline.
Code:
#include <Ethernet.h>
#include <SPI.h>
#include <EthernetUdp.h>
#include <T3Mac.h> // where we get our mac address from
IPAddress target(192, 168, 2, 1); //
IPAddress ip(192, 168, 2, 7);
EthernetUDP UdpReflect;
unsigned int localReflectPort = 8888;
long udpThenA, udpNowA;
long udpThenB, udpNowB;
long udpThenC, udpNowC;
char reflectorBuffer[8];
void setup() {
Serial.begin(57600);
delay(2000);
Serial.println("Reading MAC from hardware...");
read_mac();
Serial.print("MAC: ");
print_mac();
Serial.println();
Ethernet.begin(mac, ip);
UdpReflect.begin(localReflectPort);
}
void loop() {
Serial.print("Sent:");
udpThenA = millis();
UdpReflect.beginPacket(target, localReflectPort);
udpNowA = millis();
udpThenB = millis();
UdpReflect.write(reflectorBuffer, 8);
udpNowB = millis();
udpThenC = millis();
UdpReflect.endPacket();
udpNowC = millis();
Serial.print("beginPacket ");
Serial.print(udpNowA - udpThenA);
Serial.print(" ms : write ");
Serial.print(udpNowA - udpThenA);
Serial.print(" ms : endPacket ");
Serial.println(udpNowC - udpThenC);
}
My output when target is absent:
Reading MAC from hardware...
MAC: 04:E9:E5:01:9E:EA
Sent:beginPacket 0 ms : write 0 ms : endPacket 1602
Sent:beginPacket 0 ms : write 0 ms : endPacket 1602
Sent:beginPacket 0 ms : write 0 ms : endPacket 1602
....
My output when target is present:
Reading MAC from hardware...
MAC: 04:E9:E5:01:9E:EA
Sent:beginPacket 0 ms : write 0 ms : endPacket 1602
Sent:beginPacket 0 ms : write 0 ms : endPacket 0
Sent:beginPacket 0 ms : write 0 ms : endPacket 0
Sent:beginPacket 0 ms : write 0 ms : endPacket 0
.....
Thanks for your attention!