diff options
Diffstat (limited to 'tools/pkt_gen/moongen')
-rw-r--r-- | tools/pkt_gen/moongen/moongen.py | 73 |
1 files changed, 41 insertions, 32 deletions
diff --git a/tools/pkt_gen/moongen/moongen.py b/tools/pkt_gen/moongen/moongen.py index e14c6a79..790286d8 100644 --- a/tools/pkt_gen/moongen/moongen.py +++ b/tools/pkt_gen/moongen/moongen.py @@ -488,10 +488,21 @@ class Moongen(ITrafficGenerator): 'PARAMETERS section of Moongen log file') frame_size = 0 - if results_match and parameters_match: + # Each packet stream in the MoonGen report is prefaced with the + # words '[REPORT]Device'. Count the instances of this string to + # get the total aggregrate throughput. For example: + # + # - If num_traffic_streams = 1, there is a single + # unidirectional stream + # + # - If num_traffic_streams = 2, there is a bidirectional + # traffic stream + num_traffic_streams = mytext.count('[REPORT]Device') + + if results_match and parameters_match and num_traffic_streams: # Assume for now 10G link speed - max_theoretical_mfps = ( - (self._moongen_line_speed / 8) / (frame_size + 20)) + max_theoretical_fps = ( + num_traffic_streams * (self._moongen_line_speed / 8) / (frame_size + 20)) moongen_results[ResultsConstants.THROUGHPUT_RX_FPS] = ( float(results_match.group(6)) * 1000000) @@ -500,8 +511,7 @@ class Moongen(ITrafficGenerator): (float(results_match.group(6)) * frame_size + 20) * 8) moongen_results[ResultsConstants.THROUGHPUT_RX_PERCENT] = ( - float(results_match.group(6)) * \ - 1000000 / max_theoretical_mfps * 100) + (100 * float(results_match.group(6)) * 1000000) / max_theoretical_fps) moongen_results[ResultsConstants.TX_RATE_FPS] = ( float(results_match.group(5)) * 1000000) @@ -510,8 +520,7 @@ class Moongen(ITrafficGenerator): float(results_match.group(5)) * (frame_size + 20) * 8) moongen_results[ResultsConstants.TX_RATE_PERCENT] = ( - float(results_match.group(5)) * - 1000000 / max_theoretical_mfps * 100) + (100 * float(results_match.group(5)) * 1000000) / max_theoretical_fps) moongen_results[ResultsConstants.B2B_TX_COUNT] = ( float(results_match.group(1))) @@ -528,7 +537,7 @@ class Moongen(ITrafficGenerator): return moongen_results def send_rfc2544_throughput(self, traffic=None, duration=20, - lossrate=0.0, trials=1): + lossrate=0.0, tests=1): # # Send traffic per RFC2544 throughput test specifications. # @@ -537,7 +546,7 @@ class Moongen(ITrafficGenerator): # detected is found. # # :param traffic: Detailed "traffic" spec, see design docs for details - # :param trials: Number of trials to execute + # :param tests: Number of tests to execute # :param duration: Per iteration duration # :param lossrate: Acceptable lossrate percentage # :returns: dictionary of strings with following data: @@ -573,7 +582,7 @@ class Moongen(ITrafficGenerator): total_max_latency_ns = 0 total_avg_latency_ns = 0 - for test_run in range(1, trials+1): + for test_run in range(1, tests+1): collected_results = ( Moongen.run_moongen_and_collect_results(self, test_run=test_run)) @@ -602,35 +611,35 @@ class Moongen(ITrafficGenerator): results = OrderedDict() results[ResultsConstants.THROUGHPUT_RX_FPS] = ( - '{:.6f}'.format(total_throughput_rx_fps / trials)) + '{:.6f}'.format(total_throughput_rx_fps / tests)) results[ResultsConstants.THROUGHPUT_RX_MBPS] = ( - '{:.3f}'.format(total_throughput_rx_mbps / trials)) + '{:.3f}'.format(total_throughput_rx_mbps / tests)) results[ResultsConstants.THROUGHPUT_RX_PERCENT] = ( - '{:.3f}'.format(total_throughput_rx_pct / trials)) + '{:.3f}'.format(total_throughput_rx_pct / tests)) results[ResultsConstants.TX_RATE_FPS] = ( - '{:.6f}'.format(total_throughput_tx_fps / trials)) + '{:.6f}'.format(total_throughput_tx_fps / tests)) results[ResultsConstants.TX_RATE_MBPS] = ( - '{:.3f}'.format(total_throughput_tx_mbps / trials)) + '{:.3f}'.format(total_throughput_tx_mbps / tests)) results[ResultsConstants.TX_RATE_PERCENT] = ( - '{:.3f}'.format(total_throughput_tx_pct / trials)) + '{:.3f}'.format(total_throughput_tx_pct / tests)) results[ResultsConstants.MIN_LATENCY_NS] = ( - '{:.3f}'.format(total_min_latency_ns / trials)) + '{:.3f}'.format(total_min_latency_ns / tests)) results[ResultsConstants.MAX_LATENCY_NS] = ( - '{:.3f}'.format(total_max_latency_ns / trials)) + '{:.3f}'.format(total_max_latency_ns / tests)) results[ResultsConstants.AVG_LATENCY_NS] = ( - '{:.3f}'.format(total_avg_latency_ns / trials)) + '{:.3f}'.format(total_avg_latency_ns / tests)) return results - def start_rfc2544_throughput(self, traffic=None, trials=3, duration=20, + def start_rfc2544_throughput(self, traffic=None, tests=1, duration=20, lossrate=0.0): """Non-blocking version of 'send_rfc2544_throughput'. @@ -646,14 +655,14 @@ class Moongen(ITrafficGenerator): self._logger.info('In moongen wait_rfc2544_throughput') def send_rfc2544_back2back(self, traffic=None, duration=60, - lossrate=0.0, trials=1): + lossrate=0.0, tests=1): """Send traffic per RFC2544 back2back test specifications. Send packets at a fixed rate, using ``traffic`` configuration, for duration seconds. :param traffic: Detailed "traffic" spec, see design docs for details - :param trials: Number of trials to execute + :param tests: Number of tests to execute :param duration: Per iteration duration :param lossrate: Acceptable loss percentage @@ -687,7 +696,7 @@ class Moongen(ITrafficGenerator): results[ResultsConstants.SCAL_STREAM_TYPE] = 0 results[ResultsConstants.SCAL_PRE_INSTALLED_FLOWS] = 0 - for test_run in range(1, trials+1): + for test_run in range(1, tests+1): collected_results = ( Moongen.run_moongen_and_collect_results(self, test_run=test_run)) @@ -717,28 +726,28 @@ class Moongen(ITrafficGenerator): # Calculate average results results[ResultsConstants.B2B_RX_FPS] = ( - results[ResultsConstants.B2B_RX_FPS] / trials) + results[ResultsConstants.B2B_RX_FPS] / tests) results[ResultsConstants.B2B_RX_PERCENT] = ( - results[ResultsConstants.B2B_RX_PERCENT] / trials) + results[ResultsConstants.B2B_RX_PERCENT] / tests) results[ResultsConstants.B2B_TX_FPS] = ( - results[ResultsConstants.B2B_TX_FPS] / trials) + results[ResultsConstants.B2B_TX_FPS] / tests) results[ResultsConstants.B2B_TX_PERCENT] = ( - results[ResultsConstants.B2B_TX_PERCENT] / trials) + results[ResultsConstants.B2B_TX_PERCENT] / tests) results[ResultsConstants.B2B_TX_COUNT] = ( - results[ResultsConstants.B2B_TX_COUNT] / trials) + results[ResultsConstants.B2B_TX_COUNT] / tests) results[ResultsConstants.B2B_FRAMES] = ( - results[ResultsConstants.B2B_FRAMES] / trials) + results[ResultsConstants.B2B_FRAMES] / tests) results[ResultsConstants.B2B_FRAME_LOSS_FRAMES] = ( - results[ResultsConstants.B2B_FRAME_LOSS_FRAMES] / trials) + results[ResultsConstants.B2B_FRAME_LOSS_FRAMES] / tests) results[ResultsConstants.B2B_FRAME_LOSS_PERCENT] = ( - results[ResultsConstants.B2B_FRAME_LOSS_PERCENT] / trials) + results[ResultsConstants.B2B_FRAME_LOSS_PERCENT] / tests) results[ResultsConstants.SCAL_STREAM_COUNT] = 0 results[ResultsConstants.SCAL_STREAM_TYPE] = 0 @@ -746,7 +755,7 @@ class Moongen(ITrafficGenerator): return results - def start_rfc2544_back2back(self, traffic=None, trials=1, duration=20, + def start_rfc2544_back2back(self, traffic=None, tests=1, duration=20, lossrate=0.0): # # Non-blocking version of 'send_rfc2544_back2back'. |