pkelsey / libuinet

a library version of FreeBSD's TCP/IP stack plus extras
750 stars 198 forks source link

Getting current time in libuinet. nanotime/microtime always writes tv_sec=1 #40

Open joerango opened 8 years ago

joerango commented 8 years ago

I am trying to make some changes to congestion control in libuinet. I need to track the current time (or up time). I have tried using the nanotime/microtime and nanouptime/microuptime functions in sys/time.h but the timespec/timeval struct returned always has tv_sec=1. It does not change.

A simple test to replicate this issue would be to add the following lines at the top of the cc_ack_received function in sys/netinet/tcp_input.c:

struct timespec ts;
getnanotime(&ts);
printf("Time= %ld\n", ts.tv_sec);

I tried to trace the function calls in the sys/ folder as well as the uinetkern*.c files but I can't figure out why the tv_sec value is always equal to 1.