diff --git a/server/include/path.h b/server/include/path.h index 3bcc7ecd5..387148d02 100644 --- a/server/include/path.h +++ b/server/include/path.h @@ -51,11 +51,23 @@ struct path struct msg *current; /** A pointer to the previously received message */ struct msg *previous; + + /** The thread id for this path */ + pthread_t recv_tid; + /** A second thread id for fixed rate sending thread */ + pthread_t sent_tid; + /** A pointer to the libconfig object which instantiated this path */ + config_setting_t *cfg; /** Histogram of sequence number displacement of received messages */ struct hist hist_seq; /** Histogram for delay of received messages */ struct hist hist_delay; + + /** Last message received */ + struct timespec ts_recv; + /** Last message sent */ + struct timespec ts_sent; /** Counter for sent messages to all outgoing nodes */ unsigned int sent; @@ -67,13 +79,6 @@ struct path unsigned int skipped; /** Counter for dropped messages due to reordering */ unsigned int dropped; - - /** The thread id for this path */ - pthread_t recv_tid; - /** A second thread id for fixed rate sending thread */ - pthread_t sent_tid; - /** A pointer to the libconfig object which instantiated this path */ - config_setting_t *cfg; }; /** Create a path by allocating dynamic memory. */ @@ -118,6 +123,7 @@ int path_reset(struct path *p); */ void path_print_stats(struct path *p); + /** Fills the provided buffer with a string representation of the path. * * Format: source => [ dest1 dest2 dest3 ] diff --git a/server/src/hooks.c b/server/src/hooks.c index 1cc99ba79..3d2c9097d 100644 --- a/server/src/hooks.c +++ b/server/src/hooks.c @@ -13,8 +13,8 @@ *********************************************************************************/ #include -#include +#include "timing.h" #include "config.h" #include "msg.h" #include "hooks.h" @@ -50,7 +50,10 @@ hook_cb_t hook_lookup(const char *name) int hook_print(struct msg *m, struct path *p, struct timespec *ts) { - /* Print every message once to stdout */ + struct msg *m = p->current; + struct timespec ts = MSG_TS(m); + + fprintf(stdout, "%.3e+", time_delta(&ts, &p->ts_recv)); /* Print delay */ msg_fprint(stdout, m); return 0; @@ -67,8 +70,10 @@ int hook_tofixed(struct msg *m, struct path *p, struct timespec *ts) int hook_ts(struct msg *m, struct path *p, struct timespec *ts) { - m->ts.sec = ts->tv_sec; - m->ts.nsec = ts->tv_nsec; + struct msg *m = p->current; + + m->ts.sec = p->ts_recv.tv_sec; + m->ts.nsec = p->ts_recv.tv_nsec; return 0; } diff --git a/server/src/path.c b/server/src/path.c index fa1d8c20b..bcd6b2eb9 100644 --- a/server/src/path.c +++ b/server/src/path.c @@ -34,6 +34,8 @@ static void path_write(struct path *p) debug(1, "Sent %u messages to node '%s'", sent, it->node->name); p->sent += sent; + + clock_gettime(CLOCK_REALTIME, &p->ts_sent); } } @@ -75,8 +77,7 @@ skip: for(;;) { int recv = node_read(p->in, p->pool, p->poolsize, p->received, p->in->combine); /** @todo Replace this timestamp by hardware timestamping */ - struct timespec ts; - clock_gettime(CLOCK_REALTIME, &ts); + clock_gettime(CLOCK_REALTIME, &p->ts_recv); debug(10, "Received %u messages from node '%s'", recv, p->in->name); @@ -104,10 +105,6 @@ skip: for(;;) { /* Update sequence histogram */ hist_put(&p->hist_seq, dist); - - /* Update delay histogram */ - struct timespec sent = MSG_TS(p->current); - hist_put(&p->hist_delay, time_delta(&sent, &ts)); /* Handle simulation restart */ if (p->current->sequence == 0 && abs(dist) >= 1) {