Timestamp of IP datagrams

S

Stefan Weber

Hi

I'm looking for a way to get an as accurate as possible timestamp of an
IP datagram.

The Java API doesn't provide something like that. With TCP, one is
working with the stream abstraction anyway and the DatagramPacket (UDP)
doens't have such a method.

Does anybody know a workaround? Of course, calling
System.currentTimeMillis() after receiving/sending something over the
socket could work, but I don't know how accurate this is...

Thanks and regards,

Stefan Weber
 
S

Steve W. Jackson

Stefan Weber said:
Hi

I'm looking for a way to get an as accurate as possible timestamp of an
IP datagram.

The Java API doesn't provide something like that. With TCP, one is
working with the stream abstraction anyway and the DatagramPacket (UDP)
doens't have such a method.

Does anybody know a workaround? Of course, calling
System.currentTimeMillis() after receiving/sending something over the
socket could work, but I don't know how accurate this is...

Thanks and regards,

Stefan Weber

By definition, UDP makes no guarantees of delivery, or about the order
in which such packets arrive at their destinations. So they could
simply not arrive, or take a siesta along the way for whatever reason.
Also, the sender's time may not match the receiver's time. So what time
do you want to use?
 
N

noident

Now, I'm not a Java programmer, but I've done a bit of TCP/IP
programming, including raw sockets in C. I don't think any API in any
language will provide a timestamp of an IP/TCP/UDP or any other
protocol's packet/segment/datagram. The reason for that is that there
is no timestamp field in any of them. As far as I know only ICMP
Timestamp/Timestamp_reply have timestamps.
 
M

Mark Space

Now, I'm not a Java programmer, but I've done a bit of TCP/IP
programming, including raw sockets in C. I don't think any API in any
language will provide a timestamp of an IP/TCP/UDP or any other
protocol's packet/segment/datagram. The reason for that is that there
is no timestamp field in any of them. As far as I know only ICMP
Timestamp/Timestamp_reply have timestamps.

Yup, what he said.

There *IS* no time stamp, unless you send one in the data, and that
could be rendered moot if the packet is fragmented for networks with a
small MTU.

Adding a time stamp when your app first looks at the packet is the best
approach, unless you need to send the time stamp from the other side, in
which case you do have to send your own.

Some low level routines will, I think, record a time stamp for you when
the packet shows up. For example, the kernel module IPFilter does this
for network sniffers, I think. But I doubt there's any Java package for
direct IPFilter access. You'd have to roll your own.

TTFN.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,776
Messages
2,569,603
Members
45,189
Latest member
CryptoTaxSoftware

Latest Threads

Top