From c6ba30e6871ee37b00dc0c5aa8830040ec39c177 Mon Sep 17 00:00:00 2001 From: Quentin Date: Sun, 15 Sep 2019 18:10:45 +0200 Subject: [PATCH] Better logging and probably fix --- r/thunder_configure.R | 2 +- src/algo_thunder.c | 32 ++++++++++++++++++-------------- 2 files changed, 19 insertions(+), 15 deletions(-) diff --git a/r/thunder_configure.R b/r/thunder_configure.R index b343e7a..001b869 100644 --- a/r/thunder_configure.R +++ b/r/thunder_configure.R @@ -3,7 +3,7 @@ library(sqldf) library(plyr) library(cowplot) -thunder_ms <- read.csv("thunder_configure_2_ms.csv") +thunder_ms <- read.csv("thunder_configure_4_ms.csv") thunder_ms <- sqldf("select run,jmax,links,latency, CAST(latency as real) / 1000. as lat_ms from thunder_ms") thunder_ms$links <- as.factor(thunder_ms$links) diff --git a/src/algo_thunder.c b/src/algo_thunder.c index 6914bf9..77c58dc 100644 --- a/src/algo_thunder.c +++ b/src/algo_thunder.c @@ -185,7 +185,7 @@ void on_block (struct evt_core_ctx* ctx, void* raw) { if (thunderc->received_pkts_on_link[bi->i] >= bi->missing) goto release; if (thunderc->blacklisted[bi->i] >= bi->missing) goto release; - puts(bi->reason); + printf("%s\n", bi->reason); thunderc->blacklisted[bi->i] = bi->missing; release: @@ -249,6 +249,10 @@ void classify(struct evt_core_ctx* ctx, struct evt_core_fdinfo* fdinfo, struct b for (int i = 0; i < thunderc->total_links; i++) { int64_t remote_delta = 0, local_delta = 0, owd_difference = 0; + + uint64_t expected = i <= link_id ? thunderc->received_pkts_on_link[link_id] : thunderc->received_pkts_on_link[link_id] - 1; + if (thunderc->received_pkts_on_link[i] != expected) continue; + remote_delta = li[i].delta_t; local_delta = thunderc->rcv_delta_t_per_link[i]; if (remote_delta > 1000 || local_delta > 10000) continue; // Too many time elapsed for useful comparison @@ -256,26 +260,26 @@ void classify(struct evt_core_ctx* ctx, struct evt_core_fdinfo* fdinfo, struct b owd_difference = local_delta - remote_delta; if (owd_difference <= thunderc->allowed_jitter_ms && owd_difference >= -thunderc->allowed_jitter_ms) continue; - struct block_info bi = {0}; - bi.is_timeout = 0; + struct block_info *bi = malloc(sizeof(struct block_info)); + bi->app_ctx = app_ctx; bi->is_timeout = 1; + bi->is_timeout = 0; + bi->app_ctx = app_ctx; + sprintf(bi->reason, "Erreur"); if (owd_difference < -thunderc->allowed_jitter_ms) { - bi.i = i; - bi.app_ctx = app_ctx; - bi.missing = thunderc->received_pkts_on_link[i]; - sprintf(bi.reason, " Packet Too Late - Blocked link %d owd_diff=%ld, local_delta=%ld, remote_delta=%ld\n", i, owd_difference, local_delta, remote_delta); + bi->i = i; + bi->missing = expected; + sprintf(bi->reason, " Packet Too Late - Blocked link %d owd_diff=%ld, local_delta=%ld, remote_delta=%ld", i, owd_difference, local_delta, remote_delta); } else if (owd_difference > thunderc->allowed_jitter_ms) { - bi.i = link_id; - bi.app_ctx = app_ctx; - bi.missing = thunderc->received_pkts_on_link[link_id]; - sprintf(bi.reason, " Packet Too Late - Blocked link %d owd_diff=%ld, local_delta=%ld, remote_delta=%ld\n", link_id, owd_difference, local_delta, remote_delta); + bi->i = link_id; + bi->missing = thunderc->received_pkts_on_link[link_id]; + sprintf(bi->reason, " Packet Too Late - Blocked link %d owd_diff=%ld, local_delta=%ld, remote_delta=%ld", link_id, owd_difference, local_delta, remote_delta); } else { fprintf(stderr, "Algorithm is wrong\n"); exit(EXIT_FAILURE); } - - on_block(ctx, &bi); + on_block(ctx, bi); } } @@ -289,13 +293,13 @@ void classify(struct evt_core_ctx* ctx, struct evt_core_fdinfo* fdinfo, struct b struct block_info *bi = malloc(sizeof(struct block_info)); bi->i = i; bi->app_ctx = app_ctx; bi->missing = expected; bi->is_timeout = 1; + sprintf(bi->reason, " Missing Packet - Timeout for link %d after %ldms (expected: %ld, seen: %ld)", i, timeout, expected, thunderc->received_pkts_on_link[i]); if (timeout <= 0) { on_block(ctx, bi); //printf(" Missing Packet - Blocked link %d (expected: %ld, seen: %ld)\n", i, expected, thunderc->received_pkts_on_link[i]); continue; } - sprintf(bi->reason, " Missing Packet - Timeout for link %d after %ldms (expected: %ld, seen: %ld)\n", i, timeout, expected, thunderc->received_pkts_on_link[i]); set_timeout (ctx, timeout, bi, on_block); if (ctx->verbose > 1) {