Reputation: 11
I read pcap packets in a loop and then try to timestamp those packets.
On a 2.6 kernel (e.g. centOs 6.8) it works correctly, but on 5.15 kernel (e.g. OEL 8) the time within 1 second hardly change 100µsec. Has this something to do with "NO_HZ: Reducing Scheduling-Clock Ticks" since there are more parameters in kernel 5.15 than in 2.6 the compiled program works correctly on my CentOs 6.8, but not on OEL 7 or 8.
Part of the code:
while ((prec = pcap_next_ex(cap, &header, &pkt_data)) >= 0) {
// more code
// Time in msec
struct timeval tv;
time_t sec_midnight = time(NULL) % 86400;
if (gettimeofday(&tv, NULL)) {
printf("ERROR\n");
}
double usec = (double) tv.tv_usec;
double frametime = (double) sec_midnight;
frametime = frametime + usec / 1000000.0;
struct timespec ts;
clock_gettime(CLOCK_REALTIME_COARSE, &ts);
printf("Frametime = %f %f %i\n", frametime, usec, ts.tv_nsec);
}
Output of the program:
Frametime = 31139.900089 900089.000000 899621443
Frametime = 31139.900145 900145.000000 899621443
Frametime = 31139.900200 900200.000000 899621443
Frametime = 31139.900256 900256.000000 899621443
Frametime = 31139.900311 900311.000000 899621443
Frametime = 31139.900366 900366.000000 899621443
Frametime = 31139.900422 900422.000000 899621443
Frametime = 31139.900477 900477.000000 899621443
Frametime = 31139.900533 900533.000000 899621443
==> When the second changes, the usec changes with a big step.
Frametime = 31140.543455 543455.000000 542621443
Frametime = 31140.543519 543519.000000 542621443
Frametime = 31140.543575 543575.000000 542621443
Frametime = 31140.543630 543630.000000 543621443
Frametime = 31140.543656 543656.000000 543621443
Frametime = 31140.543712 543712.000000 543621443
Frametime = 31140.543768 543768.000000 543621443
Frametime = 31140.543823 543823.000000 543621443
Frametime = 31140.543878 543878.000000 543621443
Upvotes: 1
Views: 45