lightning is promising

This commit is contained in:
Quentin 2019-10-08 16:48:00 +02:00
parent bf9663116a
commit 11f9b46fe1
2 changed files with 27 additions and 1 deletions

18
r/lightning_begin.R Normal file
View file

@ -0,0 +1,18 @@
library(ggplot2)
library(sqldf)
library(plyr)
library(cowplot)
link_info <- read.csv("/tmp/h.csv")
ggplot(data=link_info, aes(x=timestamp, y=link, color=speed)) +
#geom_line() +
geom_point() +
theme_classic()
xx <- read.csv("/tmp/f.csv")
xx2 <- sqldf("select packet_id,MIN(latency) as lat,way from xx group by packet_id,way")
ggplot(data=xx2, aes(x=packet_id, y=lat, color=way)) +
#geom_line() +
geom_point() +
theme_classic()

View file

@ -40,6 +40,7 @@ struct light_ctx {
int sent_past_links;
struct timespec window;
size_t monit_pkt_size;
uint8_t csv;
};
void algo_lightning_free(void* v) {
@ -61,6 +62,7 @@ void algo_lightning_init(struct evt_core_ctx* ctx, struct algo_ctx* app_ctx, str
lightc->sent_past_links = lightc->total_links;
lightc->fast_count = lightc->total_links / 2;
lightc->sleep_duration = 500;
lightc->csv = 0;
uint64_t window = 2000;
if (ap->algo_specific_params != NULL) {
@ -73,6 +75,7 @@ void algo_lightning_init(struct evt_core_ctx* ctx, struct algo_ctx* app_ctx, str
sscanf(token, "recovery=%d", &lightc->sleep_duration);
sscanf(token, "window=%ld", &window);
sscanf(token, "sent_past_links=%d", &lightc->sent_past_links);
sscanf(token, "csv=%c", &lightc->csv);
}
}
@ -87,6 +90,7 @@ void algo_lightning_init(struct evt_core_ctx* ctx, struct algo_ctx* app_ctx, str
printf("recovery = %d ms\n", lightc->sleep_duration);
printf("window check = %ld ms\n", window);
printf("sent_past_links = %d\n", lightc->sent_past_links);
printf("csv = %s\n", lightc->csv ? "activated" : "deacticated");
}
void monitoring(struct evt_core_ctx* ctx, struct evt_core_fdinfo* fdinfo, struct buffer_packet* bp) {
@ -257,6 +261,7 @@ int algo_lightning_on_datagram(struct evt_core_ctx* ctx, struct evt_core_fdinfo*
struct timespec now, sel_link_last, temp_time;
set_now(&now);
uint64_t now_timestamp = timespec_get_unit(&now, MILISEC);
// Select fast link
sel_link_last = now;
@ -268,6 +273,7 @@ int algo_lightning_on_datagram(struct evt_core_ctx* ctx, struct evt_core_fdinfo*
}
}
send_message (ctx, bp);
printf("%ld,%d,fast\n", now_timestamp, lightc->selected_link);
// Select slow link
sel_link_last = now;
@ -280,8 +286,10 @@ int algo_lightning_on_datagram(struct evt_core_ctx* ctx, struct evt_core_fdinfo*
}
timespec_diff (&now, &sel_link_last, &temp_time);
uint64_t elapsed = timespec_get_unit(&temp_time, MILISEC);
if (elapsed >= lightc->sleep_duration)
if (elapsed >= lightc->sleep_duration) {
send_message (ctx, bp);
printf("%ld,%d,slow\n", now_timestamp, lightc->selected_link);
}
mv_buffer_rtof (&app_ctx->br, fdinfo);
return 0;