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

PING a host on the network


  • Please log in to reply
25 replies to this topic

#1 chedemefedeme

chedemefedeme

    New Member

  • Members
  • Pip
  • 8 posts

Posted 27 July 2011 - 12:07 AM

Perhaps the other thread dug back out of oblivion was too confused. I have a simple need: to ping another host on the network from my netduino plus' c# code. I've owned it for days and gotten it to do all manner of other things but can't seem to figure this one out. .NET seems to have a ping class but it is not supported on the netduino? Please let me know how this can be done. I really would think such a simple functionality is possible on this unit so surely I'm missing something obvious. Great device and thanks in advance!

#2 Glen

Glen

    Member

  • Members
  • PipPip
  • 26 posts

Posted 28 July 2011 - 01:20 AM

Well.....here is this. I started looking into this thinking it wouldn't be that hard, and it was harder than I thought it would be. I don't actually have my netduino yet as I'm waiting for it to arrive still. I did test this in the emulator and it does seem to work as far as I can tell. I'm sure it could work better, but this seems to do ok. I'll actually try it out when my netduino plus arrives this weekend(hopefully). I used a bunch of the code from here and cut a lot out and changed it a bit to work with the micro framework, but it was my basis: http://www.winsocket...nication8i.html You can download the original full framework C# completed solution that goes with that tutorial here: http://www.winsocket...ocketPingCS.zip I also used the code for the BitConverter by Ravenheart that he posted here: http://forums.netdui...ch__1#entry2082 I took out the unsafe methods as they weren't being used. I created the NetworkHostConverter.cs since the micro framework doesn't have those conversions. I just loaded the original dll in dotpeek and did it the same way microsoft does. All that being said, there is probably some super easy way to do it, but sometimes you learn more doing it the hard way.

Attached Files

  • Attached File  ping.zip   12.05KB   120 downloads


#3 chedemefedeme

chedemefedeme

    New Member

  • Members
  • Pip
  • 8 posts

Posted 29 July 2011 - 04:43 PM

I've downloaded and will try this later today and let you know how it goes! Thanks in advance!

#4 ColinR

ColinR

    Advanced Member

  • Members
  • PipPipPip
  • 142 posts
  • LocationCape Town, South Africa

Posted 29 July 2011 - 06:19 PM

I've just tried this now, and it hits the same issue as I had here

Exception System.Net.Sockets.SocketException - CLR_E_FAIL (1)
on
new Socket(AddressFamily.InterNetwork, SocketType.Raw, ProtocolType.Icmp);


#5 Glen

Glen

    Member

  • Members
  • PipPip
  • 26 posts

Posted 29 July 2011 - 07:27 PM

I've just tried this now, and it hits the same issue as I had here

Exception System.Net.Sockets.SocketException - CLR_E_FAIL (1)
on
new Socket(AddressFamily.InterNetwork, SocketType.Raw, ProtocolType.Icmp);

Hmm, like I said above, I was doing this in the emulator as I don't have my netduino yet(should arrive tomorrow)
May not be supported on the netduino.

I take it you are compiling fine? Just get that error when running?

#6 ColinR

ColinR

    Advanced Member

  • Members
  • PipPipPip
  • 142 posts
  • LocationCape Town, South Africa

Posted 29 July 2011 - 07:39 PM

Hmm, like I said above, I was doing this in the emulator as I don't have my netduino yet(should arrive tomorrow)
May not be supported on the netduino.

I take it you are compiling fine? Just get that error when running?



Yeah, compiled fine, and ran when in the emulator. Deployed to Netduino and exception is thrown.

#7 Chris Walker

Chris Walker

    Secret Labs Staff

  • Moderators
  • 7767 posts
  • LocationNew York, NY

Posted 29 July 2011 - 08:04 PM

I believe that the emulator uses the closed-source RTIP networking stack instead of the lwIP open-source networking stack. If this is supported in lwIP and it fits, we could certainly enable it. Chris

#8 Glen

Glen

    Member

  • Members
  • PipPip
  • 26 posts

Posted 29 July 2011 - 08:30 PM

Well, just got home and got my netduino today, I'll see if I can figure anything out. Is there a way to know what is and isn't supported by the lwIP stack?

#9 Glen

Glen

    Member

  • Members
  • PipPip
  • 26 posts

Posted 29 July 2011 - 10:27 PM

new Socket(AddressFamily.InterNetwork, SocketType.Raw, ProtocolType.Icmp);

I can change it to SocketType.Raw and ProtocolType.Raw and get past that line when debugging on the netduino pro. It fails on the sendTo though.

Works just fine in the emulator though with raw and raw. :(

Guess the lwIP stack isn't quite as comprehensive as the other one.

#10 chedemefedeme

chedemefedeme

    New Member

  • Members
  • Pip
  • 8 posts

Posted 31 July 2011 - 04:19 PM

I believe that the emulator uses the closed-source RTIP networking stack instead of the lwIP open-source networking stack.

If this is supported in lwIP and it fits, we could certainly enable it.

Chris



Chris,

If there is anything you can do to enable this soon it would be greatly appreciated by many. In my situation I bought one netduino plus to test an application. If this can be made to work I'll almost instantly be purchasing several more to use for my ping testing application. I think your choices are either to fix what these guys are hitting with sockets or implement .net's ping() class, which may just handle more of this inherently.

#11 Chris Walker

Chris Walker

    Secret Labs Staff

  • Moderators
  • 7767 posts
  • LocationNew York, NY

Posted 31 July 2011 - 05:18 PM

I just reviewed the Netduino firmware to make sure we weren't disabling outgoing pings. The Netduino firmware does compile in ICMP support in the lwIP networking stack. It appears that there may be a bug in the .NET MF implementation of lwIP which supports incoming pings correctly...but does not support outgoing pings directly. Would those of you interested in ping support in NETMF please file and/or vote for a work item over on netmf.codeplex.com? The final .NET MF 4.2 beta is currently being wrapped up...and now is the time to get any last-minute features/fixed checked in. We file a lot of bug reports/fixes...so having this come from the community will make sure it doesn't get lost in the noise. Thank you, Chris

#12 ColinR

ColinR

    Advanced Member

  • Members
  • PipPipPip
  • 142 posts
  • LocationCape Town, South Africa

Posted 31 July 2011 - 05:40 PM

Issue created, please vote! http://netmf.codeple...m/workitem/1126

#13 Chris Walker

Chris Walker

    Secret Labs Staff

  • Moderators
  • 7767 posts
  • LocationNew York, NY

Posted 31 July 2011 - 07:11 PM

Voted!

#14 chedemefedeme

chedemefedeme

    New Member

  • Members
  • Pip
  • 8 posts

Posted 31 July 2011 - 08:56 PM

I also voted...but if this works in the emulator is this not somehow an issue with the selection of stuff in firmware on the netdunio rather than the .NET framework? I could easily be wrong but just asking.

#15 ColinR

ColinR

    Advanced Member

  • Members
  • PipPipPip
  • 142 posts
  • LocationCape Town, South Africa

Posted 02 August 2011 - 06:40 AM

That was quick!

Comments
wrote Tue at 6:19 AM
Resolved with changeset 12576.



#16 Glen

Glen

    Member

  • Members
  • PipPip
  • 26 posts

Posted 02 August 2011 - 02:06 PM

That was quick!

Good to hear. Thanks for posting that bug report.

#17 Glen

Glen

    Member

  • Members
  • PipPip
  • 26 posts

Posted 04 August 2011 - 12:28 AM

I downloaded the 4.2 RC today and am using the Netduino 4.2 beta 1 firmware. Still have it throw an exception when it hits this line
new Socket(AddressFamily.InterNetwork, SocketType.Raw, ProtocolType.Icmp);


#18 Chris Walker

Chris Walker

    Secret Labs Staff

  • Moderators
  • 7767 posts
  • LocationNew York, NY

Posted 04 August 2011 - 12:40 AM

I downloaded the 4.2 RC today and am using the Netduino 4.2 beta 1 firmware. Still have it throw an exception when it hits this line

new Socket(AddressFamily.InterNetwork, SocketType.Raw, ProtocolType.Icmp);

Hi Glen,

We'll need to update the firmware to incorporate the new RC code. Should be posted by next week, for all three Netduinos (regular, Plus, and Mini).

Chris

#19 Glen

Glen

    Member

  • Members
  • PipPip
  • 26 posts

Posted 04 August 2011 - 12:43 AM

Hi Glen,

We'll need to update the firmware to incorporate the new RC code. Should be posted by next week, for all three Netduinos (regular, Plus, and Mini).

Chris


Ah, ok. I was thinking since you had mentioned earlier:

The Netduino firmware does compile in ICMP support in the lwIP networking stack. It appears that there may be a bug in the .NET MF implementation of lwIP which supports incoming pings correctly...but does not support outgoing pings directly.

That it would work straight away. I'm looking forward to next week in that case :)

#20 Glen

Glen

    Member

  • Members
  • PipPip
  • 26 posts

Posted 07 August 2011 - 10:33 PM

With the latest firmware release today, it DOES seem to work for me now :)




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.