1PCAP-TSTAMP(7) Miscellaneous Information Manual PCAP-TSTAMP(7)
2
3
4
6 pcap-tstamp - packet time stamps in libpcap
7
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 pcap_tstamp_type_val_to_name()
73 and accepted by pcap_tstamp_name_to_val().
74
75 PCAP_TSTAMP_HOST - host
76 Time stamp provided by the host on which the capture is being
77 done. The precision of this time stamp is unspecified; it
78 might or might not be synchronized with the host operating
79 system's clock.
80
81 PCAP_TSTAMP_HOST_LOWPREC - host_lowprec
82 Time stamp provided by the host on which the capture is being
83 done. This is a low-precision time stamp, synchronized with
84 the host operating system's clock.
85
86 PCAP_TSTAMP_HOST_HIPREC - host_hiprec
87 Time stamp provided by the host on which the capture is being
88 done. This is a high-precision time stamp; it might or might
89 not be synchronized with the host operating system's clock.
90 It might be more expensive to fetch than
91 PCAP_TSTAMP_HOST_LOWPREC.
92
93 PCAP_TSTAMP_ADAPTER - adapter
94 Time stamp provided by the network adapter on which the cap‐
95 ture is being done. This is a high-precision time stamp,
96 synchronized with the host operating system's clock.
97
98 PCAP_TSTAMP_ADAPTER_UNSYNCED - adapter_unsynced
99 Time stamp provided by the network adapter on which the cap‐
100 ture is being done. This is a high-precision time stamp; it
101 is not synchronized with the host operating system's clock.
102
104 pcap_set_tstamp_type(3PCAP), pcap_list_tstamp_types(3PCAP),
105 pcap_tstamp_type_val_to_name(3PCAP), pcap_tstamp_name_to_val(3PCAP)
106
107
108
109 22 August 2010 PCAP-TSTAMP(7)