I am attempting to send data with very small latency over a router to a VR headset. When the UDP Client is called and written to. It bunches packets together and sends them out in 200ms bursts. This isn't ideal since the packets should represent the most up-to-date values which are read from the sensors on the board. How do I make it so that the packets will be sent out immediately after being written to?
WiFi.begin(SECRET_SSID, SECRET_PASS);
if(debugOutput) Serial.println("Connecting to Router");
if (WiFi.waitForConnectResult() != WL_CONNECTED) {
Serial.println("Connection Failed");
init();
}
Serial.println("Connected to Router");
Do you know how fast you are sending the packets ?
I found this:
Linux places very restrictive limits on the performance of UDP protocols by limiting the size of the UDP traffic that is allowed to buffer on the receive socket. It is highly recommended that you increase these OS limits to at least 25MB before trying to run UDP traffic to your server. 25MB is just a recommendation.
I have even tried making multiple udp sender objects and sending data through different port and they always come out in these bursts, so I think it is something at a low level.
a UDP datagram carries the source and destination IP addresses, port numbers, etc and each packet has to be routed thru the network
it may be quicker to use a TCP protocol which sets up a virtual circuit thru the network
however, TCP has flow control, error correction, etc which add an overhead which may offset the advantge of the virtual circuit
Hey there, I set-up a tcp protocol for now and it works well. The only caveat is that udp supports broadcasting, which means that the board could send packets to a bunch of headsets with a single send. I am still interested in figuring out how to solve the udp problem but TCP works well for now thanks.
UDP multicast has the advantage you can transmit to multiple targets with a single transmission -
what microcontrollers are you using?
how far apart are the headsets?
are they all on the same subnet?
The headsets will all be less than 4m from the router, currently though just one headset although I am doing testing in the unity web player but regardless I know it is coming from the Arduino side since I am using wireshark to test for the latency and I have tested it with build versions on an android phone and on the headset
All the headsets are connected to a single router running without internet access
They were using ESP-NOW before they hired me, not sure if they were aware it can be done direct to a non-esp device tho.
After looking into it for a while it seems to be an issue with the firmware on the board. May end up just getting a different board to be honest. It is weird though because I couldn't imagine anybody thinking that programming UDP packets to have a delay before sending is a good idea.
Anyway thanks for the help, much appreciated. Will just keep to TCP for now because I don't think they have any plans to use multiple VR headsets anytime soon.