From c20117188cb8e69c31a01a16fcf4b71f725a2b8e Mon Sep 17 00:00:00 2001 From: Quentin Dufour Date: Tue, 15 Oct 2019 14:22:45 +0200 Subject: [PATCH] explain switch --- r/lightning_begin.R | 8 ++++---- r/tor_owd.R | 14 +++++++++++++- src/algo_lightning.c | 18 +++++++++++------- 3 files changed, 28 insertions(+), 12 deletions(-) diff --git a/r/lightning_begin.R b/r/lightning_begin.R index d47654a..7e3e98d 100644 --- a/r/lightning_begin.R +++ b/r/lightning_begin.R @@ -10,7 +10,7 @@ ggplot(data=link_info, aes(x=timestamp, y=link, color=speed)) + theme_classic() -xx <- read.csv("../res/tmp_graph/r.csv") +xx <- read.csv("../res/tmp_light/a.csv") xx2 <- sqldf("select packet_id,1.0 * MIN(latency) / 1000.0 as lat,way from xx group by packet_id,way") ggplot(data=xx2, aes(x=packet_id, y=lat, color=way)) + geom_line() + @@ -21,7 +21,7 @@ ggplot(data=xx2, aes(x=packet_id, y=lat, color=way)) + xx4 <- sqldf("select packet_id,1.0 * latency / 1000.0 as lat,way from xx where flag = 0") ggplot(data=xx4, aes(x=packet_id, y=lat, color=way)) + geom_line() + - coord_cartesian(ylim=c(0,2000)) + + coord_cartesian(ylim=c(0,1000)) + #geom_point() + theme_classic() @@ -29,7 +29,7 @@ ggplot(data=xx4, aes(x=packet_id, y=lat, color=way)) + xx5 <- sqldf("select packet_id,1.0 * latency / 1000.0 as lat,way from xx where flag = 1") ggplot(data=xx5, aes(x=packet_id, y=lat, color=way)) + geom_line() + - coord_cartesian(ylim=c(0,2000)) + + coord_cartesian(ylim=c(0,1000)) + #geom_point() + theme_classic() @@ -57,5 +57,5 @@ xx3 <- sqldf("select packet_id,1.0 * latency / 1000.0 as lat,flag,way from xx") xx3$flag <- factor(xx3$flag) ggplot(data=xx3, aes(x=lat, group=flag, color=flag)) + stat_ecdf(pad = FALSE) + - #coord_cartesian(xlim=c(0,2000)) + + coord_cartesian(xlim=c(0,1200)) + theme_classic() diff --git a/r/tor_owd.R b/r/tor_owd.R index 3922804..159d599 100644 --- a/r/tor_owd.R +++ b/r/tor_owd.R @@ -7,8 +7,9 @@ tor_owd <- read.csv("tor_owd.csv") for (run_id in c(0:39)) { print(run_id) - sel_owd <- filter(tor_owd, measure_type != "delta", run == paste("./out/nBV7DWLpj8WA6Be3-",run_id,sep="")) + sel_owd <- filter(tor_owd, measure_type != "delta", measure_type != 'd_client_server', measure_type != 'd_server_client', measure_type != 'd_server_client_abs', measure_type != 'd_client_server_abs', run == paste("./out/nBV7DWLpj8WA6Be3-",run_id,sep="")) ggplot(data = sel_owd, aes(x = packet_id, y=latency_ms, color=measure_type)) + + coord_cartesian(ylim=c(0,600)) + geom_line() + theme_classic() + ggsave(paste("tor_owd_",run_id,".png", sep = ""), dpi=150, dev='png', height=18, width=32, units="cm") @@ -18,3 +19,14 @@ ggplot(data = sqldf("select * from tor_owd where measure_type='delta_abs'"), aes stat_ecdf(pad = FALSE) + coord_cartesian(xlim = c(0,500)) + theme_classic() + +ggplot(data = sqldf("select * from tor_owd where measure_type='d_client_server_abs' or measure_type='d_server_client_abs'"), aes(x=latency_ms)) + + stat_ecdf(pad = FALSE) + + coord_cartesian(xlim = c(0,500)) + + theme_classic() + +ggplot(data = sqldf("select * from tor_owd where packet_id < 500 and run = './out/nBV7DWLpj8WA6Be3-16' and (measure_type='d_client_server' or measure_type='d_server_client')"), aes(y=latency_ms,x=packet_id,color=measure_type)) + + geom_line() + + coord_cartesian(ylim=c(-250,250)) + + geom_point() + + theme_classic() diff --git a/src/algo_lightning.c b/src/algo_lightning.c index 9854b17..6fb618e 100644 --- a/src/algo_lightning.c +++ b/src/algo_lightning.c @@ -232,10 +232,11 @@ void algo_lightning_update_stats (struct light_ctx *lightc, struct stat_entry *s delta = timespec_get_unit (&temp_time, MILISEC); break; } - printf("(stats.compute) packet=%ld, link=%d, status=%s, delta=%ld\n", lightc->historic[i].pkt_id, l, ooo_state_str[lightc->historic[i].state], delta); + + if (lightc->explain) printf("(stats.compute) packet=%ld, link=%d, status=%s, delta=%ld\n", lightc->historic[i].pkt_id, l, ooo_state_str[lightc->historic[i].state], delta); stats[l].link_id = l; if (delta > stats[l].max_ooo) { - printf("(stats.local) link=%d, delta=%ld\n", l, delta); + if (lightc->explain) printf("(stats.local) link=%d, delta=%ld\n", l, delta); stats[l].max_ooo = delta; } } @@ -244,7 +245,7 @@ void algo_lightning_update_stats (struct light_ctx *lightc, struct stat_entry *s for (int i = 0; i < lightc->total_links; i++) { lightc->local_stats[i] = stats[i].max_ooo; if (lightc->remote_stats[i] > stats[i].max_ooo) { - printf("(stats.remote) link=%d, delta=%d\n", i, lightc->remote_stats[i]); + if (lightc->explain) printf("(stats.remote) link=%d, delta=%d\n", i, lightc->remote_stats[i]); stats[i].max_ooo = lightc->remote_stats[i]; } } @@ -287,11 +288,14 @@ int send_message(struct evt_core_ctx* ctx, struct buffer_packet* bp) { links[i] = lightc->prev_links[(lightc->pkt_sent_id - (i + 1)) % MAX_LINKS]; } memcpy(remote_stats, &lightc->local_stats, sizeof(int16_t) * lightc->total_links); - printf("(send.stats) "); - for (int i = 0; i < lightc->total_links; i++) { - printf("%d, ", remote_stats[i]); + + if (lightc->explain) { + printf("(send.stats) "); + for (int i = 0; i < lightc->total_links; i++) { + printf("%d, ", remote_stats[i]); + } + printf("\n"); } - printf("\n"); lightc->prev_links[lightc->pkt_sent_id % MAX_LINKS] = lightc->selected_link;