From d14c40b700292be7b183b81528f94d55ae776e0a Mon Sep 17 00:00:00 2001 From: Quentin Date: Sun, 15 Sep 2019 09:18:09 +0200 Subject: [PATCH] WIP fix algo --- scripts/run-3 | 68 +++++++++++++++++++++------------------------- src/algo_thunder.c | 25 ++++++++++++++--- 2 files changed, 52 insertions(+), 41 deletions(-) diff --git a/scripts/run-3 b/scripts/run-3 index b35e70e..eed2ce5 100755 --- a/scripts/run-3 +++ b/scripts/run-3 @@ -36,13 +36,6 @@ for i in $(seq 0 $(expr $instances - 1)); do echo " instance=$i - server=${SERVER_TARGETS[$i]} - client=${CLIENT_TARGETS[$i]} - tor server=${TOR_DAEMON_SERVER[$i]} - tor client=${TOR_DAEMON_CLIENT[$i]}" done -echo ":: Clear Resources" -for i in $(seq 0 $(expr $instances - 1)); do - echo "clear $i" - docker container inspect donarxp_server_${i} > /dev/null 2>&1 && docker kill donarxp_server_${i} - docker container inspect donarxp_client_${i} > /dev/null 2>&1 && docker kill donarxp_client_${i} -done - echo ":: Bootstrap" echo "Create output folder..." docker run \ @@ -52,44 +45,45 @@ docker run \ registry.gitlab.inria.fr/qdufour/donar \ chown -R 1000:1000 /home/donar -for i in $(seq 0 $(expr $instances - 1)); do -echo "Spawning container for instance=$i..." -docker run \ - --rm \ - -d \ - --name "donarxp_server_${i}" \ - -e HOME='/tmp' \ - -v `pwd`/out:/home/donar/out \ - registry.gitlab.inria.fr/qdufour/donar \ - ${TOR_DAEMON_SERVER[$i]} - -docker run \ - --rm \ - -d \ - --name "donarxp_client_${i}" \ - -e HOME='/tmp' \ - -v `pwd`/out:/home/donar/out \ - registry.gitlab.inria.fr/qdufour/donar \ - ${TOR_DAEMON_CLIENT[$i]} -done - -sleep 10 - echo ":: Start experiment..." for j in $(seq 1 $REPEAT); do run_fold=`mktemp -up ./out XXXXXXXXXXXXXXXX` echo "start - batch_count=$j - folder=$run_fold" -echo " reset containers" +echo "__reset containers" for i in $(seq 0 $(expr $instances - 1)); do - docker exec donarxp_client_${i} sh -c "mkdir -p $run_fold-$i; echo repeat=$REPEAT,identifier=$IDENTIFIER > $run_fold-$i/info.txt" - docker exec donarxp_client_${i} sh -c "echo instance=$i - server=${SERVER_TARGETS[$i]} - client=${CLIENT_TARGETS[$i]} - tor server=${TOR_DAEMON_SERVER[$i]} - tor client=${TOR_DAEMON_CLIENT[$i]}>> $run_fold-$i/info.txt" - docker exec donarxp_client_${i} sh -c 'killall --quiet -9 bash; killall --quiet -9 donar; killall --quiet -9 measlat; killall --quiet -9 udpecho; killall --quiet -9 torecho' - docker exec donarxp_server_${i} sh -c 'killall --quiet -9 bash; killall --quiet -9 donar; killall --quiet -9 measlat; killall --quiet -9 udpecho; killall --quiet -9 torecho' + echo "____clear $i" + docker container inspect donarxp_server_${i} > /dev/null 2>&1 && docker kill donarxp_server_${i} + docker container inspect donarxp_client_${i} > /dev/null 2>&1 && docker kill donarxp_client_${i} + + echo "____spawning container for instance=$i..." + docker run \ + --rm \ + -d \ + --name "donarxp_server_${i}" \ + -e HOME='/tmp' \ + -v `pwd`/out:/home/donar/out \ + registry.gitlab.inria.fr/qdufour/donar \ + ${TOR_DAEMON_SERVER[$i]} + + docker run \ + --rm \ + -d \ + --name "donarxp_client_${i}" \ + -e HOME='/tmp' \ + -v `pwd`/out:/home/donar/out \ + registry.gitlab.inria.fr/qdufour/donar \ + ${TOR_DAEMON_CLIENT[$i]} + + echo "____create folder struct..." + docker exec donarxp_client_${i} sh -c "mkdir -p $run_fold-$i; echo repeat=$REPEAT,identifier=$IDENTIFIER > $run_fold-$i/info.txt" + docker exec donarxp_client_${i} sh -c "echo instance=$i - server=${SERVER_TARGETS[$i]} - client=${CLIENT_TARGETS[$i]} - tor server=${TOR_DAEMON_SERVER[$i]} - tor client=${TOR_DAEMON_CLIENT[$i]}>> $run_fold-$i/info.txt" done -echo " launch servers" +sleep 10 + +echo "__launch servers" for i in $(seq 0 $(expr $instances - 1)); do echo " instance=$i - exec=${SERVER_TARGETS[$i]}" docker exec donarxp_server_$i ${SERVER_TARGETS[$i]} ${run_fold}-$i & @@ -97,7 +91,7 @@ for i in $(seq 0 $(expr $instances - 1)); do done sleep 10 -echo " launch clients" +echo "__launch clients" (subshellpid=$BASHPID (sleep $WAITFOR; echo " timeout"; kill -9 $subshellpid) & diff --git a/src/algo_thunder.c b/src/algo_thunder.c index d9b3f40..ccc7913 100644 --- a/src/algo_thunder.c +++ b/src/algo_thunder.c @@ -19,7 +19,7 @@ struct thunder_ctx { uint64_t received_pkts_on_link[MAX_LINKS]; uint64_t blacklisted[MAX_LINKS]; size_t monit_pkt_size; - uint64_t allowed_jitter_ms; + int64_t allowed_jitter_ms; struct timespec prev_link_time, prev_rcv_link_time; }; @@ -242,11 +242,28 @@ void classify(struct evt_core_ctx* ctx, struct evt_core_fdinfo* fdinfo, struct b printf("\n");*/ for (int i = 0; i < thunderc->total_links; i++) { - if (thunderc->allowed_jitter_ms >= li[i].delta_t) continue; - if (li[i].delta_t - thunderc->allowed_jitter_ms <= thunderc->rcv_delta_t_per_link[i]) continue; + int64_t remote_delta = 0, local_delta = 0, owd_difference = 0; + remote_delta = li[i].delta_t; + local_delta = thunderc->rcv_delta_t_per_link[i]; + if (remote_delta > 10000) continue; // Too many time elapsed for useful comparison + // + owd_difference = local_delta - remote_delta; + if (owd_difference <= thunderc->allowed_jitter_ms && owd_difference >= -thunderc->allowed_jitter_ms) continue; struct block_info *bi = malloc(sizeof(struct block_info)); - bi->i = i; bi->app_ctx = app_ctx; bi->missing = thunderc->received_pkts_on_link[i]; + + if (owd_difference < -thunderc->allowed_jitter_ms) { + bi->i = link_id; + bi->app_ctx = app_ctx; + bi->missing = thunderc->received_pkts_on_link[link_id]; + } else if (owd_difference > thunderc->allowed_jitter_ms) { + bi->i = i; + bi->app_ctx = app_ctx; + bi->missing = thunderc->received_pkts_on_link[i]; + } else { + fprintf(stderr, "Algorithm is wrong\n"); + exit(EXIT_FAILURE); + } //printf(" Packet Too Late - Blocked link %d (expected: at least %dms ago, received: %ldms ago)\n", i, li[i].delta_t - thunderc->allowed_jitter_ms, thunderc->rcv_delta_t_per_link[i]); on_block(ctx, bi);