Netduino home hardware projects downloads community

Jump to content


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.
Photo

Wrong network addressing breaks netduino plus


  • Please log in to reply
5 replies to this topic

#1 Flores

Flores

    Advanced Member

  • Members
  • PipPipPip
  • 64 posts

Posted 25 September 2010 - 07:48 AM

I'm experimenting with the code I posted earlier:

using System; 
using System.Threading; 
using Microsoft.SPOT; 
using Microsoft.SPOT.Hardware; 
using SecretLabs.NETMF.Hardware; 
using SecretLabs.NETMF.Hardware.Netduino; 
using Microsoft.SPOT.Net.NetworkInformation; 
using Microsoft.SPOT.Net; 
using System.Net.Sockets; 
using System.Net; 
using System.Text; 
 
namespace NetduinoApplication2 
{ 
    public class Program 
    { 
 
        public static void Main() 
        { 
 
            using (System.Net.Sockets.Socket socket = new Socket(AddressFamily.InterNetwork, SocketType.Stream, ProtocolType.Tcp)) 
            { 
 
                IPHostEntry entry = Dns.GetHostEntry("192.168.5.111"); 
                IPAddress address = entry.AddressList[0]; 
                IPEndPoint endpoint = new IPEndPoint(address, 80); 
 
                socket.Connect(endpoint); 
                socket.Send(Encoding.UTF8.GetBytes("Hallo Netduino plus")); 
            } 
 
        } 
 
    } 
}

This works.. I'v got IIS running on my notebook, and i'm seeing this in my logfiles:

2010-09-25 07:39:58 192.168.5.150 4098 192.168.5.111 80 - Hallo Netduino 400 - BadRequest -

Which is expected.


However, if I change the ip address in the code above to a non existant address (like 192.168.5.10)..just to test what happens.. this totally crashes the netduino plus and VS 2010. Only way to recover is to reset the netduino with the reset button.

Am I just the wrong code? or is this a bug?

#2 Chris Walker

Chris Walker

    Secret Labs Staff

  • Moderators
  • 7767 posts
  • LocationNew York, NY

Posted 25 September 2010 - 11:26 AM

This works.. I'v got IIS running on my notebook, and i'm seeing this in my logfiles:

However, if I change the ip address in the code above to a non existant address (like 192.168.5.10)..just to test what happens.. this totally crashes the netduino plus and VS 2010. Only way to recover is to reset the netduino with the reset button.

Am I just the wrong code? or is this a bug?


If you try to connect to a non-existant address, it's possible that lwIP has a timeout of "infinite" and will just never stop trying :) Or it's possible that there's a bug in there. .NET MF is using interop with networking, and any native code (i.e. lwIP's socket connect routines) that don't return could cause Visual Studio to wait and wait and wait... There is room to improve this--and this is great feedback to start down that path.

If I understand it right, connecting to a good address is successful--and you can easily recover by pressing the reset button on the Netduino Plus--correct? That's a good backup plan for now.

We'll look at timeout values and see what we can do to make it throw an exception quickly rather than wait forever...

Thank you very much for the feedback!

Chris

#3 Flores

Flores

    Advanced Member

  • Members
  • PipPipPip
  • 64 posts

Posted 25 September 2010 - 12:46 PM

If you try to connect to a non-existant address, it's possible that lwIP has a timeout of "infinite" and will just never stop trying :) Or it's possible that there's a bug in there. .NET MF is using interop with networking, and any native code (i.e. lwIP's socket connect routines) that don't return could cause Visual Studio to wait and wait and wait... There is room to improve this--and this is great feedback to start down that path.

If I understand it right, connecting to a good address is successful--and you can easily recover by pressing the reset button on the Netduino Plus--correct? That's a good backup plan for now.

We'll look at timeout values and see what we can do to make it throw an exception quickly rather than wait forever...

Thank you very much for the feedback!

Chris



Yes, connecting to a existant address works fine. And yes, I can recover using the reset button.
I timeout would be nice, I would expect and exception.

#4 pascal06

pascal06

    Advanced Member

  • Members
  • PipPipPip
  • 95 posts
  • LocationFrance

Posted 25 September 2010 - 04:14 PM

I have the same experience, I can see the first ARP request, but no retry (after waiting 30 minutes :) ). A IP stack must retry after a timeout, and after multiple requests it must generate a exception. And it's not the case, like a infinite timeout after the first request. It's probably a bug. Pascal

#5 Osi

Osi

    New Member

  • Members
  • Pip
  • 3 posts

Posted 11 January 2011 - 02:48 PM

I have the same experience, I can see the first ARP request, but no retry (after waiting 30 minutes :) ). A IP stack must retry after a timeout, and after multiple requests it must generate a exception. And it's not the case, like a infinite timeout after the first request. It's probably a bug.

Pascal


Is it fixed?
Mark

#6 Valkyrie-MT

Valkyrie-MT

    Advanced Member

  • Members
  • PipPipPip
  • 315 posts
  • LocationIndiana, USA

Posted 19 July 2011 - 05:02 AM

Is it fixed?

I believe the answer is Yes, it is fixed. I tried this code from the original post on v4.1.1.0 Firmware and after 30 seconds of blocking on the Socket.Connect method with a non-existent IP address, it timed out and threw a SocketException.

-Valkyrie-MT




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users

home    hardware    projects    downloads    community    where to buy    contact Copyright © 2016 Wilderness Labs Inc.  |  Legal   |   CC BY-SA
This webpage is licensed under a Creative Commons Attribution-ShareAlike License.