Add thunder script

This commit is contained in:
Quentin 2019-09-06 11:20:17 +02:00
parent 6271b10d31
commit 9a46aef12c
5 changed files with 42 additions and 0 deletions

View file

@ -1,5 +1,13 @@
SHELL := /bin/bash SHELL := /bin/bash
simple_test:
./run-3 \
1,simple_test . \
orig-client 600 100 100 . \
orig-server . \
tor3 -f /etc/torrc_simple . \
tor3 -f /etc/torrc_simple
tor_bw_small: tor_bw_small:
./run-3 \ ./run-3 \
1,tor_bw_small . \ 1,tor_bw_small . \

14
scripts/thunder-client Executable file
View file

@ -0,0 +1,14 @@
#!/bin/bash
mkdir -p $5/{log,shared,res}
donar \
-a thunder \
-c \
-o $5/shared/onion_services.pub \
-l $4 \
-b \
-r 9000 \
> $5/log/client-donar-stdout.log 2> $5/log/client-donar-stderr.log &
sleep 2
measlat -h 127.13.3.7 -p 9000 > /dev/null 2>&1 # Used to wait for connections
measlat -h 127.13.3.7 -p 9000 -c $1 -i $2 -s $3 > $5/res/thunder.csv 2> $5/log/client-measlat-stderr.log

13
scripts/thunder-server Executable file
View file

@ -0,0 +1,13 @@
#!/bin/bash
mkdir -p $2/{log,shared}
cd $2/shared
donar \
-a thunder \
-s \
-l $1 \
-b \
-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

View file

@ -53,6 +53,7 @@ int main_on_tcp_read(struct evt_core_ctx* ctx, struct evt_core_fdinfo* fdinfo) {
if (read_res == FDS_AGAIN) return 1; if (read_res == FDS_AGAIN) return 1;
} }
app_ctx->cell_rcv++;
if (ctx->verbose > 1) fprintf(stderr, " [proxy] Call logic on packet\n"); if (ctx->verbose > 1) fprintf(stderr, " [proxy] Call logic on packet\n");
return app_ctx->desc->on_stream(ctx, fdinfo, bp); return app_ctx->desc->on_stream(ctx, fdinfo, bp);
@ -77,6 +78,7 @@ int main_on_udp_read(struct evt_core_ctx* ctx, struct evt_core_fdinfo* fdinfo) {
if (read_res == FDS_AGAIN) return 1; if (read_res == FDS_AGAIN) return 1;
// 3. Notify helpers // 3. Notify helpers
app_ctx->udp_rcv++;
traffic_capture_notify (&app_ctx->cap, bp, "in"); traffic_capture_notify (&app_ctx->cap, bp, "in");
// 4. Apply logic // 4. Apply logic
@ -111,6 +113,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_ERR) goto co_error;
if (write_res == FDS_AGAIN) return 1; if (write_res == FDS_AGAIN) return 1;
} }
app_ctx->cell_sent++;
free_buffer: free_buffer:
// 3. A whole packet has been written // 3. A whole packet has been written
@ -142,6 +145,7 @@ int main_on_udp_write (struct evt_core_ctx* ctx, struct evt_core_fdinfo* fdinfo)
// 3. Notify helpers // 3. Notify helpers
if (ctx->verbose > 1) fprintf(stderr, " [proxy] Notify traffic capture\n"); if (ctx->verbose > 1) fprintf(stderr, " [proxy] Notify traffic capture\n");
app_ctx->udp_sent++;
traffic_capture_notify (&app_ctx->cap, bp, "out"); traffic_capture_notify (&app_ctx->cap, bp, "out");
// 4. A whole packet has been written // 4. A whole packet has been written
@ -176,9 +180,11 @@ int main_on_err(struct evt_core_ctx* ctx, struct evt_core_fdinfo* fdinfo) {
void algo_main_destroy(void* app_ctx) { void algo_main_destroy(void* app_ctx) {
struct algo_ctx* ctx = (struct algo_ctx*) app_ctx; struct algo_ctx* ctx = (struct algo_ctx*) app_ctx;
ctx->ref_count--; ctx->ref_count--;
if (ctx->ref_count > 0) return; if (ctx->ref_count > 0) return;
printf("udp_sent: %ld, udp_rcv: %ld, cells_sent: %ld, cells_rcv: %ld\n", ctx->udp_sent, ctx->udp_rcv, ctx->cell_sent, ctx->cell_rcv);
traffic_capture_stop(&ctx->cap); traffic_capture_stop(&ctx->cap);
destroy_buffer_management(&ctx->br); destroy_buffer_management(&ctx->br);
if (ctx->free_misc) ctx->free_misc(ctx->misc); if (ctx->free_misc) ctx->free_misc(ctx->misc);

View file

@ -39,6 +39,7 @@ struct algo_ctx {
uint8_t is_rdy; uint8_t is_rdy;
struct algo_params ap; struct algo_params ap;
int ref_count; int ref_count;
uint64_t udp_rcv, udp_sent, cell_rcv, cell_sent;
struct capture_ctx cap; struct capture_ctx cap;
struct buffer_resources br; struct buffer_resources br;
void* misc; // Additional structures void* misc; // Additional structures