Add a flip flap strategy

This commit is contained in:
Quentin 2019-10-16 15:22:16 +02:00
parent 98a51962eb
commit b1a0194832

View file

@ -21,6 +21,25 @@ char* ooo_state_str[] = {
"OOO_DONE" "OOO_DONE"
}; };
enum schedule_group_target {
SCHEDULE_BOTH = 0,
SCHEDULE_FAST = 1,
SCHEDULE_SLOW = 2
};
int schedule_group_target_trans[] = {
SCHEDULE_BOTH,
SCHEDULE_SLOW,
SCHEDULE_FAST
};
char* schedule_group_target_str[] = {
"SCHEDULE_BOTH",
"SCHEDULE_FAST",
"SCHEDULE_SLOW"
};
struct stat_entry { struct stat_entry {
uint8_t link_id; uint8_t link_id;
int64_t max_ooo; int64_t max_ooo;
@ -53,6 +72,7 @@ struct light_ctx {
uint8_t is_measlat; uint8_t is_measlat;
uint8_t explain; uint8_t explain;
uint8_t disable_scheduler; uint8_t disable_scheduler;
enum schedule_group_target sched_strat;
}; };
void algo_lightning_free(void* v) { void algo_lightning_free(void* v) {
@ -78,6 +98,7 @@ void algo_lightning_init(struct evt_core_ctx* ctx, struct algo_ctx* app_ctx, str
lightc->pkt_sent_id = 1; lightc->pkt_sent_id = 1;
lightc->uniq_pkt_sent_id = 1; lightc->uniq_pkt_sent_id = 1;
lightc->disable_scheduler = 0; lightc->disable_scheduler = 0;
lightc->sched_strat = SCHEDULE_BOTH;
uint64_t window = 2000; uint64_t window = 2000;
if (ap->algo_specific_params != NULL) { if (ap->algo_specific_params != NULL) {
@ -93,6 +114,7 @@ void algo_lightning_init(struct evt_core_ctx* ctx, struct algo_ctx* app_ctx, str
sscanf(token, "measlat=%d", &lightc->is_measlat); sscanf(token, "measlat=%d", &lightc->is_measlat);
sscanf(token, "explain=%d", &lightc->explain); sscanf(token, "explain=%d", &lightc->explain);
sscanf(token, "disable_scheduler=%d", &lightc->disable_scheduler); sscanf(token, "disable_scheduler=%d", &lightc->disable_scheduler);
sscanf(token, "tick_tock=%d", &lightc->sched_strat);
} }
} }
@ -114,6 +136,7 @@ void algo_lightning_init(struct evt_core_ctx* ctx, struct algo_ctx* app_ctx, str
printf("measlat = %s\n", lightc->is_measlat ? "yes" : "no"); printf("measlat = %s\n", lightc->is_measlat ? "yes" : "no");
printf("explain = %s\n", lightc->explain ? "yes" : "no"); printf("explain = %s\n", lightc->explain ? "yes" : "no");
printf("disable_scheduler = %s\n", lightc->disable_scheduler ? "yes" : "no"); printf("disable_scheduler = %s\n", lightc->disable_scheduler ? "yes" : "no");
printf("schedule_group_target = %s\n", schedule_group_target_str[lightc->sched_strat]);
} }
void algo_lightning_pad(struct evt_core_ctx* ctx, struct evt_core_fdinfo* fdinfo, struct buffer_packet* bp) { void algo_lightning_pad(struct evt_core_ctx* ctx, struct evt_core_fdinfo* fdinfo, struct buffer_packet* bp) {
@ -382,6 +405,7 @@ int algo_lightning_on_datagram(struct evt_core_ctx* ctx, struct evt_core_fdinfo*
uint64_t now_timestamp = timespec_get_unit(&now, MILISEC); uint64_t now_timestamp = timespec_get_unit(&now, MILISEC);
// Select fast link // Select fast link
if (lightc->sched_strat == SCHEDULE_BOTH || lightc->sched_strat == SCHEDULE_FAST) {
sel_link_last = now; sel_link_last = now;
lightc->selected_link = UINT8_MAX; lightc->selected_link = UINT8_MAX;
for (int i = 0; i < lightc->fast_count; i++) { for (int i = 0; i < lightc->fast_count; i++) {
@ -392,7 +416,9 @@ int algo_lightning_on_datagram(struct evt_core_ctx* ctx, struct evt_core_fdinfo*
} }
send_message (ctx, bp); send_message (ctx, bp);
if (lightc->csv) printf("%ld,%d,fast\n", now_timestamp, lightc->selected_link); if (lightc->csv) printf("%ld,%d,fast\n", now_timestamp, lightc->selected_link);
}
if (lightc->sched_strat == SCHEDULE_BOTH || lightc->sched_strat == SCHEDULE_SLOW) {
// Tag packets for slow link // Tag packets for slow link
if (lightc->is_measlat) { if (lightc->is_measlat) {
union abstract_packet* cur = ap; union abstract_packet* cur = ap;
@ -418,7 +444,10 @@ int algo_lightning_on_datagram(struct evt_core_ctx* ctx, struct evt_core_fdinfo*
} }
send_message (ctx, bp); send_message (ctx, bp);
if (lightc->csv) printf("%ld,%d,slow\n", now_timestamp, lightc->selected_link); if (lightc->csv) printf("%ld,%d,slow\n", now_timestamp, lightc->selected_link);
}
// Update our algo context
lightc->sched_strat = schedule_group_target_trans[lightc->sched_strat];
lightc->uniq_pkt_sent_id++; lightc->uniq_pkt_sent_id++;
mv_buffer_rtof (&app_ctx->br, fdinfo); mv_buffer_rtof (&app_ctx->br, fdinfo);
return 0; return 0;