summaryrefslogtreecommitdiffstats
path: root/tools
diff options
context:
space:
mode:
Diffstat (limited to 'tools')
-rw-r--r--tools/hugepages.py75
-rw-r--r--tools/namespace.py4
-rwxr-xr-xtools/pkt_gen/dummy/dummy.py10
-rwxr-xr-xtools/pkt_gen/ixia/ixia.py6
-rwxr-xr-xtools/pkt_gen/ixia/pass_fail.tcl5
-rwxr-xr-xtools/pkt_gen/ixnet/ixnet.py16
-rw-r--r--tools/pkt_gen/ixnet/ixnetrfc2544.tcl11
-rwxr-xr-xtools/pkt_gen/ixnet/ixnetrfc2544v2.tcl11
-rw-r--r--tools/pkt_gen/moongen/moongen.py73
-rw-r--r--tools/pkt_gen/testcenter/testcenter.py4
-rwxr-xr-xtools/pkt_gen/trafficgen/trafficgen.py12
-rw-r--r--tools/pkt_gen/xena/XenaDriver.py16
-rwxr-xr-xtools/pkt_gen/xena/xena.py24
13 files changed, 166 insertions, 101 deletions
diff --git a/tools/hugepages.py b/tools/hugepages.py
index 119f94b5..02e4f29c 100644
--- a/tools/hugepages.py
+++ b/tools/hugepages.py
@@ -31,6 +31,7 @@ _LOGGER = logging.getLogger(__name__)
# hugepage management
#
+
def get_hugepage_size():
"""Return the size of the configured hugepages
"""
@@ -48,7 +49,6 @@ def get_hugepage_size():
return 0
-
def allocate_hugepages():
"""Allocate hugepages on the fly
"""
@@ -72,31 +72,65 @@ def allocate_hugepages():
return False
+def get_free_hugepages(socket=None):
+ """Get the free hugepage totals on the system.
+
+ :param socket: optional socket param to get free hugepages on a socket. To
+ be passed a string.
+ :returns: hugepage amount as int
+ """
+ hugepage_free_re = re.compile(r'HugePages_Free:\s+(?P<free_hp>\d+)$')
+ if socket:
+ if os.path.exists(
+ '/sys/devices/system/node/node{}/meminfo'.format(socket)):
+ meminfo_path = '/sys/devices/system/node/node{}/meminfo'.format(
+ socket)
+ else:
+ _LOGGER.info('No hugepage info found for socket {}'.format(socket))
+ return 0
+ else:
+ meminfo_path = '/proc/meminfo'
+
+ with open(meminfo_path, 'r') as fh:
+ data = fh.readlines()
+ for line in data:
+ match = hugepage_free_re.search(line)
+ if match:
+ _LOGGER.info('Hugepages free: %s %s', match.group('free_hp'),
+ 'on socket {}'.format(socket) if socket else '')
+ return int(match.group('free_hp'))
+ else:
+ _LOGGER.info('Could not parse for hugepage size')
+ return 0
+
+
def is_hugepage_available():
- """Check if hugepages are available on the system.
+ """Check if hugepages are configured/available on the system.
"""
- hugepage_re = re.compile(r'^HugePages_Free:\s+(?P<num_hp>\d+)$')
+ hugepage_size_re = re.compile(r'^Hugepagesize:\s+(?P<size_hp>\d+)\s+kB',
+ re.IGNORECASE)
# read in meminfo
with open('/proc/meminfo') as mem_file:
mem_info = mem_file.readlines()
- # first check if module is loaded
+ # see if the hugepage size is the recommended value
for line in mem_info:
- result = hugepage_re.match(line)
- if not result:
- continue
-
- num_huge = result.group('num_hp')
- if num_huge == '0':
- _LOGGER.info('No free hugepages.')
- if not allocate_hugepages():
- return False
- else:
- _LOGGER.info('Found \'%s\' free hugepage(s).', num_huge)
- return True
-
- return False
+ match_size = hugepage_size_re.match(line)
+ if match_size:
+ if match_size.group('size_hp') != '1048576':
+ _LOGGER.info(
+ '%s%s%s kB',
+ 'Hugepages not configured for recommend 1GB size. ',
+ 'Currently set at ', match_size.group('size_hp'))
+ num_huge = get_free_hugepages()
+ if num_huge == 0:
+ _LOGGER.info('No free hugepages.')
+ if not allocate_hugepages():
+ return False
+ else:
+ _LOGGER.info('Found \'%s\' free hugepage(s).', num_huge)
+ return True
def is_hugepage_mounted():
@@ -112,10 +146,11 @@ def is_hugepage_mounted():
def mount_hugepages():
- """Ensure hugepages are mounted.
+ """Ensure hugepages are mounted. Raises RuntimeError if no configured
+ hugepages are available.
"""
if not is_hugepage_available():
- return
+ raise RuntimeError('No Hugepages configured.')
if is_hugepage_mounted():
return
diff --git a/tools/namespace.py b/tools/namespace.py
index e6bcd819..9131398f 100644
--- a/tools/namespace.py
+++ b/tools/namespace.py
@@ -108,8 +108,8 @@ def get_system_namespace_list():
Return tuple of strings for namespaces on the system
:return: tuple of namespaces as string
"""
- return tuple(os.listdir('/var/run/netns'))
-
+ return tuple(os.listdir('/var/run/netns')) if os.path.exists(
+ '/var/run/netns') else tuple()
def get_vsperf_namespace_list():
"""
diff --git a/tools/pkt_gen/dummy/dummy.py b/tools/pkt_gen/dummy/dummy.py
index d3d79974..3324824c 100755
--- a/tools/pkt_gen/dummy/dummy.py
+++ b/tools/pkt_gen/dummy/dummy.py
@@ -146,8 +146,8 @@ class Dummy(trafficgen.ITrafficGenerator):
results = get_user_traffic(
'continuous',
'%dmpps, multistream %s, duration %d' % (traffic['frame_rate'],
- traffic['multistream'],
- duration), traffic_,
+ traffic['multistream'],
+ duration), traffic_,
('frames tx', 'frames rx', 'tx rate %', 'rx rate %', 'min latency',
'max latency', 'avg latency', 'frameloss %'))
@@ -169,7 +169,7 @@ class Dummy(trafficgen.ITrafficGenerator):
result[ResultsConstants.FRAME_LOSS_PERCENT] = float(results[7])
return result
- def send_rfc2544_throughput(self, traffic=None, trials=3, duration=20,
+ def send_rfc2544_throughput(self, traffic=None, tests=1, duration=20,
lossrate=0.0):
"""
Send traffic per RFC2544 throughput test specifications.
@@ -182,8 +182,8 @@ class Dummy(trafficgen.ITrafficGenerator):
results = get_user_traffic(
'throughput',
- '%d trials, %d seconds iterations, %f packet loss, multistream '
- '%s' % (trials, duration, lossrate, traffic['multistream']),
+ '%d tests, %d seconds iterations, %f packet loss, multistream '
+ '%s' % (tests, duration, lossrate, traffic['multistream']),
traffic_,
('frames tx', 'frames rx', 'tx rate %', 'rx rate %', 'min latency',
'max latency', 'avg latency', 'frameloss %'))
diff --git a/tools/pkt_gen/ixia/ixia.py b/tools/pkt_gen/ixia/ixia.py
index ae5da6d2..cd14a2a7 100755
--- a/tools/pkt_gen/ixia/ixia.py
+++ b/tools/pkt_gen/ixia/ixia.py
@@ -38,9 +38,9 @@ import tkinter
import logging
import os
+from collections import OrderedDict
from tools.pkt_gen import trafficgen
from conf import settings
-from collections import OrderedDict
from core.results.results_constants import ResultsConstants
_ROOT_DIR = os.path.dirname(os.path.realpath(__file__))
@@ -252,13 +252,13 @@ class Ixia(trafficgen.ITrafficGenerator):
"""
return self.run_tcl('stopTraffic')
- def send_rfc2544_throughput(self, traffic=None, trials=3, duration=20, lossrate=0.0):
+ def send_rfc2544_throughput(self, traffic=None, tests=1, duration=20, lossrate=0.0):
"""See ITrafficGenerator for description
"""
params = {}
params['config'] = {
- 'trials': trials,
+ 'tests': tests,
'duration': duration,
'lossrate': lossrate,
'multipleStreams': traffic['multistream'],
diff --git a/tools/pkt_gen/ixia/pass_fail.tcl b/tools/pkt_gen/ixia/pass_fail.tcl
index acb4443f..79b7f10d 100755
--- a/tools/pkt_gen/ixia/pass_fail.tcl
+++ b/tools/pkt_gen/ixia/pass_fail.tcl
@@ -675,7 +675,10 @@ proc rfcThroughputTest { testSpec trafficSpec } {
# testSpec
- set numTrials [dict get $testSpec trials] ;# we don't use this yet
+ # RFC2544 to IXIA terminology mapping (it affects Ixia configuration below):
+ # Test => Trial
+ # Trial => Iteration
+ set numTrials [dict get $testSpec tests] ;# we don't use this yet
set duration [dict get $testSpec duration]
set lossRate [dict get $testSpec lossrate]
set multipleStream [dict get $testSpec multipleStreams] ;# we don't use this yet
diff --git a/tools/pkt_gen/ixnet/ixnet.py b/tools/pkt_gen/ixnet/ixnet.py
index 928b5a6e..5e4ae569 100755
--- a/tools/pkt_gen/ixnet/ixnet.py
+++ b/tools/pkt_gen/ixnet/ixnet.py
@@ -253,15 +253,15 @@ class IxNet(trafficgen.ITrafficGenerator):
"""
return self._wait_result()
- def send_rfc2544_throughput(self, traffic=None, trials=3, duration=20,
+ def send_rfc2544_throughput(self, traffic=None, tests=1, duration=20,
lossrate=0.0):
"""See ITrafficGenerator for description
"""
- self.start_rfc2544_throughput(traffic, trials, duration, lossrate)
+ self.start_rfc2544_throughput(traffic, tests, duration, lossrate)
return self.wait_rfc2544_throughput()
- 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):
"""Start transmission.
"""
@@ -270,7 +270,7 @@ class IxNet(trafficgen.ITrafficGenerator):
self._params['config'] = {
'binary': True,
- 'trials': trials,
+ 'tests': tests,
'duration': duration,
'lossrate': lossrate,
'multipleStreams': traffic['multistream'],
@@ -387,18 +387,18 @@ class IxNet(trafficgen.ITrafficGenerator):
# the results file
return parse_ixnet_rfc_results(parse_result_string(output[0]))
- def send_rfc2544_back2back(self, traffic=None, trials=50, duration=2,
+ def send_rfc2544_back2back(self, traffic=None, tests=1, duration=2,
lossrate=0.0):
"""See ITrafficGenerator for description
"""
# NOTE 2 seconds is the recommended duration for a back 2 back
# test in RFC2544. 50 trials is the recommended number from the
# RFC also.
- self.start_rfc2544_back2back(traffic, trials, duration, lossrate)
+ self.start_rfc2544_back2back(traffic, tests, duration, lossrate)
return self.wait_rfc2544_back2back()
- def start_rfc2544_back2back(self, traffic=None, trials=50, duration=2,
+ def start_rfc2544_back2back(self, traffic=None, tests=1, duration=2,
lossrate=0.0):
"""Start transmission.
"""
@@ -407,7 +407,7 @@ class IxNet(trafficgen.ITrafficGenerator):
self._params['config'] = {
'binary': True,
- 'trials': trials,
+ 'tests': tests,
'duration': duration,
'lossrate': lossrate,
'multipleStreams': traffic['multistream'],
diff --git a/tools/pkt_gen/ixnet/ixnetrfc2544.tcl b/tools/pkt_gen/ixnet/ixnetrfc2544.tcl
index 233db040..e70ca874 100644
--- a/tools/pkt_gen/ixnet/ixnetrfc2544.tcl
+++ b/tools/pkt_gen/ixnet/ixnetrfc2544.tcl
@@ -83,13 +83,16 @@ proc startRfc2544Test { testSpec trafficSpec } {
set duration [dict get $testSpec duration]
+ # RFC2544 to IXIA terminology mapping (it affects Ixia configuration inside this script):
+ # Test => Trial
+ # Trial => Iteration
if {$binary} {
- set numTrials [dict get $testSpec trials]
+ set numTests [dict get $testSpec tests]
set frameRate 100
set tolerance [dict get $testSpec lossrate]
set loadType binary
} else {
- set numTrials 1
+ set numTests 1
set frameRate [dict get $testSpec framerate]
set tolerance 0.0
set loadType custom
@@ -7778,7 +7781,7 @@ proc startRfc2544Test { testSpec trafficSpec } {
-framesize $frameSize \
-reportTputRateUnit mbps \
-duration $duration \
- -numtrials $numTrials \
+ -numtrials $numTests \
-trafficType constantLoading \
-burstSize 1 \
-framesPerBurstGap 1 \
@@ -7951,7 +7954,7 @@ proc startRfc2544Test { testSpec trafficSpec } {
-rfc2889ordering noOrdering \
-floodedFramesEnabled False \
-duration $duration \
- -numtrials $numTrials \
+ -numtrials $numTests \
-trafficType constantLoading \
-burstSize 1 \
-framesPerBurstGap 1 \
diff --git a/tools/pkt_gen/ixnet/ixnetrfc2544v2.tcl b/tools/pkt_gen/ixnet/ixnetrfc2544v2.tcl
index 0bdba9cd..539c5a5b 100755
--- a/tools/pkt_gen/ixnet/ixnetrfc2544v2.tcl
+++ b/tools/pkt_gen/ixnet/ixnetrfc2544v2.tcl
@@ -83,13 +83,16 @@ proc startRfc2544Test { testSpec trafficSpec } {
set duration [dict get $testSpec duration]
+ # RFC2544 to IXIA terminology mapping (it affects Ixia configuration inside this script):
+ # Test => Trial
+ # Trial => Iteration
if {$binary} {
- set numTrials [dict get $testSpec trials]
+ set numTests [dict get $testSpec tests]
set frameRate 100
set tolerance [dict get $testSpec lossrate]
set loadType binary
} else {
- set numTrials 1
+ set numTests 1
set frameRate [dict get $testSpec framerate]
set tolerance 0.0
set loadType custom
@@ -3218,7 +3221,7 @@ proc startRfc2544Test { testSpec trafficSpec } {
-framesize $frameSize \
-reportTputRateUnit mbps \
-duration $duration \
- -numtrials $numTrials \
+ -numtrials $numTests \
-trafficType constantLoading \
-burstSize 1 \
-framesPerBurstGap 1 \
@@ -3391,7 +3394,7 @@ proc startRfc2544Test { testSpec trafficSpec } {
-rfc2889ordering noOrdering \
-floodedFramesEnabled False \
-duration $duration \
- -numtrials $numTrials \
+ -numtrials $numTests \
-trafficType constantLoading \
-burstSize 1 \
-framesPerBurstGap 1 \
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'.
diff --git a/tools/pkt_gen/testcenter/testcenter.py b/tools/pkt_gen/testcenter/testcenter.py
index a1f38d8b..c242269a 100644
--- a/tools/pkt_gen/testcenter/testcenter.py
+++ b/tools/pkt_gen/testcenter/testcenter.py
@@ -211,7 +211,7 @@ class TestCenter(trafficgen.ITrafficGenerator):
return self.get_rfc2544_results(filec)
- def send_rfc2544_throughput(self, traffic=None, trials=3, duration=20,
+ def send_rfc2544_throughput(self, traffic=None, tests=1, duration=20,
lossrate=0.0):
"""
Send traffic per RFC2544 throughput test specifications.
@@ -243,7 +243,7 @@ class TestCenter(trafficgen.ITrafficGenerator):
return self.get_rfc2544_results(filec)
- def send_rfc2544_back2back(self, traffic=None, trials=1, duration=20,
+ def send_rfc2544_back2back(self, traffic=None, tests=1, duration=20,
lossrate=0.0):
"""
Send traffic per RFC2544 BacktoBack test specifications.
diff --git a/tools/pkt_gen/trafficgen/trafficgen.py b/tools/pkt_gen/trafficgen/trafficgen.py
index 3953bbb1..fb40cd92 100755
--- a/tools/pkt_gen/trafficgen/trafficgen.py
+++ b/tools/pkt_gen/trafficgen/trafficgen.py
@@ -133,7 +133,7 @@ class ITrafficGenerator(object):
"""
raise NotImplementedError('Please call an implementation.')
- def send_rfc2544_throughput(self, traffic=None, trials=3, duration=20,
+ def send_rfc2544_throughput(self, traffic=None, tests=1, duration=20,
lossrate=0.0):
"""Send traffic per RFC2544 throughput test specifications.
@@ -142,7 +142,7 @@ class ITrafficGenerator(object):
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:
@@ -158,7 +158,7 @@ class ITrafficGenerator(object):
"""
raise NotImplementedError('Please call an implementation.')
- 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'.
@@ -172,7 +172,7 @@ class ITrafficGenerator(object):
"""
raise NotImplementedError('Please call an implementation.')
- def send_rfc2544_back2back(self, traffic=None, trials=1, duration=20,
+ def send_rfc2544_back2back(self, traffic=None, tests=1, duration=20,
lossrate=0.0):
"""Send traffic per RFC2544 back2back test specifications.
@@ -180,7 +180,7 @@ class ITrafficGenerator(object):
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
@@ -191,7 +191,7 @@ class ITrafficGenerator(object):
"""
raise NotImplementedError('Please call an implementation.')
- 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'.
diff --git a/tools/pkt_gen/xena/XenaDriver.py b/tools/pkt_gen/xena/XenaDriver.py
index aa8443c9..d3862312 100644
--- a/tools/pkt_gen/xena/XenaDriver.py
+++ b/tools/pkt_gen/xena/XenaDriver.py
@@ -1001,9 +1001,21 @@ class XenaTXStats(object):
mydict = statdict
return mydict
-
def aggregate_stats(stat1, stat2):
"""
+ Judge whether stat1 and stat2 both have same key, if both have same key,
+ call the aggregate fuction, else use the stat1's value
+ """
+ newstat = dict()
+ for keys in stat1.keys():
+ if keys in stat2 and isinstance(stat1[keys], dict):
+ newstat[keys] = aggregate(stat1[keys], stat2[keys])
+ else:
+ newstat[keys] = stat1[keys]
+ return newstat
+
+def aggregate(stat1, stat2):
+ """
Recursive function to aggregate two sets of statistics. This is used when
bi directional traffic is done and statistics need to be calculated based
on two sets of statistics.
@@ -1014,7 +1026,7 @@ def aggregate_stats(stat1, stat2):
newstat = dict()
for (keys1, keys2) in zip(stat1.keys(), stat2.keys()):
if isinstance(stat1[keys1], dict):
- newstat[keys1] = aggregate_stats(stat1[keys1], stat2[keys2])
+ newstat[keys1] = aggregate(stat1[keys1], stat2[keys2])
else:
if not isinstance(stat1[keys1], int) and not isinstance(
[keys1], float):
diff --git a/tools/pkt_gen/xena/xena.py b/tools/pkt_gen/xena/xena.py
index 67e9984f..449ef5b4 100755
--- a/tools/pkt_gen/xena/xena.py
+++ b/tools/pkt_gen/xena/xena.py
@@ -275,10 +275,10 @@ class Xena(ITrafficGenerator):
return result_dict
- def _setup_json_config(self, trials, loss_rate, testtype=None):
+ def _setup_json_config(self, tests, loss_rate, testtype=None):
"""
Create a 2bUsed json file that will be used for xena2544.exe execution.
- :param trials: Number of trials
+ :param tests: Number of tests
:param loss_rate: The acceptable loss rate as float
:param testtype: Either '2544_b2b' or '2544_throughput' as string
:return: None
@@ -305,7 +305,7 @@ class Xena(ITrafficGenerator):
if testtype == '2544_throughput':
j_file.set_test_options_tput(
packet_sizes=self._params['traffic']['l2']['framesize'],
- iterations=trials, loss_rate=loss_rate,
+ iterations=tests, loss_rate=loss_rate,
duration=self._duration, micro_tpld=True if self._params[
'traffic']['l2']['framesize'] == 64 else False)
j_file.enable_throughput_test()
@@ -313,7 +313,7 @@ class Xena(ITrafficGenerator):
elif testtype == '2544_b2b':
j_file.set_test_options_back2back(
packet_sizes=self._params['traffic']['l2']['framesize'],
- iterations=trials, duration=self._duration,
+ iterations=tests, duration=self._duration,
startvalue=self._params['traffic']['frame_rate'],
endvalue=self._params['traffic']['frame_rate'],
micro_tpld=True if self._params[
@@ -590,7 +590,7 @@ class Xena(ITrafficGenerator):
"""
return self._stop_api_traffic()
- def send_rfc2544_throughput(self, traffic=None, trials=3, duration=20,
+ def send_rfc2544_throughput(self, traffic=None, tests=1, duration=20,
lossrate=0.0):
"""Send traffic per RFC2544 throughput test specifications.
@@ -603,14 +603,14 @@ class Xena(ITrafficGenerator):
if traffic:
self._params['traffic'] = merge_spec(self._params['traffic'],
traffic)
- self._setup_json_config(trials, lossrate, '2544_throughput')
+ self._setup_json_config(tests, lossrate, '2544_throughput')
self._start_xena_2544()
self._wait_xena_2544_complete()
root = ET.parse(r'./tools/pkt_gen/xena/xena2544-report.xml').getroot()
return Xena._create_throughput_result(root)
- 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'.
@@ -622,7 +622,7 @@ class Xena(ITrafficGenerator):
if traffic:
self._params['traffic'] = merge_spec(self._params['traffic'],
traffic)
- self._setup_json_config(trials, lossrate, '2544_throughput')
+ self._setup_json_config(tests, lossrate, '2544_throughput')
self._start_xena_2544()
def wait_rfc2544_throughput(self):
@@ -634,7 +634,7 @@ class Xena(ITrafficGenerator):
root = ET.parse(r'./tools/pkt_gen/xena/xena2544-report.xml').getroot()
return Xena._create_throughput_result(root)
- def send_rfc2544_back2back(self, traffic=None, trials=1, duration=20,
+ def send_rfc2544_back2back(self, traffic=None, tests=1, duration=20,
lossrate=0.0):
"""Send traffic per RFC2544 back2back test specifications.
@@ -647,13 +647,13 @@ class Xena(ITrafficGenerator):
if traffic:
self._params['traffic'] = merge_spec(self._params['traffic'],
traffic)
- self._setup_json_config(trials, lossrate, '2544_b2b')
+ self._setup_json_config(tests, lossrate, '2544_b2b')
self._start_xena_2544()
self._wait_xena_2544_complete()
root = ET.parse(r'./tools/pkt_gen/xena/xena2544-report.xml').getroot()
return Xena._create_throughput_result(root)
- 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'.
@@ -665,7 +665,7 @@ class Xena(ITrafficGenerator):
if traffic:
self._params['traffic'] = merge_spec(self._params['traffic'],
traffic)
- self._setup_json_config(trials, lossrate, '2544_b2b')
+ self._setup_json_config(tests, lossrate, '2544_b2b')
self._start_xena_2544()
def wait_rfc2544_back2back(self):