The Netduino forums have been replaced by new forums at community.wildernesslabs.co.
This site has been preserved for archival purposes only
and the ability to make new accounts or posts has been turned off.
My code is below. It just loops forever "waiting for an ip address" What is up?
Thanks!
NetworkInterface NI = NetworkInterface.GetAllNetworkInterfaces()[0];
NI.EnableDhcp();
NI.RenewDhcpLease();
NetworkInterface ni;
// Wait for DHCP (on LWIP devices)
while (true)
{
ni = NetworkInterface.GetAllNetworkInterfaces()[0];
if (ni.IPAddress != "0.0.0.0") break;
Debug.Print("Waiting for an IP Address...");
Thread.Sleep(5000);
}
Debug.Print(NI.IPAddress.ToString());
Hi samjones,
Do you have a copy of WireShark by any chance? It looks like there's some disagreement between your mainboard and your DHCP server (permissions, data format, out of address range, etc.) If you can take a look at the requests/responses, that should help narrow down the issue.
If you use a static IP, does your network connectivity work alright?
Chris
Chris,
Yes, static IP works fine, but I really can't use that.
Wireshark: Ack. I know all about wireshark and protocol analyzers (I have a lot of hours on actual "sniffer" sniffers), but I do not have time to make such a research, I am afraid. I am a netduino hobbyist, and have very little time to spend on my projects.
It is disappointing to find such high level holes in the networking stack. I want to roll out a dozen or more of my project (once it is working), but I can't without dhcp.
OK, back to my project.
Hope this gets resolved soon!
Were you using a cheap domestic router? Of the six routers in my house, two won't even talk to the Netduino and one will talk but DHCP fails. All my older, much more expensive gear works perfectly. Also, at the other end of the scale, some of the fancier Cisco gear we use at work spouts discovery packets that seem to upset the Netduino.
Sometimes, if you change it to static, reboot it, change it back to DHCP and reboot it again, everything comes good.
>> Were you using a cheap domestic router?
Linksys / cisco wifi hub, same as in every house in the city....
>> Sometimes, if you change it to static, reboot it, change it back to DHCP and reboot it again, everything comes good.
That is not useful. DHCP either works or it doesn't. I will be deploying my device to several households. Without working dhcp, I have to go back to the Panda board.
If DHCP isn't working, it's most likely a communication issue.
We're using the DHCP which is built into the .NET MF, from the lwIP stack.
If you have DHCP issues, please grab a network trace using WireShark. We can look at the packets and analyze them. There are a lot of routers out there and there's a chance that lwIP doesn't know how to deal with some of them...and your sniffing will help all lwIP-based implementations.
Chris
Chris,
I will try to do a wireshark trace by Monday (I usually work on this stuff on Sat nights and Sundays, it is my hobby, not my day job).
Question: How long does it take for this kind of thing to get fixed in code, once the issue is really clarified?
Microsoft.SPOT.Net.NetworkInformation.NetworkInterface.GetAllNetworkInterfaces()[0].EnableDynamicDns ();
it will let the netduino getting dns server settings but let the devise have static ip.
Microsoft.SPOT.Net.NetworkInformation.NetworkInterface.GetAllNetworkInterfaces()[0].EnableDhcp();
this will enabledhcp
I have beeing test some http server software and enden up with the static ip and dyndns as the best solution for me.
My setup:
- In mfdeploy, networking is set to dhcp
- code is:
NetworkInterface NI = NetworkInterface.GetAllNetworkInterfaces()[0];
NI.EnableDhcp();
NI.RenewDhcpLease();
NetworkInterface ni;
// Wait for DHCP (on LWIP devices)
while (true)
{
ni = NetworkInterface.GetAllNetworkInterfaces()[0];
if (ni.IPAddress != "0.0.0.0") break;
Debug.Print("Waiting for an IP Address...");
Thread.Sleep(5000);
}
Debug.Print(NI.IPAddress.ToString());
Debug.Print("TinyCLR's IP = " + NI.IPAddress.ToString());
Curent result in debug window is:
Waiting for an IP Address...
Waiting for an IP Address...
Waiting for an IP Address...
Waiting for an IP Address...
Waiting for an IP Address...
Waiting for an IP Address...
Waiting for an IP Address...
Waiting for an IP Address...
Waiting for an IP Address...
Waiting for an IP Address...
Waiting for an IP Address...
forever...
Screen shot from wireshark is attached.
Wireshark capture is attached as zip
(Note, there may be a couple of packets not related to the netduino in the capture, sorry!)
Microsoft.SPOT.Net.NetworkInformation.NetworkInterface.GetAllNetworkInterfaces()[0].EnableDynamicDns ();
it will let the netduino getting dns server settings but let the devise have static ip.
Ummm, the above line throws an exception...
Exception System.NotSupportedException - CLR_E_NOT_SUPPORTED (1) ####
#### Message:
#### Microsoft.SPOT.Net.NetworkInformation.NetworkInterface::UpdateConfiguration [IP: 0000] ####
#### Microsoft.SPOT.Net.NetworkInformation.NetworkInterface::EnableDynamicDns [IP: 000f] ####
#### NetduinoPlusApplication1.Program::Main [IP: 0028] ####
A first chance exception of type 'System.NotSupportedException' occurred in Microsoft.SPOT.Net.dll
An unhandled exception of type 'System.NotSupportedException' occurred in Microsoft.SPOT.Net.dll
Exception System.NotSupportedException - CLR_E_NOT_SUPPORTED (1) ####
#### Message:
#### Microsoft.SPOT.Net.NetworkInformation.NetworkInterface::UpdateConfiguration [IP: 0000] ####
#### Microsoft.SPOT.Net.NetworkInformation.NetworkInterface::EnableDynamicDns [IP: 000f] ####
#### NetduinoPlusApplication1.Program::Main [IP: 0028] ####
A first chance exception of type 'System.NotSupportedException' occurred in Microsoft.SPOT.Net.dll
An unhandled exception of type 'System.NotSupportedException' occurred in Microsoft.SPOT.Net.dll
A first chance exception of type 'System.NotSupportedException' occurred in Microsoft.SPOT.Net.dll
you don't have a router that support it, remember to ip adress and router adress via mfdploy.exe
target->configuration->network or the online API
mine data is 192.168.1.51 255,255,255,0 191,168,1,1
Exception System.NotSupportedException - CLR_E_NOT_SUPPORTED (1) ####
#### Message:
#### Microsoft.SPOT.Net.NetworkInformation.NetworkInterface::UpdateConfiguration [IP: 0000] ####
#### Microsoft.SPOT.Net.NetworkInformation.NetworkInterface::EnableDynamicDns [IP: 000f] ####
#### NetduinoPlusApplication1.Program::Main [IP: 0028] ####
A first chance exception of type 'System.NotSupportedException' occurred in Microsoft.SPOT.Net.dll
An unhandled exception of type 'System.NotSupportedException' occurred in Microsoft.SPOT.Net.dll
Hi again
I have the same trouble here in my summerHouse. it is a zyxel router.
ofc. you have to change to addresses that meet your nets requirements.
as a control open a dos window and do the command ping 192.168.1.51 (your netduinos adress) end it will replay.
it is testet here and works.
using System;
using System.Net;
using System.Net.Sockets;
using System.Threading;
using Microsoft.SPOT;
using Microsoft.SPOT.Hardware;
using SecretLabs.NETMF.Hardware;
using SecretLabs.NETMF.Hardware.NetduinoPlus;
namespace staticNetworkKommection
{
public class Program
{
public static void Main()
{
// write your code here
Microsoft.SPOT.Net.NetworkInformation.NetworkInterface.GetAllNetworkInterfaces()[0].EnableStaticIP("192.168.1.51", "255.255.255.0", "192.168.1.1");
Microsoft.SPOT.Net.NetworkInformation.NetworkInterface.GetAllNetworkInterfaces()[0].EnableStaticDns(new string[] { "212.242.40.3", "212.242.40.51" });
}
}
}
If DHCP isn't working, it's most likely a communication issue.
We're using the DHCP which is built into the .NET MF, from the lwIP stack.
If you have DHCP issues, please grab a network trace using WireShark. We can look at the packets and analyze them. There are a lot of routers out there and there's a chance that lwIP doesn't know how to deal with some of them...and your sniffing will help all lwIP-based implementations.
Chris
Hi I have been testing a'lot today, and there is trouble with dhcp. Why does the code following not work.
When it work's the interface is working. But i also found that by setting some default addresses in the netduino with the MFDeploy.exe tool,
the interface sometime works.
so until the eksample code works I will use static ip adresses and dyndns adresses.
using System;
using System.Net;
using System.Net.Sockets;
using System.Threading;
using Microsoft.SPOT;
using Microsoft.SPOT.Hardware;
using Microsoft.SPOT.Net.NetworkInformation;
using SecretLabs.NETMF.Hardware;
using SecretLabs.NETMF.Hardware.NetduinoPlus;
namespace staticNetworkKommection
{
public class Program
{
static bool ipAdressChanged = false;
public static void Main()
{
int taeller = 0;
// write your code here
NetworkChange.NetworkAddressChanged += new NetworkAddressChangedEventHandler(AddressChangedCallback);
NetworkInterface.GetAllNetworkInterfaces()[0].EnableDhcp();
Debug.Print("aktuel ip address "+NetworkInterface.GetAllNetworkInterfaces()[0].IPAddress.ToString());
while ((!ipAdressChanged)&&(taeller < 5))
{
Thread.Sleep(5000);
taeller += 1;
}
if (!ipAdressChanged)
{
NetworkInterface.GetAllNetworkInterfaces()[0].EnableStaticIP("192.168.1.51", "255.255.255.0", "192.168.1.1");
NetworkInterface.GetAllNetworkInterfaces()[0].EnableDynamicDns();
//NetworkInterface.GetAllNetworkInterfaces()[0].EnableStaticDns(new string[] { "212.242.40.3", "212.242.40.51" });
}
Debug.Print("aktuel ip address " + NetworkInterface.GetAllNetworkInterfaces()[0].IPAddress.ToString());
}
static void AddressChangedCallback(object sender, EventArgs e)
{
ipAdressChanged = true;
Debug.Print("Network adress changed");
}
}
}