From 7e7db6d6df41e3e3be943954c75b44823444c8ed Mon Sep 17 00:00:00 2001 From: Quentin Date: Fri, 11 Oct 2019 16:00:56 +0200 Subject: [PATCH] Explain is a new parameter --- src/algo_lightning.c | 20 +++++++++++++------- 1 file changed, 13 insertions(+), 7 deletions(-) diff --git a/src/algo_lightning.c b/src/algo_lightning.c index 24f4fe1..9854b17 100644 --- a/src/algo_lightning.c +++ b/src/algo_lightning.c @@ -51,6 +51,7 @@ struct light_ctx { size_t monit_pkt_size; uint8_t csv; uint8_t is_measlat; + uint8_t explain; }; void algo_lightning_free(void* v) { @@ -73,6 +74,7 @@ void algo_lightning_init(struct evt_core_ctx* ctx, struct algo_ctx* app_ctx, str lightc->fast_count = lightc->total_links / 2; lightc->sleep_duration = 500; lightc->csv = 0; + lightc->explain = 0; uint64_t window = 2000; if (ap->algo_specific_params != NULL) { @@ -86,7 +88,8 @@ void algo_lightning_init(struct evt_core_ctx* ctx, struct algo_ctx* app_ctx, str sscanf(token, "window=%ld", &window); sscanf(token, "sent_past_links=%d", &lightc->sent_past_links); sscanf(token, "csv=%d", &lightc->csv); - sscanf(token, "measlat=%c", &lightc->is_measlat); + sscanf(token, "measlat=%d", &lightc->is_measlat); + sscanf(token, "explain=%d", &lightc->explain); } } @@ -107,6 +110,7 @@ void algo_lightning_init(struct evt_core_ctx* ctx, struct algo_ctx* app_ctx, str printf("sent_past_links = %d\n", lightc->sent_past_links); printf("csv = %s\n", lightc->csv ? "yes" : "no"); printf("measlat = %s\n", lightc->is_measlat ? "yes" : "no"); + printf("explain = %s\n", lightc->explain ? "yes" : "no"); } void monitoring(struct evt_core_ctx* ctx, struct evt_core_fdinfo* fdinfo, struct buffer_packet* bp) { @@ -123,11 +127,13 @@ void monitoring(struct evt_core_ctx* ctx, struct evt_core_fdinfo* fdinfo, struct uint8_t *prev_links = &ap->fmt.content.link_monitoring_lightning.dyn_struct; int16_t *remote_stats = (int16_t*)(prev_links + sizeof(uint8_t) * lightc->sent_past_links); - printf("(monitoring.stats) "); - for (int i = 0; i < lightc->total_links; i++) { - printf("%d, ", remote_stats[i]); + if (lightc->explain) { + printf("(monitoring.stats) "); + for (int i = 0; i < lightc->total_links; i++) { + printf("%d, ", remote_stats[i]); + } + printf("\n"); } - printf("\n"); int64_t pkt_id = ap->fmt.content.link_monitoring_lightning.id; int64_t missing = pkt_id - (lightc->pkt_rcv_id + 1); @@ -150,7 +156,7 @@ void monitoring(struct evt_core_ctx* ctx, struct evt_core_fdinfo* fdinfo, struct te->detected_at = now; te->link_id = link_id; te->pkt_id = miss_id; - printf("(monitoring.delay) packet=%ld, link=%d, state=%s\n", miss_id, link_id, ooo_state_str[te->state]); + if (lightc->explain) printf("(monitoring.delay) packet=%ld, link=%d, state=%s\n", miss_id, link_id, ooo_state_str[te->state]); } // Update current packet status @@ -160,7 +166,7 @@ void monitoring(struct evt_core_ctx* ctx, struct evt_core_fdinfo* fdinfo, struct te2->pkt_id = pkt_id; te2->link_id = link_id; te2->finished_at = now; - printf("(monitoring.rcv) packet=%ld, link=%d, state=%s\n", pkt_id, link_id, ooo_state_str[te2->state]); + if (lightc->explain) printf("(monitoring.rcv) packet=%ld, link=%d, state=%s\n", pkt_id, link_id, ooo_state_str[te2->state]); } int deliver(struct evt_core_ctx* ctx, struct evt_core_fdinfo* fdinfo, struct buffer_packet* bp) {