-
Notifications
You must be signed in to change notification settings - Fork 13.3k
UDP send data loss #1988
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
As mentioned in #1696 (comment), the issue here is that underlying netif implementation doesn't return an error code when UDP packet gets lost. Also there is no API in Espressif SDK which would allow one to query the amount of space left in TX buffer chain. I'll see is we can add one though. |
What about I (think) I understand the restrictions of the Espressif SDK. Yes, getting access to the state of the actual socket buffer would be great but in the mean time, what about the above? When I call Thanks! |
I think you are looking at Ethernet library. W5100 is a chip which is used in Arduino Ethernet shield. It doesn't have anything to do with WiFi stack. This library supports a use case when you plug W5100 into ESP's SPI port and use it to make an Ethernet connection. For WiFi, you need to look at WiFiUdp.cpp, UdpContext.h, and the underlying UDP implementation in LwIP stack, udp.c. |
You're right. I had done a global search (all files) and bumped into that. I will have to go back and take a better look at it. |
In strict lwip point of view, it is not possible to know about remaining room in the output queue. udp stack sends packet through "netif->linkoutput()" which should returns whether the packet could be sent or not. This function is beyond lwip's scope, part of espressif physical layer api and we have no access to its buffers. should because, as mentioned earlier in this thread, @igrr thinks it does not work. However, linkoutput()'s return value is checked in both lwip1.4 and lwip2. So a sketch is needed to try and overload udp's output and see if linklayer asks for pity at some point. It has to be noted that even if an udp packet goes out, there is no mean to know if it is lost in the network before arriving to its destination. In a network programming point of view, it is hardly necessary to know if there is room for udp output. If one need bandwidth control, there is tcp. Otherwise, a dialog with peer (to be able to know what is lost) is needed to make a sort of PID on bandwidth (nfs over udp did that, but they finally switched to tcp). |
@d-a-v We can't do anything about what happens to an UDP packet in transit, UDP is not meant for that. However, if at all possible, we should at the very least make sure the packet actually gets sent, and do so without stepping on our own feet (i.e.: not rely on delays or w/e). |
Currently the link layer (and the glue for lwip2) answer an lwIP's error code to the caller ( |
This is related to #1696.
Is there a way to expose this to WiFiUdp.h?
https://github.com/esp8266/Arduino/blob/master/libraries/Ethernet/src/utility/socket.cpp#L409
That is, a way to check the status of the buffer before attempting to write?
From WiFiUdp, we don't have access to the underlying socket. If the socket was exposed, I could do something like:
Thanks!
Want to back this issue? Post a bounty on it! We accept bounties via Bountysource.
The text was updated successfully, but these errors were encountered: