Rework code
This commit is contained in:
parent
422f1845c9
commit
07287db40d
2 changed files with 32 additions and 85 deletions
|
@ -210,28 +210,6 @@ int is_in_order(struct thunder_ctx* thunderc, uint8_t link_id) {
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
void update_owdd(struct thunder_ctx* thunderc, uint8_t link_id, struct link_info *li) {
|
|
||||||
if (!is_in_order(thunderc, link_id)) return; // Packet is out of order, computing OWDD makes no sense
|
|
||||||
|
|
||||||
for (int i = 0; i < thunderc->total_links; i++) {
|
|
||||||
int64_t remote_delta = 0, local_delta = 0, owd_difference = 0;
|
|
||||||
|
|
||||||
uint64_t expected = i <= link_id ? thunderc->received_pkts_on_link[link_id] : thunderc->received_pkts_on_link[link_id] - 1;
|
|
||||||
if (thunderc->received_pkts_on_link[i] < expected || thunderc->received_pkts_on_link[i] <= 1) {
|
|
||||||
thunderc->owdd[i] = INT64_MAX;
|
|
||||||
} else if (thunderc->received_pkts_on_link[i] > expected) {
|
|
||||||
fprintf(stderr, "We must consider in order packets only. This code path should not be triggered and proove that algo is wrong\n");
|
|
||||||
exit(EXIT_FAILURE);
|
|
||||||
}
|
|
||||||
|
|
||||||
remote_delta = li[i].delta_t;
|
|
||||||
local_delta = thunderc->rcv_delta_t_per_link[i];
|
|
||||||
owd_difference = remote_delta - local_delta;
|
|
||||||
|
|
||||||
thunderc->owdd[i] = owd_difference;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
void classify(struct evt_core_ctx* ctx, struct evt_core_fdinfo* fdinfo, struct buffer_packet* bp) {
|
void classify(struct evt_core_ctx* ctx, struct evt_core_fdinfo* fdinfo, struct buffer_packet* bp) {
|
||||||
struct algo_ctx* app_ctx = fdinfo->cat->app_ctx;
|
struct algo_ctx* app_ctx = fdinfo->cat->app_ctx;
|
||||||
struct thunder_ctx* thunderc = app_ctx->misc;
|
struct thunder_ctx* thunderc = app_ctx->misc;
|
||||||
|
@ -242,12 +220,6 @@ void classify(struct evt_core_ctx* ctx, struct evt_core_fdinfo* fdinfo, struct b
|
||||||
exit(EXIT_FAILURE);
|
exit(EXIT_FAILURE);
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
|
||||||
if (ap->fmt.headers.flags & FLAG_RESET) {
|
|
||||||
for (int i = 0; i < MAX_LINKS; i++) thunderc->received_pkts_on_link[i] = 1;
|
|
||||||
}
|
|
||||||
*/
|
|
||||||
|
|
||||||
// 1. Update link info
|
// 1. Update link info
|
||||||
int link_id = url_get_port_int(fdinfo->url) - 7500;
|
int link_id = url_get_port_int(fdinfo->url) - 7500;
|
||||||
thunderc->received_pkts_on_link[link_id] += ap->fmt.content.link_monitoring_thunder.to_increment;
|
thunderc->received_pkts_on_link[link_id] += ap->fmt.content.link_monitoring_thunder.to_increment;
|
||||||
|
@ -261,47 +233,10 @@ void classify(struct evt_core_ctx* ctx, struct evt_core_fdinfo* fdinfo, struct b
|
||||||
}
|
}
|
||||||
thunderc->rcv_delta_t_per_link[link_id] = 0;
|
thunderc->rcv_delta_t_per_link[link_id] = 0;
|
||||||
|
|
||||||
update_owdd(thunderc, link_id, li);
|
|
||||||
|
|
||||||
for (int i = 0; i < thunderc->total_links; i++) {
|
|
||||||
int64_t remote_delta = 0, local_delta = 0, owd_difference = 0;
|
|
||||||
|
|
||||||
uint64_t expected = i <= link_id ? thunderc->received_pkts_on_link[link_id] : thunderc->received_pkts_on_link[link_id] - 1;
|
|
||||||
if (thunderc->received_pkts_on_link[i] != expected) continue;
|
|
||||||
if (thunderc->received_pkts_on_link[i] <= 1) continue;
|
|
||||||
|
|
||||||
remote_delta = li[i].delta_t;
|
|
||||||
local_delta = thunderc->rcv_delta_t_per_link[i];
|
|
||||||
owd_difference = remote_delta - local_delta;
|
|
||||||
if (owd_difference <= thunderc->allowed_jitter_ms && owd_difference >= -thunderc->allowed_jitter_ms) continue;
|
|
||||||
|
|
||||||
struct block_info bi = {0};
|
|
||||||
bi.app_ctx = app_ctx;
|
|
||||||
bi.is_timeout = 0;
|
|
||||||
bi.app_ctx = app_ctx;
|
|
||||||
sprintf(bi.reason, "Erreur");
|
|
||||||
|
|
||||||
if (owd_difference > thunderc->allowed_jitter_ms) {
|
|
||||||
bi.i = i;
|
|
||||||
bi.missing = expected;
|
|
||||||
sprintf(bi.reason, " Packet Too Late - Blocked non current link %d owd_diff=%ld, local_delta=%ld, remote_delta=%ld", i, owd_difference, local_delta, remote_delta);
|
|
||||||
} else if (owd_difference < -thunderc->allowed_jitter_ms) {
|
|
||||||
bi.i = link_id;
|
|
||||||
bi.missing = thunderc->received_pkts_on_link[link_id];
|
|
||||||
sprintf(bi.reason, " Packet Too Late - Blocked current link %d owd_diff=%ld, local_delta=%ld, remote_delta=%ld", link_id, owd_difference, local_delta, remote_delta);
|
|
||||||
} else {
|
|
||||||
fprintf(stderr, "Algorithm is wrong\n");
|
|
||||||
exit(EXIT_FAILURE);
|
|
||||||
}
|
|
||||||
|
|
||||||
on_block(ctx, &bi);
|
|
||||||
}
|
|
||||||
|
|
||||||
// 3. Disable links that miss packets
|
// 3. Disable links that miss packets
|
||||||
for (uint8_t i = 0; i < thunderc->total_links; i++) {
|
for (uint8_t i = 0; i < thunderc->total_links; i++) {
|
||||||
uint64_t expected = i <= link_id ? thunderc->received_pkts_on_link[link_id] : thunderc->received_pkts_on_link[link_id] - 1;
|
uint64_t expected = i <= link_id ? thunderc->received_pkts_on_link[link_id] : thunderc->received_pkts_on_link[link_id] - 1;
|
||||||
if (thunderc->received_pkts_on_link[i] >= expected) continue; // Nothing to do, all packets have been received
|
if (thunderc->received_pkts_on_link[i] >= expected) continue; // Nothing to do, all packets have been received
|
||||||
|
|
||||||
int64_t timeout = thunderc->allowed_jitter_ms - li[i].delta_t;
|
int64_t timeout = thunderc->allowed_jitter_ms - li[i].delta_t;
|
||||||
|
|
||||||
struct block_info *bi = malloc(sizeof(struct block_info));
|
struct block_info *bi = malloc(sizeof(struct block_info));
|
||||||
|
@ -310,19 +245,14 @@ void classify(struct evt_core_ctx* ctx, struct evt_core_fdinfo* fdinfo, struct b
|
||||||
sprintf(bi->reason, " Missing Packet - Timeout for link %d after %ldms (expected: %ld, seen: %ld)", i, timeout, expected, thunderc->received_pkts_on_link[i]);
|
sprintf(bi->reason, " Missing Packet - Timeout for link %d after %ldms (expected: %ld, seen: %ld)", i, timeout, expected, thunderc->received_pkts_on_link[i]);
|
||||||
if (timeout <= 0) {
|
if (timeout <= 0) {
|
||||||
on_block(ctx, bi);
|
on_block(ctx, bi);
|
||||||
//printf(" Missing Packet - Blocked link %d (expected: %ld, seen: %ld)\n", i, expected, thunderc->received_pkts_on_link[i]);
|
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
set_timeout (ctx, timeout, bi, on_block);
|
set_timeout (ctx, timeout, bi, on_block);
|
||||||
|
|
||||||
if (ctx->verbose > 1) {
|
|
||||||
fprintf(stderr, " [algo_thunder] Set timeout on link %d of %ld ms (packets expected: %ld, seen: %ld)\n",
|
|
||||||
i, timeout, expected, thunderc->received_pkts_on_link[i]);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
if (ctx->verbose > 1) fprintf(stderr, " [algo_thunder] Classify done\n");
|
if (ctx->verbose > 1) fprintf(stderr, " [algo_thunder] Classify done\n");
|
||||||
|
|
||||||
|
if (thunderc->scheduler_activated) {
|
||||||
uint64_t ts = compute_delta (&thunderc->start_time, UINT64_MAX, 0);
|
uint64_t ts = compute_delta (&thunderc->start_time, UINT64_MAX, 0);
|
||||||
printf("[%ld] Blacklisted links: ", ts);
|
printf("[%ld] Blacklisted links: ", ts);
|
||||||
for (int i = 0; i < thunderc->total_links; i++) {
|
for (int i = 0; i < thunderc->total_links; i++) {
|
||||||
|
@ -331,6 +261,7 @@ void classify(struct evt_core_ctx* ctx, struct evt_core_fdinfo* fdinfo, struct b
|
||||||
}
|
}
|
||||||
printf("\n");
|
printf("\n");
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
struct unpad_info {
|
struct unpad_info {
|
||||||
union abstract_packet *ap_arr_pl[MAX_LINKS],
|
union abstract_packet *ap_arr_pl[MAX_LINKS],
|
||||||
|
|
32
src/proxy.h
32
src/proxy.h
|
@ -101,21 +101,37 @@ int main_on_err(struct evt_core_ctx* ctx, struct evt_core_fdinfo* fdinfo);
|
||||||
#define MAX_LINKS 64
|
#define MAX_LINKS 64
|
||||||
|
|
||||||
struct thunder_ctx {
|
struct thunder_ctx {
|
||||||
uint16_t recv_id;
|
// shared/global parameters
|
||||||
uint16_t emit_id;
|
|
||||||
uint8_t selected_link;
|
|
||||||
uint8_t total_links;
|
uint8_t total_links;
|
||||||
|
struct timespec start_time;
|
||||||
|
|
||||||
|
// scheduler parameters
|
||||||
|
uint8_t selected_link;
|
||||||
|
uint64_t blacklisted[MAX_LINKS];
|
||||||
|
|
||||||
|
// classifier send side parameters
|
||||||
|
struct timespec prev_link_time;
|
||||||
uint8_t to_increment[MAX_LINKS];
|
uint8_t to_increment[MAX_LINKS];
|
||||||
uint64_t delta_t_per_link[MAX_LINKS];
|
uint64_t delta_t_per_link[MAX_LINKS];
|
||||||
|
uint64_t sent_pkts_on_link[MAX_LINKS];
|
||||||
|
|
||||||
|
// classifier receive side parameters
|
||||||
uint64_t rcv_delta_t_per_link[MAX_LINKS];
|
uint64_t rcv_delta_t_per_link[MAX_LINKS];
|
||||||
uint64_t received_pkts_on_link[MAX_LINKS];
|
uint64_t received_pkts_on_link[MAX_LINKS];
|
||||||
uint64_t sent_pkts_on_link[MAX_LINKS];
|
struct timespec prev_rcv_link_time;
|
||||||
uint64_t blacklisted[MAX_LINKS];
|
|
||||||
int64_t estimated_sent[MAX_LINKS];
|
|
||||||
int64_t owdd[MAX_LINKS];
|
int64_t owdd[MAX_LINKS];
|
||||||
|
// uint16_t received_delta_by_links[MAX_LINKS][MAX_LINKS];
|
||||||
|
// struct timespec last_received_on_link[MAX_LINKS];
|
||||||
|
|
||||||
|
// prepare/adapt parameters
|
||||||
|
uint16_t recv_id;
|
||||||
|
uint16_t emit_id;
|
||||||
|
|
||||||
|
// pad/unpad parameter
|
||||||
size_t monit_pkt_size;
|
size_t monit_pkt_size;
|
||||||
|
|
||||||
|
// user parameters
|
||||||
int64_t allowed_jitter_ms;
|
int64_t allowed_jitter_ms;
|
||||||
int scheduler_activated;
|
int scheduler_activated;
|
||||||
struct timespec prev_link_time, prev_rcv_link_time, start_time;
|
|
||||||
};
|
};
|
||||||
void get_estimation(struct thunder_ctx* thunderc, int64_t* sorted_estimation, uint64_t* sorted_occurencies);
|
|
||||||
|
|
Loading…
Reference in a new issue