Comments (14)
Thanks for the explanation. It has helped my understanding a great deal.
from mongoose.
I have tested it just now and it works perfectly. Thanks!
from mongoose.
Good idea. In fact, our usual hexdump can be happily swallowed by Wireshark - I did that many times. Maybe just add hexdumps with MG_LL_VERBOSE ? It should not be very noisy, cause the IP is not configured at that stage anyway.
from mongoose.
Please do not paste screen captures, I need to see a Wireshark capture file to be able to guess what is going on in your network.
Please post a capture file of the traffic when your device is starting up and requesting an IP address, and the corresponding Mongoose log dump.
Out of curiosity, just in case, please write down your gateway brand name and model.
from mongoose.
Hopefully this is what you need. The router is a TPLink Deco M9.
Wireshark capture files and Mongoose log dump.zip
from mongoose.
You need to capture in a place where the traffic can be actually seen, and be kind not to include irrelevant traffic.
If your device MAC is 5a:38:83:2e:25:36, then use a capture filter for that.
You need suitable networking tools to do networking development, you need either a switch with monitor capability or a hub or a gateway that can run Wireshark or at least tcpdump, in order to be able to get the device traffic.
In your capture I see the device sends a DHCP Discovery, I don't see the answer because probably you captured in some random computer and some random switch in the middle of your network won't forward to that port any non-broadcast traffic that is not destined for that computer.
In your capture I see the device later sends a DHCP Request, I don't see the answer (same reason).
For some reason that I can't see (same reason), server id is not set in that request, and it should.
I can't see if your DHCP server never answers or our stack can't handle what it receives, all I see is that it stays in Req state, so probably your DHCP server never answers.
from mongoose.
Thanks for the advice. Unfortunately, it seems I don't have the right equipment.
Nevertheless, it seems odd that I can flash exactly the same hardware with firmware using an alternative TCPIP stack, attached to the same network cable, switch, router etc., and the whole DHCP process works fine: on debug I can see the Discover, Offer, Request and Acknowledgement packets and the process is practically instant.
from mongoose.
What is weird to me is that you are the only one having an issue like this, I offered my help to find the reason and if it turns out to be our problem, fix it. I can't do that if I don't see what is on the net. We could add extra debugging to make Mongoose log everything it sees, but that takes a lot of time.
Try to get that info and I will gladly work on it. Please reopen the issue when you have it. Regards.
from mongoose.
I appreciate the offer of help, I really do. I can also understand my problem seeming weird to you, for sure! I will see if I can find some proper network hardware to get the information requested.
Nonetheless, I noticed in a verbose debug log from rx_ip() that the packet received immediately after the DHCP request was sent contained my router IP address, but pkt->dhcp->siaddr which is passed to rx_dhcp_request_sel() was set to 0. It turns out that if I change line 4880 in rx_dhcp_client() from:
tx_dhcp_request_sel(ifp, ip, pkt->dhcp->siaddr);
to:
tx_dhcp_request_sel(ifp, ip, pkt->ip->src);
then DHCP allocation works. Maybe my router is sending back a packet with information missing that you expected to be present? Or maybe what I have done above is inappropriate for reasons I don't understand?
from mongoose.
Protocols should stay within their layer of incumbency, at least in theory.
A DHCP request takes the server IP address from that announced inside the DHCP datagram. If I understand you correctly, your DHCP server is not filling that.
The comment in that line is a reference to the section in the RFC named above, which reads:
If the parameters are acceptable, the client records the address of
the server that supplied the parameters from the 'server identifier'
field and sends that address in the 'server identifier' field of a
DHCPREQUEST broadcast message.
So, if that is correct, technically your gateway is not playing fair.
What we could do is a fallback like you did, something like:
// select IP, (4.4.1) (fallback to IP source addr on foul play)
tx_dhcp_request_sel(ifp, ip, pkt->dhcp->siaddr ? pkt->dhcp->siaddr : pkt->ip->src);
from mongoose.
tx_dhcp_request_sel(ifp, ip, pkt->ip->src);
then DHCP allocation works. Maybe my router is sending back a packet with information missing that you expected to be present? Or maybe what I have done above is inappropriate for reasons I don't understand?
This is perhaps the issue, thank you Sam!
Sergio, your fallback logic seems good, could you please send a PR
from mongoose.
Sure, I was waiting for the OP to test it as all our DHCP servers play nice.
from mongoose.
@sas229 Sam, your efforts are much appreciated!
from mongoose.
@cpq Should we add a minimum functionality tcpdump-like to be enabled on cases like this ? Only dump our frames and those for us, but do it in a way that can later be opened with Wireshark. Easily enabled with an allegoric macro like MG_TCPDUMP. Except for old and bald salty dogs, no one is expected to have a hub and getting device traffic becomes hard for most people.
from mongoose.
Related Issues (20)
- Is it possible to add the mg_mqtt_unsub function? HOT 3
- mqtt: Unable to set zero-length Will message
- how can we access fn_data from mg_http_listen's callback funtion (mg_event_handler_t) ? HOT 3
- [Request feature] can you support wolfssl library HOT 3
- upload in https using examplefile-upload-html-form is always pending in chrome but is ok in firefox. HOT 1
- Socket error after ota-updating the filesystem image HOT 1
- Fix for #2619 breaks fix for #2603 HOT 3
- Cleanup string API HOT 5
- mongoose.c:7543:accept_conn 1 accept failed, errno 24 HOT 1
- mg_http_next_multipart bug HOT 3
- cannot connect MQTT to STM32F407 HOT 1
- When I used the TLS scanning tool (https://github.com/rbsec/sslscan, scanning command: sslscan --tlsall 127.0.0.1:8443) to scan the 8443 port of the mongoose examples http-restful-server, the program appeared Infinite loop, continuous log printing, even if I have ended the TLS scan command. HOT 2
- The "mg_url_host" function is not work? HOT 1
- Can FreeRTOS_IPInit_Multi function be used properly? HOT 3
- Wrong assets in 7.14 HOT 1
- Mongoose accepts HTTP requests with invalid versions
- Mongoose accepts requests containing multiple differing Content-Length headers.
- Mongoose ignores `Connection: close` headers
- Potential Memory Leak in `mg_timer_free` Function HOT 6
- [RST, ACK] frame when starting downloading file HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from mongoose.