Skip to content
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

DHCP ignoring replies #62

Closed
HugoDamme opened this issue Apr 21, 2014 · 9 comments
Closed

DHCP ignoring replies #62

HugoDamme opened this issue Apr 21, 2014 · 9 comments
Labels

Comments

@HugoDamme
Copy link

Hello,

First I would like to thank you for your work, checking the datasheet of the ENC chip I was very glad to find a library available for this module, considering the time it requires to implement all this, this is more than helpfull.

I am facing an issue while using the DHCP feature of the library: DHCP requests are sent perfectly and well-formed, but the replies seem to be simply ignored.

My setup if fairly simple:

---------            ---------
| ATMega|            |  DHCP |
---------            ---------
    |                     |
----|--              -----|----                ---------------
| ENC |--------------| Router |----------------| workstation |
-------              ----------                ---------------

I would like to exchange data between my workstation and the ATMega328 (not an Arduino, simply the µC running at 8MHz).

When observing traffic from my workstation, I get all requests emitted by the ENC28 module, and all replies coming from the DHCP box, but they are all ignored.
Here is the tcpdump log of this:
sudo tcpdump -ni eth0 ! ip6 and (port bootpc or bootps)
tcpdump: verbose output suppressed, use -v or -vv for full protocol decode
listening on eth0, link-type EN10MB (Ethernet), capture size 65535 bytes
04:02:29.597422 IP 0.0.0.0.68 > 255.255.255.255.67: BOOTP/DHCP, Request from 00:01:02:03:04:05, length 275
04:02:29.601458 IP 192.168.1.254.67 > 255.255.255.255.68: BOOTP/DHCP, Reply, length 300
04:02:29.754674 IP 0.0.0.0.68 > 255.255.255.255.67: BOOTP/DHCP, Request from 00:01:02:03:04:05, length 287
04:02:33.764545 IP 0.0.0.0.68 > 255.255.255.255.67: BOOTP/DHCP, Request from 00:01:02:03:04:05, length 275
04:02:36.599097 IP 192.168.1.254.67 > 255.255.255.255.68: BOOTP/DHCP, Reply, length 300
04:02:36.603527 IP 192.168.1.254.67 > 255.255.255.255.68: BOOTP/DHCP, Reply, length 300
[...]
04:03:16.187336 IP 0.0.0.0.68 > 255.255.255.255.67: BOOTP/DHCP, Request from 00:01:02:03:04:05, length 287
04:03:20.199941 IP 0.0.0.0.68 > 255.255.255.255.67: BOOTP/DHCP, Request from 00:01:02:03:04:05, length 275
04:03:22.820244 IP 192.168.1.254.67 > 255.255.255.255.68: BOOTP/DHCP, Reply, length 300
04:03:22.824750 IP 192.168.1.254.67 > 255.255.255.255.68: BOOTP/DHCP, Reply, length 300
04:03:23.063464 IP 0.0.0.0.68 > 255.255.255.255.67: BOOTP/DHCP, Request from 00:01:02:03:04:05, length 287

And this is going on until the client timeouts.

While running the TcpClient example, and modifying just one line to look like this "Ethernet.begin(mac, IPAddress(192,168,1,65));", it works like a charm and I receive data:
netcat -l -p 5000
DATA from Client

I am running the library from this commit: 160df53 (tag UIPEthernet_v1.06).
My arduino is "arduino-core 1:1.0.1+dfsg-7" from Debian Wheezy repositories.

If you need any more informations I may have forgotten, I'll be glad to provide them.

Regards,

Hugo

@ntruchsess
Copy link
Owner

That is a bit strange as this is known to work since I enabled broadcast-receival on enc28J60-chip on Oct. 4th 2013:
https://github.com/ntruchsess/arduino_uip/blame/160df5327978405713cea74a22cadab71d52d7d5/utility/Enc28J60Network.cpp#L109

you might want to capture the packets using Wireshark and upload to http://www.cloudshark.org/ so I can compare bitwise to what my setup produces.

@HugoDamme
Copy link
Author

Here you go: https://www.cloudshark.org/captures/46ecfd204d4a
https://www.cloudshark.org/captures/a66eecc476aa
https://www.cloudshark.org/captures/590a4ad3ecb5

I made several captures since the beginning sequence is not always the same, even though I don't know if it's relevant with what is wrong.

Hope it helps !

@ntruchsess
Copy link
Owner

just to let you know, I won't have time to work on this before Apr. 28th...

@HugoDamme
Copy link
Author

Not a problem, take your time.
I am not expecting anything, just hope to help and understand if it's a bug
:)

@ntruchsess
Copy link
Owner

Hi, I'm back :-)

packages look all good. But I remember there can be an issue with the compiler not including the memory that contains the initialization of static variables into the hexfile. Requires the parameter '-j .data' (or .rodata, not sure where static const will be placed) in the options-list of avr-objcopy. How do you build the code?

@HugoDamme
Copy link
Author

I'll check how the code is built this evening and keep you in touch.

@HugoDamme
Copy link
Author

The objcopy invocation is the following : "/usr/bin/avr-objcopy -O ihex -R .eeprom build/cli-ethernet.elf build-cli/ethernet.hex".

Do you think removing the .eeprom section can cause the trouble ?

@HugoDamme
Copy link
Author

Ok, I had some time to dig into the problem, and found out this is just a simple timeout.
As you can see on the captures, my DHCP sends ACK 5+ seconds after the request, while in the library the timeout value is set to 4s.
Changing the default value to 6s makes the whole thing work.

Anyway, thanks for your time, this library is great !

@ntruchsess
Copy link
Owner

closing as this got solved

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants