1
0
Fork 0
mirror of https://git.rwth-aachen.de/acs/public/villas/node/ synced 2025-03-09 00:00:00 +01:00

added new fields ts_{sent,recv} for a timestamp of last sent/received messages

This commit is contained in:
Steffen Vogel 2015-06-10 15:05:36 +02:00
parent d2c0e79746
commit 2597fff110
3 changed files with 25 additions and 17 deletions

View file

@ -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 ]

View file

@ -13,8 +13,8 @@
*********************************************************************************/
#include <string.h>
#include <time.h>
#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;
}

View file

@ -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) {