The Andre-DHCP issue

@ andre.m - we spent 2 days trying to solve the issue you are seeing with DHCP and EMX. First of all the issue is defiantly related to your server. It worked in 4.1 because the stack handled the error from your server and recovered from it. This does not mean there is an issue with 4.2.

Still, we added a workaround to overcome the issue with your server. So DHCP should work fine for you on EMX on next release in few weeks.

I didn’t find your old post so I made this new one :slight_smile:

2 Likes

that’s great news.

I’m still trying to find time to test the Cobra 2 and wired network to see if the behaviour is different to wifi or not… Perhaps this long weekend I will find time. Will the same fix change the G120 behaviour (or does it need to?)

This is in the network stack itself so it will effect every single device even non GHI.

1 Like

That is great news. I’ve a couple of spiders upgraded to 4.2 and in combination with dsl routers and one of them encountered the dhcp problem. I solved it by using a fixed / static ip address. The problematic router is a (siemens) experia box, a typical dutch router used by several dutch ISP’s.

@ andre.m - I looked through your previous posts but couldn’t find the original issue you were having with DHCP and EMX.

I have a Cobra 1, and have had this issue with DHCP ever since I upgraded to 4.2.


if (ethernet.IsActivated)
{
	ethernet.Close();
	ethernet.Dispose();
	ethernet = new EthernetBuiltIn();
}

ethernet.CableConnectivityChanged += new EthernetBuiltIn.CableConnectivityChangedEventHandler(Eth1_CableConnectivityChanged);
ethernet.NetworkAddressChanged += new NetworkInterfaceExtension.NetworkAddressChangedEventHandler(Eth1_NetworkAddressChanged);

ethernet.Open();

if (NetworkInterfaceExtension.AssignedNetworkInterface == null)
{
	NetworkInterfaceExtension.AssignNetworkingStackTo(ethernet);
}
else if (NetworkInterfaceExtension.AssignedNetworkInterface.NetworkInterface.NetworkInterfaceType != NetworkInterfaceType.Ethernet)
{
	NetworkInterfaceExtension.AssignNetworkingStackTo(ethernet);
}

if (ethernet.IsActivated && ethernet.IsOpen && ethernet.IsCableConnected)
{
	NetworkInterface networkInterface = ethernet.NetworkInterface;

	if (useDHCP)
	{
		Logger.WriteInfo("Main", "Setting dynamic IP address...");
		if (networkInterface.IsDhcpEnabled == true)
		{
			networkInterface.RenewDhcpLease();
		}
		else
		{
			networkInterface.EnableDhcp();
		}

		int waitSecs = 10;
		IPAddress ip = IPAddress.GetDefaultLocalAddress();
		while (ip == IPAddress.Any && waitSecs > 0)
		{
			Thread.Sleep(1000);
			waitSecs--;
			ip = IPAddress.GetDefaultLocalAddress();
		}
	}
	else
	{
		Logger.WriteInfo("Main", "Setting static IP address...");
		networkInterface.EnableStaticIP(myIP, subnetMask, gatewayAddress);

		networkInterface.EnableStaticDns(new[] { dnsAddresses });
	}

	// display results
	if (IPAddress.GetDefaultLocalAddress() != IPAddress.Any)
	{
		Logger.WriteInfo("Main", "Network ready.");
		Logger.WriteInfo("Main", "  IP Address:      " + IPAddress.GetDefaultLocalAddress());
		Logger.WriteInfo("Main", "  IP Address:      " + networkInterface.IPAddress);
		Logger.WriteInfo("Main", "  Subnet Mask:     " + networkInterface.SubnetMask);
		Logger.WriteInfo("Main", "  Default Gateway: " + networkInterface.GatewayAddress);
		Logger.WriteInfo("Main", "  # DNS Servers:   " + networkInterface.DnsAddresses.Length);
		foreach (string dnsAddress in networkInterface.DnsAddresses)
		{
			Logger.WriteInfo("Main", "  DNS Server: " + dnsAddress);
		}
		return true;
	}
	else
	{
		Logger.WriteInfo("Main", "Network failed to initialize.");
		Logger.WriteInfo("Main", "  IP Address: " + IPAddress.GetDefaultLocalAddress());
	}
}
else
{
	Logger.WriteInfo("Main", "No network device found.");
}

Here is the output (ignore the dates and times, I didn’t initialize the system clock).
The first IP address is from IPAddress.GetDefaultLocalAddress().
I’m able to communicate with an external web site and a TCP server, so it is working, but…

Info : 06/01/2011 | 00:03:15.228 | Main | Initializing network…
Info : 06/01/2011 | 00:03:17.776 | Main | Setting dynamic IP address…
Info : 06/01/2011 | 00:03:19.489 | Main | Network ready.
Info : 06/01/2011 | 00:03:19.545 | Main | IP Address: 192.168.1.8
Info : 06/01/2011 | 00:03:19.573 | Main | IP Address: 0.0.0.0
Info : 06/01/2011 | 00:03:19.601 | Main | Subnet Mask: 0.0.0.0
Info : 06/01/2011 | 00:03:19.630 | Main | Default Gateway: 0.0.0.0
Info : 06/01/2011 | 00:03:19.654 | Main | # DNS Servers: 0

@ gus - Any estimate on the upcoming SDK? So I can start planning my in field replacement…:slight_smile:

It is done but we are on hold waiting on something GREAT from Microsoft. Not allowed to say what but you can guess :slight_smile:

Ok, I hope it is what i think it is! Can’t wait (but I have to)

@ Gus - Sorry, I don’t mean to beat this issue to death, but are you saying that you have a fix for the issue of IP addresses with all zeros being returned from:

EthernetBuiltIn.NetworkInterface

Thanks.

We fixed an issue, which is only related to Andre’s setup. It was not an issue a actually. His DHCP server is the problem.

Oh.

I thought the zero-value IP addresses being returned from EthernetBuiltIn.NetworkInterface as a result of DHCP failing was the original issue that was being looked into?

Actually in my case, it appears that DHCP is succeeding, but the values are still being set to zero.

Am I doing something wrong or missing some step in my code?

But you said earlier you changed code in the netmf IP stack implementation, right? So potentially it is something others will see, if their dchp servers behave the same/similar way to the one Andre’s did.

Yes if the have the same problem which should be rare

[ quote user=jasdev]
Oh.

I thought the zero-value IP addresses being returned from EthernetBuiltIn.NetworkInterface as a result of DHCP failing was the original issue that was being looked into?

Actually in my case, it appears that DHCP is succeeding, but the values are still being set to zero.

Am I doing something wrong or missing some step in my code?
[/quote]

We need you to start a new thread with full details please, including your complete setup.

Ok, so if the problem I am seeing is not caused by my DHCP server, then it has to be caused by a bug in the GHI or NETMF code.
Is that issue being addressed?

Ok thanks Gus I will get information about my DHCP server and start a new thread.

Ok, that is great news Andre! It should solve my problems also. I start migrating tonight…