-
Notifications
You must be signed in to change notification settings - Fork 454
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
Change to udpPrepare to handle empty return MAC address #181
Comments
I have experienced this problem as well. The problems started when the is_lan() code was added to EtherCard - previously everything was sent to the Gateway MAC address, which forwarded it on to final destination, even if the IP was actually on the same subnet. This was a bit nasty but it make things a lot simpler. When EtherCard is being used as a 'server' and replying to a UDP request, then we can just copy the SRC MAC address into the destination MAC address, for local IPs. However if EtherCard is initiating a request, then we most perform an ARP request and create a MAC<->IP mapping for every IP we need to talk to. It starts getting complex. |
Hi! I had the same problems at first. But I think you should get better results if you don't rely on the example code... I think the problem is the missing ether.packetLoop(ether.packetReceive()); in "loop()". (in udpClientSendOnly.ino) Because the packetLoop has some logic to do ARP request for "hisip" to destmacaddr if it's not already there. But there are more problems: |
i have the same problem sending udp packet to destination sw running on windows. the destination mac address remain empty so the the windows software discard packet. i solved adding two cloned methon udpPrepare->UdpPrepareMacAddr and sendUdp->sendUdpMacAddr, in this two cloned method you can specify destination mac address... this work for my use, in wire shark now i can see the right destination mac address... void EtherCard::udpPrepareMacAddr (uint16_t sport, const uint8_t dip, uint16_t dport, const uint8_t *destmacaddr) { void EtherCard::sendUdpMacAddr (const char *data, uint8_t datalen, uint16_t sport,
} sorry for my english and for any form error in C++ |
Hi, I am using sendUdp to reply to a packet sent by a Cacti temperature logger. It is not working and using WireShark I discovered that the return package has 00:00:00:00:00:00 as the destination MAC address, which makes the packet to be ignored at the destination.
Analyzing your library, in udpPrepare() it is assumed that we already have the MAC in destmacaddr, which is not the case in a program the just uses udpServerListenOnPort() to receive and sendUdp() to reply. I have seen solutions such as setting setGwIp() to the sender's IP to force the ARP search for the sender's IP and load destmacaddr but I wanted a more default behavior from sendUdp().
I found that the following modification to udpPrepare() fixes the issue for me and would like to see if you can validate it and perhaps use it as a basis to fix the issue in the official code:
Best regards,
Luiz Roberto Rocha
Rio de Janeiro - Brazil
The text was updated successfully, but these errors were encountered: