Before you start u need to do this:
First create a client server app
you need to also create your ping protocol
your classes should be like this
PingClient, PingProtocol and PingServer
Now here's your algorithm
send a ping request to your server i.e
ping [server-ip-address]
recieve the request on the server side
compare the ip-address with the server's ip-address
if they match send an acknowledgement back
if not have the client timeout