Commit f4b2d16c authored by Joanne Hugé's avatar Joanne Hugé

Fix timestamps for etf queue

parent b863db00
......@@ -34,6 +34,7 @@ typedef struct thread_param {
int interval;
int max_cycles;
int priority;
int etf_offset;
thread_stat_t stats;
} thread_param_t;
......@@ -78,11 +79,11 @@ struct timespec measures_start;
struct timespec measures_end;
static void help(char *argv[]) {
printf("Usage: %s -f IF [-abethgv] [-d BUF_LEN] [-i USEC] [-l N] [-p PRIO] [-q PACKET_PRIO] [-r USEC]\n\n", argv[0]);
printf("Usage: %s -f IF [-abthgv] [-e ETF_OFFSET] [-d BUF_LEN] [-i USEC] [-l N] [-p PRIO] [-q PACKET_PRIO] [-r USEC]\n\n", argv[0]);
printf(" -a Run the real time thread on CPU1\n");
printf(" -b Measure RTT\n");
printf(" -d BUF_LEN Set the length of tx buffer\n");
printf(" -e Set a txtime (to be used in an ETF qdisc)\n");
printf(" -e ETF_OFFSET Set a txtime with an offset of ETF_OFFSET us (to be used in an ETF qdisc)\n");
printf(" -f IF Set the network interface to be used\n");
printf(" -g Print histograms to sdtout on exit\n");
printf(" -h Show help\n");
......@@ -119,13 +120,17 @@ static void *packet_sending_thread(void *p) {
if (sched_setscheduler(0, SCHED_FIFO, &priority))
error(EXIT_FAILURE, errno, "Couldn't set priority");
clock_gettime(CLOCK_MONOTONIC, &next);
next_txtime = next.tv_sec * NSEC_PER_SEC + next.tv_nsec;
// Wait around 1 second
next_txtime += (1 * NSEC_PER_SEC / param->interval) * param->interval;
// Send packet while thread is sleeping
next_txtime += (param->interval) / 2;
if(enable_etf) {
// Measure from CLOCK_TAI to generate timestamp
clock_gettime(CLOCK_TAI, &next);
next_txtime = next.tv_sec * NSEC_PER_SEC + next.tv_nsec;
next_txtime += param->etf_offset;
}
else {
next_txtime = 0;
}
clock_gettime(CLOCK_MONOTONIC, &next);
clock_gettime(CLOCK_MONOTONIC, &measures_start);
// Packet sending loop
for (stats->nb_cycles = 0;; stats->nb_cycles++) {
......@@ -136,7 +141,9 @@ static void *packet_sending_thread(void *p) {
do_tsn_task(param, next_txtime);
add_ns(&next, param->interval);
next_txtime += (param->interval);
if(enable_etf)
next_txtime += param->interval;
clock_nanosleep(CLOCK_MONOTONIC, TIMER_ABSTIME, &next, NULL);
}
......@@ -331,7 +338,7 @@ static void process_options(int argc, char *argv[]) {
int network_if_specified = 0;
for (;;) {
int c = getopt(argc, argv, "abd:ef:ghi:l:p:q:r:tv");
int c = getopt(argc, argv, "abd:e:f:ghi:l:p:q:r:tv");
if (c == -1)
break;
......@@ -352,6 +359,7 @@ static void process_options(int argc, char *argv[]) {
break;
case 'e':
enable_etf = 1;
param->etf_offset = atoi(optarg) * 1000;
break;
case 'f':
network_if_specified = 1;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment