ICMP (ping) and Telnet


Did someone already have tried to start an ICMP Ping inside a Telnet session?

My experience is that as soon the the “ping” is started the Telnet (TCP) session is reset (RST).
I am running a Telnet server on an Arduino Uno (1.01) with an Ethernet Shield.

With the simplest sketch below, without the “ping” function the Telnet is working.
With the ping function,while looping on the “ping” function a TCP RST is send to the client .

Any idea ?


// Trace
4 4.655949 TCP 60 telnet > 56676 [RST] Seq=1 Win=0 Len=0

// Script
#include <SPI.h>
#include <Ethernet.h>
#include <ICMPPing.h>

byte mac = {0xDE, 0xAD, 0xBE, 0xEF, 0xFE, 0xED}; // max address for ethernet shield
IPAddress ip (192,168,0,252); // ip address for ethernet shield
IPAddress gateway (192,168,0,1);
IPAddress subnet (255,255,255,0);
byte pingAddr = {195,130,131,38}; // ip address to ping
SOCKET pingSocket = 0;
int charsReceived = 0;
boolean connectFlag = 0;
char buffer [256];

EthernetServer myIPserver = 23;
EthernetClient myIPclient;
ICMPPing ping(pingSocket);

void setup()
Ethernet.begin(mac, ip, dns, gateway, subnet);

void loop()
if (myIPserver.available() && !connectFlag)
connectFlag = 1;
myIPclient = myIPserver.available();
ping(4, pingAddr, buffer);


void printPrompt()
charsReceived = 0;
myIPclient.print("\n> ");


The WizNet5100 (the chip on the Ethernet shield) supports 4 active sockets. The server software reserves all 4 sockets for incoming connections. It usually takes the first one (number 0) for the first incoming connection. So socket 0 is used for this telnet connection but your doing a ping on the same socket (you explicitly specified that in the constructor:

SOCKET pingSocket = 0;

  ICMPPing ping(pingSocket);

Try using pingSocket = 3, this might work, although, as I already wrote, the server software is reserving all sockets.

Thanks for the advice, in the mean time I have a workaround.
In the void setup ()
I’ just add:

myPing (1,0,pingBuff); // gratuitous ping at startup to cope with the TCP RST issue

No matter the IP address no error is generated and no reset is generated when starting a ping in the loop ();

I also note that ICMP ping doesn’t work on the loopback address ( and the system IP address itself :roll_eyes:



OK, using another socket number such 3 is also OK.

Thanks for the fast response