tcpdump mailing list archives

Re: Fwd: Re: Printing nanosecond timestamp information in raw output


From: Maik Jäkel <email () maikjaekel de>
Date: Sat, 29 Dec 2012 12:44:38 +0100 (CET)

@Guy: Once again thanks for your detailed answer. I'll try to modify pcap then.


@James and Rixed:
I just ran a test on my device. The test takes 150 timestamps and calculates the difference between of every timestamp 
and the timestamp taken after it.
My device is a little older. Its cpu only runs at 800MHz and is a single core cpu. That output looks pretty good to me, 
even though there is a zero diff here and there.

I also ran the test in an infinity loop while putting the cpu under a stress test. The results are the same. The values 
are either 30517,30518 or 0ns. 


This is my loop code (res is a timespec struct):

for(i = 0; i < 150; i++){
  clock_gettime(CLOCK_REALTIME, &res);

  secDiff = res.tv_sec - oldSec;
  nsecDiff = 1000000000 * secDiff + res.tv_nsec - oldNSec;

  oldSec = res.tv_sec;
  oldNSec = res.tv_nsec;


  printf("Diff: %ldns\n", nsecDiff);
}


This is the output:

Diff: 30518ns
Diff: 30518ns
Diff: 30517ns
Diff: 30518ns
Diff: 30517ns
Diff: 30518ns
Diff: 30518ns
Diff: 30517ns
Diff: 30518ns
Diff: 30517ns
Diff: 30518ns
Diff: 30517ns
Diff: 30518ns
Diff: 30518ns
Diff: 30517ns
Diff: 30518ns
Diff: 30517ns
Diff: 30518ns
Diff: 30517ns
Diff: 30518ns
Diff: 30518ns
Diff: 30517ns
Diff: 30518ns
Diff: 0ns
Diff: 30517ns
Diff: 30518ns
Diff: 30518ns
Diff: 30517ns
Diff: 30518ns
Diff: 30517ns
Diff: 30518ns
Diff: 30517ns
Diff: 30518ns
Diff: 30518ns
Diff: 30517ns
Diff: 30518ns
Diff: 30517ns
Diff: 30518ns
Diff: 30517ns
Diff: 30518ns
Diff: 30518ns
Diff: 30517ns
Diff: 30518ns
Diff: 30517ns
Diff: 30518ns
Diff: 30517ns
Diff: 30518ns
Diff: 30518ns
Diff: 30517ns
Diff: 30518ns
Diff: 30517ns
Diff: 30518ns
Diff: 30518ns
Diff: 30517ns
Diff: 0ns
Diff: 30518ns
Diff: 30517ns
Diff: 30518ns
Diff: 30517ns
Diff: 30518ns
Diff: 30518ns
Diff: 30517ns
Diff: 30518ns
Diff: 30517ns
Diff: 30518ns
Diff: 30517ns
Diff: 30518ns
Diff: 30518ns
Diff: 30517ns
Diff: 30518ns
Diff: 30517ns
Diff: 30518ns
Diff: 30518ns
Diff: 30517ns
Diff: 30518ns
Diff: 30517ns
Diff: 30518ns
Diff: 30517ns
Diff: 30518ns
Diff: 30518ns
Diff: 30517ns
Diff: 30518ns
Diff: 0ns
Diff: 30517ns
Diff: 30518ns
Diff: 30517ns
Diff: 30518ns
Diff: 30518ns
Diff: 30517ns
Diff: 30518ns
Diff: 30517ns
Diff: 30518ns
Diff: 30517ns
Diff: 30518ns
Diff: 30518ns
Diff: 30517ns
Diff: 30518ns
Diff: 30517ns
Diff: 30518ns

----- Ursprüngliche Mail -----
Von: rixed () happyleptic org
An: tcpdump-workers () lists tcpdump org
CC: "Maik Jäkel" <email () maikjaekel de>
Gesendet: Samstag, 29. Dezember 2012 10:15:51
Betreff: Re: [tcpdump-workers] Fwd: Re: Printing nanosecond timestamp information in raw output

I didn't know a better way, though and hoped that the execution time between the reception of the packet and taking 
the timestamp is relatively constant (with an uncertainty of 4ns or so).

On a 1.2GHz cpu clock, as is typical of android devices these days, that
would be 5 clock ticks, ie 5 ARM instructions at best. I'd be very
surprised if the uncertainty for such a long periple from reception to
timestamping were that low. Please keep the list informed when you have
measured the actual variation between timestamps of outgoing packets.
_______________________________________________
tcpdump-workers mailing list
tcpdump-workers () lists tcpdump org
https://lists.sandelman.ca/mailman/listinfo/tcpdump-workers

Current thread: