tcpdump mailing list archives

Re: Convert timeval to timestamp


From: "Guy Harris" <guy () alum mit edu>
Date: Mon, 20 Mar 2006 22:30:11 -0800 (PST)

Luis Del Pino wrote:
What function do I have to use to convert a struct timeval (struct
pcap_pkthdr {struct timeval ts;...}) to timestamp units(u_int32)?

i like calculating jitter in RTP streams.

So by "timestamp units" do you mean IP/TCP time stamp units (which,
according to RFC 791, are in units of milliseconds since midnight), or RTP
time stamps (which appear to have a resolution that depends on the payload
type)?

As Jefferson Ogata noted, a "struct timeval" is a combination of "seconds
since January 1, 1970, 00:00:00 GMT" and "microseconds since that second".
 You convert that to "microseconds since January 1, 1970, 00:00:00 GMT" by
multiplying the tv_sec value by 1000000 and adding the tv_usec value to
it; that would be a 64-bit calculation.  Converting that to units other
than microseconds is left as an exercise to the reader.

-
This is the tcpdump-workers list.
Visit https://lists.sandelman.ca/ to unsubscribe.


Current thread: