aquatic_ws_load_test: for single connection, use same PeerId

This commit is contained in:
Joakim Frostegård 2020-08-03 05:27:40 +02:00
parent 7733ee98ca
commit e916780438
3 changed files with 16 additions and 7 deletions

View file

@ -44,10 +44,8 @@
doesn't seem to be that expensive (1-2% cpu) doesn't seem to be that expensive (1-2% cpu)
## aquatic_ws_load_test ## aquatic_ws_load_test
* there are probably many failures when running against wt-tracker causing * still maybe too few answers received with aquatic_ws
removal of connections and for that reason bad performance. likely reason * no offers received with wt-tracker. does it check that they are valid?
is different peer_id on same connection
* why are so few answers received?
## aquatic_udp ## aquatic_udp
* handle errors similarily to aquatic_ws, including errors in socket workers * handle errors similarily to aquatic_ws, including errors in socket workers

View file

@ -176,6 +176,7 @@ impl Connection {
config: &Config, config: &Config,
state: &LoadTestState, state: &LoadTestState,
rng: &mut impl Rng, rng: &mut impl Rng,
connection_id: usize
) -> bool { // bool = remove connection ) -> bool { // bool = remove connection
if !self.can_send { if !self.can_send {
return false; return false;
@ -185,7 +186,8 @@ impl Connection {
let request = create_random_request( let request = create_random_request(
&config, &config,
&state, &state,
rng rng,
connection_id
); );
// If self.send_answer is set and request is announce request, make // If self.send_answer is set and request is announce request, make
@ -217,7 +219,7 @@ impl Connection {
false false
} }
Err(err) => { Err(err) => {
// eprintln!("send request error: {:?}", err); eprintln!("send request error: {:?}", err);
true true
} }
@ -284,6 +286,7 @@ pub fn run_socket_thread(
config, config,
&state, &state,
&mut rng, &mut rng,
*k
); );
if drop_connection { if drop_connection {

View file

@ -12,6 +12,7 @@ pub fn create_random_request(
config: &Config, config: &Config,
state: &LoadTestState, state: &LoadTestState,
rng: &mut impl Rng, rng: &mut impl Rng,
connection_id: usize,
) -> InMessage { ) -> InMessage {
let weights = [ let weights = [
config.torrents.weight_announce as u32, config.torrents.weight_announce as u32,
@ -31,6 +32,7 @@ pub fn create_random_request(
config, config,
state, state,
rng, rng,
connection_id
), ),
RequestType::Scrape => create_scrape_request( RequestType::Scrape => create_scrape_request(
config, config,
@ -46,6 +48,7 @@ fn create_announce_request(
config: &Config, config: &Config,
state: &LoadTestState, state: &LoadTestState,
rng: &mut impl Rng, rng: &mut impl Rng,
connection_id: usize
) -> InMessage { ) -> InMessage {
let (event, bytes_left) = { let (event, bytes_left) = {
if rng.gen_bool(config.torrents.peer_seeder_probability) { if rng.gen_bool(config.torrents.peer_seeder_probability) {
@ -66,9 +69,14 @@ fn create_announce_request(
}) })
} }
let mut peer_id = PeerId([0u8; 20]);
(&mut peer_id.0[..8])
.copy_from_slice(&connection_id.to_ne_bytes());
InMessage::AnnounceRequest(AnnounceRequest { InMessage::AnnounceRequest(AnnounceRequest {
info_hash: state.info_hashes[info_hash_index], info_hash: state.info_hashes[info_hash_index],
peer_id: PeerId(rng.gen()), peer_id,
bytes_left: Some(bytes_left), bytes_left: Some(bytes_left),
event, event,
numwant: None, numwant: None,