Able to set jitter

This commit is contained in:
Quentin 2019-09-06 15:28:42 +02:00
parent ff714bbe27
commit 40f6e65911
11 changed files with 28 additions and 19 deletions

View file

@ -3,11 +3,10 @@ SHELL := /bin/bash
simple_test:
./run-3 \
1,simple_test . \
thunder-client 600 100 100 8 . \
thunder-server 8 . \
thunder-client 600 100 100 8 150 . \
thunder-server 8 150 . \
tor3 -f /etc/torrc_simple . \
tor3 -f /etc/torrc_simple
tor_bw_small:
./run-3 \
1,tor_bw_small . \

View file

@ -103,7 +103,7 @@ echo " launch clients"
echo " instance=$i - exec=${CLIENT_TARGETS[$i]}"
docker exec donarxp_client_$i ${CLIENT_TARGETS[$i]} ${run_fold}-$i &
sleep 10
done; wait; echo " ok"; kill -9 $subshellpid)) 2>/dev/null
done; wait; echo " ok"; docker exec donarxp_client_${i} killall -15 donar; docker exec donarxp_server_${i} killall -15 donar; kill -15 $subshellpid)) 2>/dev/null
done

View file

@ -1,10 +1,11 @@
#!/bin/bash
mkdir -p $5/{log,shared,res}
mkdir -p $6/{log,shared,res}
donar \
-a thunder \
-c \
-o $5/shared/onion_services.pub \
-o $6/shared/onion_services.pub \
-l $4 \
-p $5 \
-b \
-r 9000 \
> $5/log/client-donar-stdout.log 2> $5/log/client-donar-stderr.log &

View file

@ -1,11 +1,12 @@
#!/bin/bash
mkdir -p $2/{log,shared}
cd $2/shared
mkdir -p $3/{log,shared}
cd $3/shared
donar \
-a thunder \
-s \
-l $1 \
-p $2 \
-b \
-e 9000 \
> ../log/server-donar-stdout.log 2> ../log/server-donar-stderr.log &

View file

@ -20,6 +20,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;
struct timespec prev_link_time, prev_rcv_link_time;
};
@ -372,12 +373,18 @@ void algo_thunder_init(struct evt_core_ctx* ctx, struct algo_ctx* app_ctx, struc
thunderc->emit_id = 1;
thunderc->total_links = app_ctx->ap.links;
thunderc->selected_link = thunderc->total_links - 1;
thunderc->allowed_jitter_ms = 200;
for (int i = 0; i < MAX_LINKS; i++) thunderc->received_pkts_on_link[i] = 1;
union abstract_packet links = {};
//fprintf(stderr, "Total links %d\n", thunderc->total_links);
thunderc->monit_pkt_size = sizeof(links.fmt.headers) + sizeof(links.fmt.content.link_monitoring_thunder) + sizeof(struct link_info) * (thunderc->total_links - 1);
if (ap->algo_specific_params != NULL) {
sscanf(ap->algo_specific_params, "%ld", &thunderc->allowed_jitter_ms);
}
printf("Allowed jitter set to %ld ms\n", thunderc->allowed_jitter_ms);
init_timer(ctx);
}

View file

@ -14,7 +14,7 @@ int main(int argc, char** argv) {
struct donar_params dp = {0};
donar_init_params (&dp);
while ((dp.opt = getopt(argc, argv, "nvcse:r:o:a:bhl:d:f:i:")) != -1) {
while ((dp.opt = getopt(argc, argv, "nvcse:r:o:a:bl:d:f:i:p:")) != -1) {
switch(dp.opt) {
case 'n':
dp.tof |= TOR_ONION_FLAG_NON_ANONYMOUS;
@ -44,8 +44,8 @@ int main(int argc, char** argv) {
case 'a':
dp.algo = strdup(optarg);
break;
case 'h':
dp.is_healing = 1;
case 'p':
dp.algo_specific_params = strdup(optarg);
break;
case 'b':
dp.is_waiting_bootstrap = 1;
@ -95,6 +95,7 @@ terminate:
if (dp.algo != NULL) free(dp.algo);
if (dp.capture_file != NULL) free(dp.capture_file);
if (dp.bound_ip != NULL) free(dp.bound_ip);
if (dp.algo_specific_params != NULL) free(dp.algo_specific_params);
g_ptr_array_free(dp.exposed_ports, TRUE);
g_ptr_array_free(dp.remote_ports, TRUE);

View file

@ -72,7 +72,7 @@ void init_socks5_sinks(struct donar_client_ctx* app_ctx) {
void donar_client(struct donar_client_ctx* ctx, struct donar_params* dp) {
struct algo_params ap = {
.is_waiting_bootstrap = dp->is_waiting_bootstrap,
.is_healing = dp->is_healing,
.algo_specific_params = dp->algo_specific_params,
.algo_name = dp->algo,
.links = dp->links,
.fresh_data = dp->fresh_data,

View file

@ -20,7 +20,7 @@ int on_signal(struct evt_core_ctx* evts, struct evt_core_fdinfo* fdinfo) {
}
printf("Signal received: %d\n", fdsi.ssi_signo);
if (fdsi.ssi_signo == SIGINT || fdsi.ssi_signo == SIGQUIT) {
if (fdsi.ssi_signo == SIGINT || fdsi.ssi_signo == SIGQUIT || fdsi.ssi_signo == SIGTERM) {
printf("Stop main loop and quit\n");
evts->loop = 0;
}
@ -42,6 +42,7 @@ void signal_init(struct evt_core_ctx* evts) {
sigaddset(&mask, SIGINT);
sigaddset(&mask, SIGQUIT);
sigaddset(&mask, SIGTERM);
if (sigprocmask(SIG_BLOCK, &mask, NULL) == -1) {
perror("sigprocmask");
exit(EXIT_FAILURE);
@ -150,7 +151,7 @@ void donar_init_params(struct donar_params* dp) {
dp->bound_ip = NULL;
dp->is_server = 0;
dp->is_client = 0;
dp->is_healing = 0;
dp->algo_specific_params = NULL;
dp->is_waiting_bootstrap = 0;
dp->errored = 0;
dp->links = 8;

View file

@ -10,8 +10,8 @@
#include "tor_ctl.h"
struct donar_params {
int opt, is_server, is_client, is_waiting_bootstrap, is_healing, errored, verbose, links, fresh_data, redundant_data;
char *bound_ip, *port, *onion_file, *algo, *capture_file;
int opt, is_server, is_client, is_waiting_bootstrap, errored, verbose, links, fresh_data, redundant_data;
char *bound_ip, *port, *onion_file, *algo, *capture_file, *algo_specific_params;
GPtrArray *remote_ports, *exposed_ports;
enum TOR_ONION_FLAGS tof;
};

View file

@ -54,7 +54,7 @@ socket_create_err:
void donar_server(struct donar_server_ctx* ctx, struct donar_params* dp) {
struct algo_params ap = {
.is_waiting_bootstrap = dp->is_waiting_bootstrap,
.is_healing = dp->is_healing,
.algo_specific_params = dp->algo_specific_params,
.algo_name = dp->algo,
.links = dp->links,
.fresh_data = dp->fresh_data,

View file

@ -13,8 +13,7 @@
struct algo_params {
uint8_t is_waiting_bootstrap;
uint8_t is_healing;
char *algo_name, *capture_file;
char *algo_name, *capture_file, *algo_specific_params;
int links, fresh_data, redundant_data;
};