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

generate delay distribution histogram to RTT test

git-svn-id: https://zerberus.eonerc.rwth-aachen.de:8443/svn/s2ss/trunk@230 8ec27952-4edc-4aab-86aa-e87bb2611832
This commit is contained in:
Steffen Vogel 2014-09-09 12:07:57 +00:00
parent 270c5eb18f
commit 9a074922b5

View file

@ -19,20 +19,25 @@
#include "utils.h"
int sd;
int running = 1;
#define CLOCK_ID CLOCK_MONOTONIC_RAW
#define RTT_MIN 20
#define RTT_MAX 100
#define RTT_RESOLUTION 2
#define RTT_HIST (int) ((RTT_MAX - RTT_MIN) / RTT_RESOLUTION)
void quit(int sig, siginfo_t *si, void *ptr)
{
close(sd);
exit(EXIT_SUCCESS);
running = 0;
}
int main(int argc, char *argv[])
{
if (argc != 4) {
printf("Usage: %s TEST LOCAL REMOTE\n", argv[0]);
printf(" TEST has to be 'latency' for now\n");
printf(" TEST has to be 'rtt' for now\n");
printf(" LOCAL is a IP:PORT combination of the local host\n");
printf(" REMOTE is a IP:PORT combination of the remote host\n\n");
printf("Simulator2Simulator Server %s (built on %s %s)\n", BLU(VERSION), MAG(__DATE__), MAG(__TIME__));
@ -64,7 +69,7 @@ int main(int argc, char *argv[])
debug(1, "We listen at %s:%u", inet_ntoa(n.local.sin_addr), ntohs(n.local.sin_port));
debug(1, "We sent to %s:%u", inet_ntoa(n.remote.sin_addr), ntohs(n.remote.sin_port));
if (!strcmp(argv[1], "latency")) {
if (!strcmp(argv[1], "rtt")) {
struct msg m = MSG_INIT(sizeof(struct timespec) / sizeof(float));
struct timespec *ts1 = (struct timespec *) &m.data;
struct timespec *ts2 = malloc(sizeof(struct timespec));
@ -74,15 +79,20 @@ int main(int argc, char *argv[])
double rtt_min = LLONG_MAX;
double avg = 0;
int run = 0;
int bar;
unsigned hist[RTT_HIST];
memset(hist, 0, RTT_HIST * sizeof(unsigned));
#if 1 /* Print header */
fprintf(stdout, "%17s", "timestamp");
#endif
fprintf(stdout, "%5s%10s%10s%10s%10s\n", "seq", "rtt", "min", "max", "avg");
while (1) {
while (running) {
m.sequence++;
run++;
clock_gettime(CLOCK_ID, ts1);
msg_send(&m, &n);
@ -96,7 +106,11 @@ int main(int argc, char *argv[])
if (rtt < rtt_min) rtt_min = rtt;
avg += rtt;
run++;
/* Update histogram */
bar = (rtt * 1000 / RTT_RESOLUTION) - (RTT_MIN / RTT_RESOLUTION);
if (bar < RTT_HIST)
hist[bar]++;
#if 1
struct timespec ts;
@ -104,11 +118,16 @@ int main(int argc, char *argv[])
fprintf(stdout, "%17.6f", ts.tv_sec + ts.tv_nsec / 1e9);
#endif
fprintf(stdout, "%5u%10.3f%10.3f%10.3f%10.3f\n", m.sequence, 1e3 * rtt, 1e3 * rtt_min, 1e3 * rtt_max, 1e3 * avg / run);
fprintf(stdout, "%5u%10.3f%10.3f%10.3f%10.3f\n", m.sequence,
1e3 * rtt, 1e3 * rtt_min, 1e3 * rtt_max, 1e3 * avg / run);
}
free(ts2);
hist_plot(hist, RTT_HIST);
}
close(sd);
return 0;
}