From c919367e35087f7094c3030f27e337a18a0111ec Mon Sep 17 00:00:00 2001 From: Quentin Date: Mon, 23 Sep 2019 17:19:03 +0200 Subject: [PATCH 1/3] Add tor echo logging feature --- src/tor_echo.c | 36 +++++++++++++++++++++++++++--------- 1 file changed, 27 insertions(+), 9 deletions(-) diff --git a/src/tor_echo.c b/src/tor_echo.c index f015ece..2572f96 100644 --- a/src/tor_echo.c +++ b/src/tor_echo.c @@ -6,6 +6,12 @@ #include "evt_core.h" #include "net_tools.h" #include "url.h" +#include "measure.h" + +struct torecho_ctx { + uint8_t is_measlat; + struct measure_conf mc; +}; 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); @@ -55,21 +61,23 @@ co_error: } int te_on_tcp(struct evt_core_ctx* ctx, struct evt_core_fdinfo* fdinfo) { - char buffer[1500]; ssize_t nread, nwritten; struct sockaddr_in addr; socklen_t addrlen = sizeof(addr); + struct torecho_ctx *tctx = fdinfo->cat->app_ctx; - nread = recv(fdinfo->fd, buffer, sizeof(buffer), 0); + nread = recv(fdinfo->fd, tctx->mc.payload, tctx->mc.payload_size, 0); if (nread == -1 && errno == EAGAIN) return 1; // Read done if (nread == 0) { fprintf(stderr, "WARN! Read 0 bytes.\n"); return 1; } - if (nread < 0 || nread > sizeof(buffer)) { - fprintf(stderr, "Message is either truncated or an error occured. nread=%ld\n", nread); + if (nread < 0 || nread > tctx->mc.payload_size) { + fprintf(stderr, "Message is either truncated or an error occured. nread=%ld, expected=%ld\n", nread, tctx->mc.payload_size); perror("read errno"); exit(EXIT_FAILURE); } - nwritten = send(fdinfo->fd, buffer, nread, 0); + if (tctx->is_measlat) measure_parse (nread, &tctx->mc); + + nwritten = send(fdinfo->fd, tctx->mc.payload, nread, 0); // @FIXME don't support EAGAIN on write. Could be intended, you don't think so? if (nwritten != nread) { fprintf(stderr, "Didn't write the same number of bytes as read - not supported. nread=%ld, nwritten=%ld\n", nread, nwritten); @@ -91,13 +99,21 @@ int main(int argc, char** argv) { struct tor_ctl tctl; enum TOR_ONION_FLAGS tof = TOR_ONION_FLAG_NONE; char url[1024]; + struct torecho_ctx tctx = {0}; + tctx.mc.inhibit_exit = 1; + tctx.mc.payload_size = 1500; - - while ((opt = getopt(argc, argv, "n")) != -1) { + while ((opt = getopt(argc, argv, "ns:m")) != -1) { switch(opt) { case 'n': tof |= TOR_ONION_FLAG_NON_ANONYMOUS; break; + case 'm': + tctx.is_measlat = 1; + break; + case 's': + tctx.mc.payload_size = atoi(optarg); + break; default: break; } @@ -105,7 +121,7 @@ int main(int argc, char** argv) { // 1. Register categories struct evt_core_cat tcp_co = { - .app_ctx = NULL, + .app_ctx = &tctx, .free_app_ctx = NULL, .cb = te_on_tcp_co, .err_cb = NULL, @@ -114,7 +130,7 @@ int main(int argc, char** argv) { .socklist = NULL }; struct evt_core_cat tcp_all = { - .app_ctx = NULL, + .app_ctx = &tctx, .free_app_ctx = NULL, .cb = te_on_tcp, .err_cb = NULL, @@ -122,6 +138,8 @@ int main(int argc, char** argv) { .flags = EPOLLIN | EPOLLOUT | EPOLLET | EPOLLRDHUP, .socklist = NULL }; + measure_prepare (&tctx.mc); + evt_core_init(&evts, 0); evt_core_add_cat(&evts, &tcp_co); evt_core_add_cat(&evts, &tcp_all); From 3ebee4ff2e0c40fc0dbda5dd91ed28d1ca9a5ed3 Mon Sep 17 00:00:00 2001 From: Quentin Date: Mon, 23 Sep 2019 17:34:37 +0200 Subject: [PATCH 2/3] Upgrade scripts to print OWD --- scripts/Makefile | 286 ++++++++++++++++++------------------- scripts/dup2-server | 6 +- scripts/orig-server | 6 +- scripts/orig-server-single | 6 +- scripts/thunder-server | 6 +- 5 files changed, 155 insertions(+), 155 deletions(-) diff --git a/scripts/Makefile b/scripts/Makefile index df9cfa8..3ab4e70 100644 --- a/scripts/Makefile +++ b/scripts/Makefile @@ -4,7 +4,7 @@ simple_test: ./run-3 \ 1,simple_test . \ thunder-client 600 100 100 8 150 . \ - thunder-server 8 150 . \ + thunder-server 8 150 100. \ tor3 -f /etc/torrc_simple . \ tor3 -f /etc/torrc_simple @@ -15,10 +15,10 @@ tor_bw_small: orig-client 120 500 100, \ orig-client 600 100 100, \ orig-client 1200 50 100 . \ - orig-server, \ - orig-server, \ - orig-server, \ - orig-server . \ + orig-server 100, \ + orig-server 100, \ + orig-server 100, \ + orig-server 100. \ tor3 -f /etc/torrc_simple, \ tor3 -f /etc/torrc_simple, \ tor3 -f /etc/torrc_simple, \ @@ -40,11 +40,11 @@ tor_bw_full: orig-client 6000 100 100, \ orig-client 12000 50 100, \ orig-client 30000 20 100 . \ - orig-server, \ - orig-server, \ - orig-server, \ - orig-server, \ - orig-server . \ + orig-server 100, \ + orig-server 100, \ + orig-server 100, \ + orig-server 100, \ + orig-server 100. \ tor3 -f /etc/torrc_simple, \ tor3 -f /etc/torrc_simple, \ tor3 -f /etc/torrc_simple, \ @@ -67,10 +67,10 @@ tor_guards_small: dup2-client 600 100 100 8, \ dup2-client 600 100 100 8, \ dup2-client 600 100 100 8 . \ - dup2-server 8, \ - dup2-server 8, \ - dup2-server 8, \ - dup2-server 8 . \ + dup2-server 8 100, \ + dup2-server 8 100, \ + dup2-server 8 100, \ + dup2-server 8 100. \ tor3 -f /etc/torrc_guard_1, \ tor3 -f /etc/torrc_guard_3, \ tor3 -f /etc/torrc_guard_5, \ @@ -92,15 +92,15 @@ tor_guards_full: dup2-client 6000 100 100 8, \ dup2-client 6000 100 100 8, \ dup2-client 6000 100 100 8 . \ - dup2-server 8, \ - dup2-server 8, \ - dup2-server 8, \ - dup2-server 8, \ - dup2-server 8, \ - dup2-server 8, \ - dup2-server 8, \ - dup2-server 8, \ - dup2-server 8 . \ + dup2-server 8 100, \ + dup2-server 8 100, \ + dup2-server 8 100, \ + dup2-server 8 100, \ + dup2-server 8 100, \ + dup2-server 8 100, \ + dup2-server 8 100, \ + dup2-server 8 100, \ + dup2-server 8 100. \ tor3 -f /etc/torrc_guard_1, \ tor3 -f /etc/torrc_guard_2, \ tor3 -f /etc/torrc_guard_3, \ @@ -130,9 +130,9 @@ tor_relays_full: orig-client 6000 100 100, \ orig-client 6000 100 100, \ orig-client 6000 100 100 . \ - orig-server, \ - orig-server, \ - orig-server-single . \ + orig-server 100, \ + orig-server 100, \ + orig-server-single 100. \ tor3 -f /etc/torrc_simple, \ tor2 -f /etc/torrc_simple, \ tor2 -f /etc/torrc_simple . \ @@ -146,9 +146,9 @@ tor_relays_small: orig-client 600 100 100, \ orig-client 600 100 100, \ orig-client 600 100 100 . \ - orig-server, \ - orig-server, \ - orig-server-single . \ + orig-server 100, \ + orig-server 100, \ + orig-server-single 100. \ tor3 -f /etc/torrc_simple, \ tor2 -f /etc/torrc_simple, \ tor2 -f /etc/torrc_simple . \ @@ -170,13 +170,13 @@ thunder_configure_small: thunder-client 600 100 100 $(link_num) 250, \ thunder-client 600 100 100 $(link_num) 300, \ thunder-client 600 100 100 $(link_num) 350. \ - thunder-server $(link_num) 50, \ - thunder-server $(link_num) 100, \ - thunder-server $(link_num) 150, \ - thunder-server $(link_num) 200, \ - thunder-server $(link_num) 250, \ - thunder-server $(link_num) 300, \ - thunder-server $(link_num) 350. \ + thunder-server $(link_num) 50 100, \ + thunder-server $(link_num) 100 100, \ + thunder-server $(link_num) 150 100, \ + thunder-server $(link_num) 200 100, \ + thunder-server $(link_num) 250 100, \ + thunder-server $(link_num) 300 100, \ + thunder-server $(link_num) 350 100. \ tor2 -f /etc/torrc_guard_2, \ tor2 -f /etc/torrc_guard_2, \ tor2 -f /etc/torrc_guard_2, \ @@ -202,13 +202,13 @@ thunder_configure_full: thunder-client 6000 100 100 $(link_num) 250, \ thunder-client 6000 100 100 $(link_num) 300, \ thunder-client 6000 100 100 $(link_num) 350. \ - thunder-server $(link_num) 50, \ - thunder-server $(link_num) 100, \ - thunder-server $(link_num) 150, \ - thunder-server $(link_num) 200, \ - thunder-server $(link_num) 250, \ - thunder-server $(link_num) 300, \ - thunder-server $(link_num) 350. \ + thunder-server $(link_num) 50 100, \ + thunder-server $(link_num) 100 100, \ + thunder-server $(link_num) 150 100, \ + thunder-server $(link_num) 200 100, \ + thunder-server $(link_num) 250 100, \ + thunder-server $(link_num) 300 100, \ + thunder-server $(link_num) 350 100. \ tor2 -f /etc/torrc_guard_2, \ tor2 -f /etc/torrc_guard_2, \ tor2 -f /etc/torrc_guard_2, \ @@ -237,12 +237,12 @@ thunder_configure_2_part: thunder-client 9900 30 100 8 ${jmax}, \ thunder-client 9900 30 100 12 ${jmax}, \ thunder-client 9900 30 100 16 ${jmax}. \ - thunder-server 2 ${jmax}, \ - thunder-server 4 ${jmax}, \ - thunder-server 6 ${jmax}, \ - thunder-server 8 ${jmax}, \ - thunder-server 12 ${jmax}, \ - thunder-server 16 ${jmax}. \ + thunder-server 2 ${jmax} 100, \ + thunder-server 4 ${jmax} 100, \ + thunder-server 6 ${jmax} 100, \ + thunder-server 8 ${jmax} 100, \ + thunder-server 12 ${jmax} 100, \ + thunder-server 16 ${jmax} 100. \ tor2 -f /etc/torrc_simple, \ tor2 -f /etc/torrc_simple, \ tor2 -f /etc/torrc_simple, \ @@ -301,48 +301,48 @@ thunder_configure_2_full: thunder-client 9900 30 100 8 450, \ thunder-client 9900 30 100 8 550, \ thunder-client 9900 30 100 8 650. \ - thunder-server 2 50, \ - thunder-server 2 150, \ - thunder-server 2 250, \ - thunder-server 2 350, \ - thunder-server 2 450, \ - thunder-server 2 550, \ - thunder-server 2 650, \ - thunder-server 4 50, \ - thunder-server 4 150, \ - thunder-server 4 250, \ - thunder-server 4 350, \ - thunder-server 4 450, \ - thunder-server 4 550, \ - thunder-server 4 650, \ - thunder-server 6 50, \ - thunder-server 6 150, \ - thunder-server 6 250, \ - thunder-server 6 350, \ - thunder-server 6 450, \ - thunder-server 6 550, \ - thunder-server 6 650, \ - thunder-server 12 50, \ - thunder-server 12 150, \ - thunder-server 12 250, \ - thunder-server 12 350, \ - thunder-server 12 450, \ - thunder-server 12 550, \ - thunder-server 12 650, \ - thunder-server 16 50, \ - thunder-server 16 150, \ - thunder-server 16 250, \ - thunder-server 16 350, \ - thunder-server 16 450, \ - thunder-server 16 550, \ - thunder-server 16 650, \ - thunder-server 8 50, \ - thunder-server 8 150, \ - thunder-server 8 250, \ - thunder-server 8 350, \ - thunder-server 8 450, \ - thunder-server 8 550, \ - thunder-server 8 650. \ + thunder-server 2 50 100, \ + thunder-server 2 150 100, \ + thunder-server 2 250 100, \ + thunder-server 2 350 100, \ + thunder-server 2 450 100, \ + thunder-server 2 550 100, \ + thunder-server 2 650 100, \ + thunder-server 4 50 100, \ + thunder-server 4 150 100, \ + thunder-server 4 250 100, \ + thunder-server 4 350 100, \ + thunder-server 4 450 100, \ + thunder-server 4 550 100, \ + thunder-server 4 650 100, \ + thunder-server 6 50 100, \ + thunder-server 6 150 100, \ + thunder-server 6 250 100, \ + thunder-server 6 350 100, \ + thunder-server 6 450 100, \ + thunder-server 6 550 100, \ + thunder-server 6 650 100, \ + thunder-server 12 50 100, \ + thunder-server 12 150 100, \ + thunder-server 12 250 100, \ + thunder-server 12 350 100, \ + thunder-server 12 450 100, \ + thunder-server 12 550 100, \ + thunder-server 12 650 100, \ + thunder-server 16 50 100, \ + thunder-server 16 150 100, \ + thunder-server 16 250 100, \ + thunder-server 16 350 100, \ + thunder-server 16 450 100, \ + thunder-server 16 550 100, \ + thunder-server 16 650 100, \ + thunder-server 8 50 100, \ + thunder-server 8 150 100, \ + thunder-server 8 250 100, \ + thunder-server 8 350 100, \ + thunder-server 8 450 100, \ + thunder-server 8 550 100, \ + thunder-server 8 650 100. \ tor2 -f /etc/torrc_simple, \ tor2 -f /etc/torrc_simple, \ tor2 -f /etc/torrc_simple, \ @@ -495,46 +495,46 @@ tor_just_many_latencies: orig-client 9900 30 100, \ orig-client 9900 30 100, \ orig-client 9900 30 100 . \ - orig-server, \ - orig-server, \ - orig-server, \ - orig-server, \ - orig-server, \ - orig-server, \ - orig-server, \ - orig-server, \ - orig-server, \ - orig-server, \ - orig-server, \ - orig-server, \ - orig-server, \ - orig-server, \ - orig-server, \ - orig-server, \ - orig-server, \ - orig-server, \ - orig-server, \ - orig-server, \ - orig-server, \ - orig-server, \ - orig-server, \ - orig-server, \ - orig-server, \ - orig-server, \ - orig-server, \ - orig-server, \ - orig-server, \ - orig-server, \ - orig-server, \ - orig-server, \ - orig-server, \ - orig-server, \ - orig-server, \ - orig-server, \ - orig-server, \ - orig-server, \ - orig-server, \ - orig-server . \ + orig-server 100, \ + orig-server 100, \ + orig-server 100, \ + orig-server 100, \ + orig-server 100, \ + orig-server 100, \ + orig-server 100, \ + orig-server 100, \ + orig-server 100, \ + orig-server 100, \ + orig-server 100, \ + orig-server 100, \ + orig-server 100, \ + orig-server 100, \ + orig-server 100, \ + orig-server 100, \ + orig-server 100, \ + orig-server 100, \ + orig-server 100, \ + orig-server 100, \ + orig-server 100, \ + orig-server 100, \ + orig-server 100, \ + orig-server 100, \ + orig-server 100, \ + orig-server 100, \ + orig-server 100, \ + orig-server 100, \ + orig-server 100, \ + orig-server 100, \ + orig-server 100, \ + orig-server 100, \ + orig-server 100, \ + orig-server 100, \ + orig-server 100, \ + orig-server 100, \ + orig-server 100, \ + orig-server 100, \ + orig-server 100, \ + orig-server 100. \ tor3 -f /etc/torrc_simple, \ tor3 -f /etc/torrc_simple, \ tor3 -f /etc/torrc_simple, \ @@ -659,18 +659,18 @@ thunder_guards: thunder-client 9900 30 100 12 250, \ thunder-client 9900 30 100 12 250, \ thunder-client 9900 30 100 12 250. \ - thunder-server 12 250, \ - thunder-server 12 250, \ - thunder-server 12 250, \ - thunder-server 12 250, \ - thunder-server 12 250, \ - thunder-server 12 250, \ - thunder-server 12 250, \ - thunder-server 12 250, \ - thunder-server 12 250, \ - thunder-server 12 250, \ - thunder-server 12 250, \ - thunder-server 12 250. \ + thunder-server 12 250 100, \ + thunder-server 12 250 100, \ + thunder-server 12 250 100, \ + thunder-server 12 250 100, \ + thunder-server 12 250 100, \ + thunder-server 12 250 100, \ + thunder-server 12 250 100, \ + thunder-server 12 250 100, \ + thunder-server 12 250 100, \ + thunder-server 12 250 100, \ + thunder-server 12 250 100, \ + thunder-server 12 250 100. \ tor2 -f /etc/torrc_guard_2, \ tor2 -f /etc/torrc_guard_4, \ tor2 -f /etc/torrc_guard_6, \ diff --git a/scripts/dup2-server b/scripts/dup2-server index 6272c17..b67b4f3 100755 --- a/scripts/dup2-server +++ b/scripts/dup2-server @@ -1,6 +1,6 @@ #!/bin/bash -mkdir -p $2/{log,shared} -cd $2/shared +mkdir -p $3/{log,shared} +cd $3/shared donar \ -a dup2 \ @@ -10,4 +10,4 @@ donar \ -e 9000 \ > ../log/server-donar-stdout.log 2> ../log/server-donar-stderr.log & -udpecho -p 9000 > ../log/server-udpecho-stdout.log 2> ../log/server-udpecho-stderr.log +udpecho -p 9000 -m -s $2 > ../log/server-udpecho-stdout.log 2> ../log/server-udpecho-stderr.log diff --git a/scripts/orig-server b/scripts/orig-server index dd3cbf5..986ec9f 100755 --- a/scripts/orig-server +++ b/scripts/orig-server @@ -1,4 +1,4 @@ #!/bin/bash -mkdir -p $1/{log,shared} -cd $1/shared -torecho > ../log/server-udpecho-stdout.log 2> ../log/server-udpecho-stderr.log +mkdir -p $2/{log,shared} +cd $2/shared +torecho -m -s $1 > ../log/server-udpecho-stdout.log 2> ../log/server-udpecho-stderr.log diff --git a/scripts/orig-server-single b/scripts/orig-server-single index f785c38..1284c2e 100755 --- a/scripts/orig-server-single +++ b/scripts/orig-server-single @@ -1,4 +1,4 @@ #!/bin/bash -mkdir -p $1/{log,shared} -cd $1/shared -torecho -n > ../log/server-udpecho-stdout.log 2> ../log/server-udpecho-stderr.log +mkdir -p $2/{log,shared} +cd $2/shared +torecho -n -m -s $1 > ../log/server-udpecho-stdout.log 2> ../log/server-udpecho-stderr.log diff --git a/scripts/thunder-server b/scripts/thunder-server index e0a60e3..f7104c5 100755 --- a/scripts/thunder-server +++ b/scripts/thunder-server @@ -1,6 +1,6 @@ #!/bin/bash -mkdir -p $3/{log,shared} -cd $3/shared +mkdir -p $4/{log,shared} +cd $4/shared donar \ -a thunder \ @@ -11,4 +11,4 @@ donar \ -e 9000 \ > ../log/server-donar-stdout.log 2> ../log/server-donar-stderr.log & -udpecho -p 9000 > ../log/server-udpecho-stdout.log 2> ../log/server-udpecho-stderr.log +udpecho -p 9000 -m -s $3 > ../log/server-udpecho-stdout.log 2> ../log/server-udpecho-stderr.log From 55a09eaa3f1e877417a7b352b3bf608b25077978 Mon Sep 17 00:00:00 2001 From: Quentin Date: Mon, 23 Sep 2019 17:36:40 +0200 Subject: [PATCH 3/3] Parameterize many latencies --- scripts/Makefile | 80 ++++++++++++++++++++++++------------------------ 1 file changed, 40 insertions(+), 40 deletions(-) diff --git a/scripts/Makefile b/scripts/Makefile index 3ab4e70..cc7ead2 100644 --- a/scripts/Makefile +++ b/scripts/Makefile @@ -455,46 +455,46 @@ thunder_configure_2_full_parse_red: tor_just_many_latencies: ./run-3 \ 2,tor_just_many_latencies . \ - orig-client 9900 30 100, \ - orig-client 9900 30 100, \ - orig-client 9900 30 100, \ - orig-client 9900 30 100, \ - orig-client 9900 30 100, \ - orig-client 9900 30 100, \ - orig-client 9900 30 100, \ - orig-client 9900 30 100, \ - orig-client 9900 30 100, \ - orig-client 9900 30 100, \ - orig-client 9900 30 100, \ - orig-client 9900 30 100, \ - orig-client 9900 30 100, \ - orig-client 9900 30 100, \ - orig-client 9900 30 100, \ - orig-client 9900 30 100, \ - orig-client 9900 30 100, \ - orig-client 9900 30 100, \ - orig-client 9900 30 100, \ - orig-client 9900 30 100, \ - orig-client 9900 30 100, \ - orig-client 9900 30 100, \ - orig-client 9900 30 100, \ - orig-client 9900 30 100, \ - orig-client 9900 30 100, \ - orig-client 9900 30 100, \ - orig-client 9900 30 100, \ - orig-client 9900 30 100, \ - orig-client 9900 30 100, \ - orig-client 9900 30 100, \ - orig-client 9900 30 100, \ - orig-client 9900 30 100, \ - orig-client 9900 30 100, \ - orig-client 9900 30 100, \ - orig-client 9900 30 100, \ - orig-client 9900 30 100, \ - orig-client 9900 30 100, \ - orig-client 9900 30 100, \ - orig-client 9900 30 100, \ - orig-client 9900 30 100 . \ + orig-client ${count} ${interval} 100, \ + orig-client ${count} ${interval} 100, \ + orig-client ${count} ${interval} 100, \ + orig-client ${count} ${interval} 100, \ + orig-client ${count} ${interval} 100, \ + orig-client ${count} ${interval} 100, \ + orig-client ${count} ${interval} 100, \ + orig-client ${count} ${interval} 100, \ + orig-client ${count} ${interval} 100, \ + orig-client ${count} ${interval} 100, \ + orig-client ${count} ${interval} 100, \ + orig-client ${count} ${interval} 100, \ + orig-client ${count} ${interval} 100, \ + orig-client ${count} ${interval} 100, \ + orig-client ${count} ${interval} 100, \ + orig-client ${count} ${interval} 100, \ + orig-client ${count} ${interval} 100, \ + orig-client ${count} ${interval} 100, \ + orig-client ${count} ${interval} 100, \ + orig-client ${count} ${interval} 100, \ + orig-client ${count} ${interval} 100, \ + orig-client ${count} ${interval} 100, \ + orig-client ${count} ${interval} 100, \ + orig-client ${count} ${interval} 100, \ + orig-client ${count} ${interval} 100, \ + orig-client ${count} ${interval} 100, \ + orig-client ${count} ${interval} 100, \ + orig-client ${count} ${interval} 100, \ + orig-client ${count} ${interval} 100, \ + orig-client ${count} ${interval} 100, \ + orig-client ${count} ${interval} 100, \ + orig-client ${count} ${interval} 100, \ + orig-client ${count} ${interval} 100, \ + orig-client ${count} ${interval} 100, \ + orig-client ${count} ${interval} 100, \ + orig-client ${count} ${interval} 100, \ + orig-client ${count} ${interval} 100, \ + orig-client ${count} ${interval} 100, \ + orig-client ${count} ${interval} 100, \ + orig-client ${count} ${interval} 100 . \ orig-server 100, \ orig-server 100, \ orig-server 100, \