checking active web sites or networking device

Dear,
below code related to my project , which is use Ether-card to pinging site or network device( now i use 192.168.5.1 as a sample ) if its active ( there is a reply ) LED over pin 7 will be on, if not its will be off and so on

my issue is how to modify below code to test multiple site(IP’s) and show active sites (ip’s) be LED

any friend can modify it for 4 IP

code below

#include <EtherCard.h>
int ledPin = 7;

static byte mymac = { 0x74,0x69,0x69,0x2D,0x30,0x31 };

byte Ethernet::buffer[700];
static uint32_t timer;
// called
static void gotPinged (byte* ptr) {
ether.printIp(">>> ping from: ",ptr);
}
void setup () {

pinMode(ledPin, OUTPUT);
Serial.begin(57600);
Serial.println("\n[pings]");
if (ether.begin(sizeof Ethernet::buffer,mymac)==0)
Serial.println( “sailed to access Ethernet controller”);
if (!ether.dhcpSetup())
Serial.println(“DHCP failed”);
ether.printIp("mac: ", ether.mymac);
ether.printIp("IP: ", ether.myip);
ether.printIp("GW: ", ether.gwip);

#if 1
// use dnc to locate the ip address we want to ping
if (ether.parseIp(ether.hisip, “192.168.5.1”));
Serial.println(“DNC failed”);

#endif
ether.printIp("SRV: ", ether.hisip);

// call this to report others pinging us
ether.registerPingCallback(gotPinged);
timer = -9999999; // start timing out right away
Serial.println();
}
void loop () {
digitalWrite(ledPin, LOW);
word len = ether.packetReceive(); // go receive new packets
word pos = ether.packetLoop(len); // respond to incoming pings

// report whenever a replt to out outgoining ping comes back
if (len > 0 && ether.packetLoopIcmpCheckReply(ether.hisip)) {
Serial.print(" “);
Serial.print((micros() - timer) * 0.001, 3);
Serial.println(” ms");
digitalWrite(ledPin, HIGH);
}
// ping a remote server once every few seconds
if (micros() - timer >= 1000000) {
ether.printIp("Pinging: ", ether.hisip);
timer = micros();
ether.clientIcmpRequest(ether.hisip);

}
}

You've got all the hard stuff done.

Just get all the IP's ready ahead of time, and keep track of which IP you've pinged by keeping a global variable containing the number of the IP in the cycle you pinged (ie, 0-3 for 4 IP's), and a global to track whether you've sent the ping request.

Then before sending a ping request, check those globals to figure out which IP to use.

Very thanks Can you modify the code for pinging below ip's and make pins 4,5,6,7 on when ip's give reply

Ip's 192.168.5.90 192.168.5.110 192.168.5.190 192.168.5.230

anything support please

Dear friend This issue need your support So please any idea help

Still need you friend

i have arduino with ethercard code below

#include <EtherCard.h>

static byte mymac[] = { 0x74,0x69,0x69,0x2D,0x30,0x31 };

byte Ethernet::buffer[700];
static uint32_t timer;
// called
static void gotPinged (byte* ptr) {
  ether.printIp(">>> ping from: ",ptr);
}
void setup () {
  
  Serial.begin(57600);
  Serial.println("\n[pings]");
  if (ether.begin(sizeof Ethernet::buffer,mymac)==0)
   Serial.println( "sailed to access Ethernet controller");
   if (!ether.dhcpSetup())
   Serial.println("DHCP failed");
  ether.printIp("mac:  ", ether.mymac);
  ether.printIp("IP:  ", ether.myip);
  ether.printIp("GW:  ", ether.gwip);

i get when ping come to arduino , serial monitor show the pc ip that made ping to arduino
can we modify this ping and run LED1 if ping come from PC1 and LED 2 if ping come from PC2 and so on

and so on

can we modify this ping and run LED1 if ping come from PC1 and LED 2 if ping come from PC2 and so on

Yes, you may.

can you please

Threads merged. Please don't cross-post

can you please

If I was sufficiently motivated. I'm not.

  ether.printIp(">>> ping from: ",ptr);

Look at how that function takes the data pointed by ptr, and sends it to the serial port.

That will give you a clue what you would want to compare what ptr point to to. If ptr points to "192.1.168.13", then define a char array containing "192.1.168.13", and compare ptr to that array, using strcmp(). If they match, turn pin n on.

it can not by merged the subject is different

the subject is different

Really?

pinging site or network device( now i use 192.168.5.1 as a sample ) if its active ( there is a reply ) LED over pin 7 will be on, if not its will be off and so on

arduino make a pig to sites and Make LED on is different from

pc make Ping to Arduino and arduino sense that ping and check to turn the LED on

Pinging is not always a reliable way of determining device availability. My web and email servers used to be behind a router using port forwarding from the public IP to the localnet private IP of the servers. If you pinged the public IP, the router would respond to the ping, but that would not determine if the web server or email server was up and running.

all the servers in local network so the will take static ips

That makes it easy. You only need to keep track of the last octet. The first three should be the same on a localnet. These are the same: 192.168.5. Then the last octets are these: 90 110 190 230

Build the IP. Ping the IP. Put the results in a 4 entry array.