Dear all I have made a simple project,but the DHCP seems to not working,Here is my code,
void TcpTickTask(void const *argument) { /* System tick timer task */ os_itv_set (100); while (1) { timer_tick (); tick = __TRUE; os_itv_wait (); } } static void dhcp_check () { /* Monitor DHCP IP address assignment. */ if (tick == __FALSE || dhcp_tout == 0) { return; } tick = __FALSE; if (mem_test (&localm[NETIF_ETH].IpAdr, 0, IP_ADRLEN) == __FALSE && !(dhcp_tout & 0x80000000)) { /* Success, DHCP has already got the IP address. */ dhcp_tout = 0; return; } if (--dhcp_tout == 0) { /* A timeout, disable DHCP and use static IP address. */ dhcp_disable (); dhcp_tout = 30 | 0x80000000; return; } if (dhcp_tout == 0x80000000) { dhcp_tout = 0; } } void MainTcpTask(void const *argument) { dhcp_tout = DHCP_TOUT; for(;;) { osMutexWait (mutex_TcpNet_ID, osWaitForever); main_TcpNet (); dhcp_check (); osMutexRelease (mutex_TcpNet_ID); } }
Some pictures, s30.postimg.org/.../DHCP.png postimg.org/.../ postimg.org/.../
Do you suggest any work around?
Do you have any Idea what's going on wrong?
You should probably start debugging ethernet driver :)
Wireshark is also very useful tool for tracking ethernet traffic. You should download and install it, to check what is going on with your DHCP packets.
Are you using some board any one might recognize, or some custom one? Has the design been validated in any way? Can you send/receive Ethernet traffic? What kind of testing and debugging of the driver have you done?
Thanks for the info,Actually the board is a costume design,And I have tested the HTTP server on it with the static IP, every thing is working as expected, and the Ethernet derive and everything else like FTP Server, HTTP server are working,Now I wanted to switch to DHCP,So any Idea?
Maybe, if you gave us a little bit of a clue as to what you see happening apart from but the DHCP seems to not working, we might be able to make a diagnosis.
Have you done any debugging yourself on the code that is failing? What do you see? What does what you see indicate?
Thanks, I have debugged the code, there is no crash, but the code does not got any other IP than the static one that I have defined in the netconfig file,As you can see in this picture, the DHCP will eventually got a time out and will be disabled after 5 seconds.Also I have tried to increase the timeout but Still I will get the same result.
postimg.org/.../
You have debugged?
So do you see any messages being sent by the board? Do you see any DHCP server respond? Do you see if the TCP/IP stack in the board receives any data? Is the received data containing any information that should make the board accept it as a valid DHCP-based IP allocation? Does the TCP/IP stack in the board see any other messages?
So do you see any messages being sent by the board? Do you see any DHCP server respond? Do you see if the TCP/IP stack in the board receives any data? Is the received data containing any information that should make the board accept it as a valid DHCP-based IP allocation? Does the TCP/IP stack in the board see any other messages? How should I do that?
>>How should I do that?
You could start by configuring your network hardware to permit viewing the signals with something like WireShark. sourceforge.net/.../
An old 10BT HUB might help here in terms of seeing all the traffic.
The purpose would be to see if your board sends a DHCP request, and if the DHCP server on your network responds to that request. This will provide you with some insight about what is and what is not going on. Basic network debugging requires that you go look at what's actually going on.
For other code related events you'll want to examine your drivers and add breakpoints to see what's going on with them.