aspose file tools*
The moose likes Sockets and Internet Protocols and the fly likes Java Ping and RTT Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Soft Skills this week in the Jobs Discussion forum!
JavaRanch » Java Forums » Java » Sockets and Internet Protocols
Bookmark "Java Ping and RTT" Watch "Java Ping and RTT" New topic
Author

Java Ping and RTT

subham soni
Greenhorn

Joined: Jun 30, 2013
Posts: 3
I need to write the TCP socket program client-server architecture for ping command and also determine the Round Trip Time of the Host connected too.. I can ping the host by isReachable() method but what to do about RTT? please help
Henry Wong
author
Sheriff

Joined: Sep 28, 2004
Posts: 19060
    
  40

subham soni wrote:I need to write the TCP socket program client-server architecture for ping command and also determine the Round Trip Time of the Host connected too.. I can ping the host by isReachable() method but what to do about RTT? please help



I don't think that there is a way to calculate RTT from one host, to any random host. Pinging another host works because there is a standard service -- and even then, it isn't guaranteed to work reliably. If you want to calculate RTT, you will need to install agents on the remote host (either something you write, or just install, if you find some sort of service).


Regardless, it isn't had to do (if you want to write it yourself). To calculate RTT, you need a pinger and ponger. The ponger is just a reflector (running on the remote host) -- that just bounces the same packet back. And as for the pinger, it just takes a time stamp, sends a packet to the ponger, gets the response, takes another time stamp; and if the returned packet is confirmed to be the same packet, the RTT is the difference between the two timestamps.


Henry


Books: Java Threads, 3rd Edition, Jini in a Nutshell, and Java Gems (contributor)
subham soni
Greenhorn

Joined: Jun 30, 2013
Posts: 3
Ok to be frank I need to write java program(sockets) to implement the ping command
Henry Wong
author
Sheriff

Joined: Sep 28, 2004
Posts: 19060
    
  40

subham soni wrote:Ok to be frank I need to write java program(sockets) to implement the ping command


The nice thing here is that you don't need to worry about writing the ping program. Once you write the RTT program(s), ping is done. If you can get an RTT, then it is there. Of course, you have to modify the RTT program with a timeout, which you have to do for error handling anyway.

Henry
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Java Ping and RTT