Great news! Thanks for testing this, Glen.With the latest firmware release today, it DOES seem to work for me now
Chris
  | ||||||||||||||
PING a host on the network
Started by chedemefedeme, Jul 27 2011 12:07 AM
25 replies to this topic
#21Posted 08 August 2011 - 12:30 AM Great news! Thanks for testing this, Glen. Chris #22Posted 10 August 2011 - 12:45 AM
Cool. Thanks for sharing this! I just tried it and it does appear to work (Wireshark screenshot below - notice the 2 ICMP lines). My only complaint is that I wish the ReceiveFrom command (Part of the Framework) would not throw an exception when it times out. If you are trying to ping all the addresses in your LAN, it will take much longer because of this. Update: Actually, the overhead from the caught exceptions is not too bad (still don't like it). I set the timeout to 100ms and the exception overhead was 200ms. Bad, but I can live with that. So you could scan the 255 address in your local LAN in about 82 seconds. Of course, I'm still hoping UDP broadcast will work sometime soon... -Valkyrie-MT #23Posted 10 August 2011 - 03:41 AM
I guess you could spin some threads and do more than one at a time and keep track of which ones respond and don't. Might get that time down a bit.
#24Posted 29 December 2011 - 04:20 AM
>> With the latest firmware release today, it DOES seem to work for me now
This is the beta firmware?
Or is it released now?
#25Posted 17 March 2013 - 06:11 PM If anyone is interested I've made some alterations to this program to make it act as an automated pingbox.
This is my first foray in to the *duino world, after finally finding a real life problem I needed to solve.
Currently my version will send a ping to our dns server(I work for one of Norways oldest ISP's) and if it works it will blink the onboard led. I've made it trigger on a buttonpush instead of just launching in to the ping on boot. This way I can use it as verification tool when testing modems.
The next bit wil be to add a second led to indicate wethter dhcp works or not.
This is my version of programs.cs:
using System; using System.Threading; using System.Net; using System.Net.Sockets; using Microsoft.SPOT; using Microsoft.SPOT.Hardware; using SecretLabs.NETMF.Hardware; using SecretLabs.NETMF.Hardware.NetduinoPlus; namespace NetduinoPlusApplication1 { public class Program { static OutputPort led = new OutputPort(Pins.ONBOARD_LED, false); static void ledblink(OutputPort led, bool state) { led.Write(state); Thread.Sleep(250); } public static void Main() { InterruptPort button = new InterruptPort(Pins.ONBOARD_SW1, false, Port.ResistorMode.Disabled, Port.InterruptMode.InterruptEdgeBoth); button.OnInterrupt += new NativeEventHandler(button_OnInterrupt); Thread.Sleep(Timeout.Infinite); } static void button_OnInterrupt(uint data1, uint data2, DateTime time) { RawSocketPing pingSocket = null; IPAddress remoteAddress = IPAddress.Parse("195.159.0.100"); int dataSize = 512, ttlValue = 128, sendCount = 8; try { // Create a RawSocketPing class that wraps all the ping functionality pingSocket = new RawSocketPing( ttlValue, dataSize, sendCount, 123 ); // Set the destination address we want to ping pingSocket.PingAddress = remoteAddress; // Initialize the raw socket pingSocket.InitializeSocket(); // Create the ICMP packets to send pingSocket.BuildPingPacket(); // Actually send the ping request bool success = pingSocket.DoPing(); if (success) { //Debug.Print("Hey, we got a response!"); ledblink(led, true); ledblink(led, false); ledblink(led, true); ledblink(led, false); } } catch (SocketException err) { Debug.Print("Socket error occured: " + err.Message); } finally { if (pingSocket != null) pingSocket.Close(); } return; } } } #26Posted 05 January 2014 - 09:07 PM While this may not be of use to anyone, I've uploaded my project on Github. The project has advanced a bit towards an actual appliance we can use. https://github.com/gittela/pingbox 0 user(s) are reading this topic0 members, 0 guests, 0 anonymous users | ||||||||||||||
|
||||||||||||||
This webpage is licensed under a Creative Commons Attribution-ShareAlike License. | ||||||||||||||