fallback to AutoIP if DHCP fails
fallback to AutoIP if DHCP fails
I could not find an example, but I think the following should work despite the warnings in the documentation about not mixing DHCP and AutoIP.
if (GetDHCPAddress() != DHCP_OK)
{
StopDHCP(0);
AutoIPClient(0);
iprintf("\r\nAutoIP: ");
}
else
{
iprintf("\r\nDHCP assigned: ");
}
ShowIP(EthernetIP);
iprintf("\r\n");
Is there anything else I should do?
if (GetDHCPAddress() != DHCP_OK)
{
StopDHCP(0);
AutoIPClient(0);
iprintf("\r\nAutoIP: ");
}
else
{
iprintf("\r\nDHCP assigned: ");
}
ShowIP(EthernetIP);
iprintf("\r\n");
Is there anything else I should do?
Re: fallback to AutoIP if DHCP fails
Technically, I think this would work, but is (probably) unnecessary. Under normal conditions (unless you explicitly configure it otherwise), the network stack creates a secondary multi-home interface and assigns it an address using AutoIP. Therefore, if DHCP fails, AutoIP will already be configured.
Do you specifically need to use AutoIP without using multi-homing?
Do you specifically need to use AutoIP without using multi-homing?
Dan Ciliske
Project Engineer
Netburner, Inc
Project Engineer
Netburner, Inc
Re: fallback to AutoIP if DHCP fails
My application logs data from a sensor device that connects via UDP over ethernet. Most of the time, the system will operate without a network connection in the field, thus the need for AutoIP. When the device is brought into the lab, we strongly prefer it "play nicely" with the lab's LAN, so proper DHCP client behavior is wanted.
The sensor device (from a third party) already has DHCP with fallback to AutoIP. When it "boots up", it first tries to get an IP address via DHCP, then falls back to AutoIP if that fails. We want our data logger to behave the same.
Maybe I'm doing something wrong, but as best I can tell, the DHCP isn't reverting to AutoIP. (During the first phase of development, we only ran it while connected to our lab's LAN. Today, I unplugged the LAN connection. It did not work until I rebuilt the application without DHCP client support.)
My UserMain() starts out:
InitializeStack();
GetDHCPAddress();
Which works with the system connected to our LAN. I had to comment GetDHCPAddress and rebuild to get it to work with out the LAN connection.
The sensor device (from a third party) already has DHCP with fallback to AutoIP. When it "boots up", it first tries to get an IP address via DHCP, then falls back to AutoIP if that fails. We want our data logger to behave the same.
Maybe I'm doing something wrong, but as best I can tell, the DHCP isn't reverting to AutoIP. (During the first phase of development, we only ran it while connected to our lab's LAN. Today, I unplugged the LAN connection. It did not work until I rebuilt the application without DHCP client support.)
My UserMain() starts out:
InitializeStack();
GetDHCPAddress();
Which works with the system connected to our LAN. I had to comment GetDHCPAddress and rebuild to get it to work with out the LAN connection.
Re: fallback to AutoIP if DHCP fails
Can you have your device print out all the interfaces it has? The following code will do that:
I strongly suspect that you have either disabled AutoIP (unlikely) or, more likely, you are attempting to send to an address outside of the AutoIP address space (169.254.0.0/16). If you are trying to send to the broadcast address or other address in the 192.168.0.0/16 or 10.0.0.0/8 space, AutoIP will not work.
Also, can you elaborate on what "did not work" means? Does your application not log the data? Can you not see the data being sent via the AutoIP interface? Details! Details!
Think of this like a bug report; often times we (the forums) can save you hours of work if you give us enough information to go on. Otherwise, we're really just guessing as to what might be happening based on what we think you might be doing
-Dan
Code: Select all
void DisplayAllInterfaces()
{
int InterfaceNumber = GetFirstInterface(); // Get first interface identifier
do {
InterfaceBlock *ib = GetInterFaceBlock(InterfaceNumber);
iprintf("Interface: %d\r\n", InterfaceNumber );
iprintf("IP: "); ShowIP(ib->netIP); iprintf("\r\n");
iprintf("Mask: "); ShowIP(ib->netIpMask); iprintf("\r\n");
iprintf("Gate: "); ShowIP(ib->netIpGate); iprintf("\r\n");
iprintf("DNS: "); ShowIP(ib->netDNS); iprintf("\r\n");
iprintf("Interface Name: %s\r\n", ib->InterfaceName);
iprintf("\r\n");
InterfaceNumber = GetnextInterface( InterfaceNumber );
} while ( InterfaceNumber > 0 );
}
Also, can you elaborate on what "did not work" means? Does your application not log the data? Can you not see the data being sent via the AutoIP interface? Details! Details!

-Dan
Dan Ciliske
Project Engineer
Netburner, Inc
Project Engineer
Netburner, Inc
Re: fallback to AutoIP if DHCP fails
Did not intend this as a bug report, just trying to figure out how to get what we want. (We are using ver 2.6 of the SDK as that is what our customer gave us to use.)
With the system connected to the LAN, I got:
The address and mask for interface 1 are as expected.
With the system not connected to the LAN:
With the GetDHCPAddress(); commented:
With the system connected to the LAN, I got:
Code: Select all
Interface: 1
IP: 192.168.9.99
Mask: 255.255.255.0
Gate: 192.168.9.1
DNS: 192.168.9.1
Interface Name: Ethernet
Interface: 2
IP: 0.0.0.0
Mask: 255.255.0.0
Gate: 0.0.0.0
DNS: 0.0.0.0
Interface Name: Ethernet
With the system not connected to the LAN:
Code: Select all
Interface: 1
IP: 0.0.0.0
Mask: 0.0.0.0
Gate: 0.0.0.0
DNS: 0.0.0.0
Interface Name: Ethernet
Interface: 2
IP: 0.0.0.0
Mask: 255.255.0.0
Gate: 0.0.0.0
DNS: 0.0.0.0
Interface Name: Ethernet
Code: Select all
Interface: 1
IP: 0.0.0.0
Mask: 255.255.0.0
Gate: 0.0.0.0
DNS: 0.0.0.0
Interface Name: Ethernet
Interface: 2
IP: 0.0.0.0
Mask: 255.255.0.0
Gate: 0.0.0.0
DNS: 0.0.0.0
Interface Name: Ethernet
Re: fallback to AutoIP if DHCP fails
Also, our app in the NetBurner only receives UDP messages as the sensor device only sends UDP messages. The sensor sends on the broadcast address of what ever network it "finds" itself connected to. When the system is connected to our LAN, the sensor broadcasts to 192.168.9.255. When the LAN is not connected, it broadcasts to 169.254.255.255. Our app receives the messages, extracts the desired data and logs to a file on an SD card. We monitor the app via the serial port and the sensor via ethernet.
Re: fallback to AutoIP if DHCP fails
Are you actively creating the second interface? It doesn't sound like you are which would make this the one created for AutoIP. The netmask is right, but the IP address is not set. It seems something is zeroing out the IP address of the interface after it has been configured (hence the netmask matching).
Ok, tell ya what, I'm gonna give one last point to check before needing this to move to support (because we're really digging in the weeds now). Check to see if a) there exists an AutoIPClient on the interfaces, and b) if there is print the state of the client:
My hunch is that it will report being in state 5 (AUTO_IP_STARTARP), 6 (AUTO_IP_ANNOUNCING), or 8 (AUTO_IP_CONFLICT), most likely state 5. To be honest, I don't think this is going to be solved without a packet dump from the boot sequence and going through support. (I wrote the code in question and can't see what on our end could be hanging it up like this).
And one last check: it looks like you may have a static netmask set of 255.255.0.0 in the ConfigRecord, I can't figure out why this would be issue, but maybe try making sure that's 0.0.0.0? Also, can you try loading a simple example onto the device which only reports the interface information?
Also, make sure you're reporting the interface states a while after boot, AutoIP takes ~5-10 seconds per round of negotiations, so if you're unlucky it could take a while on a moderately sized network.
-Dan
Ok, tell ya what, I'm gonna give one last point to check before needing this to move to support (because we're really digging in the weeds now). Check to see if a) there exists an AutoIPClient on the interfaces, and b) if there is print the state of the client:
Code: Select all
if(ib->AutoIPC) {
iprintf("AutoIP State: %d\r\n", ib->AutoIPC.getState());
}
And one last check: it looks like you may have a static netmask set of 255.255.0.0 in the ConfigRecord, I can't figure out why this would be issue, but maybe try making sure that's 0.0.0.0? Also, can you try loading a simple example onto the device which only reports the interface information?
Also, make sure you're reporting the interface states a while after boot, AutoIP takes ~5-10 seconds per round of negotiations, so if you're unlucky it could take a while on a moderately sized network.
-Dan
Dan Ciliske
Project Engineer
Netburner, Inc
Project Engineer
Netburner, Inc
Re: fallback to AutoIP if DHCP fails
On power up, the NetBurner displays:
I will add the additional code and let you know.
Code: Select all
Waiting 2sec to start 'A' to abort
Configured IP = 0.0.0.0
Configured Mask = 0.0.0.0
Re: fallback to AutoIP if DHCP fails
The project has been canceled.
If I have time before we have to return the NetBurner to our customer, I will try to continue this investigation.
In any case, sorry to distract you.
Thanks again
If I have time before we have to return the NetBurner to our customer, I will try to continue this investigation.
In any case, sorry to distract you.
Thanks again