ICMP ping address problem

Hi guys …

I’m trying to make the Arduino pull an IP address automatically but all I get in the serial is echo request failed.

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

byte mac[] = {0x00, 0xAA, 0xBB, 0xCC, 0xDE, 0x02}; // max address for ethernet shield
//byte ip[] = {192,168,2,177}; // ip address for ethernet shield
IPAddress pingAddr(8,8,8,8); // ip address to ping
IPAddress ip(Ethernet.localIP());
IPAddress gateway(Ethernet.gatewayIP());
IPAddress subnet(Ethernet.subnetMask());

SOCKET pingSocket = 0;

char buffer [256];
ICMPPing ping(pingSocket, (uint16_t)random(0, 255));

void setup() 
{
  // start Ethernet
  Ethernet.begin(mac, ip, gateway,subnet);
  Serial.begin(9600);
}

void loop()
{
  ICMPEchoReply echoReply = ping(pingAddr, 4);
  if (echoReply.status == SUCCESS)
  {
    sprintf(buffer,
            "Reply[%d] from: %d.%d.%d.%d: bytes=%d time=%ldms TTL=%d",
            echoReply.data.seq,
            echoReply.addr[0],
            echoReply.addr[1],
            echoReply.addr[2],
            echoReply.addr[3],
            REQ_DATASIZE,
            millis() - echoReply.data.time,
            echoReply.ttl);
  }
  else
  {
    sprintf(buffer, "Echo request failed; %d", echoReply.status);
  }
  Serial.println(buffer);
  delay(500);
}

In a PC or a raspberry Pi(any master) if I have several auduinos attached to it each doing several other functions(slaves),how can we differentiate each of them?Please help.

@123_able: Don't hijack a thread if your problem is not associated with the OP's problem. Open your own thread!

I'm trying to make the Arduino pull an IP address automatically but all I get in the serial is echo request failed.

This code:

IPAddress ip(Ethernet.localIP());
IPAddress gateway(Ethernet.gatewayIP());
IPAddress subnet(Ethernet.subnetMask());

won't result in a working network configuration as you configure illegal values. For auto-configuration (DHCP) use the constructor:

Ethernet.begin(mac);

If the Arduino is connected to your Internet router this should work.