From 0d604e159ba0da80f9156921ea4aeaca7f8dbc05 Mon Sep 17 00:00:00 2001 From: Neil Tallim Date: Thu, 8 Sep 2022 16:25:16 -0600 Subject: [PATCH] Parallel fix for TCP --- src/stream/tcp.rs | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/src/stream/tcp.rs b/src/stream/tcp.rs index 8aa71dd..2f8bd3d 100644 --- a/src/stream/tcp.rs +++ b/src/stream/tcp.rs @@ -511,6 +511,7 @@ pub mod sender { let interval_duration = Duration::from_secs_f32(self.send_interval); + let mut interval_iteration = 0; let bytes_to_send = ((self.test_definition.bandwidth as f32) * super::INTERVAL.as_secs_f32()) as i64; let mut bytes_to_send_remaining = bytes_to_send; let bytes_to_send_per_interval_slice = ((bytes_to_send as f32) * self.send_interval) as i64; @@ -567,10 +568,12 @@ pub mod sender { sleep(super::INTERVAL - elapsed_time); } } else if bytes_to_send_per_interval_slice_remaining <= 0 { // interval subsection exhausted + interval_iteration += 1; bytes_to_send_per_interval_slice_remaining = bytes_to_send_per_interval_slice; let elapsed_time = cycle_start.elapsed(); - if interval_duration > elapsed_time { - sleep(interval_duration - elapsed_time); + let interval_endtime = interval_iteration * interval_duration; + if interval_endtime > elapsed_time { + sleep(interval_endtime - elapsed_time); } } self.remaining_duration -= packet_start.elapsed().as_secs_f32();