Re: Ping (ICMP) in Java over TCP?

From: Tilman Bohn (myfirstname_at_gmx.net)
Date: 02/22/05


Date: Tue, 22 Feb 2005 06:24:56 GMT

In message <HaidnWfD6pqXFYffRVn-gg@rogers.com>,
00_CumPeeWearD12 wrote on Mon, 21 Feb 2005 20:16:55 -0500:

> According to the Java FAQ, ICMP ping is not possible.
> http://www.ibiblio.org/javafaq/javafaq.html#ping
>
> But how does this Java Applet calculate the Round Trip Time?
> http://www.vonage-forum.com/voip-speed-test/

  Using TCP, as far as I can see.

> I assume RRT = Ping.. right?

  No, it's simply the round trip time. You can send data containing
timestamps back and forth over TCP and calculate it that way. Of course
the resulting value could be completely different for TCP than for UDP
or ICMP, but it's a valid ballpark estimate.

  BTW, TCP has had its own internal (optional) timestamp mechanism since
1992 (RFC 1323). The meaning of the numbers in that are completely un-
defined and implementation dependent (they only need to be monotonically
increasing). However, if the original sender knows when it sent a given
segment, it knows how long it took the corresponding ACK to return to
it => RTT. I'm not aware of any way to access this low level facility
from Java though, short of using JNI to interface to pcap or such-like.

> If so, is there any sample Java code that
> implements ICMP over TCP?

  This question doesn't make any sense. ICMP and TCP are on the same
layer of the protocol stack. If anything, ICMP can be considered to
reside on a _lower_ layer. What you probably mean is how to do echo and
echo reply type communications over TCP. Simple: Just send timestamps
back and forth, and include the most recently received timestamp from
the other side in the next reply. You probably want to at least disable
the Nagle algorithm for that (TCP_NODELAY, which can be set on any
socket within Java), but the results will still be somewhat arbitrary
for various reasons.

-- 
Cheers, Tilman
`Boy, life takes a long time to live...'      -- Steven Wright


Relevant Pages

  • Re: HOW TO: write Java client to call WSE 2.0 web server over TCP
    ... There isn't a soap over TCP standard yet so therefore you'll run into compat ... WSE TCP messaging uses DIME framing so whatever toolkit you use ... non IIS hosted web service. ... > call this webservice over TCP using a java client. ...
    (microsoft.public.dotnet.framework.webservices.enhancements)
  • Re: Multi thread (2nd post)
    ... In Java I used several method, and even sending whole object by TCP ... but someone have told me that pipes are much better and are new fashion ... I have spent for the protocol quite a time ... ...
    (microsoft.public.vc.language)
  • Re: Java process and .Net process and Win32 communication?
    ... communication over TCP or UDP will ... Of course Java supports TCP and UDP protocols. ...
    (microsoft.public.win32.programmer.networks)
  • Re: suggestion about chat s/w based protocol tcp or udp?
    ... i'm writing java application for chat ... or udp for voice based chat ... and tcp for texted based ... java and Java are some "all ways are the same":) then guys i mean all ...
    (comp.lang.java.programmer)
  • Re: How do I alter values for TCP timeouts (SRTT & RTO)
    ... >> will have a quick TCP response and dynamically alter its RTT to say 25 secs. ... >> give less weight of SRTT to the last measured RTT. ... >> Windows 2000 TCP Retransmission Behavior ... A Smoothed Round Trip Time ...
    (microsoft.public.win2000.general)