How do I check that a device with a specific IP Address is still part of my network without searching for all the IP Addresses that I am connected to. Is it possible to ping an IP address of a connected hardware directly?
-
Why not just send something to that device that it responds to (i.e. does it respond to ping?) and see if it responds? – Owen Hartnett Jun 06 '18 at 16:46
1 Answers
IP address is just an identifier, i.e. a number. Using that number you can try to reach a device that is assigned to that number by your network infrastructure (like network routers).
You say that you have some
IP Addresses that I am connected to
If you are already connected to the device's IP address using TCP, HTTP or any other protocol that has long-running connections, the easiest is to just check if that connection is alive. If you can store all your connections in a hashtable (or map/dictionary) and searching would be very quick.
If you are not really connected, a good way to solve this would be to implement a ping/pong (aka ECHO) scheme: when you send a network packet (or request) with some data and expect that data to come back to you within a reasonable time interval. This could be based on ICMP or your own custom protocol.
Alternatively you can implement a "heartbeat" scheme (or keep-alive, see also: https://serverfault.com/questions/361071/what-is-the-difference-between-keepalive-and-heartbeat , Do I need to heartbeat to keep a TCP connection open? , https://en.wikipedia.org/wiki/HTTP_persistent_connection ), where each device sends a periodic "I'm alive" packet do your side.

- 5,841
- 1
- 23
- 33