1PCAP-TSTAMP(7)         Miscellaneous Information Manual         PCAP-TSTAMP(7)
2
3
4

NAME

6       pcap-tstamp - packet time stamps in libpcap
7

DESCRIPTION

9       When capturing traffic, each packet is given a time stamp representing,
10       for incoming packets, the arrival time of the packet and, for  outgoing
11       packets, the transmission time of the packet.  This time is an approxi‐
12       mation of the arrival or transmission time.  If it is supplied  by  the
13       operating  system  running  on  the  host on which the capture is being
14       done, there are several reasons why it might  not  precisely  represent
15       the arrival or transmission time:
16
17              if  the  time stamp is applied to the packet when the networking
18              stack receives the packet, the networking stack  might  not  see
19              the  packet  until an interrupt is delivered for the packet or a
20              timer event causes the networking  device  driver  to  poll  for
21              packets,  and  the  time  stamp  might  not be applied until the
22              packet has had some processing done by other code  in  the  net‐
23              working stack, so there might be a significant delay between the
24              time when the last bit of the packet is received by the  capture
25              device and when the networking stack time-stamps the packet;
26
27              the  timer used to generate the time stamps might have low reso‐
28              lution, for example, it might be a timer updated once  per  host
29              operating  system  timer  tick,  with  the host operating system
30              timer ticking once every few milliseconds;
31
32              a high-resolution timer might use a counter that runs at a  rate
33              dependent  on  the  processor  clock speed, and that clock speed
34              might be adjusted upwards or downwards over time and  the  timer
35              might not be able to compensate for all those adjustments;
36
37              the host operating system's clock might be adjusted over time to
38              match a time standard to which the host is  being  synchronized,
39              which  might  be done by temporarily slowing down or speeding up
40              the clock or by making a single adjustment;
41
42              different CPU cores on a multi-core  or  multi-processor  system
43              might  be  running  at  different speeds, or might not have time
44              counters all synchronized, so packets time-stamped by  different
45              cores might not have consistent time stamps.
46
47       In  addition,  packets  time-stamped  by different cores might be time-
48       stamped in one order and added to the queue of packets for  libpcap  to
49       read  in  another  order,  so  time  stamps  might not be monotonically
50       increasing.
51
52       Some capture devices on some platforms  can  provide  time  stamps  for
53       packets; those time stamps are usually high-resolution time stamps, and
54       are usually applied to the packet when the first or  last  bit  of  the
55       packet arrives, and are thus more accurate than time stamps provided by
56       the host operating system.  Those time stamps might  not,  however,  be
57       synchronized with the host operating system's clock, so that, for exam‐
58       ple, the time stamp of a packet might not correspond to the time  stamp
59       of an event on the host triggered by the arrival of that packet.
60
61       Depending  on  the capture device and the software on the host, libpcap
62       might  allow  different  types  of  time  stamp  to   be   used.    The
63       pcap_list_tstamp_types(3PCAP)  routine  provides,  for a packet capture
64       handle  created  by  pcap_create(3PCAP)  but  not  yet   activated   by
65       pcap_activate(3PCAP),  a list of time stamp types supported by the cap‐
66       ture device for that handle.  The list might be empty, in which case no
67       choice  of  time stamp type is offered for that capture device.  If the
68       list is not empty, the pcap_set_tstamp_type(3PCAP) routine can be  used
69       after a pcap_create() call and before a pcap_activate() call to specify
70       the type of time stamp to be used on the device.  The time stamp  types
71       are  listed  here;  the  first value is the #define to use in code, the
72       second      value      is       the       value       returned       by
73       pcap_tstamp_type_val_to_name(3PCAP)        and        accepted       by
74       pcap_tstamp_type_name_to_val(3PCAP).
75
76            PCAP_TSTAMP_HOST - host
77                 Time stamp provided by the host on which the capture is being
78                 done.   The  precision  of this time stamp is unspecified; it
79                 might or might not be synchronized with  the  host  operating
80                 system's clock.
81
82            PCAP_TSTAMP_HOST_LOWPREC - host_lowprec
83                 Time stamp provided by the host on which the capture is being
84                 done.  This is a low-precision time stamp, synchronized  with
85                 the host operating system's clock.
86
87            PCAP_TSTAMP_HOST_HIPREC - host_hiprec
88                 Time stamp provided by the host on which the capture is being
89                 done.  This is a high-precision time stamp; it might or might
90                 not  be  synchronized with the host operating system's clock.
91                 It    might    be    more    expensive    to    fetch    than
92                 PCAP_TSTAMP_HOST_LOWPREC.
93
94            PCAP_TSTAMP_ADAPTER - adapter
95                 Time  stamp provided by the network adapter on which the cap‐
96                 ture is being done.  This is  a  high-precision  time  stamp,
97                 synchronized with the host operating system's clock.
98
99            PCAP_TSTAMP_ADAPTER_UNSYNCED - adapter_unsynced
100                 Time  stamp provided by the network adapter on which the cap‐
101                 ture is being done.  This is a high-precision time stamp;  it
102                 is not synchronized with the host operating system's clock.
103
104       By  default, when performing a live capture or reading from a savefile,
105       time stamps are supplied as seconds since  January  1,  1970,  00:00:00
106       UTC,  and microseconds since that seconds value, even if higher-resolu‐
107       tion time stamps are available from the capture device or in the  save‐
108       file.   If, when reading a savefile, the time stamps in the file have a
109       higher resolution than one microsecond, the additional digits of  reso‐
110       lution are discarded.
111
112       The  pcap_set_tstamp_precision(3PCAP)  routine  can  be  used  after  a
113       pcap_create() call and after a pcap_activate() call to specify the res‐
114       olution  of  the time stamps to get for the device.  If the hardware or
115       software  cannot   supply   a   higher-resolution   time   stamp,   the
116       pcap_set_tstamp_precision()  call  will  fail, and the time stamps sup‐
117       plied after the pcap_activate() call will have microsecond resolution.
118
119       When           opening            a            savefile,            the
120       pcap_open_offline_with_tstamp_precision(3PCAP)                      and
121       pcap_fopen_offline_with_tstamp_precision(3PCAP) routines can be used to
122       specify  the resolution of time stamps to be read from the file; if the
123       time stamps in the file have a lower resolution, the fraction-of-a-sec‐
124       ond  portion of the time stamps will be scaled to the specified resolu‐
125       tion.
126
127       The pcap_get_tstamp_precision(3PCAP) routine returns the resolution  of
128       time  stamps  that  will be supplied; when capturing packets, this does
129       not reflect the actual precision of the  time  stamp  supplied  by  the
130       hardware  or  operating  system and, when reading a savefile, this does
131       not indicate the actual precision of time stamps in the file.
132

SEE ALSO

134       pcap(3PCAP)
135
136
137
138                                 8 March 2015                   PCAP-TSTAMP(7)
Impressum