WIP owdd
This commit is contained in:
parent
cb9b9f7bc6
commit
422f1845c9
3 changed files with 28 additions and 75 deletions
|
@ -210,6 +210,28 @@ int is_in_order(struct thunder_ctx* thunderc, uint8_t link_id) {
|
|||
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) {
|
||||
struct algo_ctx* app_ctx = fdinfo->cat->app_ctx;
|
||||
struct thunder_ctx* thunderc = app_ctx->misc;
|
||||
|
@ -239,10 +261,7 @@ void classify(struct evt_core_ctx* ctx, struct evt_core_fdinfo* fdinfo, struct b
|
|||
}
|
||||
thunderc->rcv_delta_t_per_link[link_id] = 0;
|
||||
|
||||
// 2.
|
||||
|
||||
int64_t current_owdd = 0;
|
||||
int64_t biggest_owdd = current_owdd;
|
||||
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;
|
||||
|
@ -253,15 +272,7 @@ void classify(struct evt_core_ctx* ctx, struct evt_core_fdinfo* fdinfo, struct b
|
|||
|
||||
remote_delta = li[i].delta_t;
|
||||
local_delta = thunderc->rcv_delta_t_per_link[i];
|
||||
owd_difference = local_delta - remote_delta;
|
||||
//printf("li[i].delta_t=%d, remote_delta=%ld, thunderc->rcv_delta_t_per_link[i]=%ld, local_delta=%ld, owd_difference=%ld\n", li[i].delta_t, remote_delta, thunderc->rcv_delta_t_per_link[i], local_delta, owd_difference);
|
||||
//if (remote_delta > 10000 || local_delta > 10000) continue; // Too many time elapsed for useful comparison
|
||||
if (owd_difference > biggest_owdd) {
|
||||
biggest_owdd = owd_difference;
|
||||
}
|
||||
//printf("----> %ld vs %ld for i=%d, link_id=%d, owd_difference=%ld, smallest=%ld, remote=%ld, local=%ld\n", thunderc->received_pkts_on_link[i], expected, i, link_id, owd_difference, smallest_owdd, local_delta, remote_delta);
|
||||
|
||||
//printf(" owd_difference = %ld, max=%ld, min=%ld\n", owd_difference, thunderc->allowed_jitter_ms, -thunderc->allowed_jitter_ms);
|
||||
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};
|
||||
|
@ -270,11 +281,11 @@ void classify(struct evt_core_ctx* ctx, struct evt_core_fdinfo* fdinfo, struct b
|
|||
bi.app_ctx = app_ctx;
|
||||
sprintf(bi.reason, "Erreur");
|
||||
|
||||
if (owd_difference < -thunderc->allowed_jitter_ms) {
|
||||
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) {
|
||||
} 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);
|
||||
|
@ -286,13 +297,6 @@ void classify(struct evt_core_ctx* ctx, struct evt_core_fdinfo* fdinfo, struct b
|
|||
on_block(ctx, &bi);
|
||||
}
|
||||
|
||||
// 2.5 Compute link jitter
|
||||
//printf("retained owd: %ld\n", biggest_owdd);
|
||||
int64_t current_link_jitter = biggest_owdd;
|
||||
for (int i = 0; i < thunderc->total_links; i++) {
|
||||
thunderc->estimated_sent[i] = li[i].delta_t /*+ current_link_jitter*/;
|
||||
}
|
||||
|
||||
// 3. Disable links that miss packets
|
||||
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;
|
||||
|
@ -359,21 +363,6 @@ int compare_int64(const void *a,const void *b) {
|
|||
return *x - *y;
|
||||
}
|
||||
|
||||
void get_estimation(struct thunder_ctx* thunderc, int64_t* sorted_estimation, uint64_t* sorted_occurencies) {
|
||||
uint64_t deleted = 0;
|
||||
memcpy (sorted_estimation, thunderc->estimated_sent, thunderc->total_links * sizeof(int64_t));
|
||||
qsort(sorted_estimation, thunderc->total_links, sizeof(int64_t), compare_int64);
|
||||
for (int i = 0; i < thunderc->total_links - 1; i++) {
|
||||
if (sorted_estimation[i - deleted] == sorted_estimation[i - deleted + 1]) {
|
||||
for (int j = i - deleted + 1; j < thunderc->total_links - 1 - deleted; j++) {
|
||||
sorted_estimation[j] = sorted_estimation[j + 1];
|
||||
}
|
||||
deleted++;
|
||||
}
|
||||
}
|
||||
*sorted_occurencies = thunderc->total_links - deleted;
|
||||
}
|
||||
|
||||
void adapt(struct evt_core_ctx* ctx, struct evt_core_fdinfo* fdinfo, struct buffer_packet* bp, struct unpad_info *ui) {
|
||||
struct algo_ctx* app_ctx = fdinfo->cat->app_ctx;
|
||||
struct thunder_ctx* thunderc = app_ctx->misc;
|
||||
|
@ -381,28 +370,12 @@ void adapt(struct evt_core_ctx* ctx, struct evt_core_fdinfo* fdinfo, struct buff
|
|||
struct evt_core_fdinfo *to_fdinfo = NULL;
|
||||
uint64_t delivered = 0;
|
||||
|
||||
int64_t sorted_estimation[MAX_LINKS];
|
||||
uint64_t sorted_occurencies;
|
||||
get_estimation (thunderc, sorted_estimation, &sorted_occurencies);
|
||||
|
||||
/*
|
||||
printf("%d packets with estimated jitter ", ui->ap_arr_vals);
|
||||
for (int i = 0; i < sorted_occurencies; i++) {
|
||||
printf("%ld, ", sorted_estimation[i]);
|
||||
}
|
||||
printf("\n");*/
|
||||
|
||||
for (int i = ui->ap_arr_vals-1; i >= 0; i--) {
|
||||
//fprintf(stderr, "i=%d, ui->ap_arr_vals=%d\n", i, ui->ap_arr_vals);
|
||||
if (ui->ap_arr_meta[i]->fmt.content.udp_metadata_thunder.id <= thunderc->recv_id) continue; // already delivered
|
||||
thunderc->recv_id = ui->ap_arr_meta[i]->fmt.content.udp_metadata_thunder.id;
|
||||
|
||||
int64_t estimation_index = i > sorted_occurencies - 1 ? sorted_occurencies - 1 : i;
|
||||
if (sorted_estimation[estimation_index] > thunderc->allowed_jitter_ms) {
|
||||
printf("Would have dropped %d\n",i);
|
||||
//continue;
|
||||
}
|
||||
|
||||
// Find destination
|
||||
sprintf(url, "udp:write:127.0.0.1:%d", ui->ap_arr_pl[i]->fmt.content.udp_encapsulated.port);
|
||||
to_fdinfo = evt_core_get_from_url (ctx, url);
|
||||
|
|
|
@ -112,6 +112,7 @@ struct thunder_ctx {
|
|||
uint64_t sent_pkts_on_link[MAX_LINKS];
|
||||
uint64_t blacklisted[MAX_LINKS];
|
||||
int64_t estimated_sent[MAX_LINKS];
|
||||
int64_t owdd[MAX_LINKS];
|
||||
size_t monit_pkt_size;
|
||||
int64_t allowed_jitter_ms;
|
||||
int scheduler_activated;
|
||||
|
|
23
src/test.c
23
src/test.c
|
@ -6,27 +6,6 @@
|
|||
|
||||
int main(int argc, char** argv) {
|
||||
setvbuf(stdout, NULL, _IONBF, 0);
|
||||
printf("~ udpecho ~\n");
|
||||
|
||||
|
||||
int64_t sorted_estimation[MAX_LINKS];
|
||||
uint64_t sorted_occurencies;
|
||||
struct thunder_ctx thunderc = {0};
|
||||
thunderc.total_links = 8;
|
||||
thunderc.estimated_sent[0] = 221;
|
||||
thunderc.estimated_sent[1] = 110;
|
||||
thunderc.estimated_sent[2] = 0;
|
||||
thunderc.estimated_sent[3] = 522;
|
||||
thunderc.estimated_sent[4] = 522;
|
||||
thunderc.estimated_sent[5] = 443;
|
||||
thunderc.estimated_sent[6] = 333;
|
||||
thunderc.estimated_sent[7] = 333;
|
||||
|
||||
get_estimation (&thunderc, sorted_estimation, &sorted_occurencies);
|
||||
printf("sorted_occurencies = %ld, vals=", sorted_occurencies);
|
||||
for (int i = 0; i < sorted_occurencies; i++) {
|
||||
printf("%ld,", sorted_estimation[i]);
|
||||
}
|
||||
printf("\n");
|
||||
printf("~ test ~\n");
|
||||
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue