From e1300791b8e343db3173af975bfab01891afdb64 Mon Sep 17 00:00:00 2001 From: Quentin Date: Sat, 1 Feb 2020 19:43:28 +0100 Subject: [PATCH 01/27] Reduce parallel --- scripts/Makefile | 66 +----------------------------------------------- 1 file changed, 1 insertion(+), 65 deletions(-) diff --git a/scripts/Makefile b/scripts/Makefile index 32db450..8e3157d 100644 --- a/scripts/Makefile +++ b/scripts/Makefile @@ -822,11 +822,7 @@ jan_battle_normal: jan_battle_hardened: ./run-3 \ - 8,jan_battle_hardened. \ - orig-client 135000 40 172, \ - orig-client 135000 40 172, \ - orig-client 135000 40 172, \ - orig-client 135000 40 172, \ + 32,jan_battle_hardened. \ orig-client 135000 40 172, \ orig-client 135000 40 172, \ orig-client 135000 40 172, \ @@ -835,22 +831,10 @@ jan_battle_hardened: dup2-client 135000 40 172 2, \ dup2-client 135000 40 172 2, \ dup2-client 135000 40 172 2, \ - dup2-client 135000 40 172 2, \ - dup2-client 135000 40 172 2, \ - dup2-client 135000 40 172 2, \ - dup2-client 135000 40 172 2, \ lightning-client 135000 40 172 12 fast_count=3!tick_tock=1!measlat=1!window=2000, \ lightning-client 135000 40 172 12 fast_count=3!tick_tock=1!measlat=1!window=2000, \ lightning-client 135000 40 172 12 fast_count=3!tick_tock=1!measlat=1!window=2000, \ lightning-client 135000 40 172 12 fast_count=3!tick_tock=1!measlat=1!window=2000, \ - lightning-client 135000 40 172 12 fast_count=3!tick_tock=1!measlat=1!window=2000, \ - lightning-client 135000 40 172 12 fast_count=3!tick_tock=1!measlat=1!window=2000, \ - lightning-client 135000 40 172 12 fast_count=3!tick_tock=1!measlat=1!window=2000, \ - lightning-client 135000 40 172 12 fast_count=3!tick_tock=1!measlat=1!window=2000, \ - lightning-client 135000 40 172 12 fast_count=3!tick_tock=0!measlat=1!window=2000, \ - lightning-client 135000 40 172 12 fast_count=3!tick_tock=0!measlat=1!window=2000, \ - lightning-client 135000 40 172 12 fast_count=3!tick_tock=0!measlat=1!window=2000, \ - lightning-client 135000 40 172 12 fast_count=3!tick_tock=0!measlat=1!window=2000, \ lightning-client 135000 40 172 12 fast_count=3!tick_tock=0!measlat=1!window=2000, \ lightning-client 135000 40 172 12 fast_count=3!tick_tock=0!measlat=1!window=2000, \ lightning-client 135000 40 172 12 fast_count=3!tick_tock=0!measlat=1!window=2000, \ @@ -859,14 +843,6 @@ jan_battle_hardened: orig-server 135000 40 172, \ orig-server 135000 40 172, \ orig-server 135000 40 172, \ - orig-server 135000 40 172, \ - orig-server 135000 40 172, \ - orig-server 135000 40 172, \ - orig-server 135000 40 172, \ - dup2-server 135000 40 172 2, \ - dup2-server 135000 40 172 2, \ - dup2-server 135000 40 172 2, \ - dup2-server 135000 40 172 2, \ dup2-server 135000 40 172 2, \ dup2-server 135000 40 172 2, \ dup2-server 135000 40 172 2, \ @@ -875,14 +851,6 @@ jan_battle_hardened: lightning-server 135000 40 172 12 fast_count=3!tick_tock=1!measlat=1!window=2000, \ lightning-server 135000 40 172 12 fast_count=3!tick_tock=1!measlat=1!window=2000, \ lightning-server 135000 40 172 12 fast_count=3!tick_tock=1!measlat=1!window=2000, \ - lightning-server 135000 40 172 12 fast_count=3!tick_tock=1!measlat=1!window=2000, \ - lightning-server 135000 40 172 12 fast_count=3!tick_tock=1!measlat=1!window=2000, \ - lightning-server 135000 40 172 12 fast_count=3!tick_tock=1!measlat=1!window=2000, \ - lightning-server 135000 40 172 12 fast_count=3!tick_tock=1!measlat=1!window=2000, \ - lightning-server 135000 40 172 12 fast_count=3!tick_tock=0!measlat=1!window=2000, \ - lightning-server 135000 40 172 12 fast_count=3!tick_tock=0!measlat=1!window=2000, \ - lightning-server 135000 40 172 12 fast_count=3!tick_tock=0!measlat=1!window=2000, \ - lightning-server 135000 40 172 12 fast_count=3!tick_tock=0!measlat=1!window=2000, \ lightning-server 135000 40 172 12 fast_count=3!tick_tock=0!measlat=1!window=2000, \ lightning-server 135000 40 172 12 fast_count=3!tick_tock=0!measlat=1!window=2000, \ lightning-server 135000 40 172 12 fast_count=3!tick_tock=0!measlat=1!window=2000, \ @@ -902,22 +870,6 @@ jan_battle_hardened: tor3 -f /etc/torrc_guard_2, \ tor3 -f /etc/torrc_guard_2, \ tor3 -f /etc/torrc_guard_2, \ - tor3 -f /etc/torrc_guard_2, \ - tor3 -f /etc/torrc_guard_2, \ - tor3 -f /etc/torrc_guard_2, \ - tor3 -f /etc/torrc_guard_2, \ - tor3 -f /etc/torrc_guard_2, \ - tor3 -f /etc/torrc_guard_2, \ - tor3 -f /etc/torrc_guard_2, \ - tor3 -f /etc/torrc_guard_2, \ - tor3 -f /etc/torrc_guard_2, \ - tor3 -f /etc/torrc_guard_2, \ - tor3 -f /etc/torrc_guard_2, \ - tor3 -f /etc/torrc_guard_2, \ - tor3 -f /etc/torrc_guard_2, \ - tor3 -f /etc/torrc_guard_2, \ - tor3 -f /etc/torrc_guard_2, \ - tor3 -f /etc/torrc_guard_2, \ tor3 -f /etc/torrc_guard_2. \ tor3 -f /etc/torrc_guard_2, \ tor3 -f /etc/torrc_guard_2, \ @@ -934,22 +886,6 @@ jan_battle_hardened: tor3 -f /etc/torrc_guard_2, \ tor3 -f /etc/torrc_guard_2, \ tor3 -f /etc/torrc_guard_2, \ - tor3 -f /etc/torrc_guard_2, \ - tor3 -f /etc/torrc_guard_2, \ - tor3 -f /etc/torrc_guard_2, \ - tor3 -f /etc/torrc_guard_2, \ - tor3 -f /etc/torrc_guard_2, \ - tor3 -f /etc/torrc_guard_2, \ - tor3 -f /etc/torrc_guard_2, \ - tor3 -f /etc/torrc_guard_2, \ - tor3 -f /etc/torrc_guard_2, \ - tor3 -f /etc/torrc_guard_2, \ - tor3 -f /etc/torrc_guard_2, \ - tor3 -f /etc/torrc_guard_2, \ - tor3 -f /etc/torrc_guard_2, \ - tor3 -f /etc/torrc_guard_2, \ - tor3 -f /etc/torrc_guard_2, \ - tor3 -f /etc/torrc_guard_2, \ tor3 -f /etc/torrc_guard_2. jan_battle_light: From f94427ecca937742d4dc224d592c63a931892721 Mon Sep 17 00:00:00 2001 From: Quentin Date: Sat, 1 Feb 2020 20:21:41 +0100 Subject: [PATCH 02/27] Improve retry mechanism --- src/donar_client.c | 43 ++++++++++++++++++++++++++++++------------- src/donar_client.h | 1 + 2 files changed, 31 insertions(+), 13 deletions(-) diff --git a/src/donar_client.c b/src/donar_client.c index dd57647..0de2797 100644 --- a/src/donar_client.c +++ b/src/donar_client.c @@ -44,13 +44,31 @@ failed: exit(EXIT_FAILURE); } +void reinit_socks5(struct evt_core_ctx* ctx, void* user_data) { + // @FIXME: Ugly way to get donar_client_ctx. Shame on me :/ + struct evt_core_cat* cat = evt_core_get_from_cat (ctx, "socks5-failed"); + if (cat == NULL) { + fprintf(stderr, "Unable to reconnect stream as socks5-failed cat is not available...\n"); + exit(EXIT_FAILURE); + } + struct donar_client_ctx* app_ctx = cat->app_ctx; + int64_t pos = (int64_t) user_data; // trust me... + + fprintf(stdout, "[%s][donar-client] We have waited enough, retriggering socks5 for port %ld\n", current_human_datetime (), pos+7500); + init_socks5_client (app_ctx, pos); +} + int on_socks5_failed(struct evt_core_ctx* ctx, struct evt_core_fdinfo* fdinfo) { struct donar_client_ctx* app_ctx = fdinfo->cat->app_ctx; struct socks5_ctx* s5ctx = fdinfo->other; - int pos = s5ctx->port - 7500; + int64_t pos = 0; + pos = s5ctx->port - 7500; + int64_t to_wait_sec = 30 + pos*3; + fprintf(stdout, "[%s][donar-client] Retriggering socks5 in %ld seconds for port %d\n", current_human_datetime (), to_wait_sec, s5ctx->port); + set_timeout(ctx, 1000 * to_wait_sec, (void*) pos, reinit_socks5); evt_core_rm_fd (ctx, fdinfo->fd); - init_socks5_client (app_ctx, pos); + //init_socks5_client (app_ctx, pos); return 1; } @@ -70,18 +88,11 @@ void init_socks5_sinks(struct donar_client_ctx* app_ctx) { } int donar_client_stream_repair(struct evt_core_ctx* ctx, struct evt_core_fdinfo* fdinfo) { - // @FIXME: Ugly way to get donar_client_ctx. Shame on me :/ fprintf(stdout, "[%s][donar-client] %s broke\n", current_human_datetime (), fdinfo->url); - struct evt_core_cat* cat = evt_core_get_from_cat (ctx, "socks5-failed"); - if (cat == NULL) { - fprintf(stderr, "Unable to reconnect stream as socks5-failed cat is not available...\n"); - exit(EXIT_FAILURE); - } - struct donar_client_ctx* app_ctx = cat->app_ctx; - struct evt_core_fdinfo* fdtarget = NULL; int port = url_get_port_int (fdinfo->url); - int pos = port - 7500, removed = 0; + int64_t pos = 0, removed = 0; + pos = port - 7500; char buffer[256]; sprintf(buffer, "tcp:read:127.0.0.1:%d", port); @@ -99,8 +110,10 @@ int donar_client_stream_repair(struct evt_core_ctx* ctx, struct evt_core_fdinfo* } if (removed == 2) { - fprintf(stdout, "[%s][donar-client] Retriggering socks5 for port %d\n", current_human_datetime (), port); - init_socks5_client (app_ctx, pos); + int64_t to_wait_sec = 10 + pos*3; + fprintf(stdout, "[%s][donar-client] Retriggering socks5 in %ld seconds for port %d\n", current_human_datetime (), to_wait_sec, port); + set_timeout(ctx, 1000 * to_wait_sec, (void*) pos, reinit_socks5); + //init_socks5_client (app_ctx, pos); return 1; } else if (removed == 0) { fprintf(stdout, "[%s][donar-client] Socks5 has already been retriggered for port %d\n", current_human_datetime (), port); @@ -143,6 +156,9 @@ void donar_client(struct donar_client_ctx* ctx, struct donar_params* dp) { } printf("--- TCP Clients Connected\n"); + init_timer(&ctx->evts); + printf("--- Inited Timer\n"); + g_ptr_array_foreach (dp->remote_ports, (void(*)(void*, void*))init_udp_remote, &(ctx->evts)); printf("--- Remote ports are binded locally\n"); @@ -153,5 +169,6 @@ void donar_client(struct donar_client_ctx* ctx, struct donar_params* dp) { evt_core_loop(&(ctx->evts)); + //stop_timer(&(ctx->evts)); tor_os_free (&(ctx->tos)); } diff --git a/src/donar_client.h b/src/donar_client.h index ad44f12..41fdfc5 100644 --- a/src/donar_client.h +++ b/src/donar_client.h @@ -6,6 +6,7 @@ #include "socks5.h" #include "proxy.h" #include "donar_init.h" +#include "timer.h" #define CLIENT_PORT_SIZE 64 From 187266426a82307686f44d1625d009ccc70736f2 Mon Sep 17 00:00:00 2001 From: Quentin Date: Sat, 1 Feb 2020 22:14:34 +0100 Subject: [PATCH 03/27] rate limit socks 5 connections --- src/donar_client.c | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/src/donar_client.c b/src/donar_client.c index 0de2797..4f1f598 100644 --- a/src/donar_client.c +++ b/src/donar_client.c @@ -151,14 +151,16 @@ void donar_client(struct donar_client_ctx* ctx, struct donar_params* dp) { load_onion_services (ctx, dp->onion_file, dp->links); printf("--- Onion services loaded\n"); - for (int i = 0; i < dp->links; i++) { - init_socks5_client(ctx, i); - } - printf("--- TCP Clients Connected\n"); - init_timer(&ctx->evts); printf("--- Inited Timer\n"); + for (int64_t i = 0; i < dp->links; i++) { + int64_t to_wait_sec = 10 + i * 3; + fprintf(stdout, "[%s][donar-client] Triggering socks5 in %ld seconds for port %d\n", current_human_datetime (), to_wait_sec, i+7500); + set_timeout(&ctx->evts, 1000 * to_wait_sec, (void*) i, reinit_socks5); + } + printf("--- TCP Clients Connected\n"); + g_ptr_array_foreach (dp->remote_ports, (void(*)(void*, void*))init_udp_remote, &(ctx->evts)); printf("--- Remote ports are binded locally\n"); From d956f0278ec327c9d340ac10d2360caf63193967 Mon Sep 17 00:00:00 2001 From: Quentin Date: Sat, 1 Feb 2020 22:49:41 +0100 Subject: [PATCH 04/27] isolate dest port --- torrc_guard_1 | 1 + torrc_guard_10 | 7 +++++++ torrc_guard_11 | 7 +++++++ torrc_guard_12 | 1 + torrc_guard_13 | 7 +++++++ torrc_guard_14 | 7 +++++++ torrc_guard_15 | 7 +++++++ torrc_guard_16 | 1 + torrc_guard_2 | 1 + torrc_guard_3 | 1 + torrc_guard_4 | 1 + torrc_guard_5 | 1 + torrc_guard_6 | 1 + torrc_guard_7 | 1 + torrc_guard_8 | 1 + torrc_guard_9 | 7 +++++++ torrc_simple | 1 + torrc_single_hop | 1 + torrc_single_hop_12 | 1 + torrc_single_hop_16 | 1 + 20 files changed, 56 insertions(+) create mode 100644 torrc_guard_10 create mode 100644 torrc_guard_11 create mode 100644 torrc_guard_13 create mode 100644 torrc_guard_14 create mode 100644 torrc_guard_15 create mode 100644 torrc_guard_9 diff --git a/torrc_guard_1 b/torrc_guard_1 index 2b07da1..188a5c0 100644 --- a/torrc_guard_1 +++ b/torrc_guard_1 @@ -3,4 +3,5 @@ UseEntryGuards 1 NumEntryGuards 1 NumPrimaryGuards 1 SafeLogging 0 +SocksPort 127.0.0.1:9500 IsolateDestPort #Log INFO stdout diff --git a/torrc_guard_10 b/torrc_guard_10 new file mode 100644 index 0000000..76e9108 --- /dev/null +++ b/torrc_guard_10 @@ -0,0 +1,7 @@ +ControlPort 9051 +UseEntryGuards 1 +NumEntryGuards 10 +NumPrimaryGuards 10 +SafeLogging 0 +SocksPort 127.0.0.1:9500 IsolateDestPort +#Log INFO stdout diff --git a/torrc_guard_11 b/torrc_guard_11 new file mode 100644 index 0000000..76fdbbd --- /dev/null +++ b/torrc_guard_11 @@ -0,0 +1,7 @@ +ControlPort 9051 +UseEntryGuards 1 +NumEntryGuards 11 +NumPrimaryGuards 11 +SafeLogging 0 +SocksPort 127.0.0.1:9500 IsolateDestPort +#Log INFO stdout diff --git a/torrc_guard_12 b/torrc_guard_12 index 4c8a921..c265f6c 100644 --- a/torrc_guard_12 +++ b/torrc_guard_12 @@ -3,4 +3,5 @@ UseEntryGuards 1 NumEntryGuards 12 NumPrimaryGuards 12 SafeLogging 0 +SocksPort 127.0.0.1:9500 IsolateDestPort #Log INFO stdout diff --git a/torrc_guard_13 b/torrc_guard_13 new file mode 100644 index 0000000..0bacd45 --- /dev/null +++ b/torrc_guard_13 @@ -0,0 +1,7 @@ +ControlPort 9051 +UseEntryGuards 1 +NumEntryGuards 13 +NumPrimaryGuards 13 +SafeLogging 0 +SocksPort 127.0.0.1:9500 IsolateDestPort +#Log INFO stdout diff --git a/torrc_guard_14 b/torrc_guard_14 new file mode 100644 index 0000000..846a703 --- /dev/null +++ b/torrc_guard_14 @@ -0,0 +1,7 @@ +ControlPort 9051 +UseEntryGuards 1 +NumEntryGuards 14 +NumPrimaryGuards 14 +SafeLogging 0 +SocksPort 127.0.0.1:9500 IsolateDestPort +#Log INFO stdout diff --git a/torrc_guard_15 b/torrc_guard_15 new file mode 100644 index 0000000..4a1f081 --- /dev/null +++ b/torrc_guard_15 @@ -0,0 +1,7 @@ +ControlPort 9051 +UseEntryGuards 1 +NumEntryGuards 15 +NumPrimaryGuards 15 +SafeLogging 0 +SocksPort 127.0.0.1:9500 IsolateDestPort +#Log INFO stdout diff --git a/torrc_guard_16 b/torrc_guard_16 index dd7248c..0987810 100644 --- a/torrc_guard_16 +++ b/torrc_guard_16 @@ -3,4 +3,5 @@ UseEntryGuards 1 NumEntryGuards 16 NumPrimaryGuards 16 SafeLogging 0 +SocksPort 127.0.0.1:9500 IsolateDestPort #Log INFO stdout diff --git a/torrc_guard_2 b/torrc_guard_2 index 903908e..d638283 100644 --- a/torrc_guard_2 +++ b/torrc_guard_2 @@ -3,4 +3,5 @@ UseEntryGuards 1 NumEntryGuards 2 NumPrimaryGuards 2 SafeLogging 0 +SocksPort 127.0.0.1:9500 IsolateDestPort #Log DEBUG stdout diff --git a/torrc_guard_3 b/torrc_guard_3 index e64d87d..2a3861f 100644 --- a/torrc_guard_3 +++ b/torrc_guard_3 @@ -3,4 +3,5 @@ UseEntryGuards 1 NumEntryGuards 3 NumPrimaryGuards 3 SafeLogging 0 +SocksPort 127.0.0.1:9500 IsolateDestPort #Log INFO stdout diff --git a/torrc_guard_4 b/torrc_guard_4 index 720924a..22eda5b 100644 --- a/torrc_guard_4 +++ b/torrc_guard_4 @@ -3,4 +3,5 @@ UseEntryGuards 1 NumEntryGuards 4 NumPrimaryGuards 4 SafeLogging 0 +SocksPort 127.0.0.1:9500 IsolateDestPort #Log INFO stdout diff --git a/torrc_guard_5 b/torrc_guard_5 index b26ae35..5d763b0 100644 --- a/torrc_guard_5 +++ b/torrc_guard_5 @@ -3,4 +3,5 @@ UseEntryGuards 1 NumEntryGuards 5 NumPrimaryGuards 5 SafeLogging 0 +SocksPort 127.0.0.1:9500 IsolateDestPort #Log INFO stdout diff --git a/torrc_guard_6 b/torrc_guard_6 index bdb6f18..eae8eac 100644 --- a/torrc_guard_6 +++ b/torrc_guard_6 @@ -3,4 +3,5 @@ UseEntryGuards 1 NumEntryGuards 6 NumPrimaryGuards 6 SafeLogging 0 +SocksPort 127.0.0.1:9500 IsolateDestPort #Log INFO stdout diff --git a/torrc_guard_7 b/torrc_guard_7 index 28b8ac4..5cdd696 100644 --- a/torrc_guard_7 +++ b/torrc_guard_7 @@ -3,4 +3,5 @@ UseEntryGuards 1 NumEntryGuards 7 NumPrimaryGuards 7 SafeLogging 0 +SocksPort 127.0.0.1:9500 IsolateDestPort #Log INFO stdout diff --git a/torrc_guard_8 b/torrc_guard_8 index ba18a3d..9e1a7f5 100644 --- a/torrc_guard_8 +++ b/torrc_guard_8 @@ -3,4 +3,5 @@ UseEntryGuards 1 NumEntryGuards 8 NumPrimaryGuards 8 SafeLogging 0 +SocksPort 127.0.0.1:9500 IsolateDestPort #Log INFO stdout diff --git a/torrc_guard_9 b/torrc_guard_9 new file mode 100644 index 0000000..bcabfb3 --- /dev/null +++ b/torrc_guard_9 @@ -0,0 +1,7 @@ +ControlPort 9051 +UseEntryGuards 1 +NumEntryGuards 9 +NumPrimaryGuards 9 +SafeLogging 0 +SocksPort 127.0.0.1:9500 IsolateDestPort +#Log INFO stdout diff --git a/torrc_simple b/torrc_simple index 2a1bbdd..8b08057 100644 --- a/torrc_simple +++ b/torrc_simple @@ -1,5 +1,6 @@ ControlPort 9051 UseEntryGuards 0 +SocksPort 127.0.0.1:9500 IsolateDestPort SafeLogging 0 #IsolateDestPort 1 #Log INFO stdout diff --git a/torrc_single_hop b/torrc_single_hop index 08c7295..a02020f 100644 --- a/torrc_single_hop +++ b/torrc_single_hop @@ -4,4 +4,5 @@ UseEntryGuards 0 SafeLogging 0 HiddenServiceNonAnonymousMode 1 HiddenServiceSingleHopMode 1 +SocksPort 127.0.0.1:9500 IsolateDestPort #Log INFO stdout diff --git a/torrc_single_hop_12 b/torrc_single_hop_12 index 7d48d31..d1e11d7 100644 --- a/torrc_single_hop_12 +++ b/torrc_single_hop_12 @@ -6,4 +6,5 @@ NumPrimaryGuards 12 SafeLogging 0 HiddenServiceNonAnonymousMode 1 HiddenServiceSingleHopMode 1 +SocksPort 127.0.0.1:9500 IsolateDestPort #Log INFO stdout diff --git a/torrc_single_hop_16 b/torrc_single_hop_16 index 964d7d1..d6110b7 100644 --- a/torrc_single_hop_16 +++ b/torrc_single_hop_16 @@ -4,6 +4,7 @@ UseEntryGuards 1 NumEntryGuards 16 NumPrimaryGuards 16 SafeLogging 0 +SocksPort 127.0.0.1:9500 IsolateDestPort HiddenServiceNonAnonymousMode 1 HiddenServiceSingleHopMode 1 #Log INFO stdout From b8cf2cbcab3dcce0c14da135ea77bd2d3f30c641 Mon Sep 17 00:00:00 2001 From: Quentin Date: Sat, 1 Feb 2020 23:32:16 +0100 Subject: [PATCH 05/27] fix torrc port --- torrc_guard_1 | 2 +- torrc_guard_10 | 2 +- torrc_guard_11 | 2 +- torrc_guard_12 | 2 +- torrc_guard_13 | 2 +- torrc_guard_14 | 2 +- torrc_guard_15 | 2 +- torrc_guard_16 | 2 +- torrc_guard_2 | 2 +- torrc_guard_3 | 2 +- torrc_guard_4 | 2 +- torrc_guard_5 | 2 +- torrc_guard_6 | 2 +- torrc_guard_7 | 2 +- torrc_guard_8 | 2 +- torrc_guard_9 | 2 +- torrc_simple | 2 +- torrc_single_hop | 2 +- torrc_single_hop_12 | 2 +- torrc_single_hop_16 | 2 +- 20 files changed, 20 insertions(+), 20 deletions(-) diff --git a/torrc_guard_1 b/torrc_guard_1 index 188a5c0..cce8a5b 100644 --- a/torrc_guard_1 +++ b/torrc_guard_1 @@ -3,5 +3,5 @@ UseEntryGuards 1 NumEntryGuards 1 NumPrimaryGuards 1 SafeLogging 0 -SocksPort 127.0.0.1:9500 IsolateDestPort +SocksPort 127.0.0.1:9050 IsolateDestPort #Log INFO stdout diff --git a/torrc_guard_10 b/torrc_guard_10 index 76e9108..4fc2c60 100644 --- a/torrc_guard_10 +++ b/torrc_guard_10 @@ -3,5 +3,5 @@ UseEntryGuards 1 NumEntryGuards 10 NumPrimaryGuards 10 SafeLogging 0 -SocksPort 127.0.0.1:9500 IsolateDestPort +SocksPort 127.0.0.1:9050 IsolateDestPort #Log INFO stdout diff --git a/torrc_guard_11 b/torrc_guard_11 index 76fdbbd..50151a3 100644 --- a/torrc_guard_11 +++ b/torrc_guard_11 @@ -3,5 +3,5 @@ UseEntryGuards 1 NumEntryGuards 11 NumPrimaryGuards 11 SafeLogging 0 -SocksPort 127.0.0.1:9500 IsolateDestPort +SocksPort 127.0.0.1:9050 IsolateDestPort #Log INFO stdout diff --git a/torrc_guard_12 b/torrc_guard_12 index c265f6c..4382d75 100644 --- a/torrc_guard_12 +++ b/torrc_guard_12 @@ -3,5 +3,5 @@ UseEntryGuards 1 NumEntryGuards 12 NumPrimaryGuards 12 SafeLogging 0 -SocksPort 127.0.0.1:9500 IsolateDestPort +SocksPort 127.0.0.1:9050 IsolateDestPort #Log INFO stdout diff --git a/torrc_guard_13 b/torrc_guard_13 index 0bacd45..aa9f2b0 100644 --- a/torrc_guard_13 +++ b/torrc_guard_13 @@ -3,5 +3,5 @@ UseEntryGuards 1 NumEntryGuards 13 NumPrimaryGuards 13 SafeLogging 0 -SocksPort 127.0.0.1:9500 IsolateDestPort +SocksPort 127.0.0.1:9050 IsolateDestPort #Log INFO stdout diff --git a/torrc_guard_14 b/torrc_guard_14 index 846a703..9d71c6f 100644 --- a/torrc_guard_14 +++ b/torrc_guard_14 @@ -3,5 +3,5 @@ UseEntryGuards 1 NumEntryGuards 14 NumPrimaryGuards 14 SafeLogging 0 -SocksPort 127.0.0.1:9500 IsolateDestPort +SocksPort 127.0.0.1:9050 IsolateDestPort #Log INFO stdout diff --git a/torrc_guard_15 b/torrc_guard_15 index 4a1f081..216dc59 100644 --- a/torrc_guard_15 +++ b/torrc_guard_15 @@ -3,5 +3,5 @@ UseEntryGuards 1 NumEntryGuards 15 NumPrimaryGuards 15 SafeLogging 0 -SocksPort 127.0.0.1:9500 IsolateDestPort +SocksPort 127.0.0.1:9050 IsolateDestPort #Log INFO stdout diff --git a/torrc_guard_16 b/torrc_guard_16 index 0987810..a72fe43 100644 --- a/torrc_guard_16 +++ b/torrc_guard_16 @@ -3,5 +3,5 @@ UseEntryGuards 1 NumEntryGuards 16 NumPrimaryGuards 16 SafeLogging 0 -SocksPort 127.0.0.1:9500 IsolateDestPort +SocksPort 127.0.0.1:9050 IsolateDestPort #Log INFO stdout diff --git a/torrc_guard_2 b/torrc_guard_2 index d638283..d910064 100644 --- a/torrc_guard_2 +++ b/torrc_guard_2 @@ -3,5 +3,5 @@ UseEntryGuards 1 NumEntryGuards 2 NumPrimaryGuards 2 SafeLogging 0 -SocksPort 127.0.0.1:9500 IsolateDestPort +SocksPort 127.0.0.1:9050 IsolateDestPort #Log DEBUG stdout diff --git a/torrc_guard_3 b/torrc_guard_3 index 2a3861f..9a08f16 100644 --- a/torrc_guard_3 +++ b/torrc_guard_3 @@ -3,5 +3,5 @@ UseEntryGuards 1 NumEntryGuards 3 NumPrimaryGuards 3 SafeLogging 0 -SocksPort 127.0.0.1:9500 IsolateDestPort +SocksPort 127.0.0.1:9050 IsolateDestPort #Log INFO stdout diff --git a/torrc_guard_4 b/torrc_guard_4 index 22eda5b..96d2b62 100644 --- a/torrc_guard_4 +++ b/torrc_guard_4 @@ -3,5 +3,5 @@ UseEntryGuards 1 NumEntryGuards 4 NumPrimaryGuards 4 SafeLogging 0 -SocksPort 127.0.0.1:9500 IsolateDestPort +SocksPort 127.0.0.1:9050 IsolateDestPort #Log INFO stdout diff --git a/torrc_guard_5 b/torrc_guard_5 index 5d763b0..c6a63d6 100644 --- a/torrc_guard_5 +++ b/torrc_guard_5 @@ -3,5 +3,5 @@ UseEntryGuards 1 NumEntryGuards 5 NumPrimaryGuards 5 SafeLogging 0 -SocksPort 127.0.0.1:9500 IsolateDestPort +SocksPort 127.0.0.1:9050 IsolateDestPort #Log INFO stdout diff --git a/torrc_guard_6 b/torrc_guard_6 index eae8eac..3325be5 100644 --- a/torrc_guard_6 +++ b/torrc_guard_6 @@ -3,5 +3,5 @@ UseEntryGuards 1 NumEntryGuards 6 NumPrimaryGuards 6 SafeLogging 0 -SocksPort 127.0.0.1:9500 IsolateDestPort +SocksPort 127.0.0.1:9050 IsolateDestPort #Log INFO stdout diff --git a/torrc_guard_7 b/torrc_guard_7 index 5cdd696..572ae75 100644 --- a/torrc_guard_7 +++ b/torrc_guard_7 @@ -3,5 +3,5 @@ UseEntryGuards 1 NumEntryGuards 7 NumPrimaryGuards 7 SafeLogging 0 -SocksPort 127.0.0.1:9500 IsolateDestPort +SocksPort 127.0.0.1:9050 IsolateDestPort #Log INFO stdout diff --git a/torrc_guard_8 b/torrc_guard_8 index 9e1a7f5..def8b7a 100644 --- a/torrc_guard_8 +++ b/torrc_guard_8 @@ -3,5 +3,5 @@ UseEntryGuards 1 NumEntryGuards 8 NumPrimaryGuards 8 SafeLogging 0 -SocksPort 127.0.0.1:9500 IsolateDestPort +SocksPort 127.0.0.1:9050 IsolateDestPort #Log INFO stdout diff --git a/torrc_guard_9 b/torrc_guard_9 index bcabfb3..26b62a2 100644 --- a/torrc_guard_9 +++ b/torrc_guard_9 @@ -3,5 +3,5 @@ UseEntryGuards 1 NumEntryGuards 9 NumPrimaryGuards 9 SafeLogging 0 -SocksPort 127.0.0.1:9500 IsolateDestPort +SocksPort 127.0.0.1:9050 IsolateDestPort #Log INFO stdout diff --git a/torrc_simple b/torrc_simple index 8b08057..96c3261 100644 --- a/torrc_simple +++ b/torrc_simple @@ -1,6 +1,6 @@ ControlPort 9051 UseEntryGuards 0 -SocksPort 127.0.0.1:9500 IsolateDestPort +SocksPort 127.0.0.1:9050 IsolateDestPort SafeLogging 0 #IsolateDestPort 1 #Log INFO stdout diff --git a/torrc_single_hop b/torrc_single_hop index a02020f..26c1736 100644 --- a/torrc_single_hop +++ b/torrc_single_hop @@ -4,5 +4,5 @@ UseEntryGuards 0 SafeLogging 0 HiddenServiceNonAnonymousMode 1 HiddenServiceSingleHopMode 1 -SocksPort 127.0.0.1:9500 IsolateDestPort +SocksPort 127.0.0.1:9050 IsolateDestPort #Log INFO stdout diff --git a/torrc_single_hop_12 b/torrc_single_hop_12 index d1e11d7..25aac56 100644 --- a/torrc_single_hop_12 +++ b/torrc_single_hop_12 @@ -6,5 +6,5 @@ NumPrimaryGuards 12 SafeLogging 0 HiddenServiceNonAnonymousMode 1 HiddenServiceSingleHopMode 1 -SocksPort 127.0.0.1:9500 IsolateDestPort +SocksPort 127.0.0.1:9050 IsolateDestPort #Log INFO stdout diff --git a/torrc_single_hop_16 b/torrc_single_hop_16 index d6110b7..41743a8 100644 --- a/torrc_single_hop_16 +++ b/torrc_single_hop_16 @@ -4,7 +4,7 @@ UseEntryGuards 1 NumEntryGuards 16 NumPrimaryGuards 16 SafeLogging 0 -SocksPort 127.0.0.1:9500 IsolateDestPort +SocksPort 127.0.0.1:9050 IsolateDestPort HiddenServiceNonAnonymousMode 1 HiddenServiceSingleHopMode 1 #Log INFO stdout From a8e0f6f827ee653a6dd4ed7d2408d6851bb86272 Mon Sep 17 00:00:00 2001 From: Quentin Date: Sat, 1 Feb 2020 23:33:45 +0100 Subject: [PATCH 06/27] Use only one onion service --- src/donar_client.c | 11 +++++------ src/donar_server.c | 8 ++++---- src/meas_lat.c | 4 ++-- src/net_tools.c | 2 +- src/tor_ctl.c | 27 ++++++++++++++++----------- src/tor_ctl.h | 2 +- src/tor_echo.c | 4 ++-- 7 files changed, 31 insertions(+), 27 deletions(-) diff --git a/src/donar_client.c b/src/donar_client.c index 4f1f598..781f673 100644 --- a/src/donar_client.c +++ b/src/donar_client.c @@ -7,12 +7,11 @@ void load_onion_services(struct donar_client_ctx* ctx, char* onion_file, int por void init_socks5_client(struct donar_client_ctx* app_ctx, int pos) { char target_host[255]; - if (strlen(app_ctx->tos.keys[pos].pub) > 254) { - fprintf(stderr, "Domain name is too long\n"); - exit(EXIT_FAILURE); - } - sprintf(target_host, "%s.onion", app_ctx->tos.keys[pos].pub); - + if (strlen(app_ctx->tos.keys[0].pub) > 254) { + fprintf(stderr, "Domain name is too long\n"); + exit(EXIT_FAILURE); + } + sprintf(target_host, "%s.onion", app_ctx->tos.keys[0].pub); app_ctx->ports[pos] = 7500 + pos; socks5_create_dns_client (&app_ctx->evts, "127.0.0.1", "9050", target_host, app_ctx->ports[pos]); diff --git a/src/donar_server.c b/src/donar_server.c index 64e06b1..44c1987 100644 --- a/src/donar_server.c +++ b/src/donar_server.c @@ -1,7 +1,7 @@ #include "donar_server.h" void create_onion_services(struct tor_os_str* tos, struct tor_ctl* tctl, uint16_t* ports, int ports_count, enum TOR_ONION_FLAGS tof) { - tor_os_create (tos, "onion_services.pub", "onion_services.txt", ports_count); + tor_os_create (tos, "onion_services.pub", "onion_services.txt", 1); tor_os_read (tos); int err = 0; @@ -10,7 +10,7 @@ void create_onion_services(struct tor_os_str* tos, struct tor_ctl* tctl, uint16_ fprintf(stderr, "Unable to open Tor Socket\n"); exit(EXIT_FAILURE); } - err = tor_ctl_add_onion (tctl, tos, ports, tof); + err = tor_ctl_add_onion (tctl, tos, ports, ports_count, tof); if (err != 0) { fprintf(stderr, "Unable to create Onion Services (error: %d)\n", err); exit(EXIT_FAILURE); @@ -82,7 +82,7 @@ struct donar_server_os_republish_params { struct donar_server_ctx* dctx; struct donar_params* dp; }; - +/* void republish_tor_os(struct evt_core_ctx* ctx, void* user_data) { struct donar_server_os_republish_params* dsorp = user_data; @@ -94,7 +94,7 @@ void republish_tor_os(struct evt_core_ctx* ctx, void* user_data) { exit(EXIT_FAILURE); } printf("Republish Tor OS\n"); -} +}*/ void donar_server(struct donar_server_ctx* ctx, struct donar_params* dp) { struct algo_params ap = { diff --git a/src/meas_lat.c b/src/meas_lat.c index ed5af9e..a8ff328 100644 --- a/src/meas_lat.c +++ b/src/meas_lat.c @@ -350,7 +350,7 @@ void spawn_tor_server(struct evt_core_ctx* evts, uint16_t *ports) { } void measlat_create_onion_services(struct tor_os_str* tos, struct tor_ctl* tctl, uint16_t* ports, int ports_count, enum TOR_ONION_FLAGS tof) { - tor_os_create (tos, "onion_services.pub", "onion_services.txt", ports_count); + tor_os_create (tos, "onion_services.pub", "onion_services.txt", 1); tor_os_read (tos); int err = 0; @@ -359,7 +359,7 @@ void measlat_create_onion_services(struct tor_os_str* tos, struct tor_ctl* tctl, fprintf(stderr, "Unable to open Tor Socket\n"); exit(EXIT_FAILURE); } - err = tor_ctl_add_onion (tctl, tos, ports, tof); + err = tor_ctl_add_onion (tctl, tos, ports, ports_count, tof); if (err != 0) { fprintf(stderr, "Unable to create Onion Services (error: %d)\n", err); exit(EXIT_FAILURE); diff --git a/src/net_tools.c b/src/net_tools.c index 0b01658..4a44e14 100644 --- a/src/net_tools.c +++ b/src/net_tools.c @@ -34,7 +34,7 @@ int create_ip_client(char* host, char* service, int type) { } if (cursor == NULL) { - fprintf(stderr, "No connect worked\n"); + fprintf(stderr, "No connect worked for %s:%s\n", host, service); exit(EXIT_FAILURE); } diff --git a/src/tor_ctl.c b/src/tor_ctl.c index 093d16b..cf04583 100644 --- a/src/tor_ctl.c +++ b/src/tor_ctl.c @@ -51,7 +51,7 @@ void tor_ctl_list_onions(struct tor_ctl* ctx) { } } -int tor_ctl_add_onion(struct tor_ctl* ctx, struct tor_os_str* tos, uint16_t* port, enum TOR_ONION_FLAGS flags) { +int tor_ctl_add_onion(struct tor_ctl* ctx, struct tor_os_str* tos, uint16_t* port, uint64_t port_per_os, enum TOR_ONION_FLAGS flags) { int err = 0; char buffer1[1024] = {0}; char buffer2[1024] = {0}; @@ -59,12 +59,14 @@ int tor_ctl_add_onion(struct tor_ctl* ctx, struct tor_os_str* tos, uint16_t* por /* Add onion services loaded from file */ for (int i = 0; i < tos->filled; i++) { - if (flags == TOR_ONION_FLAG_NONE) - fprintf(ctx->wsock, "add_onion %s Port=%d,127.13.3.7:%d\n", tos->keys[i].priv, port[i], port[i]); + fprintf(ctx->wsock, "add_onion %s ", tos->keys[i].priv); + for (int j = 0; j < port_per_os; j++) { + fprintf(ctx->wsock, "Port=%d,127.13.3.7:%d ", port[i*port_per_os+j], port[i*port_per_os+j]); + } + if (flags == TOR_ONION_FLAG_NONE) fprintf(ctx->wsock, "\n"); else { - fprintf(ctx->wsock, "add_onion %s Port=%d,127.13.3.7:%d Flags=", tos->keys[i].priv, port[i], port[i]); - if (flags & TOR_ONION_FLAG_NON_ANONYMOUS) - fprintf(ctx->wsock, "NonAnonymous,"); + fprintf(ctx->wsock, "Flags="); + if (flags & TOR_ONION_FLAG_NON_ANONYMOUS) fprintf(ctx->wsock, "NonAnonymous,"); fprintf(ctx->wsock, "\n"); } @@ -80,14 +82,17 @@ int tor_ctl_add_onion(struct tor_ctl* ctx, struct tor_os_str* tos, uint16_t* por /* Complete by creating new onion services */ for (int i = tos->filled; i < tos->size; i++) { - if (flags == TOR_ONION_FLAG_NONE) - fprintf(ctx->wsock, "add_onion NEW:ED25519-V3 Port=%d\n", port[i]); + fprintf(ctx->wsock, "add_onion NEW:ED25519-V3 "); + for (int j = 0; j < port_per_os; j++) { + fprintf(ctx->wsock, "Port=%d,127.13.3.7:%d ", port[i*port_per_os+j], port[i*port_per_os+j]); + } + if (flags == TOR_ONION_FLAG_NONE) fprintf(ctx->wsock, "\n"); else { - fprintf(ctx->wsock, "add_onion NEW:ED25519-V3 Port=%d Flags=", port[i]); - if (flags & TOR_ONION_FLAG_NON_ANONYMOUS) - fprintf(ctx->wsock, "NonAnonymous,"); + fprintf(ctx->wsock, "Flags="); + if (flags & TOR_ONION_FLAG_NON_ANONYMOUS) fprintf(ctx->wsock, "NonAnonymous,"); fprintf(ctx->wsock, "\n"); } + //fprintf(ctx->wsock, "add_onion NEW:RSA1024 Port=%d\n", port[i]); fscanf(ctx->rsock, "%d", &err); diff --git a/src/tor_ctl.h b/src/tor_ctl.h index 3f85eb4..e1c6c86 100644 --- a/src/tor_ctl.h +++ b/src/tor_ctl.h @@ -20,6 +20,6 @@ enum TOR_ONION_FLAGS { }; int tor_ctl_connect(struct tor_ctl* ctx, char* addr, char* service); -int tor_ctl_add_onion(struct tor_ctl* ctx, struct tor_os_str* tos, uint16_t* port, enum TOR_ONION_FLAGS flags); +int tor_ctl_add_onion(struct tor_ctl* ctx, struct tor_os_str* tos, uint16_t* port, uint64_t port_per_os, enum TOR_ONION_FLAGS flags); void tor_ctl_list_onions(struct tor_ctl* ctx); void tor_ctl_close(struct tor_ctl* ctx); diff --git a/src/tor_echo.c b/src/tor_echo.c index 7c33600..98dd874 100644 --- a/src/tor_echo.c +++ b/src/tor_echo.c @@ -14,7 +14,7 @@ struct torecho_ctx { }; void te_create_onion_services(struct tor_os_str* tos, struct tor_ctl* tctl, uint16_t* ports, int ports_count, enum TOR_ONION_FLAGS tof) { - tor_os_create (tos, "onion_services.pub", "onion_services.txt", ports_count); + tor_os_create (tos, "onion_services.pub", "onion_services.txt", 1); tor_os_read (tos); int err = 0; @@ -23,7 +23,7 @@ void te_create_onion_services(struct tor_os_str* tos, struct tor_ctl* tctl, uint fprintf(stderr, "Unable to open Tor Socket\n"); exit(EXIT_FAILURE); } - err = tor_ctl_add_onion (tctl, tos, ports, tof); + err = tor_ctl_add_onion (tctl, tos, ports, ports_count, tof); if (err != 0) { fprintf(stderr, "Unable to create Onion Services (error: %d)\n", err); exit(EXIT_FAILURE); From 1f43970e233937bbb3594241b90972c53bb6721f Mon Sep 17 00:00:00 2001 From: Quentin Date: Sun, 2 Feb 2020 00:01:17 +0100 Subject: [PATCH 07/27] Update makefile --- scripts/Makefile | 132 +-------------------------------------------- src/donar_client.c | 2 +- 2 files changed, 3 insertions(+), 131 deletions(-) diff --git a/scripts/Makefile b/scripts/Makefile index 8e3157d..7f4ac7a 100644 --- a/scripts/Makefile +++ b/scripts/Makefile @@ -690,11 +690,7 @@ jan_tor_analysis: jan_battle_normal: ./run-3 \ - 8,jan_battle_normal. \ - orig-client 135000 40 172, \ - orig-client 135000 40 172, \ - orig-client 135000 40 172, \ - orig-client 135000 40 172, \ + 32,jan_battle_normal. \ orig-client 135000 40 172, \ orig-client 135000 40 172, \ orig-client 135000 40 172, \ @@ -703,22 +699,10 @@ jan_battle_normal: dup2-client 135000 40 172 2, \ dup2-client 135000 40 172 2, \ dup2-client 135000 40 172 2, \ - dup2-client 135000 40 172 2, \ - dup2-client 135000 40 172 2, \ - dup2-client 135000 40 172 2, \ - dup2-client 135000 40 172 2, \ lightning-client 135000 40 172 12 fast_count=3!tick_tock=1!measlat=1!window=2000, \ lightning-client 135000 40 172 12 fast_count=3!tick_tock=1!measlat=1!window=2000, \ lightning-client 135000 40 172 12 fast_count=3!tick_tock=1!measlat=1!window=2000, \ lightning-client 135000 40 172 12 fast_count=3!tick_tock=1!measlat=1!window=2000, \ - lightning-client 135000 40 172 12 fast_count=3!tick_tock=1!measlat=1!window=2000, \ - lightning-client 135000 40 172 12 fast_count=3!tick_tock=1!measlat=1!window=2000, \ - lightning-client 135000 40 172 12 fast_count=3!tick_tock=1!measlat=1!window=2000, \ - lightning-client 135000 40 172 12 fast_count=3!tick_tock=1!measlat=1!window=2000, \ - lightning-client 135000 40 172 12 fast_count=3!tick_tock=0!measlat=1!window=2000, \ - lightning-client 135000 40 172 12 fast_count=3!tick_tock=0!measlat=1!window=2000, \ - lightning-client 135000 40 172 12 fast_count=3!tick_tock=0!measlat=1!window=2000, \ - lightning-client 135000 40 172 12 fast_count=3!tick_tock=0!measlat=1!window=2000, \ lightning-client 135000 40 172 12 fast_count=3!tick_tock=0!measlat=1!window=2000, \ lightning-client 135000 40 172 12 fast_count=3!tick_tock=0!measlat=1!window=2000, \ lightning-client 135000 40 172 12 fast_count=3!tick_tock=0!measlat=1!window=2000, \ @@ -727,14 +711,6 @@ jan_battle_normal: orig-server 135000 40 172, \ orig-server 135000 40 172, \ orig-server 135000 40 172, \ - orig-server 135000 40 172, \ - orig-server 135000 40 172, \ - orig-server 135000 40 172, \ - orig-server 135000 40 172, \ - dup2-server 135000 40 172 2, \ - dup2-server 135000 40 172 2, \ - dup2-server 135000 40 172 2, \ - dup2-server 135000 40 172 2, \ dup2-server 135000 40 172 2, \ dup2-server 135000 40 172 2, \ dup2-server 135000 40 172 2, \ @@ -743,14 +719,6 @@ jan_battle_normal: lightning-server 135000 40 172 12 fast_count=3!tick_tock=1!measlat=1!window=2000, \ lightning-server 135000 40 172 12 fast_count=3!tick_tock=1!measlat=1!window=2000, \ lightning-server 135000 40 172 12 fast_count=3!tick_tock=1!measlat=1!window=2000, \ - lightning-server 135000 40 172 12 fast_count=3!tick_tock=1!measlat=1!window=2000, \ - lightning-server 135000 40 172 12 fast_count=3!tick_tock=1!measlat=1!window=2000, \ - lightning-server 135000 40 172 12 fast_count=3!tick_tock=1!measlat=1!window=2000, \ - lightning-server 135000 40 172 12 fast_count=3!tick_tock=1!measlat=1!window=2000, \ - lightning-server 135000 40 172 12 fast_count=3!tick_tock=0!measlat=1!window=2000, \ - lightning-server 135000 40 172 12 fast_count=3!tick_tock=0!measlat=1!window=2000, \ - lightning-server 135000 40 172 12 fast_count=3!tick_tock=0!measlat=1!window=2000, \ - lightning-server 135000 40 172 12 fast_count=3!tick_tock=0!measlat=1!window=2000, \ lightning-server 135000 40 172 12 fast_count=3!tick_tock=0!measlat=1!window=2000, \ lightning-server 135000 40 172 12 fast_count=3!tick_tock=0!measlat=1!window=2000, \ lightning-server 135000 40 172 12 fast_count=3!tick_tock=0!measlat=1!window=2000, \ @@ -770,22 +738,6 @@ jan_battle_normal: tor2 -f /etc/torrc_guard_16, \ tor2 -f /etc/torrc_guard_16, \ tor2 -f /etc/torrc_guard_16, \ - tor2 -f /etc/torrc_guard_16, \ - tor2 -f /etc/torrc_guard_16, \ - tor2 -f /etc/torrc_guard_16, \ - tor2 -f /etc/torrc_guard_16, \ - tor2 -f /etc/torrc_guard_16, \ - tor2 -f /etc/torrc_guard_16, \ - tor2 -f /etc/torrc_guard_16, \ - tor2 -f /etc/torrc_guard_16, \ - tor2 -f /etc/torrc_guard_16, \ - tor2 -f /etc/torrc_guard_16, \ - tor2 -f /etc/torrc_guard_16, \ - tor2 -f /etc/torrc_guard_16, \ - tor2 -f /etc/torrc_guard_16, \ - tor2 -f /etc/torrc_guard_16, \ - tor2 -f /etc/torrc_guard_16, \ - tor2 -f /etc/torrc_guard_16, \ tor2 -f /etc/torrc_guard_16. \ tor2 -f /etc/torrc_guard_16, \ tor2 -f /etc/torrc_guard_16, \ @@ -802,22 +754,6 @@ jan_battle_normal: tor2 -f /etc/torrc_guard_16, \ tor2 -f /etc/torrc_guard_16, \ tor2 -f /etc/torrc_guard_16, \ - tor2 -f /etc/torrc_guard_16, \ - tor2 -f /etc/torrc_guard_16, \ - tor2 -f /etc/torrc_guard_16, \ - tor2 -f /etc/torrc_guard_16, \ - tor2 -f /etc/torrc_guard_16, \ - tor2 -f /etc/torrc_guard_16, \ - tor2 -f /etc/torrc_guard_16, \ - tor2 -f /etc/torrc_guard_16, \ - tor2 -f /etc/torrc_guard_16, \ - tor2 -f /etc/torrc_guard_16, \ - tor2 -f /etc/torrc_guard_16, \ - tor2 -f /etc/torrc_guard_16, \ - tor2 -f /etc/torrc_guard_16, \ - tor2 -f /etc/torrc_guard_16, \ - tor2 -f /etc/torrc_guard_16, \ - tor2 -f /etc/torrc_guard_16, \ tor2 -f /etc/torrc_guard_16. jan_battle_hardened: @@ -890,11 +826,7 @@ jan_battle_hardened: jan_battle_light: ./run-3 \ - 8,jan_battle_light. \ - orig-client 135000 40 172, \ - orig-client 135000 40 172, \ - orig-client 135000 40 172, \ - orig-client 135000 40 172, \ + 32,jan_battle_light. \ orig-client 135000 40 172, \ orig-client 135000 40 172, \ orig-client 135000 40 172, \ @@ -903,22 +835,10 @@ jan_battle_light: dup2-client 135000 40 172 2, \ dup2-client 135000 40 172 2, \ dup2-client 135000 40 172 2, \ - dup2-client 135000 40 172 2, \ - dup2-client 135000 40 172 2, \ - dup2-client 135000 40 172 2, \ - dup2-client 135000 40 172 2, \ lightning-client 135000 40 172 12 fast_count=3!tick_tock=1!measlat=1!window=2000, \ lightning-client 135000 40 172 12 fast_count=3!tick_tock=1!measlat=1!window=2000, \ lightning-client 135000 40 172 12 fast_count=3!tick_tock=1!measlat=1!window=2000, \ lightning-client 135000 40 172 12 fast_count=3!tick_tock=1!measlat=1!window=2000, \ - lightning-client 135000 40 172 12 fast_count=3!tick_tock=1!measlat=1!window=2000, \ - lightning-client 135000 40 172 12 fast_count=3!tick_tock=1!measlat=1!window=2000, \ - lightning-client 135000 40 172 12 fast_count=3!tick_tock=1!measlat=1!window=2000, \ - lightning-client 135000 40 172 12 fast_count=3!tick_tock=1!measlat=1!window=2000, \ - lightning-client 135000 40 172 12 fast_count=3!tick_tock=0!measlat=1!window=2000, \ - lightning-client 135000 40 172 12 fast_count=3!tick_tock=0!measlat=1!window=2000, \ - lightning-client 135000 40 172 12 fast_count=3!tick_tock=0!measlat=1!window=2000, \ - lightning-client 135000 40 172 12 fast_count=3!tick_tock=0!measlat=1!window=2000, \ lightning-client 135000 40 172 12 fast_count=3!tick_tock=0!measlat=1!window=2000, \ lightning-client 135000 40 172 12 fast_count=3!tick_tock=0!measlat=1!window=2000, \ lightning-client 135000 40 172 12 fast_count=3!tick_tock=0!measlat=1!window=2000, \ @@ -927,14 +847,6 @@ jan_battle_light: orig-server-single 135000 40 172, \ orig-server-single 135000 40 172, \ orig-server-single 135000 40 172, \ - orig-server-single 135000 40 172, \ - orig-server-single 135000 40 172, \ - orig-server-single 135000 40 172, \ - orig-server-single 135000 40 172, \ - dup2-server-single 135000 40 172 2, \ - dup2-server-single 135000 40 172 2, \ - dup2-server-single 135000 40 172 2, \ - dup2-server-single 135000 40 172 2, \ dup2-server-single 135000 40 172 2, \ dup2-server-single 135000 40 172 2, \ dup2-server-single 135000 40 172 2, \ @@ -943,14 +855,6 @@ jan_battle_light: lightning-server-single 135000 40 172 12 fast_count=3!tick_tock=1!measlat=1!window=2000, \ lightning-server-single 135000 40 172 12 fast_count=3!tick_tock=1!measlat=1!window=2000, \ lightning-server-single 135000 40 172 12 fast_count=3!tick_tock=1!measlat=1!window=2000, \ - lightning-server-single 135000 40 172 12 fast_count=3!tick_tock=1!measlat=1!window=2000, \ - lightning-server-single 135000 40 172 12 fast_count=3!tick_tock=1!measlat=1!window=2000, \ - lightning-server-single 135000 40 172 12 fast_count=3!tick_tock=1!measlat=1!window=2000, \ - lightning-server-single 135000 40 172 12 fast_count=3!tick_tock=1!measlat=1!window=2000, \ - lightning-server-single 135000 40 172 12 fast_count=3!tick_tock=0!measlat=1!window=2000, \ - lightning-server-single 135000 40 172 12 fast_count=3!tick_tock=0!measlat=1!window=2000, \ - lightning-server-single 135000 40 172 12 fast_count=3!tick_tock=0!measlat=1!window=2000, \ - lightning-server-single 135000 40 172 12 fast_count=3!tick_tock=0!measlat=1!window=2000, \ lightning-server-single 135000 40 172 12 fast_count=3!tick_tock=0!measlat=1!window=2000, \ lightning-server-single 135000 40 172 12 fast_count=3!tick_tock=0!measlat=1!window=2000, \ lightning-server-single 135000 40 172 12 fast_count=3!tick_tock=0!measlat=1!window=2000, \ @@ -970,22 +874,6 @@ jan_battle_light: tor2 -f /etc/torrc_guard_16, \ tor2 -f /etc/torrc_guard_16, \ tor2 -f /etc/torrc_guard_16, \ - tor2 -f /etc/torrc_guard_16, \ - tor2 -f /etc/torrc_guard_16, \ - tor2 -f /etc/torrc_guard_16, \ - tor2 -f /etc/torrc_guard_16, \ - tor2 -f /etc/torrc_guard_16, \ - tor2 -f /etc/torrc_guard_16, \ - tor2 -f /etc/torrc_guard_16, \ - tor2 -f /etc/torrc_guard_16, \ - tor2 -f /etc/torrc_guard_16, \ - tor2 -f /etc/torrc_guard_16, \ - tor2 -f /etc/torrc_guard_16, \ - tor2 -f /etc/torrc_guard_16, \ - tor2 -f /etc/torrc_guard_16, \ - tor2 -f /etc/torrc_guard_16, \ - tor2 -f /etc/torrc_guard_16, \ - tor2 -f /etc/torrc_guard_16, \ tor2 -f /etc/torrc_guard_16. \ tor2 -f /etc/torrc_single_hop_16, \ tor2 -f /etc/torrc_single_hop_16, \ @@ -1002,22 +890,6 @@ jan_battle_light: tor2 -f /etc/torrc_single_hop_16, \ tor2 -f /etc/torrc_single_hop_16, \ tor2 -f /etc/torrc_single_hop_16, \ - tor2 -f /etc/torrc_single_hop_16, \ - tor2 -f /etc/torrc_single_hop_16, \ - tor2 -f /etc/torrc_single_hop_16, \ - tor2 -f /etc/torrc_single_hop_16, \ - tor2 -f /etc/torrc_single_hop_16, \ - tor2 -f /etc/torrc_single_hop_16, \ - tor2 -f /etc/torrc_single_hop_16, \ - tor2 -f /etc/torrc_single_hop_16, \ - tor2 -f /etc/torrc_single_hop_16, \ - tor2 -f /etc/torrc_single_hop_16, \ - tor2 -f /etc/torrc_single_hop_16, \ - tor2 -f /etc/torrc_single_hop_16, \ - tor2 -f /etc/torrc_single_hop_16, \ - tor2 -f /etc/torrc_single_hop_16, \ - tor2 -f /etc/torrc_single_hop_16, \ - tor2 -f /etc/torrc_single_hop_16, \ tor2 -f /etc/torrc_single_hop_16. diff --git a/src/donar_client.c b/src/donar_client.c index 781f673..aa77b0d 100644 --- a/src/donar_client.c +++ b/src/donar_client.c @@ -154,7 +154,7 @@ void donar_client(struct donar_client_ctx* ctx, struct donar_params* dp) { printf("--- Inited Timer\n"); for (int64_t i = 0; i < dp->links; i++) { - int64_t to_wait_sec = 10 + i * 3; + int64_t to_wait_sec = i * 3; fprintf(stdout, "[%s][donar-client] Triggering socks5 in %ld seconds for port %d\n", current_human_datetime (), to_wait_sec, i+7500); set_timeout(&ctx->evts, 1000 * to_wait_sec, (void*) i, reinit_socks5); } From 86a476cc47604f8b78b76cb6b166ccf2296f716e Mon Sep 17 00:00:00 2001 From: Quentin Date: Sun, 2 Feb 2020 00:02:42 +0100 Subject: [PATCH 08/27] Force pull before xp --- scripts/run-3 | 1 + 1 file changed, 1 insertion(+) diff --git a/scripts/run-3 b/scripts/run-3 index f7dd03b..aad4727 100755 --- a/scripts/run-3 +++ b/scripts/run-3 @@ -39,6 +39,7 @@ done echo ":: Bootstrap" echo "Create output folder..." +docker pull registry.gitlab.inria.fr/qdufour/donar docker run \ --rm \ --user root \ From 730a067e29b201366a353c0e3e1827303fd81802 Mon Sep 17 00:00:00 2001 From: Quentin Date: Sun, 2 Feb 2020 00:17:27 +0100 Subject: [PATCH 09/27] No socks port servers --- torrc_single_hop | 1 - torrc_single_hop_12 | 1 - torrc_single_hop_16 | 1 - 3 files changed, 3 deletions(-) diff --git a/torrc_single_hop b/torrc_single_hop index 26c1736..08c7295 100644 --- a/torrc_single_hop +++ b/torrc_single_hop @@ -4,5 +4,4 @@ UseEntryGuards 0 SafeLogging 0 HiddenServiceNonAnonymousMode 1 HiddenServiceSingleHopMode 1 -SocksPort 127.0.0.1:9050 IsolateDestPort #Log INFO stdout diff --git a/torrc_single_hop_12 b/torrc_single_hop_12 index 25aac56..7d48d31 100644 --- a/torrc_single_hop_12 +++ b/torrc_single_hop_12 @@ -6,5 +6,4 @@ NumPrimaryGuards 12 SafeLogging 0 HiddenServiceNonAnonymousMode 1 HiddenServiceSingleHopMode 1 -SocksPort 127.0.0.1:9050 IsolateDestPort #Log INFO stdout diff --git a/torrc_single_hop_16 b/torrc_single_hop_16 index 41743a8..964d7d1 100644 --- a/torrc_single_hop_16 +++ b/torrc_single_hop_16 @@ -4,7 +4,6 @@ UseEntryGuards 1 NumEntryGuards 16 NumPrimaryGuards 16 SafeLogging 0 -SocksPort 127.0.0.1:9050 IsolateDestPort HiddenServiceNonAnonymousMode 1 HiddenServiceSingleHopMode 1 #Log INFO stdout From 1d41bbc187ac59ba497b092133fa4ec72949a3a6 Mon Sep 17 00:00:00 2001 From: Quentin Date: Sun, 2 Feb 2020 10:04:56 +0100 Subject: [PATCH 10/27] Improve script --- scripts/jantoran_2.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/scripts/jantoran_2.py b/scripts/jantoran_2.py index 8a7decb..3205dbc 100755 --- a/scripts/jantoran_2.py +++ b/scripts/jantoran_2.py @@ -25,8 +25,11 @@ def compute_dropped(s): s['current']['missing'].append((start, s['current']['npkt'], 1+s['current']['npkt']-start)) t = s['current']['missing'] - t = filter(lambda p: (lambda start, stop, diff: start != 0)(*p), t) + # Don't consider first 10 seconds are links are still being connected + t = filter(lambda p: (lambda start, stop, diff: start > 250)(*p), t) + # Below 1 second continuous drop, don't consider the call dropped t = filter(lambda p: (lambda start, stop, diff: diff > 25)(*p), t) + # Don't consider the last drop as it is already parsed elsewhere t = filter(lambda p: (lambda start, stop, diff: stop != s['current']['npkt'])(*p), t) t = [x for x in t] if len(t) > 0: From 2754b33bbf9eccd76295fe4548303b92b5e8ee65 Mon Sep 17 00:00:00 2001 From: Quentin Date: Sun, 2 Feb 2020 12:26:32 +0100 Subject: [PATCH 11/27] dcall is now exiting after end of file --- src/dcall.c | 69 ++++++++++++++++++++++++++++++++++++++++++++++------- 1 file changed, 60 insertions(+), 9 deletions(-) diff --git a/src/dcall.c b/src/dcall.c index c719be1..ade1a1c 100644 --- a/src/dcall.c +++ b/src/dcall.c @@ -15,6 +15,7 @@ struct dcall_elements { char *remote_host, *audio_tap, *audio_sink, *audio_file, *gstreamer_log_path; int remote_port, latency; guint64 grtppktlost; + GMainLoop *loop; }; int create_rx_chain(struct dcall_elements* de) { @@ -65,9 +66,56 @@ int create_rx_chain(struct dcall_elements* de) { return 0; } +static void uridecodebin_newpad (GstElement *src, GstPad *new_pad, gpointer data) { + struct dcall_elements *de = data; + GstPad *sink_pad = gst_element_get_static_pad (de->tx_audioconvert, "sink"); + GstPadLinkReturn ret; + GstCaps *new_pad_caps = NULL; + GstStructure *new_pad_struct = NULL; + const gchar *new_pad_type = NULL; + + g_print ("Received new pad '%s' from '%s':\n", GST_PAD_NAME (new_pad), GST_ELEMENT_NAME (src)); + + /* If our converter is already linked, we have nothing to do here */ + if (gst_pad_is_linked (sink_pad)) { + g_print ("We are already linked. Ignoring.\n"); + goto exit; + } + + /* Check the new pad's type */ + new_pad_caps = gst_pad_get_current_caps (new_pad); + new_pad_struct = gst_caps_get_structure (new_pad_caps, 0); + new_pad_type = gst_structure_get_name (new_pad_struct); + if (!g_str_has_prefix (new_pad_type, "audio/x-raw")) { + g_print ("It has type '%s' which is not raw audio. Ignoring.\n", new_pad_type); + goto exit; + } + + /* Attempt the link */ + ret = gst_pad_link (new_pad, sink_pad); + if (GST_PAD_LINK_FAILED (ret)) { + g_print ("Type is '%s' but link failed.\n", new_pad_type); + } else { + g_print ("Link succeeded (type '%s').\n", new_pad_type); + } + +exit: + /* Unreference the new pad's caps, if we got them */ + if (new_pad_caps != NULL) + gst_caps_unref (new_pad_caps); + + /* Unreference the sink pad */ + gst_object_unref (sink_pad); +} + +static void uridecodebin_drained (GstElement *src, gpointer data) { + struct dcall_elements *de = data; + g_main_loop_quit (de->loop); +} + int create_tx_chain(struct dcall_elements* de) { de->tx_pulse = gst_element_factory_make("pulsesrc", "tx-pulse"); - de->tx_filesrc = gst_element_factory_make("filesrc", "tx-filesrc"); + de->tx_filesrc = gst_element_factory_make("uridecodebin", "tx-filesrc"); de->tx_mpegaudioparse = gst_element_factory_make("mpegaudioparse", "tx-mpegaudioparse"); de->tx_mpgaudiodec = gst_element_factory_make("mpg123audiodec", "tx-mpgaudiodec"); de->tx_audioconvert = gst_element_factory_make("audioconvert", "tx-audioconvert"); @@ -107,14 +155,16 @@ int create_tx_chain(struct dcall_elements* de) { g_object_set (de->tx_pulse, "stream-properties", props, NULL); gst_structure_free (props); - g_object_set(de->tx_filesrc, "location", de->audio_file, NULL); + g_object_set(de->tx_filesrc, "uri", de->audio_file, NULL); if (strcmp(de->audio_tap, "pulsesrc") == 0) { gst_bin_add_many(GST_BIN(de->pipeline), de->tx_pulse, de->tx_echocancel, de->tx_queue, de->tx_resample, de->tx_opusenc, de->tx_pay, de->tx_sink, NULL); gst_element_link_many(de->tx_pulse, de->tx_resample, de->tx_echocancel, de->tx_queue, de->tx_opusenc, de->tx_pay, de->tx_sink, NULL); } else if (strcmp(de->audio_tap, "filesrc") == 0) { gst_bin_add_many(GST_BIN(de->pipeline), de->tx_filesrc, de->tx_mpegaudioparse, de->tx_mpgaudiodec, de->tx_audioconvert, de->tx_queue, de->tx_resample, de->tx_opusenc, de->tx_pay, de->tx_sink, NULL); - gst_element_link_many(de->tx_filesrc, de->tx_mpegaudioparse, de->tx_mpgaudiodec, de->tx_audioconvert, de->tx_resample, de->tx_queue, de->tx_opusenc, de->tx_pay, de->tx_sink, NULL); + gst_element_link_many(de->tx_audioconvert, de->tx_resample, de->tx_queue, de->tx_opusenc, de->tx_pay, de->tx_sink, NULL); + g_signal_connect (de->tx_filesrc, "pad-added", G_CALLBACK (uridecodebin_newpad), de); + g_signal_connect (de->tx_filesrc, "drained", G_CALLBACK(uridecodebin_drained), de); } else { fprintf(stderr, "Wrong audio tap %s, exiting...\n", de->audio_tap); exit(EXIT_FAILURE); @@ -165,7 +215,8 @@ gboolean stop_handler(gpointer user_data) { } int main(int argc, char *argv[]) { - GMainLoop *loop; + + GstBus *bus; struct dcall_elements de = { .audio_file = "voice.mp3", .gstreamer_log_path = "dcall.log", @@ -213,7 +264,7 @@ int main(int argc, char *argv[]) { setenv("GST_DEBUG", "3,opusdec:5", 0); gst_init (&argc, &argv); - loop = g_main_loop_new (NULL, FALSE); + de.loop = g_main_loop_new (NULL, FALSE); de.pipeline = gst_pipeline_new ("pipeline"); if (!de.pipeline) { @@ -226,11 +277,11 @@ int main(int argc, char *argv[]) { gst_element_set_state (de.pipeline, GST_STATE_PLAYING); - g_unix_signal_add (SIGTERM, stop_handler, loop); - g_unix_signal_add (SIGINT, stop_handler, loop); + g_unix_signal_add (SIGTERM, stop_handler, de.loop); + g_unix_signal_add (SIGINT, stop_handler, de.loop); g_print ("Running...\n"); - g_main_loop_run (loop); + g_main_loop_run (de.loop); g_print ("Main loop stopped...\n"); @@ -247,7 +298,7 @@ int main(int argc, char *argv[]) { gst_element_set_state (de.pipeline, GST_STATE_NULL); gst_object_unref (GST_OBJECT (de.pipeline)); - g_main_loop_unref (loop); + g_main_loop_unref (de.loop); return 0; } From 95dd164609c8e734d60fd29a28b43ea9c164a848 Mon Sep 17 00:00:00 2001 From: Quentin Date: Sun, 2 Feb 2020 13:03:55 +0100 Subject: [PATCH 12/27] Fix Makefile --- scripts/Makefile | 135 +++++++++++++++++++++++++---------------------- 1 file changed, 71 insertions(+), 64 deletions(-) diff --git a/scripts/Makefile b/scripts/Makefile index 7f4ac7a..6c76f8f 100644 --- a/scripts/Makefile +++ b/scripts/Makefile @@ -723,38 +723,38 @@ jan_battle_normal: lightning-server 135000 40 172 12 fast_count=3!tick_tock=0!measlat=1!window=2000, \ lightning-server 135000 40 172 12 fast_count=3!tick_tock=0!measlat=1!window=2000, \ lightning-server 135000 40 172 12 fast_count=3!tick_tock=0!measlat=1!window=2000. \ - tor2 -f /etc/torrc_guard_16, \ - tor2 -f /etc/torrc_guard_16, \ - tor2 -f /etc/torrc_guard_16, \ - tor2 -f /etc/torrc_guard_16, \ - tor2 -f /etc/torrc_guard_16, \ - tor2 -f /etc/torrc_guard_16, \ - tor2 -f /etc/torrc_guard_16, \ - tor2 -f /etc/torrc_guard_16, \ - tor2 -f /etc/torrc_guard_16, \ - tor2 -f /etc/torrc_guard_16, \ - tor2 -f /etc/torrc_guard_16, \ - tor2 -f /etc/torrc_guard_16, \ - tor2 -f /etc/torrc_guard_16, \ - tor2 -f /etc/torrc_guard_16, \ - tor2 -f /etc/torrc_guard_16, \ - tor2 -f /etc/torrc_guard_16. \ - tor2 -f /etc/torrc_guard_16, \ - tor2 -f /etc/torrc_guard_16, \ - tor2 -f /etc/torrc_guard_16, \ - tor2 -f /etc/torrc_guard_16, \ - tor2 -f /etc/torrc_guard_16, \ - tor2 -f /etc/torrc_guard_16, \ - tor2 -f /etc/torrc_guard_16, \ - tor2 -f /etc/torrc_guard_16, \ - tor2 -f /etc/torrc_guard_16, \ - tor2 -f /etc/torrc_guard_16, \ - tor2 -f /etc/torrc_guard_16, \ - tor2 -f /etc/torrc_guard_16, \ - tor2 -f /etc/torrc_guard_16, \ - tor2 -f /etc/torrc_guard_16, \ - tor2 -f /etc/torrc_guard_16, \ - tor2 -f /etc/torrc_guard_16. + tor2 -f /etc/torrc_guard_12, \ + tor2 -f /etc/torrc_guard_12, \ + tor2 -f /etc/torrc_guard_12, \ + tor2 -f /etc/torrc_guard_12, \ + tor2 -f /etc/torrc_guard_12, \ + tor2 -f /etc/torrc_guard_12, \ + tor2 -f /etc/torrc_guard_12, \ + tor2 -f /etc/torrc_guard_12, \ + tor2 -f /etc/torrc_guard_12, \ + tor2 -f /etc/torrc_guard_12, \ + tor2 -f /etc/torrc_guard_12, \ + tor2 -f /etc/torrc_guard_12, \ + tor2 -f /etc/torrc_guard_12, \ + tor2 -f /etc/torrc_guard_12, \ + tor2 -f /etc/torrc_guard_12, \ + tor2 -f /etc/torrc_guard_12. \ + tor2 -f /etc/torrc_guard_12, \ + tor2 -f /etc/torrc_guard_12, \ + tor2 -f /etc/torrc_guard_12, \ + tor2 -f /etc/torrc_guard_12, \ + tor2 -f /etc/torrc_guard_12, \ + tor2 -f /etc/torrc_guard_12, \ + tor2 -f /etc/torrc_guard_12, \ + tor2 -f /etc/torrc_guard_12, \ + tor2 -f /etc/torrc_guard_12, \ + tor2 -f /etc/torrc_guard_12, \ + tor2 -f /etc/torrc_guard_12, \ + tor2 -f /etc/torrc_guard_12, \ + tor2 -f /etc/torrc_guard_12, \ + tor2 -f /etc/torrc_guard_12, \ + tor2 -f /etc/torrc_guard_12, \ + tor2 -f /etc/torrc_guard_12. jan_battle_hardened: ./run-3 \ @@ -859,37 +859,44 @@ jan_battle_light: lightning-server-single 135000 40 172 12 fast_count=3!tick_tock=0!measlat=1!window=2000, \ lightning-server-single 135000 40 172 12 fast_count=3!tick_tock=0!measlat=1!window=2000, \ lightning-server-single 135000 40 172 12 fast_count=3!tick_tock=0!measlat=1!window=2000. \ - tor2 -f /etc/torrc_guard_16, \ - tor2 -f /etc/torrc_guard_16, \ - tor2 -f /etc/torrc_guard_16, \ - tor2 -f /etc/torrc_guard_16, \ - tor2 -f /etc/torrc_guard_16, \ - tor2 -f /etc/torrc_guard_16, \ - tor2 -f /etc/torrc_guard_16, \ - tor2 -f /etc/torrc_guard_16, \ - tor2 -f /etc/torrc_guard_16, \ - tor2 -f /etc/torrc_guard_16, \ - tor2 -f /etc/torrc_guard_16, \ - tor2 -f /etc/torrc_guard_16, \ - tor2 -f /etc/torrc_guard_16, \ - tor2 -f /etc/torrc_guard_16, \ - tor2 -f /etc/torrc_guard_16, \ - tor2 -f /etc/torrc_guard_16. \ - tor2 -f /etc/torrc_single_hop_16, \ - tor2 -f /etc/torrc_single_hop_16, \ - tor2 -f /etc/torrc_single_hop_16, \ - tor2 -f /etc/torrc_single_hop_16, \ - tor2 -f /etc/torrc_single_hop_16, \ - tor2 -f /etc/torrc_single_hop_16, \ - tor2 -f /etc/torrc_single_hop_16, \ - tor2 -f /etc/torrc_single_hop_16, \ - tor2 -f /etc/torrc_single_hop_16, \ - tor2 -f /etc/torrc_single_hop_16, \ - tor2 -f /etc/torrc_single_hop_16, \ - tor2 -f /etc/torrc_single_hop_16, \ - tor2 -f /etc/torrc_single_hop_16, \ - tor2 -f /etc/torrc_single_hop_16, \ - tor2 -f /etc/torrc_single_hop_16, \ - tor2 -f /etc/torrc_single_hop_16. + tor2 -f /etc/torrc_guard_12, \ + tor2 -f /etc/torrc_guard_12, \ + tor2 -f /etc/torrc_guard_12, \ + tor2 -f /etc/torrc_guard_12, \ + tor2 -f /etc/torrc_guard_12, \ + tor2 -f /etc/torrc_guard_12, \ + tor2 -f /etc/torrc_guard_12, \ + tor2 -f /etc/torrc_guard_12, \ + tor2 -f /etc/torrc_guard_12, \ + tor2 -f /etc/torrc_guard_12, \ + tor2 -f /etc/torrc_guard_12, \ + tor2 -f /etc/torrc_guard_12, \ + tor2 -f /etc/torrc_guard_12, \ + tor2 -f /etc/torrc_guard_12, \ + tor2 -f /etc/torrc_guard_12, \ + tor2 -f /etc/torrc_guard_12. \ + tor2 -f /etc/torrc_single_hop_12, \ + tor2 -f /etc/torrc_single_hop_12, \ + tor2 -f /etc/torrc_single_hop_12, \ + tor2 -f /etc/torrc_single_hop_12, \ + tor2 -f /etc/torrc_single_hop_12, \ + tor2 -f /etc/torrc_single_hop_12, \ + tor2 -f /etc/torrc_single_hop_12, \ + tor2 -f /etc/torrc_single_hop_12, \ + tor2 -f /etc/torrc_single_hop_12, \ + tor2 -f /etc/torrc_single_hop_12, \ + tor2 -f /etc/torrc_single_hop_12, \ + tor2 -f /etc/torrc_single_hop_12, \ + tor2 -f /etc/torrc_single_hop_12, \ + tor2 -f /etc/torrc_single_hop_12, \ + tor2 -f /etc/torrc_single_hop_12, \ + tor2 -f /etc/torrc_single_hop_12. +jan_dcall_normal: + ./run-3 \ + 1,jan_dcall_normal. \ + dcall-lightning-client 12 fast_count=3!tick_tock=1!measlat=0!window=2000. \ + dcall-lightning-server 12 fast_count=3!tick_tock=1!measlat=0!window=2000. \ + tor2 -f /etc/torrc_guard_12. \ + tor2 -f /etc/torrc_guard_12. From 11b2c67da426c1de6d2a3dac84a285ba738c970a Mon Sep 17 00:00:00 2001 From: Quentin Date: Sun, 2 Feb 2020 15:11:15 +0100 Subject: [PATCH 13/27] add missing latency --- scripts/Makefile | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/scripts/Makefile b/scripts/Makefile index 6c76f8f..876e673 100644 --- a/scripts/Makefile +++ b/scripts/Makefile @@ -896,7 +896,7 @@ jan_battle_light: jan_dcall_normal: ./run-3 \ 1,jan_dcall_normal. \ - dcall-lightning-client 12 fast_count=3!tick_tock=1!measlat=0!window=2000. \ - dcall-lightning-server 12 fast_count=3!tick_tock=1!measlat=0!window=2000. \ + dcall-lightning-client 12 fast_count=3!tick_tock=1!measlat=0!window=2000 150. \ + dcall-lightning-server 12 fast_count=3!tick_tock=1!measlat=0!window=2000 150. \ tor2 -f /etc/torrc_guard_12. \ tor2 -f /etc/torrc_guard_12. From de7dfe355f469ad6ebcd6b96288c425e0bb72215 Mon Sep 17 00:00:00 2001 From: Quentin Date: Sun, 2 Feb 2020 15:15:50 +0100 Subject: [PATCH 14/27] fix audio path --- scripts/container/dcall-lightning-client | 2 +- scripts/container/dcall-lightning-server | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/scripts/container/dcall-lightning-client b/scripts/container/dcall-lightning-client index 886d326..b310171 100755 --- a/scripts/container/dcall-lightning-client +++ b/scripts/container/dcall-lightning-client @@ -13,7 +13,7 @@ donar \ dcall \ -t filesrc \ - -a /assets/i_have_a_dream.mp3 \ + -a file:///assets/i_have_a_dream.mp3 \ -s fakesink \ -l $3 \ -d $4/log/server-dcall-gstreamer.log \ diff --git a/scripts/container/dcall-lightning-server b/scripts/container/dcall-lightning-server index ec9db4f..46a2c51 100755 --- a/scripts/container/dcall-lightning-server +++ b/scripts/container/dcall-lightning-server @@ -13,7 +13,7 @@ donar \ dcall \ -t filesrc \ - -a /assets/i_have_a_dream.mp3 \ + -a file:///assets/i_have_a_dream.mp3 \ -s fakesink \ -l $3 \ -d ../log/server-dcall-gstreamer.log \ From ce2f67cec8c620af8bda930b63cc71d3f73caa1d Mon Sep 17 00:00:00 2001 From: Quentin Date: Sun, 2 Feb 2020 15:27:30 +0100 Subject: [PATCH 15/27] fix wrong path --- scripts/container/dcall-lightning-client | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/scripts/container/dcall-lightning-client b/scripts/container/dcall-lightning-client index b310171..8a459bd 100755 --- a/scripts/container/dcall-lightning-client +++ b/scripts/container/dcall-lightning-client @@ -16,5 +16,5 @@ dcall \ -a file:///assets/i_have_a_dream.mp3 \ -s fakesink \ -l $3 \ - -d $4/log/server-dcall-gstreamer.log \ + -d $4/log/client-dcall-gstreamer.log \ > $4/log/client-dcall-stdout.log 2> $4/log/client-dcall-stderr.log From 156439e390157ffc96b2921c1e4398bd28d70a16 Mon Sep 17 00:00:00 2001 From: Quentin Date: Sun, 2 Feb 2020 15:47:13 +0100 Subject: [PATCH 16/27] Log parameters + bind localhost is now possible --- scripts/container/dcall-lightning-client | 1 + scripts/container/dcall-lightning-server | 1 + src/dcall.c | 25 ++++++++++++++++-------- 3 files changed, 19 insertions(+), 8 deletions(-) diff --git a/scripts/container/dcall-lightning-client b/scripts/container/dcall-lightning-client index 8a459bd..4c3061f 100755 --- a/scripts/container/dcall-lightning-client +++ b/scripts/container/dcall-lightning-client @@ -15,6 +15,7 @@ dcall \ -t filesrc \ -a file:///assets/i_have_a_dream.mp3 \ -s fakesink \ + -b 127.0.0.1 -l $3 \ -d $4/log/client-dcall-gstreamer.log \ > $4/log/client-dcall-stdout.log 2> $4/log/client-dcall-stderr.log diff --git a/scripts/container/dcall-lightning-server b/scripts/container/dcall-lightning-server index 46a2c51..4bc30b8 100755 --- a/scripts/container/dcall-lightning-server +++ b/scripts/container/dcall-lightning-server @@ -15,6 +15,7 @@ dcall \ -t filesrc \ -a file:///assets/i_have_a_dream.mp3 \ -s fakesink \ + -b 127.0.0.1 -l $3 \ -d ../log/server-dcall-gstreamer.log \ > ../log/server-dcall-stdout.log 2> ../log/server-dcall-stderr.log diff --git a/src/dcall.c b/src/dcall.c index ade1a1c..e4f9e23 100644 --- a/src/dcall.c +++ b/src/dcall.c @@ -12,8 +12,8 @@ struct dcall_elements { GstElement *pipeline; GstElement *rx_tap, *rx_jitterbuffer, *rx_depay, *rx_opusdec, *rx_resample, *rx_echocancel, *rx_pulse, *rx_fakesink; GstElement *tx_pulse, *tx_filesrc, *tx_mpegaudioparse, *tx_mpgaudiodec, *tx_audioconvert, *tx_echocancel, *tx_queue, *tx_resample, *tx_opusenc, *tx_pay, *tx_sink; - char *remote_host, *audio_tap, *audio_sink, *audio_file, *gstreamer_log_path; - int remote_port, latency; + char *local_host, *remote_host, *audio_tap, *audio_sink, *audio_file, *gstreamer_log_path; + int remote_port, local_port, latency; guint64 grtppktlost; GMainLoop *loop; }; @@ -33,8 +33,8 @@ int create_rx_chain(struct dcall_elements* de) { return -1; } - g_object_set(G_OBJECT (de->rx_tap), "port", 5000, NULL); - //g_object_set(G_OBJECT (rx_tap), "address", "127.0.0.1", NULL); + g_object_set(G_OBJECT (de->rx_tap), "port", de->local_port, NULL); + g_object_set(G_OBJECT (de->rx_tap), "address", de->local_host, NULL); g_object_set(G_OBJECT (de->rx_tap), "caps", gst_caps_new_simple("application/x-rtp", "media", G_TYPE_STRING, "audio", NULL), NULL); g_object_set(G_OBJECT (de->rx_jitterbuffer), "do-lost", TRUE, NULL); @@ -218,22 +218,29 @@ int main(int argc, char *argv[]) { GstBus *bus; struct dcall_elements de = { - .audio_file = "voice.mp3", + .audio_file = "file://./voice.mp3", .gstreamer_log_path = "dcall.log", .latency = 150, - .remote_port = 5000, .remote_host = "127.13.3.7", + .remote_port = 5000, + .local_host = "0.0.0.0", + .local_port = 5000, .audio_sink = "pulsesink", .audio_tap = "pulsesrc", .grtppktlost = 0 }; int opt = 0; - while ((opt = getopt(argc, argv, "t:s:r:p:l:d:a:h")) != -1) { + while ((opt = getopt(argc, argv, "t:s:r:p:l:d:a:hb:c:")) != -1) { switch(opt) { - case 'a': //latency + case 'a': de.audio_file = optarg; break; + case 'b': + de.local_host = optarg; + break; + case 'c': + de.local_port = atoi(optarg); case 'd': de.gstreamer_log_path = optarg; break; @@ -259,6 +266,8 @@ int main(int argc, char *argv[]) { break; } } + printf("dcall configuration:\n\tnetwork in: %s:%d, out: %s:%d\n\taudio in: %s, out: %s\n\tmisc latency: %dms, audio_file: %s\n", + de.local_host, de.local_port, de.remote_host, de.remote_port, de.audio_tap, de.audio_sink, de.latency, de.audio_file); setenv("GST_DEBUG_FILE", de.gstreamer_log_path, 0); setenv("GST_DEBUG", "3,opusdec:5", 0); From 473368f3660ef808576cc6b80c07522a5467c1cb Mon Sep 17 00:00:00 2001 From: Quentin Date: Sun, 2 Feb 2020 15:51:15 +0100 Subject: [PATCH 17/27] fix bug --- scripts/container/dcall-lightning-client | 2 +- scripts/container/dcall-lightning-server | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/scripts/container/dcall-lightning-client b/scripts/container/dcall-lightning-client index 4c3061f..6be6a5b 100755 --- a/scripts/container/dcall-lightning-client +++ b/scripts/container/dcall-lightning-client @@ -15,7 +15,7 @@ dcall \ -t filesrc \ -a file:///assets/i_have_a_dream.mp3 \ -s fakesink \ - -b 127.0.0.1 + -b 127.0.0.1 \ -l $3 \ -d $4/log/client-dcall-gstreamer.log \ > $4/log/client-dcall-stdout.log 2> $4/log/client-dcall-stderr.log diff --git a/scripts/container/dcall-lightning-server b/scripts/container/dcall-lightning-server index 4bc30b8..6080146 100755 --- a/scripts/container/dcall-lightning-server +++ b/scripts/container/dcall-lightning-server @@ -15,7 +15,7 @@ dcall \ -t filesrc \ -a file:///assets/i_have_a_dream.mp3 \ -s fakesink \ - -b 127.0.0.1 + -b 127.0.0.1 \ -l $3 \ -d ../log/server-dcall-gstreamer.log \ > ../log/server-dcall-stdout.log 2> ../log/server-dcall-stderr.log From 8d9e9f53539a6a450fd7b5753716187b2451cc89 Mon Sep 17 00:00:00 2001 From: Quentin Date: Sun, 2 Feb 2020 17:44:33 +0100 Subject: [PATCH 18/27] Prepare for bench --- scripts/Makefile | 16 ++++++++++++++-- scripts/container/dcall-dup2-client | 20 ++++++++++++++++++++ scripts/container/dcall-dup2-server | 20 ++++++++++++++++++++ scripts/container/dcall-simple-client | 20 ++++++++++++++++++++ scripts/container/dcall-simple-server | 20 ++++++++++++++++++++ src/algo_naive.c | 7 ++++++- 6 files changed, 100 insertions(+), 3 deletions(-) create mode 100755 scripts/container/dcall-dup2-client create mode 100755 scripts/container/dcall-dup2-server create mode 100755 scripts/container/dcall-simple-client create mode 100755 scripts/container/dcall-simple-server diff --git a/scripts/Makefile b/scripts/Makefile index 876e673..197bb68 100644 --- a/scripts/Makefile +++ b/scripts/Makefile @@ -896,7 +896,19 @@ jan_battle_light: jan_dcall_normal: ./run-3 \ 1,jan_dcall_normal. \ - dcall-lightning-client 12 fast_count=3!tick_tock=1!measlat=0!window=2000 150. \ - dcall-lightning-server 12 fast_count=3!tick_tock=1!measlat=0!window=2000 150. \ + dcall-simple-client 1 360, + dcall-dup2-client 2 352, + dcall-lightning-client 12 fast_count=3!tick_tock=1!measlat=0!window=2000 213, \ + dcall-lightning-client 12 fast_count=3!tick_tock=0!measlat=0!window=2000 176. \ + dcall-simple-server 1 360, + dcall-dup2-server 2 352, + dcall-lightning-server 12 fast_count=3!tick_tock=1!measlat=0!window=2000 213, \ + dcall-lightning-server 12 fast_count=3!tick_tock=0!measlat=0!window=2000 176. \ + tor2 -f /etc/torrc_guard_12, \ + tor2 -f /etc/torrc_guard_12, \ + tor2 -f /etc/torrc_guard_12, \ tor2 -f /etc/torrc_guard_12. \ + tor2 -f /etc/torrc_guard_12, \ + tor2 -f /etc/torrc_guard_12, \ + tor2 -f /etc/torrc_guard_12, \ tor2 -f /etc/torrc_guard_12. diff --git a/scripts/container/dcall-dup2-client b/scripts/container/dcall-dup2-client new file mode 100755 index 0000000..eb8ea62 --- /dev/null +++ b/scripts/container/dcall-dup2-client @@ -0,0 +1,20 @@ +#!/bin/bash +mkdir -p $3/{log,shared,res} + +donar \ + -a dup2 \ + -c \ + -o $3/shared/onion_services.pub \ + -l $1 \ + -e 5000 \ + -r 5000 \ +> $3/log/client-donar-stdout.log 2> $3/log/client-donar-stderr.log & + +dcall \ + -t filesrc \ + -a file:///assets/i_have_a_dream.mp3 \ + -s fakesink \ + -b 127.0.0.1 \ + -l $2 \ + -d $3/log/client-dcall-gstreamer.log \ +> $3/log/client-dcall-stdout.log 2> $3/log/client-dcall-stderr.log diff --git a/scripts/container/dcall-dup2-server b/scripts/container/dcall-dup2-server new file mode 100755 index 0000000..84d5d14 --- /dev/null +++ b/scripts/container/dcall-dup2-server @@ -0,0 +1,20 @@ +#!/bin/bash +mkdir -p $3/{log,shared} +cd $3/shared + +donar \ + -a dup2 \ + -s \ + -l $1 \ + -e 5000 \ + -r 5000 \ +> ../log/server-donar-stdout.log 2> ../log/server-donar-stderr.log & + +dcall \ + -t filesrc \ + -a file:///assets/i_have_a_dream.mp3 \ + -s fakesink \ + -b 127.0.0.1 \ + -l $2 \ + -d ../log/server-dcall-gstreamer.log \ +> ../log/server-dcall-stdout.log 2> ../log/server-dcall-stderr.log diff --git a/scripts/container/dcall-simple-client b/scripts/container/dcall-simple-client new file mode 100755 index 0000000..a134737 --- /dev/null +++ b/scripts/container/dcall-simple-client @@ -0,0 +1,20 @@ +#!/bin/bash +mkdir -p $3/{log,shared,res} + +donar \ + -a naive \ + -c \ + -o $3/shared/onion_services.pub \ + -l $1 \ + -e 5000 \ + -r 5000 \ +> $3/log/client-donar-stdout.log 2> $3/log/client-donar-stderr.log & + +dcall \ + -t filesrc \ + -a file:///assets/i_have_a_dream.mp3 \ + -s fakesink \ + -b 127.0.0.1 \ + -l $2 \ + -d $3/log/client-dcall-gstreamer.log \ +> $3/log/client-dcall-stdout.log 2> $3/log/client-dcall-stderr.log diff --git a/scripts/container/dcall-simple-server b/scripts/container/dcall-simple-server new file mode 100755 index 0000000..eae200a --- /dev/null +++ b/scripts/container/dcall-simple-server @@ -0,0 +1,20 @@ +#!/bin/bash +mkdir -p $3/{log,shared} +cd $3/shared + +donar \ + -a naive \ + -s \ + -l $1 \ + -e 5000 \ + -r 5000 \ +> ../log/server-donar-stdout.log 2> ../log/server-donar-stderr.log & + +dcall \ + -t filesrc \ + -a file:///assets/i_have_a_dream.mp3 \ + -s fakesink \ + -b 127.0.0.1 \ + -l $2 \ + -d ../log/server-dcall-gstreamer.log \ +> ../log/server-dcall-stdout.log 2> ../log/server-dcall-stderr.log diff --git a/src/algo_naive.c b/src/algo_naive.c index 8b7a51e..d791caa 100644 --- a/src/algo_naive.c +++ b/src/algo_naive.c @@ -49,6 +49,11 @@ int algo_naive_on_datagram(struct evt_core_ctx* ctx, struct evt_core_fdinfo* fdi } int algo_naive_on_err(struct evt_core_ctx *ctx, struct evt_core_fdinfo *fdinfo) { - // We do nothing + struct algo_ctx* app_ctx = fdinfo->cat->app_ctx; + if (strcmp("tcp-read", fdinfo->cat->name) == 0 || strcmp("tcp-write", fdinfo->cat->name) == 0) + return app_ctx->ap.sr(ctx, fdinfo); + + fprintf(stderr, "%s is not eligible for a reconnect\n", fdinfo->url); + // We do nothing return 1; } From 31a2a5a0bdf7796191e6019240774b46193923d7 Mon Sep 17 00:00:00 2001 From: Quentin Date: Sun, 2 Feb 2020 17:55:45 +0100 Subject: [PATCH 19/27] fix new lines --- scripts/Makefile | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/scripts/Makefile b/scripts/Makefile index 197bb68..b23ec89 100644 --- a/scripts/Makefile +++ b/scripts/Makefile @@ -896,12 +896,12 @@ jan_battle_light: jan_dcall_normal: ./run-3 \ 1,jan_dcall_normal. \ - dcall-simple-client 1 360, - dcall-dup2-client 2 352, + dcall-simple-client 1 360, \ + dcall-dup2-client 2 352, \ dcall-lightning-client 12 fast_count=3!tick_tock=1!measlat=0!window=2000 213, \ dcall-lightning-client 12 fast_count=3!tick_tock=0!measlat=0!window=2000 176. \ - dcall-simple-server 1 360, - dcall-dup2-server 2 352, + dcall-simple-server 1 360, \ + dcall-dup2-server 2 352, \ dcall-lightning-server 12 fast_count=3!tick_tock=1!measlat=0!window=2000 213, \ dcall-lightning-server 12 fast_count=3!tick_tock=0!measlat=0!window=2000 176. \ tor2 -f /etc/torrc_guard_12, \ From a9b4e2d2077b2527f4e1d62b48f291c171f94128 Mon Sep 17 00:00:00 2001 From: Quentin Date: Sun, 2 Feb 2020 18:54:28 +0100 Subject: [PATCH 20/27] prepare dcall real bench --- scripts/Makefile | 186 ++++++++++++++++++++++++++++++++++++++++++++++- 1 file changed, 185 insertions(+), 1 deletion(-) diff --git a/scripts/Makefile b/scripts/Makefile index b23ec89..b47a180 100644 --- a/scripts/Makefile +++ b/scripts/Makefile @@ -895,20 +895,204 @@ jan_battle_light: jan_dcall_normal: ./run-3 \ - 1,jan_dcall_normal. \ + 32,jan_dcall_normal. \ + dcall-simple-client 1 360, \ + dcall-simple-client 1 360, \ + dcall-simple-client 1 360, \ dcall-simple-client 1 360, \ dcall-dup2-client 2 352, \ + dcall-dup2-client 2 352, \ + dcall-dup2-client 2 352, \ + dcall-dup2-client 2 352, \ dcall-lightning-client 12 fast_count=3!tick_tock=1!measlat=0!window=2000 213, \ + dcall-lightning-client 12 fast_count=3!tick_tock=1!measlat=0!window=2000 213, \ + dcall-lightning-client 12 fast_count=3!tick_tock=1!measlat=0!window=2000 213, \ + dcall-lightning-client 12 fast_count=3!tick_tock=1!measlat=0!window=2000 213, \ + dcall-lightning-client 12 fast_count=3!tick_tock=0!measlat=0!window=2000 176, \ + dcall-lightning-client 12 fast_count=3!tick_tock=0!measlat=0!window=2000 176, \ + dcall-lightning-client 12 fast_count=3!tick_tock=0!measlat=0!window=2000 176, \ dcall-lightning-client 12 fast_count=3!tick_tock=0!measlat=0!window=2000 176. \ dcall-simple-server 1 360, \ + dcall-simple-server 1 360, \ + dcall-simple-server 1 360, \ + dcall-simple-server 1 360, \ + dcall-dup2-server 2 352, \ + dcall-dup2-server 2 352, \ + dcall-dup2-server 2 352, \ dcall-dup2-server 2 352, \ dcall-lightning-server 12 fast_count=3!tick_tock=1!measlat=0!window=2000 213, \ + dcall-lightning-server 12 fast_count=3!tick_tock=1!measlat=0!window=2000 213, \ + dcall-lightning-server 12 fast_count=3!tick_tock=1!measlat=0!window=2000 213, \ + dcall-lightning-server 12 fast_count=3!tick_tock=1!measlat=0!window=2000 213, \ + dcall-lightning-server 12 fast_count=3!tick_tock=0!measlat=0!window=2000 176, \ + dcall-lightning-server 12 fast_count=3!tick_tock=0!measlat=0!window=2000 176, \ + dcall-lightning-server 12 fast_count=3!tick_tock=0!measlat=0!window=2000 176, \ dcall-lightning-server 12 fast_count=3!tick_tock=0!measlat=0!window=2000 176. \ tor2 -f /etc/torrc_guard_12, \ tor2 -f /etc/torrc_guard_12, \ tor2 -f /etc/torrc_guard_12, \ + tor2 -f /etc/torrc_guard_12, \ + tor2 -f /etc/torrc_guard_12, \ + tor2 -f /etc/torrc_guard_12, \ + tor2 -f /etc/torrc_guard_12, \ + tor2 -f /etc/torrc_guard_12, \ + tor2 -f /etc/torrc_guard_12, \ + tor2 -f /etc/torrc_guard_12, \ + tor2 -f /etc/torrc_guard_12, \ + tor2 -f /etc/torrc_guard_12, \ + tor2 -f /etc/torrc_guard_12, \ + tor2 -f /etc/torrc_guard_12, \ + tor2 -f /etc/torrc_guard_12, \ tor2 -f /etc/torrc_guard_12. \ tor2 -f /etc/torrc_guard_12, \ tor2 -f /etc/torrc_guard_12, \ tor2 -f /etc/torrc_guard_12, \ + tor2 -f /etc/torrc_guard_12, \ + tor2 -f /etc/torrc_guard_12, \ + tor2 -f /etc/torrc_guard_12, \ + tor2 -f /etc/torrc_guard_12, \ + tor2 -f /etc/torrc_guard_12, \ + tor2 -f /etc/torrc_guard_12, \ + tor2 -f /etc/torrc_guard_12, \ + tor2 -f /etc/torrc_guard_12, \ + tor2 -f /etc/torrc_guard_12, \ + tor2 -f /etc/torrc_guard_12, \ + tor2 -f /etc/torrc_guard_12, \ + tor2 -f /etc/torrc_guard_12, \ tor2 -f /etc/torrc_guard_12. + +jan_dcall_hardened: + ./run-3 \ + 32,jan_dcall_hardened. \ + dcall-simple-client 1 360, \ + dcall-simple-client 1 360, \ + dcall-simple-client 1 360, \ + dcall-simple-client 1 360, \ + dcall-dup2-client 2 360, \ + dcall-dup2-client 2 360, \ + dcall-dup2-client 2 360, \ + dcall-dup2-client 2 360, \ + dcall-lightning-client 12 fast_count=3!tick_tock=1!measlat=0!window=2000 360, \ + dcall-lightning-client 12 fast_count=3!tick_tock=1!measlat=0!window=2000 360, \ + dcall-lightning-client 12 fast_count=3!tick_tock=1!measlat=0!window=2000 360, \ + dcall-lightning-client 12 fast_count=3!tick_tock=1!measlat=0!window=2000 360, \ + dcall-lightning-client 12 fast_count=3!tick_tock=0!measlat=0!window=2000 311, \ + dcall-lightning-client 12 fast_count=3!tick_tock=0!measlat=0!window=2000 311, \ + dcall-lightning-client 12 fast_count=3!tick_tock=0!measlat=0!window=2000 311, \ + dcall-lightning-client 12 fast_count=3!tick_tock=0!measlat=0!window=2000 311. \ + dcall-simple-server 1 360, \ + dcall-simple-server 1 360, \ + dcall-simple-server 1 360, \ + dcall-simple-server 1 360, \ + dcall-dup2-server 2 360, \ + dcall-dup2-server 2 360, \ + dcall-dup2-server 2 360, \ + dcall-dup2-server 2 360, \ + dcall-lightning-server 12 fast_count=3!tick_tock=1!measlat=0!window=2000 360, \ + dcall-lightning-server 12 fast_count=3!tick_tock=1!measlat=0!window=2000 360, \ + dcall-lightning-server 12 fast_count=3!tick_tock=1!measlat=0!window=2000 360, \ + dcall-lightning-server 12 fast_count=3!tick_tock=1!measlat=0!window=2000 360, \ + dcall-lightning-server 12 fast_count=3!tick_tock=0!measlat=0!window=2000 311, \ + dcall-lightning-server 12 fast_count=3!tick_tock=0!measlat=0!window=2000 311, \ + dcall-lightning-server 12 fast_count=3!tick_tock=0!measlat=0!window=2000 311, \ + dcall-lightning-server 12 fast_count=3!tick_tock=0!measlat=0!window=2000 311. \ + tor3 -f /etc/torrc_guard_2, \ + tor3 -f /etc/torrc_guard_2, \ + tor3 -f /etc/torrc_guard_2, \ + tor3 -f /etc/torrc_guard_2, \ + tor3 -f /etc/torrc_guard_2, \ + tor3 -f /etc/torrc_guard_2, \ + tor3 -f /etc/torrc_guard_2, \ + tor3 -f /etc/torrc_guard_2, \ + tor3 -f /etc/torrc_guard_2, \ + tor3 -f /etc/torrc_guard_2, \ + tor3 -f /etc/torrc_guard_2, \ + tor3 -f /etc/torrc_guard_2, \ + tor3 -f /etc/torrc_guard_2, \ + tor3 -f /etc/torrc_guard_2, \ + tor3 -f /etc/torrc_guard_2, \ + tor3 -f /etc/torrc_guard_2. \ + tor3 -f /etc/torrc_guard_2, \ + tor3 -f /etc/torrc_guard_2, \ + tor3 -f /etc/torrc_guard_2, \ + tor3 -f /etc/torrc_guard_2, \ + tor3 -f /etc/torrc_guard_2, \ + tor3 -f /etc/torrc_guard_2, \ + tor3 -f /etc/torrc_guard_2, \ + tor3 -f /etc/torrc_guard_2, \ + tor3 -f /etc/torrc_guard_2, \ + tor3 -f /etc/torrc_guard_2, \ + tor3 -f /etc/torrc_guard_2, \ + tor3 -f /etc/torrc_guard_2, \ + tor3 -f /etc/torrc_guard_2, \ + tor3 -f /etc/torrc_guard_2, \ + tor3 -f /etc/torrc_guard_2, \ + tor3 -f /etc/torrc_guard_2. + +jan_dcall_light: + ./run-3 \ + 32,jan_dcall_light. \ + dcall-simple-client 1 360, \ + dcall-simple-client 1 360, \ + dcall-simple-client 1 360, \ + dcall-simple-client 1 360, \ + dcall-dup2-client 2 355, \ + dcall-dup2-client 2 355, \ + dcall-dup2-client 2 355, \ + dcall-dup2-client 2 355, \ + dcall-lightning-client 12 fast_count=3!tick_tock=1!measlat=0!window=2000 198, \ + dcall-lightning-client 12 fast_count=3!tick_tock=1!measlat=0!window=2000 198, \ + dcall-lightning-client 12 fast_count=3!tick_tock=1!measlat=0!window=2000 198, \ + dcall-lightning-client 12 fast_count=3!tick_tock=1!measlat=0!window=2000 198, \ + dcall-lightning-client 12 fast_count=3!tick_tock=0!measlat=0!window=2000 153, \ + dcall-lightning-client 12 fast_count=3!tick_tock=0!measlat=0!window=2000 153, \ + dcall-lightning-client 12 fast_count=3!tick_tock=0!measlat=0!window=2000 153, \ + dcall-lightning-client 12 fast_count=3!tick_tock=0!measlat=0!window=2000 153. \ + dcall-simple-server 1 360, \ + dcall-simple-server 1 360, \ + dcall-simple-server 1 360, \ + dcall-simple-server 1 360, \ + dcall-dup2-server 2 355, \ + dcall-dup2-server 2 355, \ + dcall-dup2-server 2 355, \ + dcall-dup2-server 2 355, \ + dcall-lightning-server 12 fast_count=3!tick_tock=1!measlat=0!window=2000 198, \ + dcall-lightning-server 12 fast_count=3!tick_tock=1!measlat=0!window=2000 198, \ + dcall-lightning-server 12 fast_count=3!tick_tock=1!measlat=0!window=2000 198, \ + dcall-lightning-server 12 fast_count=3!tick_tock=1!measlat=0!window=2000 198, \ + dcall-lightning-server 12 fast_count=3!tick_tock=0!measlat=0!window=2000 153, \ + dcall-lightning-server 12 fast_count=3!tick_tock=0!measlat=0!window=2000 153, \ + dcall-lightning-server 12 fast_count=3!tick_tock=0!measlat=0!window=2000 153, \ + dcall-lightning-server 12 fast_count=3!tick_tock=0!measlat=0!window=2000 153. \ + tor2 -f /etc/torrc_guard_12, \ + tor2 -f /etc/torrc_guard_12, \ + tor2 -f /etc/torrc_guard_12, \ + tor2 -f /etc/torrc_guard_12, \ + tor2 -f /etc/torrc_guard_12, \ + tor2 -f /etc/torrc_guard_12, \ + tor2 -f /etc/torrc_guard_12, \ + tor2 -f /etc/torrc_guard_12, \ + tor2 -f /etc/torrc_guard_12, \ + tor2 -f /etc/torrc_guard_12, \ + tor2 -f /etc/torrc_guard_12, \ + tor2 -f /etc/torrc_guard_12, \ + tor2 -f /etc/torrc_guard_12, \ + tor2 -f /etc/torrc_guard_12, \ + tor2 -f /etc/torrc_guard_12, \ + tor2 -f /etc/torrc_guard_12. \ + tor2 -f /etc/torrc_single_hop_12, \ + tor2 -f /etc/torrc_single_hop_12, \ + tor2 -f /etc/torrc_single_hop_12, \ + tor2 -f /etc/torrc_single_hop_12, \ + tor2 -f /etc/torrc_single_hop_12, \ + tor2 -f /etc/torrc_single_hop_12, \ + tor2 -f /etc/torrc_single_hop_12, \ + tor2 -f /etc/torrc_single_hop_12, \ + tor2 -f /etc/torrc_single_hop_12, \ + tor2 -f /etc/torrc_single_hop_12, \ + tor2 -f /etc/torrc_single_hop_12, \ + tor2 -f /etc/torrc_single_hop_12, \ + tor2 -f /etc/torrc_single_hop_12, \ + tor2 -f /etc/torrc_single_hop_12, \ + tor2 -f /etc/torrc_single_hop_12, \ + tor2 -f /etc/torrc_single_hop_12. From 5f5a4387ec842d61629e2acbf07fc54e9316a3d9 Mon Sep 17 00:00:00 2001 From: Quentin Date: Sun, 2 Feb 2020 19:13:23 +0100 Subject: [PATCH 21/27] Fix light --- scripts/Makefile | 32 +++++++++---------- scripts/container/dcall-dup2-server-single | 21 ++++++++++++ .../container/dcall-lightning-server-single | 22 +++++++++++++ scripts/container/dcall-simple-server-single | 21 ++++++++++++ 4 files changed, 80 insertions(+), 16 deletions(-) create mode 100755 scripts/container/dcall-dup2-server-single create mode 100755 scripts/container/dcall-lightning-server-single create mode 100755 scripts/container/dcall-simple-server-single diff --git a/scripts/Makefile b/scripts/Makefile index b47a180..9e65dc1 100644 --- a/scripts/Makefile +++ b/scripts/Makefile @@ -1048,22 +1048,22 @@ jan_dcall_light: dcall-lightning-client 12 fast_count=3!tick_tock=0!measlat=0!window=2000 153, \ dcall-lightning-client 12 fast_count=3!tick_tock=0!measlat=0!window=2000 153, \ dcall-lightning-client 12 fast_count=3!tick_tock=0!measlat=0!window=2000 153. \ - dcall-simple-server 1 360, \ - dcall-simple-server 1 360, \ - dcall-simple-server 1 360, \ - dcall-simple-server 1 360, \ - dcall-dup2-server 2 355, \ - dcall-dup2-server 2 355, \ - dcall-dup2-server 2 355, \ - dcall-dup2-server 2 355, \ - dcall-lightning-server 12 fast_count=3!tick_tock=1!measlat=0!window=2000 198, \ - dcall-lightning-server 12 fast_count=3!tick_tock=1!measlat=0!window=2000 198, \ - dcall-lightning-server 12 fast_count=3!tick_tock=1!measlat=0!window=2000 198, \ - dcall-lightning-server 12 fast_count=3!tick_tock=1!measlat=0!window=2000 198, \ - dcall-lightning-server 12 fast_count=3!tick_tock=0!measlat=0!window=2000 153, \ - dcall-lightning-server 12 fast_count=3!tick_tock=0!measlat=0!window=2000 153, \ - dcall-lightning-server 12 fast_count=3!tick_tock=0!measlat=0!window=2000 153, \ - dcall-lightning-server 12 fast_count=3!tick_tock=0!measlat=0!window=2000 153. \ + dcall-simple-server-single 1 360, \ + dcall-simple-server-single 1 360, \ + dcall-simple-server-single 1 360, \ + dcall-simple-server-single 1 360, \ + dcall-dup2-server-single 2 355, \ + dcall-dup2-server-single 2 355, \ + dcall-dup2-server-single 2 355, \ + dcall-dup2-server-single 2 355, \ + dcall-lightning-server-single 12 fast_count=3!tick_tock=1!measlat=0!window=2000 198, \ + dcall-lightning-server-single 12 fast_count=3!tick_tock=1!measlat=0!window=2000 198, \ + dcall-lightning-server-single 12 fast_count=3!tick_tock=1!measlat=0!window=2000 198, \ + dcall-lightning-server-single 12 fast_count=3!tick_tock=1!measlat=0!window=2000 198, \ + dcall-lightning-server-single 12 fast_count=3!tick_tock=0!measlat=0!window=2000 153, \ + dcall-lightning-server-single 12 fast_count=3!tick_tock=0!measlat=0!window=2000 153, \ + dcall-lightning-server-single 12 fast_count=3!tick_tock=0!measlat=0!window=2000 153, \ + dcall-lightning-server-single 12 fast_count=3!tick_tock=0!measlat=0!window=2000 153. \ tor2 -f /etc/torrc_guard_12, \ tor2 -f /etc/torrc_guard_12, \ tor2 -f /etc/torrc_guard_12, \ diff --git a/scripts/container/dcall-dup2-server-single b/scripts/container/dcall-dup2-server-single new file mode 100755 index 0000000..f3dc076 --- /dev/null +++ b/scripts/container/dcall-dup2-server-single @@ -0,0 +1,21 @@ +#!/bin/bash +mkdir -p $3/{log,shared} +cd $3/shared + +donar \ + -a dup2 \ + -s \ + -n \ + -l $1 \ + -e 5000 \ + -r 5000 \ +> ../log/server-donar-stdout.log 2> ../log/server-donar-stderr.log & + +dcall \ + -t filesrc \ + -a file:///assets/i_have_a_dream.mp3 \ + -s fakesink \ + -b 127.0.0.1 \ + -l $2 \ + -d ../log/server-dcall-gstreamer.log \ +> ../log/server-dcall-stdout.log 2> ../log/server-dcall-stderr.log diff --git a/scripts/container/dcall-lightning-server-single b/scripts/container/dcall-lightning-server-single new file mode 100755 index 0000000..0a40a42 --- /dev/null +++ b/scripts/container/dcall-lightning-server-single @@ -0,0 +1,22 @@ +#!/bin/bash +mkdir -p $4/{log,shared} +cd $4/shared + +donar \ + -a lightning \ + -s \ + -n \ + -l $1 \ + -p $2 \ + -e 5000 \ + -r 5000 \ +> ../log/server-donar-stdout.log 2> ../log/server-donar-stderr.log & + +dcall \ + -t filesrc \ + -a file:///assets/i_have_a_dream.mp3 \ + -s fakesink \ + -b 127.0.0.1 \ + -l $3 \ + -d ../log/server-dcall-gstreamer.log \ +> ../log/server-dcall-stdout.log 2> ../log/server-dcall-stderr.log diff --git a/scripts/container/dcall-simple-server-single b/scripts/container/dcall-simple-server-single new file mode 100755 index 0000000..99475bf --- /dev/null +++ b/scripts/container/dcall-simple-server-single @@ -0,0 +1,21 @@ +#!/bin/bash +mkdir -p $3/{log,shared} +cd $3/shared + +donar \ + -a naive \ + -s \ + -n \ + -l $1 \ + -e 5000 \ + -r 5000 \ +> ../log/server-donar-stdout.log 2> ../log/server-donar-stderr.log & + +dcall \ + -t filesrc \ + -a file:///assets/i_have_a_dream.mp3 \ + -s fakesink \ + -b 127.0.0.1 \ + -l $2 \ + -d ../log/server-dcall-gstreamer.log \ +> ../log/server-dcall-stdout.log 2> ../log/server-dcall-stderr.log From 960f63bcc07d669290a1429628924521b29ad9db Mon Sep 17 00:00:00 2001 From: Quentin Dufour Date: Tue, 4 Feb 2020 11:44:20 +0100 Subject: [PATCH 22/27] Try to harden Donar --- src/algo_lightning.c | 20 ++++++++++++-------- src/proxy.c | 7 ++++--- 2 files changed, 16 insertions(+), 11 deletions(-) diff --git a/src/algo_lightning.c b/src/algo_lightning.c index e87146a..851bedb 100644 --- a/src/algo_lightning.c +++ b/src/algo_lightning.c @@ -319,22 +319,20 @@ void algo_lightning_update_stats (struct light_ctx *lightc) { int64_t delta = 0; switch (lightc->historic[i].state) { case IN_ORDER: - lightc->stats[l].ooo += delta; - lightc->stats[l].meas_occ += 1; + delta = 0; break; case OOO_ONGOING: timespec_diff(&now, &lightc->historic[i].detected_at, &temp_time); delta = timespec_get_unit (&temp_time, MILISEC); - lightc->stats[l].ooo += delta; - lightc->stats[l].meas_occ += 1; + delta *= 2; break; case OOO_DONE: timespec_diff(&lightc->historic[i].finished_at, &lightc->historic[i].detected_at, &temp_time); delta = timespec_get_unit (&temp_time, MILISEC); - lightc->stats[l].ooo += delta; - lightc->stats[l].meas_occ += 1; break; } + lightc->stats[l].ooo += delta; + lightc->stats[l].meas_occ += 1; if (lightc->explain) printf("(stats.compute) packet=%ld, link=%d, status=%s, delta=%ld\n", lightc->historic[i].pkt_id, l, ooo_state_str[lightc->historic[i].state], delta); lightc->stats[l].link_id = l; @@ -384,12 +382,18 @@ int send_message(struct evt_core_ctx* ctx, struct buffer_packet* bp) { struct algo_ctx* app_ctx = cat->app_ctx; struct light_ctx* lightc = app_ctx->misc; - if (lightc->selected_link >= lightc->total_links) return 0; + if (lightc->selected_link >= lightc->total_links) { + fprintf(stderr, "[algo_lightning] PACKET DROPPED! Selected link id %d is greater than the total number of links %d\n", lightc->selected_link, lightc->total_links); + return 0; + } set_now(&lightc->status[lightc->selected_link].last); sprintf(url, "tcp:write:127.0.0.1:%d", 7500 + lightc->selected_link); struct evt_core_fdinfo *to_fdinfo = evt_core_get_from_url (ctx, url); - if (to_fdinfo == NULL) return 0; + if (to_fdinfo == NULL) { + fprintf(stderr, "[algo_lightning] PACKET DROPPED! We don't have any entry for %s currently\n", url); + return 0; + } struct buffer_packet* bp_dup = dup_buffer_tow (&app_ctx->br, bp, to_fdinfo); diff --git a/src/proxy.c b/src/proxy.c index 1f8e3be..c569047 100644 --- a/src/proxy.c +++ b/src/proxy.c @@ -103,7 +103,7 @@ int main_on_tcp_write(struct evt_core_ctx* ctx, struct evt_core_fdinfo* fdinfo) uint8_t is_rdy = fdinfo->cat->socklist->len >= app_ctx->link_count ? 1 : 0; if (!app_ctx->is_rdy && is_rdy) printf("=== Our %d requested circuits are now up ===\n", app_ctx->link_count); else if (app_ctx->is_rdy && !is_rdy) printf("=== Only %d/%d circuits are available, results could be biased ===\n", fdinfo->cat->socklist->len, app_ctx->link_count); - app_ctx->is_rdy = app_ctx->is_rdy || is_rdy; // @FIXME prevent deactivation for our tests + app_ctx->is_rdy = app_ctx->is_rdy || is_rdy; // @FIXME we don't want deactivation finally // 1. Get current write buffer OR a buffer from the waiting queue OR leave if ((bp = get_write_buffer(&app_ctx->br, fdinfo)) == NULL) return 1; @@ -117,6 +117,7 @@ int main_on_tcp_write(struct evt_core_ctx* ctx, struct evt_core_fdinfo* fdinfo) if (write_res == FDS_ERR) goto co_error; if (write_res == FDS_AGAIN) return 1; } + app_ctx->cell_sent++; free_buffer: @@ -218,7 +219,7 @@ void algo_main_init(struct evt_core_ctx* evt, struct algo_params* ap) { struct evt_core_cat tcp_read = { .name = "tcp-read", - .flags = EPOLLIN | EPOLLET | EPOLLHUP, + .flags = EPOLLIN | EPOLLET | EPOLLHUP | EPOLLRDHUP, .app_ctx = ctx, .free_app_ctx = algo_main_destroy, .cb = main_on_tcp_read, @@ -240,7 +241,7 @@ void algo_main_init(struct evt_core_ctx* evt, struct algo_params* ap) { struct evt_core_cat tcp_write = { .name = "tcp-write", - .flags = EPOLLOUT | EPOLLET | EPOLLHUP, + .flags = EPOLLOUT | EPOLLET | EPOLLHUP | EPOLLRDHUP, .app_ctx = ctx, .free_app_ctx = algo_main_destroy, .cb = main_on_tcp_write, From 2a772edc844fa630ccaccf1839c964cb0e674329 Mon Sep 17 00:00:00 2001 From: Quentin Dufour Date: Tue, 4 Feb 2020 14:10:27 +0100 Subject: [PATCH 23/27] fix bugs... --- src/algo_lightning.c | 17 ++++++++++++----- 1 file changed, 12 insertions(+), 5 deletions(-) diff --git a/src/algo_lightning.c b/src/algo_lightning.c index 851bedb..4061b3a 100644 --- a/src/algo_lightning.c +++ b/src/algo_lightning.c @@ -299,7 +299,7 @@ int compare_stat_entry_max(const void *a, const void *b) { return sea->ooo - seb->ooo; } -void algo_lightning_update_stats (struct light_ctx *lightc) { +void algo_lightning_update_stats (struct light_ctx *lightc, struct evt_core_ctx* ctx) { struct timespec now, not_before = {0}, temp_time; set_now(&now); timespec_diff (&now, &lightc->window, ¬_before); @@ -324,7 +324,6 @@ void algo_lightning_update_stats (struct light_ctx *lightc) { case OOO_ONGOING: timespec_diff(&now, &lightc->historic[i].detected_at, &temp_time); delta = timespec_get_unit (&temp_time, MILISEC); - delta *= 2; break; case OOO_DONE: timespec_diff(&lightc->historic[i].finished_at, &lightc->historic[i].detected_at, &temp_time); @@ -346,8 +345,8 @@ void algo_lightning_update_stats (struct light_ctx *lightc) { // Compute average for (int i = 0; i < lightc->total_links; i++) { - if (lightc->stats[i].meas_occ <= 0) continue; - lightc->stats[i].ooo = lightc->stats[i].ooo / lightc->stats[i].meas_occ; + if (lightc->stats[i].meas_occ <= 0) lightc->stats[i].ooo = -1; + else lightc->stats[i].ooo = lightc->stats[i].ooo / lightc->stats[i].meas_occ; } // Set my local stats + merge remote stats @@ -366,6 +365,14 @@ void algo_lightning_update_stats (struct light_ctx *lightc) { } */ } + // Disable broken links + char url[256]; + for (int i = 0; i < lightc->total_links; i++) { + sprintf(url, "tcp:write:127.0.0.1:%d", 7500 + i); + struct evt_core_fdinfo *to_fdinfo = evt_core_get_from_url (ctx, url); + if (to_fdinfo == NULL) lightc->stats[i].ooo = -1; + } + // Sort if (!lightc->disable_scheduler) { qsort(lightc->stats, lightc->total_links, sizeof(struct stat_entry), compare_stat_entry_max); @@ -512,7 +519,7 @@ int algo_lightning_on_datagram(struct evt_core_ctx* ctx, struct evt_core_fdinfo* algo_lightning_pad (ctx, fdinfo, bp); // Compute stats - algo_lightning_update_stats(lightc); + algo_lightning_update_stats(lightc, ctx); algo_lightning_update_used(lightc, &now); algo_lightning_link_cat(lightc); From 09a8572e2bd78a1b29f3be8a46c7f008e55a70fe Mon Sep 17 00:00:00 2001 From: Quentin Dufour Date: Tue, 4 Feb 2020 16:09:26 +0100 Subject: [PATCH 24/27] improve donar --- src/algo_lightning.c | 74 +++++++++++++++++++++++++++----------------- src/dcall.c | 1 + 2 files changed, 46 insertions(+), 29 deletions(-) diff --git a/src/algo_lightning.c b/src/algo_lightning.c index 4061b3a..9b39109 100644 --- a/src/algo_lightning.c +++ b/src/algo_lightning.c @@ -77,7 +77,7 @@ struct light_ctx { int16_t local_stats[MAX_LINKS]; struct timing_entry historic[HISTORIC_SIZE]; struct link_status status[MAX_LINKS]; - uint8_t used; + uint8_t active; uint64_t pkt_rcv_id; uint64_t pkt_sent_id; uint64_t uniq_pkt_sent_id; @@ -119,6 +119,7 @@ void algo_lightning_init(struct evt_core_ctx* ctx, struct algo_ctx* app_ctx, str lightc->pkt_sent_id = 1; lightc->uniq_pkt_sent_id = 1; lightc->disable_scheduler = 0; + lightc->active = 0; lightc->sched_strat = SCHEDULE_BOTH; uint64_t window = 2000; @@ -142,9 +143,8 @@ void algo_lightning_init(struct evt_core_ctx* ctx, struct algo_ctx* app_ctx, str for (int i = 0; i < lightc->sent_past_links; i++) lightc->prev_links[i] = UINT8_MAX; - lightc->used = lightc->fast_count * 2; for (int i = 0; i < lightc->total_links; i++) { - lightc->status[i].used = i < lightc->used ? LINK_SLOW : LINK_NOT_USED; + lightc->status[i].used = LINK_NOT_USED; } union abstract_packet m; @@ -294,9 +294,11 @@ int algo_lightning_on_stream(struct evt_core_ctx* ctx, struct evt_core_fdinfo* f int compare_stat_entry_max(const void *a, const void *b) { const struct stat_entry *sea = a, *seb = b; - if (sea->ooo == -1) return 1; - if (seb->ooo == -1) return -1; - return sea->ooo - seb->ooo; + int ra = sea->ooo; + int rb = seb->ooo; + if (ra < 0) ra = INT16_MAX + -ra; + if (rb < 0) rb = INT16_MAX + -rb; + return ra - rb; } void algo_lightning_update_stats (struct light_ctx *lightc, struct evt_core_ctx* ctx) { @@ -347,15 +349,16 @@ void algo_lightning_update_stats (struct light_ctx *lightc, struct evt_core_ctx* for (int i = 0; i < lightc->total_links; i++) { if (lightc->stats[i].meas_occ <= 0) lightc->stats[i].ooo = -1; else lightc->stats[i].ooo = lightc->stats[i].ooo / lightc->stats[i].meas_occ; + + lightc->local_stats[i] = lightc->stats[i].ooo; } // Set my local stats + merge remote stats for (int i = 0; i < lightc->total_links; i++) { - lightc->local_stats[i] = lightc->stats[i].ooo; /* AVG */ - if (lightc->remote_stats[i] == -1) continue; - if (lightc->stats[i].ooo == -1) lightc->stats[i].ooo = lightc->remote_stats[i]; + if (lightc->remote_stats[i] < 0) continue; + if (lightc->stats[i].ooo < 0) lightc->stats[i].ooo = lightc->remote_stats[i]; else lightc->stats[i].ooo = (lightc->remote_stats[i] + lightc->stats[i].ooo) / 2; /* MAX @@ -370,7 +373,7 @@ void algo_lightning_update_stats (struct light_ctx *lightc, struct evt_core_ctx* for (int i = 0; i < lightc->total_links; i++) { sprintf(url, "tcp:write:127.0.0.1:%d", 7500 + i); struct evt_core_fdinfo *to_fdinfo = evt_core_get_from_url (ctx, url); - if (to_fdinfo == NULL) lightc->stats[i].ooo = -1; + if (to_fdinfo == NULL) lightc->stats[i].ooo = -2; } // Sort @@ -463,16 +466,17 @@ void algo_lightning_update_used(struct light_ctx *lightc, struct timespec *now) timespec_diff(now, &lightc->window, ¬_before); if (timespec_gt(&lightc->last_update_used, ¬_before)) return; - int used_to_not = 0, not_to_used = 0; + int used_to_not = -1, not_to_used = -1; int64_t max_ooo = 0; for (int i = 0; i < lightc->total_links; i++) { if (lightc->status[lightc->stats[i].link_id].used == LINK_FAST || lightc->status[lightc->stats[i].link_id].used == LINK_SLOW) { - int64_t retained_ooo = lightc->stats[i].ooo == -1 ? INT64_MAX : lightc->stats[i].ooo; + int64_t retained_ooo = lightc->stats[i].ooo < 0 ? INT64_MAX : lightc->stats[i].ooo; if (retained_ooo >= max_ooo) { max_ooo = retained_ooo; used_to_not = lightc->stats[i].link_id; } } else { + if (lightc->stats[i].ooo == -2) continue; if (timespec_lt(&lightc->status[lightc->stats[i].link_id].last, &oldest)) { oldest = lightc->status[lightc->stats[i].link_id].last; not_to_used = lightc->stats[i].link_id; @@ -480,27 +484,20 @@ void algo_lightning_update_used(struct light_ctx *lightc, struct timespec *now) } } - // Do we have a good link not used? - /*for (int i = 0; i < lightc->used; i++) { - if (lightc->status[lightc->stats[i].link_id].used == LINK_NOT_USED) { - not_to_used = lightc->stats[i].link_id; - break; - } - }*/ - // Swap them //printf("Link %d will be disabled, %d will be enabled\n", used_to_not, not_to_used); + if (used_to_not < 0 || not_to_used < 0) return; lightc->status[used_to_not].used = LINK_NOT_USED; lightc->status[not_to_used].used = LINK_SLOW; lightc->last_update_used = *now; } -void algo_lightning_link_cat(struct light_ctx *lightc) { +void algo_lightning_link_cat(struct light_ctx *lightc, int cur_fast_count) { uint8_t used = 0; //printf("---\n"); for (int i = 0; i < lightc->total_links; i++) { if (lightc->status[lightc->stats[i].link_id].used != LINK_NOT_USED) { - if (used < lightc->fast_count) lightc->status[lightc->stats[i].link_id].used = LINK_FAST; + if (used < cur_fast_count) lightc->status[lightc->stats[i].link_id].used = LINK_FAST; else lightc->status[lightc->stats[i].link_id].used = LINK_SLOW; used++; } @@ -518,15 +515,34 @@ int algo_lightning_on_datagram(struct evt_core_ctx* ctx, struct evt_core_fdinfo* // Pad packet algo_lightning_pad (ctx, fdinfo, bp); - // Compute stats + // Prepare links algo_lightning_update_stats(lightc, ctx); - algo_lightning_update_used(lightc, &now); - algo_lightning_link_cat(lightc); - if (ctx->verbose > 1) { - printf("after sort: "); + // Adapt tags quantity to active links + struct evt_core_cat *cat = evt_core_get_from_cat (ctx, "tcp-write"); + int target_to_use = lightc->fast_count*2 < cat->socklist->len ? lightc->fast_count*2 : cat->socklist->len; + int diff = target_to_use - ((int) lightc->active); + for (int i = 0; i < lightc->total_links && diff > 0; i++) { + if (lightc->status[lightc->stats[i].link_id].used != LINK_NOT_USED) continue; + lightc->status[lightc->stats[i].link_id].used = LINK_SLOW; + diff--; + } + for (int i = lightc->total_links-1; i >= 0 && diff < 0; i--) { + if (lightc->status[lightc->stats[i].link_id].used == LINK_NOT_USED) continue; + lightc->status[lightc->stats[i].link_id].used = LINK_NOT_USED; + diff++; + } + + lightc->active = target_to_use; + + // Update link tags + algo_lightning_update_used(lightc, &now); + algo_lightning_link_cat(lightc, target_to_use/2); + + if (ctx->verbose > 1 || TRUE) { + printf("link ranking (%d fast links, %d total links)\nposition | port | score | class \n", target_to_use/2, target_to_use); for (int i = 0; i < lightc->total_links; i++) { - printf("%d (%ld), ", lightc->stats[i].link_id, lightc->stats[i].ooo); + printf("%8d | %4d | %9ld | %9s \n", i, lightc->stats[i].link_id+7500, lightc->stats[i].ooo, link_cat_str[lightc->status[lightc->stats[i].link_id].used]); } printf("\n"); } @@ -537,7 +553,7 @@ int algo_lightning_on_datagram(struct evt_core_ctx* ctx, struct evt_core_fdinfo* if (lightc->sched_strat == SCHEDULE_BOTH || lightc->sched_strat == SCHEDULE_FAST) { sel_link_last = now; lightc->selected_link = UINT8_MAX; - for (int i = 0, j = 0; i < lightc->total_links && j < lightc->fast_count; i++) { + for (int i = 0; i < lightc->total_links; i++) { if (lightc->status[lightc->stats[i].link_id].used != LINK_FAST) continue; if (timespec_lt (&lightc->status[lightc->stats[i].link_id].last, &sel_link_last)) { lightc->selected_link = lightc->stats[i].link_id; diff --git a/src/dcall.c b/src/dcall.c index e4f9e23..6cf9313 100644 --- a/src/dcall.c +++ b/src/dcall.c @@ -241,6 +241,7 @@ int main(int argc, char *argv[]) { break; case 'c': de.local_port = atoi(optarg); + break; case 'd': de.gstreamer_log_path = optarg; break; From 4a6a197e9860457ee1d85a5bdec10b826f0cbe13 Mon Sep 17 00:00:00 2001 From: Quentin Dufour Date: Tue, 4 Feb 2020 16:53:30 +0100 Subject: [PATCH 25/27] Remove debug --- src/algo_lightning.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/algo_lightning.c b/src/algo_lightning.c index 9b39109..6ce3c06 100644 --- a/src/algo_lightning.c +++ b/src/algo_lightning.c @@ -539,7 +539,7 @@ int algo_lightning_on_datagram(struct evt_core_ctx* ctx, struct evt_core_fdinfo* algo_lightning_update_used(lightc, &now); algo_lightning_link_cat(lightc, target_to_use/2); - if (ctx->verbose > 1 || TRUE) { + if (ctx->verbose > 1) { printf("link ranking (%d fast links, %d total links)\nposition | port | score | class \n", target_to_use/2, target_to_use); for (int i = 0; i < lightc->total_links; i++) { printf("%8d | %4d | %9ld | %9s \n", i, lightc->stats[i].link_id+7500, lightc->stats[i].ooo, link_cat_str[lightc->status[lightc->stats[i].link_id].used]); From 025c42222913669985e24001a08cbb0e3ff10c91 Mon Sep 17 00:00:00 2001 From: Quentin Dufour Date: Tue, 4 Feb 2020 17:24:53 +0100 Subject: [PATCH 26/27] Add a quick XP readme --- QUICK_XP.txt | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) create mode 100644 QUICK_XP.txt diff --git a/QUICK_XP.txt b/QUICK_XP.txt new file mode 100644 index 0000000..d1c88dd --- /dev/null +++ b/QUICK_XP.txt @@ -0,0 +1,17 @@ +curl -fsSL https://download.docker.com/linux/debian/gpg | sudo apt-key add - +add-apt-repository \ + "deb [arch=amd64] https://download.docker.com/linux/debian \ + $(lsb_release -cs) \ + stable" + +apt-get update +apt-get install -y docker-ce docker-ce-cli containerd.io + +wget https://gitlab.inria.fr/qdufour/donar/raw/master/scripts/Makefile +wget https://gitlab.inria.fr/qdufour/donar/raw/master/scripts/run-3 +chmod +x run-3 + +docker login registry.gitlab.inria.fr +docker pull registry.gitlab.inria.fr/qdufour/donar + + From c2037f3440606200283b704871f77ec2c36ea0da Mon Sep 17 00:00:00 2001 From: Quentin Dufour Date: Tue, 4 Feb 2020 17:45:16 +0100 Subject: [PATCH 27/27] fix quick xp --- QUICK_XP.txt | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/QUICK_XP.txt b/QUICK_XP.txt index d1c88dd..16bcfda 100644 --- a/QUICK_XP.txt +++ b/QUICK_XP.txt @@ -1,4 +1,4 @@ -curl -fsSL https://download.docker.com/linux/debian/gpg | sudo apt-key add - +curl -fsSL https://download.docker.com/linux/debian/gpg | apt-key add - add-apt-repository \ "deb [arch=amd64] https://download.docker.com/linux/debian \ $(lsb_release -cs) \ @@ -14,4 +14,4 @@ chmod +x run-3 docker login registry.gitlab.inria.fr docker pull registry.gitlab.inria.fr/qdufour/donar - +make ...