Satisfying donar
This commit is contained in:
parent
a5d5d37389
commit
840f95eaa3
2 changed files with 51 additions and 16 deletions
|
@ -122,7 +122,7 @@ int schedule(struct evt_core_ctx* ctx, struct evt_core_fdinfo* fdinfo, struct bu
|
||||||
if (protect == thunderc->total_links)
|
if (protect == thunderc->total_links)
|
||||||
mili_sec = compute_delta (&thunderc->prev_link_time, UINT16_MAX);
|
mili_sec = compute_delta (&thunderc->prev_link_time, UINT16_MAX);
|
||||||
|
|
||||||
printf("send packet on link %d with delta=%ld\n", thunderc->selected_link, mili_sec);
|
//printf("send packet on link %d with delta=%ld\n", thunderc->selected_link, mili_sec);
|
||||||
// 5. We create the array
|
// 5. We create the array
|
||||||
struct link_info *li = &new_ap->fmt.content.link_monitoring_thunder.links_status;
|
struct link_info *li = &new_ap->fmt.content.link_monitoring_thunder.links_status;
|
||||||
for (int i = 0; i < thunderc->total_links; i++) {
|
for (int i = 0; i < thunderc->total_links; i++) {
|
||||||
|
@ -170,7 +170,7 @@ void on_block (struct evt_core_ctx* ctx, void* raw) {
|
||||||
struct block_info* bi = raw;
|
struct block_info* bi = raw;
|
||||||
struct thunder_ctx* thunderc = bi->app_ctx->misc;
|
struct thunder_ctx* thunderc = bi->app_ctx->misc;
|
||||||
|
|
||||||
if (thunderc->received_pkts_on_link[bi->i] >= bi->missing) goto release;
|
if (bi->is_timeout && thunderc->received_pkts_on_link[bi->i] >= bi->missing) goto release;
|
||||||
if (thunderc->blacklisted[bi->i] >= bi->missing) goto release;
|
if (thunderc->blacklisted[bi->i] >= bi->missing) goto release;
|
||||||
|
|
||||||
printf("%s\n", bi->reason);
|
printf("%s\n", bi->reason);
|
||||||
|
@ -217,7 +217,7 @@ void classify(struct evt_core_ctx* ctx, struct evt_core_fdinfo* fdinfo, struct b
|
||||||
|
|
||||||
uint64_t mili_sec = compute_delta (&thunderc->prev_rcv_link_time, UINT16_MAX);
|
uint64_t mili_sec = compute_delta (&thunderc->prev_rcv_link_time, UINT16_MAX);
|
||||||
for (int i = 0; i < thunderc->total_links; i++) {
|
for (int i = 0; i < thunderc->total_links; i++) {
|
||||||
if (thunderc->received_pkts_on_link[i] == 0) continue;
|
if (thunderc->received_pkts_on_link[i] <= 1) continue;
|
||||||
thunderc->rcv_delta_t_per_link[i] += mili_sec;
|
thunderc->rcv_delta_t_per_link[i] += mili_sec;
|
||||||
}
|
}
|
||||||
thunderc->rcv_delta_t_per_link[link_id] = 0;
|
thunderc->rcv_delta_t_per_link[link_id] = 0;
|
||||||
|
@ -232,6 +232,7 @@ void classify(struct evt_core_ctx* ctx, struct evt_core_fdinfo* fdinfo, struct b
|
||||||
|
|
||||||
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;
|
if (thunderc->received_pkts_on_link[i] != expected) continue;
|
||||||
|
if (thunderc->received_pkts_on_link[i] <= 1) continue;
|
||||||
|
|
||||||
remote_delta = li[i].delta_t;
|
remote_delta = li[i].delta_t;
|
||||||
local_delta = thunderc->rcv_delta_t_per_link[i];
|
local_delta = thunderc->rcv_delta_t_per_link[i];
|
||||||
|
@ -243,34 +244,36 @@ void classify(struct evt_core_ctx* ctx, struct evt_core_fdinfo* fdinfo, struct b
|
||||||
}
|
}
|
||||||
//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("----> %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);
|
||||||
if (owd_difference <= thunderc->allowed_jitter_ms && owd_difference >= -thunderc->allowed_jitter_ms) continue;
|
if (owd_difference <= thunderc->allowed_jitter_ms && owd_difference >= -thunderc->allowed_jitter_ms) continue;
|
||||||
|
|
||||||
struct block_info *bi = malloc(sizeof(struct block_info));
|
struct block_info bi = {0};
|
||||||
bi->app_ctx = app_ctx; bi->is_timeout = 1;
|
bi.app_ctx = app_ctx;
|
||||||
bi->is_timeout = 0;
|
bi.is_timeout = 0;
|
||||||
bi->app_ctx = app_ctx;
|
bi.app_ctx = app_ctx;
|
||||||
sprintf(bi->reason, "Erreur");
|
sprintf(bi.reason, "Erreur");
|
||||||
|
|
||||||
if (owd_difference < -thunderc->allowed_jitter_ms) {
|
if (owd_difference < -thunderc->allowed_jitter_ms) {
|
||||||
bi->i = i;
|
bi.i = i;
|
||||||
bi->missing = expected;
|
bi.missing = expected;
|
||||||
sprintf(bi->reason, " Packet Too Late - Blocked link %d owd_diff=%ld, local_delta=%ld, remote_delta=%ld", i, owd_difference, local_delta, remote_delta);
|
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.i = link_id;
|
||||||
bi->missing = thunderc->received_pkts_on_link[link_id];
|
bi.missing = thunderc->received_pkts_on_link[link_id];
|
||||||
sprintf(bi->reason, " Packet Too Late - Blocked link %d owd_diff=%ld, local_delta=%ld, remote_delta=%ld", link_id, owd_difference, local_delta, remote_delta);
|
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 {
|
} else {
|
||||||
fprintf(stderr, "Algorithm is wrong\n");
|
fprintf(stderr, "Algorithm is wrong\n");
|
||||||
exit(EXIT_FAILURE);
|
exit(EXIT_FAILURE);
|
||||||
}
|
}
|
||||||
|
|
||||||
on_block(ctx, bi);
|
on_block(ctx, &bi);
|
||||||
}
|
}
|
||||||
|
|
||||||
// 2.5 Compute link jitter
|
// 2.5 Compute link jitter
|
||||||
|
//printf("retained owd: %ld\n", biggest_owdd);
|
||||||
int64_t current_link_jitter = biggest_owdd;
|
int64_t current_link_jitter = biggest_owdd;
|
||||||
for (int i = 0; i < thunderc->total_links; i++) {
|
for (int i = 0; i < thunderc->total_links; i++) {
|
||||||
thunderc->estimated_sent[i] = li[i].delta_t + current_link_jitter;
|
thunderc->estimated_sent[i] = li[i].delta_t /*+ current_link_jitter*/;
|
||||||
}
|
}
|
||||||
|
|
||||||
// 3. Disable links that miss packets
|
// 3. Disable links that miss packets
|
||||||
|
|
32
src/test.c
Normal file
32
src/test.c
Normal file
|
@ -0,0 +1,32 @@
|
||||||
|
#include <stdio.h>
|
||||||
|
#include <stdlib.h>
|
||||||
|
#include <unistd.h>
|
||||||
|
#include <errno.h>
|
||||||
|
#include "proxy.h"
|
||||||
|
|
||||||
|
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");
|
||||||
|
|
||||||
|
}
|
Loading…
Reference in a new issue