@@ -817,11 +817,11 @@ fn test_replay() {
817817 let trace_config = RepeatedBwPatternConfig :: new ( ) . pattern ( vec ! [
818818 Box :: new( StaticBwConfig {
819819 bw: Some ( Bandwidth :: from_mbps( 100 ) ) ,
820- duration: Some ( Duration :: from_secs( 5 ) ) ,
820+ duration: Some ( Duration :: from_secs( 6 ) ) ,
821821 } ) ,
822822 Box :: new( StaticBwConfig {
823823 bw: Some ( Bandwidth :: from_mbps( 20 ) ) ,
824- duration: Some ( Duration :: from_secs( 5 ) ) ,
824+ duration: Some ( Duration :: from_secs( 6 ) ) ,
825825 } ) as Box <dyn BwTraceConfig >,
826826 ] ) ;
827827 control_interface
@@ -836,7 +836,7 @@ fn test_replay() {
836836 . left_spawn ( None , move || {
837837 let client_handle = std:: process:: Command :: new ( "iperf3" )
838838 . args ( [
839- "-c" , & right_ip, "-p" , "9000" , "--cport" , "10000" , "-t" , "10 " , "-J" , "-R" ,
839+ "-c" , & right_ip, "-p" , "9000" , "--cport" , "10000" , "-t" , "12 " , "-J" , "-R" ,
840840 "-C" , "reno" ,
841841 ] )
842842 . stdout ( std:: process:: Stdio :: piped ( ) )
@@ -860,9 +860,13 @@ fn test_replay() {
860860 . captures_iter ( & stdout)
861861 . flat_map ( |cap| cap[ 1 ] . parse :: < u64 > ( ) )
862862 . step_by ( 2 )
863- . take ( 10 )
863+ . take ( 11 )
864864 . collect :: < Vec < _ > > ( ) ;
865865 let front_5s_bandwidth = bandwidth. drain ( 0 ..5 ) . collect :: < Vec < _ > > ( ) ;
866+
867+ // There could be a multi-hundred-ms gap between the initial request by iperf and the actual start point
868+ // of trasmission. Thus, skip one sec near the change point of bw.
869+ let _ = bandwidth. drain ( 0 ..1 ) . take ( 1 ) ;
866870 let back_5s_bandwidth = bandwidth. drain ( 0 ..5 ) . collect :: < Vec < _ > > ( ) ;
867871
868872 let front_5s_bitrate =
@@ -881,7 +885,16 @@ fn test_replay() {
881885 back_5s_bandwidth
882886 ) ;
883887
884- assert ! ( front_5s_bitrate > 90000000 && front_5s_bitrate < 100000000 ) ;
885- assert ! ( back_5s_bitrate > 18000000 && back_5s_bitrate < 22000000 ) ;
888+ // Correct for difference between payload length and L2 length
889+ let front_5s_target_rate = Bandwidth :: from_mbps ( 100 ) . as_bps ( ) as f64 * 1460.0 / 1514.0 ;
890+ let back_5s_target_rate = Bandwidth :: from_mbps ( 20 ) . as_bps ( ) as f64 * 1460.0 / 1514.0 ;
891+
892+ let front_5s_bitrate = front_5s_bitrate as f64 ;
893+ let back_5s_bitrate = back_5s_bitrate as f64 ;
894+
895+ assert ! ( front_5s_bitrate > front_5s_target_rate * 0.97 ) ;
896+ assert ! ( front_5s_bitrate < front_5s_target_rate * 1.03 ) ;
897+ assert ! ( back_5s_bitrate > back_5s_target_rate * 0.97 ) ;
898+ assert ! ( back_5s_bitrate < back_5s_target_rate * 1.03 ) ;
886899 }
887900}
0 commit comments