Main Site Documentation

DHCP and WizNet


#1

Hi,

Just got my Panda II board the other day, and wired in a WizNet 5100 adapter card to SPI1 etc.

Interface is working BUT DHCP seems not to want to take out a lease correctly.

Each time I call EnableDhcp - I get a different IP address allocated AND my DHCP server appears not to be ‘registering’ the lease - at least its not showing up in the list of DHCP clients…

Same happens when I call RenewDhcpLease() - it returns a new IP each time it is called. It ‘should’ return the same IP address - unless the lease has expired (DHCP server set for 24 hours (1440 minutes).

I have tried with and without a ‘hostname’, and it seems to make no difference.

So - my guess is that somehow the WizNet DHCP handshake is not completing fully.

Is this a known problem and is there a likely fix please ??.

Thanks

Graham


#2

Grab netmon trace to see what’s going on (you need a hub to plug the netmon-collecting PC and the Fez into) Might also help if you tell us what your DHCP server is, assuming it’s your local router what brand / model / firmware it is.


#3

Brett,

Thanks for getting back so quickly ;-).

Yup - thats what I was figuring I needed to do - but posted in the ‘hope’ that it was a known issue with a workaround ;-).

Guess I’ll have to dust off an old 10MHz hub, and do it that way then…

Router is a trusty old D-Link DIR 655, which does wireless and wired.

I’ll post some results when I have them.

Thanks

Graham


#4

Also try to use a valid mac address such as 00-A0-D1-40-77-E8
Many problems have been reported in the past that were due to illedigimate Mac address use…

Have fun ! :wink:


#5

Guys,

OK then - I finally found an old hub which is working (ie not a switch!)., and managed to capture the DHCP trace using netmon 3.4.

The problem is (as I originally suspected) with the ‘accept’ message from the client code. Somehow - it seems to be getting a fixed Server IP address (probably hard-coded :-O) of 192.168.0.1.

My DHCP server is 192.168.1.1.

The DHCPOFFER clearly has the ServerIdentifier as its own correct address :
ServerIdentifier: 192.168.1.1 - Type 54

The following DHCPREQUEST from the Wiznet client code tries to accept the offer from the wrong server:
ServerIdentifier: 192.168.0.1 - Type 54

This would therefore explain why the DHCP server never responds with a DHCPACK (or even NAK), and thus also never registers the address in its list of DHCP clients !!.

Of course - in practice the client code should not go ahead and start using this IP address until the server responds with a DHCPACK anyway - but it currently does :wink: - as EnableDhcp just exits and we carry on…

So - the question is how to get this code fixed ???.

As this is ‘open-source’ code - do I have to find the code, fix it, rebuild it and then reload, test and upload the changes ??? This would of course mean that I am then working on a ‘special’ code build - which I would definitely rather NOT do !!

Sorry - not up to speed with modifying open source code :open_mouth: - its something I have avoided for way too many years !!..I just want to be an application programmer - really ;-)).

NB I added the packet captures below to confirm my findings…enjoy!!

Many Thanks

Graham


 Frame: Number = 55, Captured Frame Length = 342, MediaType = ETHERNET
+ Ethernet: Etype = Internet IP (IPv4),DestinationAddress:[FF-FF-FF-FF-FF-FF],SourceAddress:[00-1C-F0-F1-96-A4]
+ Ipv4: Src = 192.168.1.1, Dest = 255.255.255.255, Next Protocol = UDP, Packet ID = 20886, Total IP Length = 328
+ Udp: SrcPort = BOOTP server(67), DstPort = BOOTP client(68), Length = 308
- Dhcp: Reply, MsgType = OFFER, TransactionID = 0x12345678
    OpCode: Reply, 2(0x02)
    Hardwaretype: Ethernet
    HardwareAddressLength: 6 (0x6)
    HopCount: 0 (0x0)
    TransactionID: 305419896 (0x12345678)
    Seconds: 0 (0x0)
  + Flags: 32768 (0x8000)
    ClientIP: 0.0.0.0
    YourIP: 192.168.1.35
    ServerIP: 0.0.0.0
    RelayAgentIP: 0.0.0.0
  + ClientHardwareAddress: 00-26-1C-7B-29-E8
    ServerHostName: 
    BootFileName: 
    MagicCookie: 99.130.83.99
  + MessageType: OFFER - Type 53
  + RebindingTimeValue: Subnet Mask: 0 day(s),21 hour(s) 0 minute(s) 0 second(s) - Type 59
  + RenewTimeValue: Subnet Mask: 0 day(s),12 hour(s) 0 minute(s) 0 second(s) - Type 58
  + DomainName: GS - Type 15
  - DomainNameServer: 0.0.773752851.773752850 - Type 6
     Code: Domain Name Server, 6(0x06)
     Length: 8 UINT8(s)
   - IpAddress: 
      IpAddress: 46.30.136.18
      IpAddress: 46.30.136.19
  - Router: 192.168.1.1 - Type 3
     Code: Router, 3(0x03)
     Length: 4 UINT8(s)
   - IpAddress: 
      IpAddress: 192.168.1.1
  - SubnetMask: 255.255.255.0 - Type 1
     Code: Subnet Mask, 1(0x01)
     Length: 4 UINT8(s)
   - IpAddress: 
      IpAddress: 255.255.255.0
  - ServerIdentifier: 192.168.1.1 - Type 54
     Code: Server Identifier, 54(0x36)
     Length: 4 UINT8(s)
   - IpAddress: 
      IpAddress: 192.168.1.1
  + IPAddressLeaseTime: Subnet Mask: 1 day(s),0 hour(s) 0 minute(s) 0 second(s) - Type 51
  + End: 
    Padding: Binary Large Object (6 Bytes)


  Frame: Number = 56, Captured Frame Length = 590, MediaType = ETHERNET
+ Ethernet: Etype = Internet IP (IPv4),DestinationAddress:[FF-FF-FF-FF-FF-FF],SourceAddress:[00-26-1C-7B-29-E8]
+ Ipv4: Src = 0.0.0.0, Dest = 255.255.255.255, Next Protocol = UDP, Packet ID = 7, Total IP Length = 576
+ Udp: SrcPort = BOOTP client(68), DstPort = BOOTP server(67), Length = 556
- Dhcp: Request, MsgType = REQUEST, TransactionID = 0x12345678
    OpCode: Request, 1(0x01)
    Hardwaretype: Ethernet
    HardwareAddressLength: 6 (0x6)
    HopCount: 0 (0x0)
    TransactionID: 305419896 (0x12345678)
    Seconds: 0 (0x0)
  + Flags: 0 (0x0)
    ClientIP: 0.0.0.0
    YourIP: 0.0.0.0
    ServerIP: 0.0.0.0
    RelayAgentIP: 0.0.0.0
  + ClientHardwareAddress: 00-26-1C-7B-29-E8
    ServerHostName: 
    BootFileName: 
    MagicCookie: 99.130.83.99
  + MessageType: REQUEST - Type 53
  - clientID: (Type 1) - Type 61
     Code: Client-identifier, 61(0x3D)
     Length: 7 UINT8(s)
     Type: HardwareAddress(1)
     ClientID: Binary Large Object (6 Bytes)
  - RequestedIPAddress: 192.168.1.35 - Type 50
     Code: Requested IP Address, 50(0x32)
     Length: 4 UINT8(s)
   - IpAddress: 
      IpAddress: 192.168.1.35
  - ServerIdentifier: 192.168.0.1 - Type 54
     Code: Server Identifier, 54(0x36)
     Length: 4 UINT8(s)
   - IpAddress: 
      IpAddress: 192.168.0.1
  - DHCPEOptionsHostName: 
   + HostName: panda - Type 12
  + ParameterRequestList:  - Type 55
  + End: 
    Padding: Binary Large Object (263 Bytes)



#6

Thanks for the detailed report. I will pass this on the right person for a fix.


#7

No problem - glad I could help ;-)).

Look forward to seeing a fix…

Thanks again

Impressive support - on a Sunday as well ;-)). The more I see - the more I like of this family of products ;-)) - should certainly cut down on my ‘time to market’.


#8

GrahamS,

I sent you an email with a new library. Please check it :wink:

Joe


#9

Joe,

Many thanks for all your support in fixing the DHCP issue - glad to be able to help test/prove the fix :-)).

Now working a treat…

Best Regards

Graham


#10

Joe,

It looks like i am also having problems with the EnableDhcp function call.

Is there any way you can send me that same library too?

Thanks,

Giancarlo Delgado


#11

Hello :slight_smile:

Does the new software released last week actualy solves this problem ?
(this does not appear in the release information)

Thank You !


#12

Yes it should include the W5100 Dhcp fix