Skip to content

Commit

Permalink
udp load test: use connection IDs from responses in requests
Browse files Browse the repository at this point in the history
  • Loading branch information
greatest-ape committed Feb 6, 2024
1 parent efa7930 commit 0b6a02e
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 2 deletions.
2 changes: 1 addition & 1 deletion crates/udp_load_test/src/config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,7 @@ impl Default for RequestConfig {
number_of_peers: 2_000_000,
scrape_max_torrents: 10,
announce_peers_wanted: 30,
weight_connect: 0,
weight_connect: 1,
weight_announce: 100,
weight_scrape: 1,
peer_seeder_probability: 0.75,
Expand Down
15 changes: 14 additions & 1 deletion crates/udp_load_test/src/worker.rs
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,10 @@ impl Worker {
for _ in 0..self.sockets.len() {
match self.request_type_dist.sample(&mut self.rng) {
RequestType::Connect => {
self.send_connect_request(connect_socket_index, u32::MAX - 1);
self.send_connect_request(
connect_socket_index,
connect_socket_index.into(),
);

connect_socket_index = connect_socket_index.wrapping_add(1)
% self.config.network.sockets_per_worker;
Expand Down Expand Up @@ -117,6 +120,16 @@ impl Worker {
match socket.recv(&mut self.buffer[..]) {
Ok(amt) => {
match Response::parse_bytes(&self.buffer[0..amt], self.addr.is_ipv4()) {
Ok(Response::Connect(r)) => {
// If we're sending connect requests, we might
// as well keep connection IDs valid
let connection_id_index =
u32::from_ne_bytes(r.transaction_id.0.get().to_ne_bytes())
as usize;
connection_ids[connection_id_index] = r.connection_id;

self.handle_response(Response::Connect(r));
}
Ok(response) => {
self.handle_response(response);
}
Expand Down

0 comments on commit 0b6a02e

Please sign in to comment.