As part of a project I'm working on, I need to ping computers on my network with the Arduino Ethernet shield. I saw several old posts on the forum asking how to send out pings from the ethernet shield, so I've made my ping code into a library, available here:
I tried to use this tiny little library in my arduino project because i lost connection between the ethernet shield and my router. After reconnection i always had to reset the arduino to make ethernet working again.
So my idea was to use the ICMPPing every hour to find out if my connection still exists. If not i do a "ethernet.begin(..)" again and with this the w5100 is not resetted but restarted and in most cases the net is working again.
But i have the weird behavior that every second hour the ping gets a timeout even when the net is ok.
Here is a small part of my logfile (because i couldn't believe it i extended the text which is given back so that i can see how many loops have been passed in every case):
I changed the used socket number from 0 to 1 with no effect.
Concerning the net my application is reacting passive. That means that in the BIG loop nothing happens if there is no request from another computer. If there is a request it is executed and then the loop starts again. So when i am calling the ping there is no other net activity pending on the arduino.
Using socket number 3 all pings are successful.
I expanded the ping-example with the WebServer example (from the Ethernet library) and with socket #0 and 1 i had no success.
Then i tried socket number 3 in my own application and since then everything is fine.
Thanks to Blake for this routine. I tried to examine the source but it is really tricky and goes very deep so i didn't try to make any changes.