Author Topic: DHCP Host Name  (Read 7886 times)

Offline Phil

  • Jr. Member
  • **
  • Posts: 54
    • View Profile
DHCP Host Name
« on: February 23, 2017, 02:53:28 AM »
Mark,

I have a router connected to a router. Each router supports DHCP for the devices connected to each.
Router 1 has a base IP address of 192.168.0.1 and the second has a base address of 192.168.1.1.
Our device isn't able to get an appropriate IP address via DHCP. uTasker says the DHCP server is missing or not responding. I believe this is because
DHCP is using the DEFAULT_NETWORK which is 192.168.0.1. This is not the server to which I am connected and may be the reason.
It appears that there is a definition DHCP_HOST_NAME which signals to get the DHCP server address from cDeviceIDName. This appears
to be a string of 21 byte length. I assume this is the address of the DHCP Server which I would use a uStrcpy to set to "192.168.1.1".
However, I am still not able to get an IP address via DHCP. I know the DHCP service is available because I have other devices that regularly
connect via DHCP and get proper addresses. The MAC address is set to a proper address so this should not be an issue.

Any idea how I can resolve this problem getting a proper DHCP address?

Thank you.

Phil


Offline mark

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 3234
    • View Profile
    • uTasker
Re: DHCP Host Name
« Reply #1 on: February 23, 2017, 04:05:34 AM »
Hi Phil

When the DHCP client starts it can either try to obtain a specific address (when its own IP address is set to anything other than 0.0.0.0) or it can start with no address and request any new setting. Usually requesting a predefined address is refused and then it falls back on the request for any address.

In both cases it will accept any setup so there will be no conflict with its pre-defined setup (and sub-net).

It is probably best to post a Wireshark recording of the discovery process to see whether the DHCP servers are sending something back informing that they are refusing discovery for a reason.

Regards

Mark

Offline Phil

  • Jr. Member
  • **
  • Posts: 54
    • View Profile
Re: DHCP Host Name
« Reply #2 on: February 23, 2017, 06:33:38 PM »
Attached you will find the Wireshark capture file from the point of starting the MCU to the point where uTasker responds with a DHCP Missing Server failure.

Thank you.

Phil

Offline mark

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 3234
    • View Profile
    • uTasker
Re: DHCP Host Name
« Reply #3 on: February 23, 2017, 08:17:44 PM »
Phil

When I simulate with the recording I don't have any problem but I do see that your DHCP client is not sending the correct source address in the request.

Compare the normal DHCP discovery request compared with the one that your board is doing (attached image). You will see that normally the discovery is sent as a broadcast (which yours is doing) but with a 0.0.0.0 source address. I believe that versions pre-2013 may have done this if the user didn't clear the IP address before starting the DHCP server. If using an old version do the following before calling:
uMemset(&network.ucOurIP[0], 0, IPV4_LENGTH);
This is a violation of the specification but not a reason for it to not work - also in the recording the server does accept it.

In both cases there is an offer received - it is offering you the address 192.168.1.160 - but your board is ignoring it. It looks like it is not accepting broadcast receptions, although this would only be possible if it were expressly disabled - which is very unlikely.
Check therefore whether the DHCP client's UDP call back is being reached:
static int fnDHCPListener(USOCKET SocketNr, unsigned char ucEvent, unsigned char *ucIP, unsigned short usPortNr, unsigned char *data, unsigned short usLength)

If it is, step though the code to see whether any checks cause it to be rejected. I did the same in the simulator and all was accepted so didn't see what it could be.

Finally check the DHCP version in the latest release against yours to verify that there are no changes that may be of importance. Apart from some new options I don't in fact find anything critical.

Regards

Mark


Offline Phil

  • Jr. Member
  • **
  • Posts: 54
    • View Profile
Re: DHCP Host Name
« Reply #4 on: February 24, 2017, 09:18:28 PM »
Mark,

Last edit in the dhcp.c file is dated 15.10.2015.

Tried setting IP to 0.0.0.0 but didn't work. Had to modify your uMemset routine to:  uMemset(&network[DEFAULT_NETWORK].ucOurIP[0], 0, IPV4_LENGTH);
The uMemset command you suggested failed otherwise.

fnDHCPListener is actually called fnDCHPListner in my copy of dhcp.c. This routine is never called. I have put in debug stops and even put in a fnDebugMsg to verify and it isn't called. Maybe this is a key fact in which to diagnose the problem.

Thoughts?

Phil

Offline mark

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 3234
    • View Profile
    • uTasker
Re: DHCP Host Name
« Reply #5 on: February 24, 2017, 11:19:14 PM »
Phil

If the listener is not called it is due to one of the following reasons:
- it wasn't installed (check the call that starts DHCP client)
- the Ethernet is sending but not receiving - check to see whether the Ethernet task is scheduled each time there is reception for the Ethernet (any broadcast should do it)
- the IP broadcast is not being accepted - if you can break on any reception in the Ethernet task you can see why it rejects the frame.

Good luck

Regards

Mark

Offline Phil

  • Jr. Member
  • **
  • Posts: 54
    • View Profile
Re: DHCP Host Name
« Reply #6 on: February 25, 2017, 09:35:39 PM »
Mark,

Problem resolved.

Your comment, "Ethernet is sending but not receiving", had me recheck the hardware looking for a problem with one of the Ethernet lines. Turns out the problem was not with the board at all. The problem was with the Ethernet cable. At some point, the cable got munched or somehow damaged. Replacing the cable corrected the problem. DHCP Listener is activated and after two hits the DHCP Successful flag happens and the IP is set just as it should.

Thanks, Mark.

Phil

Offline mark

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 3234
    • View Profile
    • uTasker
Re: DHCP Host Name
« Reply #7 on: February 25, 2017, 10:25:04 PM »
Phil

Thanks for the feedback - I am glad to hear that things are working now!

Regards

Mark

Offline Phil

  • Jr. Member
  • **
  • Posts: 54
    • View Profile
Re: DHCP Host Name
« Reply #8 on: February 27, 2017, 08:21:32 PM »
Thank you, Mark.

I must admit another thing I found:  The Ethernet cable seems to be just fine. We tested, it turns out the cable is a cross over cable. I'm not sure how I got ahold of this special cable but it through me for a loop until it was tested. Later I found a small label on the cable saying it was indeed a cross over cable.

Just an FYI. It may explain certain behaviors.

Phil

Offline mark

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 3234
    • View Profile
    • uTasker
Re: DHCP Host Name
« Reply #9 on: February 27, 2017, 08:58:45 PM »
Phil

Most phys allow cross-over cables to be used (auto cross-over operation) but maybe the one you have doesn't or hasn't been configured with this mode enabled.

Regards

Mark