Re: [vpp-dev] Clock time in pcap
I wasn’t clear enough: your proposal uses a single clock object across multiple threads. The counters returned by the x86_64 rdtsc instruction are per-core, and differ by a noticeable fraction of a second... HTH... Dave From: vpp-dev@lists.fd.io On Behalf Of srinimurth...@gmail.com Sent: Friday, April 16, 2021 4:18 AM To: vpp-dev@lists.fd.io Subject: Re: [vpp-dev] Clock time in pcap Hi Dave, Thanks! for the response. My proposed changes are in pcap_add_packet, which is called from dispatch_pcap_trace and pcap_add_buffer after aquiring spin lock. So, I think it's MT-safe. Thanks, Srini -=-=-=-=-=-=-=-=-=-=-=- Links: You receive all messages sent to this group. View/Reply Online (#19226): https://lists.fd.io/g/vpp-dev/message/19226 Mute This Topic: https://lists.fd.io/mt/82117060/21656 Group Owner: vpp-dev+ow...@lists.fd.io Unsubscribe: https://lists.fd.io/g/vpp-dev/unsub [arch...@mail-archive.com] -=-=-=-=-=-=-=-=-=-=-=-
Re: [vpp-dev] Clock time in pcap
Hi Dave, Thanks! for the response. My proposed changes are in pcap_add_packet, which is called from dispatch_pcap_trace and pcap_add_buffer after aquiring spin lock. So, I think it's MT-safe. Thanks, Srini -=-=-=-=-=-=-=-=-=-=-=- Links: You receive all messages sent to this group. View/Reply Online (#19223): https://lists.fd.io/g/vpp-dev/message/19223 Mute This Topic: https://lists.fd.io/mt/82117060/21656 Group Owner: vpp-dev+ow...@lists.fd.io Unsubscribe: https://lists.fd.io/g/vpp-dev/unsub [arch...@mail-archive.com] -=-=-=-=-=-=-=-=-=-=-=-
Re: [vpp-dev] Clock time in pcap
The proposed fix won’t work correctly with multiple threads. Instead, please address the issue in pcap_write(...) by adding an offset argument and passing the required offset as f64 seconds since the epoch: f64 seconds_since_vpp_started = vlib_time_now(vm); f64 seconds_since_the_epoch = unix_time_now(); f64 vpp_start_time = seconds_since_the_epoch – seconds_since_vpp_started; In the while-loop which writes out pm->pcap_data, add the supplied offset to each packet header timestamp. Simplest to convert the stored (sec,usec) data back to f64 seconds, add the supplied constant, then store as (sec,usec). HTH... Dave From: vpp-dev@lists.fd.io On Behalf Of srinimurth...@gmail.com Sent: Thursday, April 15, 2021 9:55 AM To: vpp-dev@lists.fd.io Subject: [vpp-dev] Clock time in pcap Hello Team, I observe that timestamp captured in pcap collected on VPP with below command captures the time since VPP started rather than the clock time. "pcap trace rx tx max 1 intfc any file rxt.pcap" Further looking into code(version 20.05), I observe that time since VPP restarted is being set. Code reference below. static inline void pcap_add_buffer (pcap_main_t * pm, struct vlib_main_t *vm, u32 buffer_index, u32 n_bytes_in_trace) { vlib_buffer_t *b = vlib_get_buffer (vm, buffer_index); u32 n = vlib_buffer_length_in_chain (vm, b); i32 n_left = clib_min (n_bytes_in_trace, n); f64 time_now = vlib_time_now (vm); <<--- ... } After modifying code as below, packets are timestamped with clock time. src/vppinfra/pcap.h ++#include /** Min/Max Packet bytes */ u32 min_packet_bytes, max_packet_bytes; /** Time */ ++ clib_timebase_t timebase; } pcap_main_t; src/vppinfra/pcap_funcs.h pcap_add_packet() { ++ vlib_main_t *vm = vlib_get_main(); ++ if(!(pm->timebase.clib_time)) ++{ ++clib_timebase_init (&(pm->timebase), 0 /* GMT */ , ++ CLIB_TIMEBASE_DAYLIGHT_NONE, ++>clib_time /* share the system clock */ ); ++ } ++ time_now = clib_timebase_now(&(pm->timebase)); } My questions below. 1)Currently in fdio version 20.05 packets captured in pcap are timestamped with the time since VPP restarted. Is this understanding correct? 2) If answer to above question is "YES", then is the fix correct? Thanks, Srini -=-=-=-=-=-=-=-=-=-=-=- Links: You receive all messages sent to this group. View/Reply Online (#19215): https://lists.fd.io/g/vpp-dev/message/19215 Mute This Topic: https://lists.fd.io/mt/82117060/21656 Group Owner: vpp-dev+ow...@lists.fd.io Unsubscribe: https://lists.fd.io/g/vpp-dev/unsub [arch...@mail-archive.com] -=-=-=-=-=-=-=-=-=-=-=-
[vpp-dev] Clock time in pcap
Hello Team, I observe that timestamp captured in pcap collected on VPP with below command captures the time since VPP started rather than the clock time. "pcap trace rx tx max 1 intfc any file rxt.pcap" Further looking into code(version 20.05), I observe that time since VPP restarted is being set. Code reference below. static inline void pcap_add_buffer (pcap_main_t * pm, struct vlib_main_t *vm, u32 buffer_index, u32 n_bytes_in_trace) { vlib_buffer_t *b = vlib_get_buffer (vm, buffer_index); u32 n = vlib_buffer_length_in_chain (vm, b); i32 n_left = clib_min (n_bytes_in_trace, n); f64 time_now = vlib_time_now (vm); <<--- ... } After modifying code as below, packets are timestamped with clock time. src/vppinfra/pcap.h ++#include /** Min/Max Packet bytes */ u32 min_packet_bytes, max_packet_bytes; /** Time */ ++ clib_timebase_t timebase; } pcap_main_t; src/vppinfra/pcap_funcs.h pcap_add_packet() { ++ vlib_main_t *vm = vlib_get_main(); ++ if(!(pm->timebase.clib_time)) ++{ ++ clib_timebase_init (&(pm->timebase), 0 /* GMT */ , ++ CLIB_TIMEBASE_DAYLIGHT_NONE, ++ >clib_time /* share the system clock */ ); ++ } ++ time_now = clib_timebase_now(&(pm->timebase)); } My questions below. 1)Currently in fdio version 20.05 packets captured in pcap are timestamped with the time since VPP restarted. Is this understanding correct? 2) If answer to above question is "YES", then is the fix correct? Thanks, Srini -=-=-=-=-=-=-=-=-=-=-=- Links: You receive all messages sent to this group. View/Reply Online (#19213): https://lists.fd.io/g/vpp-dev/message/19213 Mute This Topic: https://lists.fd.io/mt/82117060/21656 Group Owner: vpp-dev+ow...@lists.fd.io Unsubscribe: https://lists.fd.io/g/vpp-dev/unsub [arch...@mail-archive.com] -=-=-=-=-=-=-=-=-=-=-=-