Arduino Ethernet shield not working with Arduino Uno

Hi all,

I've been struggling with this problem for a couple of days now, so finally decided to ping the forum. Hopefully someone out there will help me figure out what might be going wrong. Ok, for the scenario details..

I have a freetronics "Eleven" connected to an Arduino Ethernet shield. I
I'm running the Arduino IDE version 1.0.
Have compiled and uploaded the DhcpChatServer sketch (from the Ethernet library examples folder) and it fails to obtain an address from my DHCP server. The DHCP server is running on a NETGEAR DGN2200 hub/router.
I've added some debug code to the Dhcp.cpp source so that I could track the data sent/received by the application, and have pasted it below. I hope it will make some sense to a TCP/IP or DHCP expert out there...

Request message constructed in send_DHCP_MESSAGE() method and passed to socket.write(). I can see that this is a request message of type DHCP_DISCOVER.

01 01 06 00 00 00 03 31     00 00 80 00 00 00 00 00     
00 00 00 00 00 00 00 00     00 00 00 00 00 AA BB CC     
DE 02 00 00 00 00 00 00     00 00 00 00 00 00 00 00     
00 00 00 00 00 00 00 00     00 00 00 00 00 00 00 00     
00 00 00 00 00 00 00 00     00 00 00 00 00 00 00 00     
00 00 00 00 00 00 00 00     00 00 00 00 00 00 00 00     
00 00 00 00 00 00 00 00     00 00 00 00 00 00 00 00     
00 00 00 00 00 00 00 00     00 00 00 00 00 00 00 00     
00 00 00 00 00 00 00 00     00 00 00 00 00 00 00 00     
00 00 00 00 00 00 00 00     00 00 00 00 00 00 00 00     
00 00 00 00 00 00 00 00     00 00 00 00 00 00 00 00     
00 00 00 00 00 00 00 00     00 00 00 00 00 00 00 00     
00 00 00 00 00 00 00 00     00 00 00 00 00 00 00 00     
00 00 00 00 00 00 00 00     00 00 00 00 00 00 00 00     
00 00 00 00 00 00 00 00     00 00 00 00 63 82 53 63     
35 01 01 3D 07 01 00 AA     BB CC DE 02 0C 09 57 49     
5A 6E 65 74 CC DE 02 37     06 01 03 06 0F 3A 3B FF

The following is the data returned from the socket.read()...

0F C4 9C C0 9D 26 EE A6     26 0E A5 66 44 59 9C 46     
5C B5 02 CF DE B8 21 96     C0 2D 2E EF BF 2C 4E B4     
E9 9E

The code expects a DHCP_BOOTREPLY message, which this is not, so the rest of the logic then fails.

Can someone help to decipher what this response message is? Unfortunately, I can't find any low-level logging on my hub router to help here :frowning:

Two things could be causing that problem.

First, IDE versions prior to v1.0.1 had a bug in the ethernet library that caused failures. I recommend downloading IDE v1.0.1 from the Arduino site and trying it.

Second, if there is a memory card in the microSD slot, that will cause problems with UDP functions like DHCP and NTP if the memory card is not disabled or initialized.

I recommend trying the DhcpAddressPrinter sketch in the ethernet examples. Once you get that working, you should be ok.

Thanks for the post SurferTim - the problem was due to the IDE version. I upgraded to 1.0.1 and hey presto...it works. Out of curiosity I thought I'd see what had changed and found that the initial DHCP_DISCOVER message has been modified as below.

01 01 06 00 00 00 03 31     00 00 80 00 00 00 00 00     
00 00 00 00 00 00 00 00     00 00 00 00 00 AA BB CC     
DE 02 00 00 00 00 00 00     00 00 00 00 00 00 00 00     
00 00 00 00 00 00 00 00     00 00 00 00 00 00 00 00     
00 00 00 00 00 00 00 00     00 00 00 00 00 00 00 00     
00 00 00 00 00 00 00 00     00 00 00 00 00 00 00 00     
00 00 00 00 00 00 00 00     00 00 00 00 00 00 00 00     
00 00 00 00 00 00 00 00     00 00 00 00 00 00 00 00     
00 00 00 00 00 00 00 00     00 00 00 00 00 00 00 00     
00 00 00 00 00 00 00 00     00 00 00 00 00 00 00 00     
00 00 00 00 00 00 00 00     00 00 00 00 00 00 00 00     
00 00 00 00 00 00 00 00     00 00 00 00 00 00 00 00     
00 00 00 00 00 00 00 00     00 00 00 00 00 00 00 00     
00 00 00 00 00 00 00 00     00 00 00 00 00 00 00 00     
00 00 00 00 00 00 00 00     00 00 00 00 63 82 53 63     
35 01 01 3D 07 01 00 AA     BB CC DE 02 0C 0C 57 49     
5A 6E 65 74 43 43 44 45     30 32 37 06 01 03 06 0F     
3A 3B FF

The main difference I can see is in the creation of the hostname which was intended to be "WIZnet" concatenated to the last 3 bytes of the MAC address. In the earlier version, the binary MAC address values were used, resulting (I guess) in a non-printable hostname. In the later version, the binary values have been converted into their hexadecimal equivalents, and then concatenated as the character representations, i.e. 0xCCDE02 becomes the character sequence 'C', 'C', 'D', 'E', '0', '2', resulting (in my case) in the hostname "WIZnetCCDE02".

Thanks again for helping me with this problem.