diff --git a/scripts/2021/torfone b/scripts/2021/torfone index 29d1388..47fcd7e 100755 --- a/scripts/2021/torfone +++ b/scripts/2021/torfone @@ -62,7 +62,7 @@ popd -t udp \ -h 127.0.0.1 \ -p $LOCAL_PORT \ - -c 1350 \ + -c 135000 \ -i 40 \ -m torfone \ -s 172 2>&1 | cyan & @@ -82,7 +82,7 @@ sleep 1 -t udp \ -h 127.13.3.7 \ -p $LOCAL_PORT \ - -c 1350 \ + -c 135000 \ -i 40 \ -m torfone \ -s 172 2>&1 | purple diff --git a/src/algo_lightning.c b/src/algo_lightning.c index dd73237..95383c9 100644 --- a/src/algo_lightning.c +++ b/src/algo_lightning.c @@ -92,6 +92,7 @@ struct light_ctx { int is_measlat; int explain; int disable_scheduler; + int base_port; struct stat_entry stats[MAX_LINKS]; enum schedule_group_target sched_strat; }; @@ -121,6 +122,7 @@ void algo_lightning_init(struct evt_core_ctx* ctx, struct algo_ctx* app_ctx, str lightc->disable_scheduler = 0; lightc->active = 0; lightc->sched_strat = SCHEDULE_BOTH; + lightc->base_port = ap->base_port; uint64_t window = 2000; if (ap->algo_specific_params != NULL) { @@ -256,7 +258,7 @@ void monitoring(struct evt_core_ctx* ctx, struct evt_core_fdinfo* fdinfo, struct } // Update current packet status - int link_id = url_get_port_int(fdinfo->url) - 7500; + int link_id = url_get_port_int(fdinfo->url) - lightc->base_port; struct timing_entry *te2 = &lightc->historic[pkt_id % HISTORIC_SIZE]; te2->state = te2->pkt_id == pkt_id ? OOO_DONE : IN_ORDER; te2->pkt_id = pkt_id; @@ -371,7 +373,7 @@ void algo_lightning_update_stats (struct light_ctx *lightc, struct evt_core_ctx* // 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); + sprintf(url, "tcp:write:127.0.0.1:%d", lightc->base_port + i); struct evt_core_fdinfo *to_fdinfo = evt_core_get_from_url (ctx, url); if (to_fdinfo == NULL) lightc->stats[i].ooo = -2; } @@ -399,7 +401,7 @@ int send_message(struct evt_core_ctx* ctx, struct buffer_packet* bp) { } set_now(&lightc->status[lightc->selected_link].last); - sprintf(url, "tcp:write:127.0.0.1:%d", 7500 + lightc->selected_link); + sprintf(url, "tcp:write:127.0.0.1:%d", lightc->base_port + lightc->selected_link); struct evt_core_fdinfo *to_fdinfo = evt_core_get_from_url (ctx, url); if (to_fdinfo == NULL) { fprintf(stderr, "[algo_lightning] PACKET DROPPED! We don't have any entry for %s currently\n", url); @@ -543,7 +545,7 @@ int algo_lightning_on_datagram(struct evt_core_ctx* ctx, struct evt_core_fdinfo* 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]); + printf("%8d | %4d | %9ld | %9s \n", i, lightc->stats[i].link_id + lightc->base_port, lightc->stats[i].ooo, link_cat_str[lightc->status[lightc->stats[i].link_id].used]); } printf("\n"); } diff --git a/src/donar.c b/src/donar.c index b3cadd7..5232eff 100644 --- a/src/donar.c +++ b/src/donar.c @@ -83,8 +83,8 @@ int main(int argc, char** argv) { if (dp.tor_port == NULL) dp.tor_port = dp.is_client ? "9050" : "9051"; if (dp.algo == NULL) goto in_error; - fprintf(stderr, "Passed parameters: client=%d, server=%d, algo=%s, exposed_ports=%d, remote_ports=%d, transfer_base_port=%d, tor_daemon_port=%s, onion_file=%s, links=%d, duplication=%d,%d\n", - dp.is_client, dp.is_server, dp.algo, dp.exposed_ports->len, dp.remote_ports->len, dp.base_port, dp.tor_port, dp.onion_file, dp.links, dp.fresh_data, dp.redundant_data); + fprintf(stderr, "Passed parameters: is_waiting_bootstrap=%d, client=%d, server=%d, algo=%s, exposed_ports=%d, remote_ports=%d, transfer_base_port=%d, tor_daemon_port=%s, onion_file=%s, links=%d, duplication=%d,%d\n", + dp.is_waiting_bootstrap, dp.is_client, dp.is_server, dp.algo, dp.exposed_ports->len, dp.remote_ports->len, dp.base_port, dp.tor_port, dp.onion_file, dp.links, dp.fresh_data, dp.redundant_data); if (dp.is_server) { diff --git a/src/donar_client.c b/src/donar_client.c index 35a497f..681d2f6 100644 --- a/src/donar_client.c +++ b/src/donar_client.c @@ -140,6 +140,7 @@ void donar_client(struct donar_client_ctx* ctx, struct donar_params* dp) { .fresh_data = dp->fresh_data, .redundant_data = dp->redundant_data, .capture_file = dp->capture_file, + .base_port = dp->base_port, .sr = donar_client_stream_repair }; ctx->tor_ip = dp->tor_ip; diff --git a/src/donar_server.c b/src/donar_server.c index 3487825..3a680d8 100644 --- a/src/donar_server.c +++ b/src/donar_server.c @@ -87,6 +87,7 @@ void donar_server(struct donar_server_ctx* ctx, struct donar_params* dp) { .fresh_data = dp->fresh_data, .redundant_data = dp->redundant_data, .capture_file = dp->capture_file, + .base_port = dp->base_port, .sr = donar_server_stream_repair }; diff --git a/src/meas_lat.c b/src/meas_lat.c index b4dde8b..d9358b3 100644 --- a/src/meas_lat.c +++ b/src/meas_lat.c @@ -152,20 +152,24 @@ int on_receive_measure_packet(struct evt_core_ctx* ctx, struct evt_core_fdinfo* measure_parse (&mctx->mp, ms, mctx->verbose); // 4. Detect if it is a probe - if (ms->mp_in->probe) { // Allow for probing without registering a timer + if (ms->mp_in->probe && mctx->role == MEASLAT_SERVER) { // Allow for probing without registering a timer int s = mctx->connectionless && mctx->role == MEASLAT_SERVER ? sendto(ms->fd, ms->mp_in, mctx->mp.payload_size, 0, (struct sockaddr*)&mctx->addr, mctx->addrlen) : send(ms->fd, ms->mp_in, mctx->mp.payload_size, 0); - if (!mctx->connectionless || mctx->role == MEASLAT_CLIENT) + if (!mctx->connectionless) evt_core_rm_fd (ctx, fdinfo->fd); - if (mctx->role == MEASLAT_CLIENT) - exit(EXIT_SUCCESS); - return 1; + } else if (ms->mp_in->probe && mctx->role == MEASLAT_CLIENT) { + if (ms->mp_out->probe) exit(EXIT_SUCCESS); + else { + fprintf(stderr, "lost probe, ignoring\n"); + return 0; + } } + // 5. Persist our measurement object if needed // It includes starting a timer. if (ms == &ms_transi) { diff --git a/src/measure.c b/src/measure.c index 44118c6..c4f2a17 100644 --- a/src/measure.c +++ b/src/measure.c @@ -86,11 +86,11 @@ void measure_parse(struct measure_params* mp, struct measure_state* ms, uint8_t micro_sec = elapsed_micros (&ms->mp_in->emit_time, &curr); - if (ms->mp_in->counter <= mp->max_measure) { + if (ms->mp_in->counter <= mp->max_measure && !ms->mp_in->probe) { ms->log[ms->mp_in->counter-1] = micro_sec; } else { verbose = 1; - fprintf(stderr, "measure will be ignored: counter=%lu, max_measure=%lu\n", ms->mp_in->counter, mp->max_measure); + fprintf(stderr, "measure will be ignored: probe=%d, counter=%lu, max_measure=%lu\n", ms->mp_in->probe, ms->mp_in->counter, mp->max_measure); } if (verbose) { diff --git a/src/proxy.c b/src/proxy.c index 77ba61c..e3e73e1 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 we don't want deactivation finally + app_ctx->is_rdy = app_ctx->is_rdy || is_rdy; // we don't want deactivation finally, after all the test is running // 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; diff --git a/src/proxy.h b/src/proxy.h index 4a0fd1d..2c298dd 100644 --- a/src/proxy.h +++ b/src/proxy.h @@ -16,7 +16,7 @@ typedef int (*stream_repair)(struct evt_core_ctx* ctx, struct evt_core_fdinfo* f struct algo_params { uint8_t is_waiting_bootstrap; char *algo_name, *capture_file, *algo_specific_params; - int links, fresh_data, redundant_data; + int links, fresh_data, redundant_data, base_port; stream_repair sr; };