How would you approach this project?

As a task for my latest endeavour into college education I have been asked to code an application that can monitor when a number of remote devices have been disconnected from the network using IP addresses.

My idea was to utilise the PING function, and loop through the range of addresses until it finds one that does not respond, my only problem is that although I know how to PING in C++, I am struggling to find how I can make my program "react" to the results i.e. using an IF statement.

Various people have pointed me in various directions, for example outputting to a text document or suing scripting, but I was wondering if anyone here would be able to take the time to explain in a little more detail exactly what this would entail.

Many Thanks

Martin


If your using the built-in OS ping functionality, then you can have some fun by trying to read the response it gives to stdout. Your best bet would be to pipe the output of it into a file.

e.g ping 127.0.0.1 > response_127_0_0_1.txt

Once you have it in the file, you can read the file and parse the results.

A much better way to do it is to create the sockets and ping packets yourself. Then you can interpret the response from the host and set your own timeouts etc. The Socket coding will be a bit trickier, but the solution is overall alot more elegant.
I agree with Zaita with what he said. Main thing is how much time do you have to finish this project? As if you do have some good spare time to sit down and make it - I'd do the one Zaita said here:
A much better way to do it is to create the sockets and ping packets yourself. Then you can interpret the response from the host and set your own timeouts etc. The Socket coding will be a bit trickier, but the solution is overall alot more elegant.

It would come out a lot better in the long run :)
I have a considerable amount of time yes. Any suggestions with regards to resources (books, online articles) that may help with the socket coding?

Thanks

Martin
It really depends upon a number of factors, you say devices... what kind of devices are we talking about here? Do you have access to these devices or are they like black boxes from your point of view?

Normally the most reliable way is to let the devices multicast their existence over the net i.e. sending packages without waiting for answer. That way you can timeout the devices when they go off-line, you also can detect new devices easily as they come on-line regardless of what IP address they have.

see e.g. http://en.wikipedia.org/wiki/Multicast
Last edited on
@anders: For a simple application like this, your solution does include alot of un-necessary complexity. He'd have to configure, or install software on every potential device he wished to monitor. Not to mention the un-necessary network traffic generated by devices with it installed, but not required to be monitored.

Having it driven from the monitoring application via a ping is going to be alot smaller, quicker, easier and more maintainable. Also causing less network traffic.
Topic archived. No new replies allowed.