Add a flip flap strategy
This commit is contained in:
parent
98a51962eb
commit
b1a0194832
1 changed files with 60 additions and 31 deletions
|
@ -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,43 +405,49 @@ 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
|
||||||
sel_link_last = now;
|
if (lightc->sched_strat == SCHEDULE_BOTH || lightc->sched_strat == SCHEDULE_FAST) {
|
||||||
lightc->selected_link = UINT8_MAX;
|
sel_link_last = now;
|
||||||
for (int i = 0; i < lightc->fast_count; i++) {
|
lightc->selected_link = UINT8_MAX;
|
||||||
if (timespec_lt (&lightc->last[stats[i].link_id], &sel_link_last)) {
|
for (int i = 0; i < lightc->fast_count; i++) {
|
||||||
lightc->selected_link = stats[i].link_id;
|
if (timespec_lt (&lightc->last[stats[i].link_id], &sel_link_last)) {
|
||||||
sel_link_last = lightc->last[stats[i].link_id];
|
lightc->selected_link = stats[i].link_id;
|
||||||
}
|
sel_link_last = lightc->last[stats[i].link_id];
|
||||||
}
|
|
||||||
send_message (ctx, bp);
|
|
||||||
if (lightc->csv) printf("%ld,%d,fast\n", now_timestamp, lightc->selected_link);
|
|
||||||
|
|
||||||
// Tag packets for slow link
|
|
||||||
if (lightc->is_measlat) {
|
|
||||||
union abstract_packet* cur = ap;
|
|
||||||
while (cur != NULL) {
|
|
||||||
if (ap->fmt.headers.cmd != CMD_UDP_ENCAPSULATED) {
|
|
||||||
cur = ap_next(cur);
|
|
||||||
continue;
|
|
||||||
}
|
}
|
||||||
struct measure_packet *mp = (void*)&cur->fmt.content.udp_encapsulated.payload;
|
|
||||||
mp->flag = 1;
|
|
||||||
cur = ap_next(cur);
|
|
||||||
}
|
}
|
||||||
|
send_message (ctx, bp);
|
||||||
|
if (lightc->csv) printf("%ld,%d,fast\n", now_timestamp, lightc->selected_link);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Select slow link
|
if (lightc->sched_strat == SCHEDULE_BOTH || lightc->sched_strat == SCHEDULE_SLOW) {
|
||||||
sel_link_last = now;
|
// Tag packets for slow link
|
||||||
lightc->selected_link = UINT8_MAX;
|
if (lightc->is_measlat) {
|
||||||
for (int i = lightc->fast_count; i < lightc->total_links; i++) {
|
union abstract_packet* cur = ap;
|
||||||
if (timespec_lt (&lightc->last[stats[i].link_id], &sel_link_last)) {
|
while (cur != NULL) {
|
||||||
lightc->selected_link = stats[i].link_id;
|
if (ap->fmt.headers.cmd != CMD_UDP_ENCAPSULATED) {
|
||||||
sel_link_last = lightc->last[stats[i].link_id];
|
cur = ap_next(cur);
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
struct measure_packet *mp = (void*)&cur->fmt.content.udp_encapsulated.payload;
|
||||||
|
mp->flag = 1;
|
||||||
|
cur = ap_next(cur);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
send_message (ctx, bp);
|
|
||||||
if (lightc->csv) printf("%ld,%d,slow\n", now_timestamp, lightc->selected_link);
|
|
||||||
|
|
||||||
|
// Select slow link
|
||||||
|
sel_link_last = now;
|
||||||
|
lightc->selected_link = UINT8_MAX;
|
||||||
|
for (int i = lightc->fast_count; i < lightc->total_links; i++) {
|
||||||
|
if (timespec_lt (&lightc->last[stats[i].link_id], &sel_link_last)) {
|
||||||
|
lightc->selected_link = stats[i].link_id;
|
||||||
|
sel_link_last = lightc->last[stats[i].link_id];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
send_message (ctx, bp);
|
||||||
|
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;
|
||||||
|
|
Loading…
Reference in a new issue