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

Network stability issues


  • Please log in to reply
7 replies to this topic

#1 Moskus

Moskus

    Advanced Member

  • Members
  • PipPipPip
  • 132 posts
  • LocationNorway

Posted 27 September 2011 - 01:29 PM

As I'm trying to get my FTP client working (which is getting along, hopefully), I ran into problems with creating sockets, resolving domain names and open a socket connection. Sometimes it worked, and sometimes it didn't And I couldn't figure out why!

But now it seems that the Netduino is losing the connection from time to time, and I don't see any patterns. I've tried switching the cable, switching switch, connecting directly to the router, both at home and work, and so on. Nothing.

In the end I ran a simple test program:
Sub Main()
        AddHandler Net.NetworkInformation.NetworkChange.NetworkAvailabilityChanged, AddressOf NetworkAvailability

        For i As Integer = 100 To 1 Step -1
            Debug.Print("Sleeping... " & i)
            Thread.Sleep(500)
        Next

    End Sub

    Private Sub NetworkAvailability(ByVal sender As Object, ByVal e As Net.NetworkInformation.NetworkAvailabilityEventArgs)
        Debug.Print("Network availability: " & e.IsAvailable)
    End Sub

(you can translate it to C# here if you prefer).

Here's the output:

Sleeping... 100
Sleeping... 99
Sleeping... 98
Sleeping... 97
Sleeping... 96
Sleeping... 95
Sleeping... 94
Sleeping... 93
Network availability: True
Sleeping... 92
Sleeping... 91
Sleeping... 90
Sleeping... 89
Sleeping... 88
Sleeping... 87
Sleeping... 86
Sleeping... 85
Sleeping... 84
Sleeping... 83
Sleeping... 82
Sleeping... 81
Sleeping... 80
Network availability: False
Sleeping... 79
Sleeping... 78
Sleeping... 77
Sleeping... 76
Network availability: True
Sleeping... 75
Sleeping... 74
Sleeping... 73
Sleeping... 72
Sleeping... 71
Sleeping... 70
Sleeping... 69
Sleeping... 68
Sleeping... 67
Sleeping... 66
Sleeping... 65
Sleeping... 64
Sleeping... 63
Sleeping... 62
Sleeping... 61
Sleeping... 60
Sleeping... 59
Network availability: False
Sleeping... 58
Sleeping... 57
Sleeping... 56
Sleeping... 55
Sleeping... 54
Sleeping... 53
Sleeping... 52
Sleeping... 51
Network availability: True
Sleeping... 50
Sleeping... 49
Sleeping... 48
Sleeping... 47
Sleeping... 46
Sleeping... 45
Sleeping... 44
Sleeping... 43
Sleeping... 42
Sleeping... 41
Sleeping... 40
Sleeping... 39
Sleeping... 38
Sleeping... 37
Sleeping... 36
Sleeping... 35
Sleeping... 34
Sleeping... 33
Sleeping... 32
Sleeping... 31
Sleeping... 30
Network availability: False
Sleeping... 29
Sleeping... 28
Sleeping... 27
Sleeping... 26
Network availability: True
Sleeping... 25
Sleeping... 24
Sleeping... 23
Sleeping... 22
Sleeping... 21
Sleeping... 20
Sleeping... 19
Sleeping... 18
Sleeping... 17
Sleeping... 16
Sleeping... 15
Sleeping... 14
Sleeping... 13
Sleeping... 12
Sleeping... 11
Sleeping... 10
Sleeping... 9
Sleeping... 8
Sleeping... 7
Sleeping... 6
Sleeping... 5
Sleeping... 4
Sleeping... 3
Sleeping... 2
Sleeping... 1
Done.



What's going on?! Posted Image

#2 Stefan

Stefan

    Moderator

  • Members
  • PipPipPip
  • 1965 posts
  • LocationBreda, the Netherlands

Posted 27 September 2011 - 01:45 PM

Would you like to upload the full project? If you do, I will test it tonight on my Plus to rule out if it's a networking issue, software issue, or netduino issue. -edit- I see its a short testcode already, going to try it tonight!

Edited by Stefan, 27 September 2011 - 01:59 PM.

"Fact that I'm a moderator doesn't make me an expert in things." Stefan, the eternal newb!
My .NETMF projects: .NETMF Toolbox / Gadgeteer Light / Some PCB designs

#3 erich

erich

    Member

  • Members
  • PipPip
  • 21 posts
  • LocationFrance

Posted 27 September 2011 - 02:44 PM

I have a C# version without non availability for 500+ iterations but it is interesting. I hoped it might have explained a Socket.Connect() problem I am experiencing.


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;
using Microsoft.SPOT.Net.NetworkInformation;

namespace NetstabTest
{
public class Program
{
public static void Main()
{
Program p = new Program();
NetworkChange.NetworkAvailabilityChanged += p.NetworkAvailibilty;
p.GetNetworkAccess();

int i = 0;
while (true)
{
Debug.Print("sleeping:" + i++);
Thread.Sleep(500);
}

}

private void NetworkAvailibilty(object sender, NetworkAvailabilityEventArgs e)
{
Debug.Print("Network availibility" + e.IsAvailable);
GetNetworkAccess();
}

public void GetNetworkAccess()
{

NetworkInterface[] nis = NetworkInterface.GetAllNetworkInterfaces();

for (int i = 0; i < nis.Length; i++)
{
NetworkInterface networkInterface = nis[i];

if (networkInterface.NetworkInterfaceType == NetworkInterfaceType.Ethernet)
{
string m_macAddress = networkInterface.PhysicalAddress[0].ToString();
for (int j = 1; j < networkInterface.PhysicalAddress.Length; ++j)
{
m_macAddress += "-" + networkInterface.PhysicalAddress[j].ToString();
}

string[] m_staticDnsAddresses = new string[] { "0.0.0.0", "0.0.0.0" };
for (int k = 0; k < networkInterface.DnsAddresses.Length; ++k)
{
m_staticDnsAddresses[k] = networkInterface.DnsAddresses[k];
}

Debug.Print(networkInterface.IPAddress);
}
}
}

}
}

#4 Stefan

Stefan

    Moderator

  • Members
  • PipPipPip
  • 1965 posts
  • LocationBreda, the Netherlands

Posted 27 September 2011 - 05:59 PM

As I'm trying to get my FTP client working (which is getting along, hopefully), I ran into problems with creating sockets, resolving domain names and open a socket connection. Sometimes it worked, and sometimes it didn't And I couldn't figure out why!

But now it seems that the Netduino is losing the connection from time to time, and I don't see any patterns. I've tried switching the cable, switching switch, connecting directly to the router, both at home and work, and so on. Nothing.

In the end I ran a simple test program:

Sub Main()
        AddHandler Net.NetworkInformation.NetworkChange.NetworkAvailabilityChanged, AddressOf NetworkAvailability

        For i As Integer = 100 To 1 Step -1
            Debug.Print("Sleeping... " & i)
            Thread.Sleep(500)
        Next

    End Sub

    Private Sub NetworkAvailability(ByVal sender As Object, ByVal e As Net.NetworkInformation.NetworkAvailabilityEventArgs)
        Debug.Print("Network availability: " & e.IsAvailable)
    End Sub

(you can translate it to C# here if you prefer).

Strange, when I run the exact same code in VB it works perfectly. No problems at all.

Netduino Plus rev.B, capabilities:
HalSystemInfo.halVersion:               4.2.0.0
HalSystemInfo.halVendorInfo:            Netduino Plus (v4.2.0.0 RC1) by Secret Labs LLC
HalSystemInfo.oemCode:                  34
HalSystemInfo.modelCode:                177
HalSystemInfo.skuCode:                  4097
HalSystemInfo.moduleSerialNumber:       00000000000000000000000000000000
HalSystemInfo.systemSerialNumber:       0000000000000000
ClrInfo.clrVersion:                     4.2.0.0
ClrInfo.clrVendorInfo:                  Netduino Plus (v4.2.0.0 RC1) by Secret Labs LLC
ClrInfo.targetFrameworkVersion:         4.2.0.0
SolutionReleaseInfo.solutionVersion:    4.2.0.0
SolutionReleaseInfo.solutionVendorInfo: Netduino Plus (v4.2.0.0 RC1) by Secret Labs LLC
SoftwareVersion.BuildDate:              Aug  7 2011
SoftwareVersion.CompilerVersion:        400902
FloatingPoint:                          True
SourceLevelDebugging:                   True
ThreadCreateEx:                         True
LCD.Width:                              0
LCD.Height:                             0
LCD.BitsPerPixel:                       0
AppDomains:                             False
ExceptionFilters:                       True
IncrementalDeployment:                  True
SoftReboot:                             True
Profiling:                              False
ProfilingAllocations:                   False
ProfilingCalls:                         False
IsUnknown:                              False

Try running with MFDeploy instead of the Visual Studio debugger, it gives some more info like:

DM9161_AutoNegotiate
Valid PHY Found: 31
PHY: Vendor Number Model = 0xA
PHY: Model Revision Number = 0x0
AutoNegotiate complete
Network availability: True


You can do this by opening C:\Program Files (x86)\Microsoft .NET Micro Framework\v4.2\Tools\MFDeploy.exe, select USB, the device and press F5. Then press the reset button on your netduino to re-run your app.
"Fact that I'm a moderator doesn't make me an expert in things." Stefan, the eternal newb!
My .NETMF projects: .NETMF Toolbox / Gadgeteer Light / Some PCB designs

#5 Moskus

Moskus

    Advanced Member

  • Members
  • PipPipPip
  • 132 posts
  • LocationNorway

Posted 27 September 2011 - 07:55 PM

After changing yet another switch back home, I got it working! :) But I suspect I still have stability issues at work (and I have a better network at home), I'll double check tomorrow. It seems like the N+ is a little picky about its connections.

#6 Moskus

Moskus

    Advanced Member

  • Members
  • PipPipPip
  • 132 posts
  • LocationNorway

Posted 28 September 2011 - 06:13 AM

Try running with MFDeploy instead of the Visual Studio debugger, it gives some more info like:

You can do this by opening C:\Program Files (x86)\Microsoft .NET Micro Framework\v4.2\Tools\MFDeploy.exe, select USB, the device and press F5. Then press the reset button on your netduino to re-run your app.

Great tip! Didn't know that, thanks! :)

It's stuff like this I feel is missing from "opening the box" experience. Hopefully Chris's book will do something about that...

#7 erich

erich

    Member

  • Members
  • PipPip
  • 21 posts
  • LocationFrance

Posted 28 September 2011 - 08:13 AM

Strange, when I run the exact same code in VB it works perfectly. No problems at all.

Netduino Plus rev.B, capabilities:

HalSystemInfo.halVersion:               4.2.0.0
HalSystemInfo.halVendorInfo:            Netduino Plus (v4.2.0.0 RC1) by Secret Labs LLC
HalSystemInfo.oemCode:                  34
HalSystemInfo.modelCode:                177
HalSystemInfo.skuCode:                  4097
HalSystemInfo.moduleSerialNumber:       00000000000000000000000000000000
HalSystemInfo.systemSerialNumber:       0000000000000000
ClrInfo.clrVersion:                     4.2.0.0
ClrInfo.clrVendorInfo:                  Netduino Plus (v4.2.0.0 RC1) by Secret Labs LLC
ClrInfo.targetFrameworkVersion:         4.2.0.0
SolutionReleaseInfo.solutionVersion:    4.2.0.0
SolutionReleaseInfo.solutionVendorInfo: Netduino Plus (v4.2.0.0 RC1) by Secret Labs LLC
SoftwareVersion.BuildDate:              Aug  7 2011
SoftwareVersion.CompilerVersion:        400902
FloatingPoint:                          True
SourceLevelDebugging:                   True
ThreadCreateEx:                         True
LCD.Width:                              0
LCD.Height:                             0
LCD.BitsPerPixel:                       0
AppDomains:                             False
ExceptionFilters:                       True
IncrementalDeployment:                  True
SoftReboot:                             True
Profiling:                              False
ProfilingAllocations:                   False
ProfilingCalls:                         False
IsUnknown:                              False

Try running with MFDeploy instead of the Visual Studio debugger, it gives some more info like:

You can do this by opening C:\Program Files (x86)\Microsoft .NET Micro Framework\v4.2\Tools\MFDeploy.exe, select USB, the device and press F5. Then press the reset button on your netduino to re-run your app.


Hi Stephan,

Just been using MFDeploy - once I reverted to DHCP - I the same as you got except after AutoNegotiate complete -rather than getting NetworkConnection true I get System.Net.Sockets.SocketException. Any ideas why? I am running RC4.2

regards
Eric

#8 Stefan

Stefan

    Moderator

  • Members
  • PipPipPip
  • 1965 posts
  • LocationBreda, the Netherlands

Posted 28 September 2011 - 08:20 AM

Hi Stephan,

Just been using MFDeploy - once I reverted to DHCP - I the same as you got except after AutoNegotiate complete -rather than getting NetworkConnection true I get System.Net.Sockets.SocketException. Any ideas why? I am running RC4.2

regards
Eric


Hi Eric,

Could you upload a zipfile with the full project you've got? I will try to run it tonight on my Plus.

Kind regards,
Stefan


:rolleyes:
"Fact that I'm a moderator doesn't make me an expert in things." Stefan, the eternal newb!
My .NETMF projects: .NETMF Toolbox / Gadgeteer Light / Some PCB designs




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.