"""
# python imports
-import logging
from collections import OrderedDict
-import subprocess
+import logging
+import math
import re
+import subprocess
# VSPerf imports
from conf import settings
self._moongen_user = settings.getValue('TRAFFICGEN_MOONGEN_USER')
self._moongen_ports = settings.getValue('TRAFFICGEN_MOONGEN_PORTS')
+ if settings.getValue('TRAFFICGEN_MOONGEN_LINE_SPEED_GBPS') == '10':
+ self._moongen_line_speed = math.pow(10, 10)
+ else:
+ raise RuntimeError(
+ 'MOONGEN: Invalid line speed in configuration ' + \
+ 'file (today 10Gbps supported)')
+
@property
def traffic_defaults(self):
"""Default traffic values.
out_file.write("dstIp = \"" + \
str(traffic['l3']['dstip']) + "\",\n")
- out_file.write("vlanId = " + \
- str(traffic['vlan']['id']) + ",\n")
+ if traffic['vlan']['enabled']:
+ out_file.write("vlanId = " + \
+ str(traffic['vlan']['id']) + ",\n")
out_file.write("searchRunTime = " + \
str(duration) + ",\n")
if one_shot:
out_file.write("oneShot = true,\n")
- # Assume 10G line rates at the moment. Need to convert VSPERF
- # frame_rate (percentage of line rate) to Mpps for Moongen
+ # Need to convert VSPERF frame_rate (percentage of line rate)
+ # to Mpps for Moongen
+ start_rate = str(
+ (traffic['frame_rate'] / 100) * (self._moongen_line_speed / \
+ (8 * (traffic['l2']['framesize'] + 20)) / math.pow(10, 6)))
+
+ logging.debug("startRate = " + start_rate)
+
+ out_file.write("startRate = " + \
+ start_rate + "\n")
- out_file.write("startRate = " + str((traffic['frame_rate'] / 100) * 14.88) + "\n")
out_file.write("}" + "\n")
out_file.close()
"@" + self._moongen_host_ip_addr
cmd_find_moongen = connect_moongen + " ls " + \
- self._moongen_base_dir + "/examples/opnfv-vsperf.lua"
+ self._moongen_base_dir + "/trafficgen.lua"
find_moongen = subprocess.Popen(cmd_find_moongen,
shell=True,
collected_results = Moongen.run_moongen_and_collect_results(self,
test_run=1)
- total_throughput_rx_fps = (
- float(collected_results[ResultsConstants.THROUGHPUT_RX_FPS]))
-
- total_throughput_rx_mbps = (
- float(collected_results[ResultsConstants.THROUGHPUT_RX_MBPS]))
-
- total_throughput_rx_pct = (
- float(collected_results[ResultsConstants.THROUGHPUT_RX_PERCENT]))
-
- total_throughput_tx_fps = (
- float(collected_results[ResultsConstants.TX_RATE_FPS]))
-
- total_throughput_tx_mbps = (
- float(collected_results[ResultsConstants.TX_RATE_MBPS]))
-
- total_throughput_tx_pct = (
- float(collected_results[ResultsConstants.TX_RATE_PERCENT]))
-
- total_min_latency_ns = 0
- total_max_latency_ns = 0
- total_avg_latency_ns = 0
-
results = OrderedDict()
+
results[ResultsConstants.THROUGHPUT_RX_FPS] = (
- '{:,.6f}'.format(total_throughput_rx_fps))
+ '{:.6f}'.format(
+ float(collected_results[ResultsConstants.THROUGHPUT_RX_FPS])))
results[ResultsConstants.THROUGHPUT_RX_MBPS] = (
- '{:,.3f}'.format(total_throughput_rx_mbps))
+ '{:.3f}'.format(
+ float(collected_results[ResultsConstants.THROUGHPUT_RX_MBPS])))
results[ResultsConstants.THROUGHPUT_RX_PERCENT] = (
- '{:,.3f}'.format(total_throughput_rx_pct))
+ '{:.3f}'.format(
+ float(
+ collected_results[ResultsConstants.THROUGHPUT_RX_PERCENT])))
results[ResultsConstants.TX_RATE_FPS] = (
- '{:,.6f}'.format(total_throughput_tx_fps))
+ '{:.3f}'.format(
+ float(collected_results[ResultsConstants.TX_RATE_FPS])))
results[ResultsConstants.TX_RATE_MBPS] = (
- '{:,.3f}'.format(total_throughput_tx_mbps))
+ '{:.3f}'.format(
+ float(collected_results[ResultsConstants.TX_RATE_MBPS])))
results[ResultsConstants.TX_RATE_PERCENT] = (
- '{:,.3f}'.format(total_throughput_tx_pct))
+ '{:.3f}'.format(
+ float(collected_results[ResultsConstants.TX_RATE_PERCENT])))
- results[ResultsConstants.MIN_LATENCY_NS] = (
- '{:,.3f}'.format(total_min_latency_ns))
+ results[ResultsConstants.MIN_LATENCY_NS] = 0
- results[ResultsConstants.MAX_LATENCY_NS] = (
- '{:,.3f}'.format(total_max_latency_ns))
+ results[ResultsConstants.MAX_LATENCY_NS] = 0
- results[ResultsConstants.AVG_LATENCY_NS] = (
- '{:,.3f}'.format(total_avg_latency_ns))
+ results[ResultsConstants.AVG_LATENCY_NS] = 0
return results
self._moongen_host_ip_addr
cmd_moongen = " 'cd " + self._moongen_base_dir + \
- "; ./build/MoonGen examples/opnfv-vsperf.lua | tee moongen_log.txt'"
+ "; ./MoonGen/build/MoonGen trafficgen.lua | tee moongen_log.txt'"
cmd_start_moongen = connect_moongen + cmd_moongen
'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 = (
- (10000000000 / 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)
moongen_results[ResultsConstants.THROUGHPUT_RX_MBPS] = (
- (float(results_match.group(6)) * frame_size + 20) * 8)
+ 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)
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)))
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.
#
# 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:
duration=duration,
acceptable_loss_pct=lossrate)
- total_throughput_rx_fps = 0
- total_throughput_rx_mbps = 0
- total_throughput_rx_pct = 0
- total_throughput_tx_fps = 0
- total_throughput_tx_mbps = 0
- total_throughput_tx_pct = 0
- total_min_latency_ns = 0
- total_max_latency_ns = 0
- total_avg_latency_ns = 0
-
- for test_run in range(1, trials+1):
+ # Initialize RFC 2544 throughput specific results
+ results = OrderedDict()
+ results[ResultsConstants.THROUGHPUT_RX_FPS] = 0
+ results[ResultsConstants.THROUGHPUT_RX_MBPS] = 0
+ results[ResultsConstants.THROUGHPUT_RX_PERCENT] = 0
+ results[ResultsConstants.TX_RATE_FPS] = 0
+ results[ResultsConstants.TX_RATE_MBPS] = 0
+ results[ResultsConstants.TX_RATE_PERCENT] = 0
+ results[ResultsConstants.MIN_LATENCY_NS] = 0
+ results[ResultsConstants.MAX_LATENCY_NS] = 0
+ results[ResultsConstants.AVG_LATENCY_NS] = 0
+
+ for test_run in range(1, tests+1):
collected_results = (
Moongen.run_moongen_and_collect_results(self, test_run=test_run))
- total_throughput_rx_fps += (
+ results[ResultsConstants.THROUGHPUT_RX_FPS] += (
float(collected_results[ResultsConstants.THROUGHPUT_RX_FPS]))
- total_throughput_rx_mbps += (
+ results[ResultsConstants.THROUGHPUT_RX_MBPS] += (
float(collected_results[ResultsConstants.THROUGHPUT_RX_MBPS]))
- total_throughput_rx_pct += (
+ results[ResultsConstants.THROUGHPUT_RX_PERCENT] += (
float(collected_results[ResultsConstants.THROUGHPUT_RX_PERCENT]))
- total_throughput_tx_fps += (
+ results[ResultsConstants.TX_RATE_FPS] += (
float(collected_results[ResultsConstants.TX_RATE_FPS]))
- total_throughput_tx_mbps += (
+ results[ResultsConstants.TX_RATE_MBPS] += (
float(collected_results[ResultsConstants.TX_RATE_MBPS]))
- total_throughput_tx_pct += (
+ results[ResultsConstants.TX_RATE_PERCENT] += (
float(collected_results[ResultsConstants.TX_RATE_PERCENT]))
- # Latency not supported now, leaving as placeholder
- total_min_latency_ns = 0
- total_max_latency_ns = 0
- total_avg_latency_ns = 0
-
- results = OrderedDict()
results[ResultsConstants.THROUGHPUT_RX_FPS] = (
- '{:,.6f}'.format(total_throughput_rx_fps / trials))
+ '{:.6f}'.format(results[ResultsConstants.THROUGHPUT_RX_FPS] /
+ tests))
results[ResultsConstants.THROUGHPUT_RX_MBPS] = (
- '{:,.3f}'.format(total_throughput_rx_mbps / trials))
+ '{:.3f}'.format(results[ResultsConstants.THROUGHPUT_RX_MBPS] /
+ tests))
results[ResultsConstants.THROUGHPUT_RX_PERCENT] = (
- '{:,.3f}'.format(total_throughput_rx_pct / trials))
+ '{:.3f}'.format(results[ResultsConstants.THROUGHPUT_RX_PERCENT] /
+ tests))
results[ResultsConstants.TX_RATE_FPS] = (
- '{:,.6f}'.format(total_throughput_tx_fps / trials))
+ '{:.6f}'.format(results[ResultsConstants.TX_RATE_FPS] /
+ tests))
results[ResultsConstants.TX_RATE_MBPS] = (
- '{:,.3f}'.format(total_throughput_tx_mbps / trials))
+ '{:.3f}'.format(results[ResultsConstants.TX_RATE_MBPS] /
+ tests))
results[ResultsConstants.TX_RATE_PERCENT] = (
- '{:,.3f}'.format(total_throughput_tx_pct / trials))
+ '{:.3f}'.format(results[ResultsConstants.TX_RATE_PERCENT] /
+ tests))
results[ResultsConstants.MIN_LATENCY_NS] = (
- '{:,.3f}'.format(total_min_latency_ns / trials))
+ '{:.3f}'.format(results[ResultsConstants.MIN_LATENCY_NS] /
+ tests))
results[ResultsConstants.MAX_LATENCY_NS] = (
- '{:,.3f}'.format(total_max_latency_ns / trials))
+ '{:.3f}'.format(results[ResultsConstants.MAX_LATENCY_NS] /
+ tests))
results[ResultsConstants.AVG_LATENCY_NS] = (
- '{:,.3f}'.format(total_avg_latency_ns / trials))
+ '{:.3f}'.format(results[ResultsConstants.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'.
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
Back to Back Count (frames), Frame Loss (frames), Frame Loss (%)
:rtype: :class:`Back2BackResult`
"""
+ self._logger.info("In moongen send_rfc2544_back2back method")
self._params.clear()
self._params['traffic'] = self.traffic_defaults.copy()
duration=duration,
acceptable_loss_pct=lossrate)
+ # Initialize RFC 2544 B2B specific results
results = OrderedDict()
results[ResultsConstants.B2B_RX_FPS] = 0
results[ResultsConstants.B2B_TX_FPS] = 0
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))
# 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
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'.