aboutsummaryrefslogtreecommitdiffstats
path: root/tools/pkt_gen
diff options
context:
space:
mode:
Diffstat (limited to 'tools/pkt_gen')
-rwxr-xr-xtools/pkt_gen/ixnet/ixnet.py86
-rw-r--r--tools/pkt_gen/testcenter/testcenter-rfc2544-rest.py6
-rw-r--r--tools/pkt_gen/testcenter/testcenter.py8
-rw-r--r--tools/pkt_gen/trex/trex_client.py (renamed from tools/pkt_gen/trex/trex.py)20
4 files changed, 91 insertions, 29 deletions
diff --git a/tools/pkt_gen/ixnet/ixnet.py b/tools/pkt_gen/ixnet/ixnet.py
index 87fb2c65..c7036606 100755
--- a/tools/pkt_gen/ixnet/ixnet.py
+++ b/tools/pkt_gen/ixnet/ixnet.py
@@ -83,6 +83,7 @@ import logging
import os
import re
import csv
+import random
from collections import OrderedDict
from tools.pkt_gen import trafficgen
@@ -129,7 +130,7 @@ def _build_set_cmds(values, prefix='dict set'):
if isinstance(value, list):
value = '{{{}}}'.format(' '.join(str(x) for x in value))
- yield ' '.join([prefix, 'set', key, value]).strip()
+ yield ' '.join([prefix, key, value]).strip()
continue
# tcl doesn't recognise the strings "True" or "False", only "1"
@@ -176,10 +177,9 @@ class IxNet(trafficgen.ITrafficGenerator):
:returns: Output of command, where applicable.
"""
self._logger.debug('%s%s', trafficgen.CMD_PREFIX, cmd)
-
output = self._tclsh.eval(cmd)
- return output.split()
+ return output
def configure(self):
"""Configure system for IxNetwork.
@@ -193,12 +193,16 @@ class IxNet(trafficgen.ITrafficGenerator):
'port': settings.getValue('TRAFFICGEN_IXNET_PORT'),
'user': settings.getValue('TRAFFICGEN_IXNET_USER'),
# IXIA chassis configuration
- 'chassis': settings.getValue('TRAFFICGEN_IXIA_HOST'),
- 'card': settings.getValue('TRAFFICGEN_IXIA_CARD'),
- 'port1': settings.getValue('TRAFFICGEN_IXIA_PORT1'),
- 'port2': settings.getValue('TRAFFICGEN_IXIA_PORT2'),
+ 'chassis_east': settings.getValue('TRAFFICGEN_EAST_IXIA_HOST'),
+ 'card_east': settings.getValue('TRAFFICGEN_EAST_IXIA_CARD'),
+ 'port_east': settings.getValue('TRAFFICGEN_EAST_IXIA_PORT'),
+ 'chassis_west': settings.getValue('TRAFFICGEN_WEST_IXIA_HOST'),
+ 'card_west': settings.getValue('TRAFFICGEN_WEST_IXIA_CARD'),
+ 'port_west': settings.getValue('TRAFFICGEN_WEST_IXIA_PORT'),
'output_dir':
settings.getValue('TRAFFICGEN_IXNET_TESTER_RESULT_DIR'),
+ 'frame_size_list':
+ settings.getValue('TRAFFICGEN_PKT_SIZES'),
}
self._logger.debug('IXIA configuration configuration : %s', self._cfg)
@@ -256,11 +260,12 @@ class IxNet(trafficgen.ITrafficGenerator):
'An error occured when connecting to IxNetwork machine...')
raise RuntimeError('Ixia failed to initialise.')
- self.run_tcl('startRfc2544Test $config $traffic')
+ results_path = self.run_tcl('startRfc2544Test $config $traffic')
if output:
self._logger.critical(
'Failed to start continuous traffic test')
raise RuntimeError('Continuous traffic test failed to start.')
+ return results_path
def stop_cont_traffic(self):
"""See ITrafficGenerator for description
@@ -271,9 +276,12 @@ class IxNet(trafficgen.ITrafficGenerator):
lossrate=0.0):
"""See ITrafficGenerator for description
"""
- self.start_rfc2544_throughput(traffic, tests, duration, lossrate)
-
- return self.wait_rfc2544_throughput()
+ results_file = self.start_rfc2544_throughput(traffic, tests, duration, lossrate)
+ run_result = self.wait_rfc2544_throughput()
+ dest_file_name = 'Traffic_Item_Statistics_' + str(random.randrange(1, 100)) + '.csv'
+ self.copy_results_file(results_file,
+ os.path.join(settings.getValue('RESULTS_PATH'), dest_file_name))
+ return run_result
def start_rfc2544_throughput(self, traffic=None, tests=1, duration=20,
lossrate=0.0):
@@ -313,12 +321,14 @@ class IxNet(trafficgen.ITrafficGenerator):
'An error occured when connecting to IxNetwork machine...')
raise RuntimeError('Ixia failed to initialise.')
- self.run_tcl('startRfc2544Test $config $traffic')
+ results_file = self.run_tcl('startRfc2544Test $config $traffic')
if output:
self._logger.critical(
'Failed to start RFC2544 test')
raise RuntimeError('RFC2544 test failed to start.')
+ return results_file
+
def wait_rfc2544_throughput(self):
"""See ITrafficGenerator for description
"""
@@ -397,12 +407,34 @@ class IxNet(trafficgen.ITrafficGenerator):
return results
output = self.run_tcl('waitForRfc2544Test')
-
# the run_tcl function will return a list with one element. We extract
# that one element (a string representation of an IXIA-specific Tcl
# datatype), parse it to find the path of the results file then parse
# the results file
- return parse_ixnet_rfc_results(parse_result_string(output[0]))
+ test_result = parse_ixnet_rfc_results(parse_result_string(output))
+ return test_result
+
+ def copy_results_file(self, source_file=None, dest_file=None):
+ """Copy a file from a source address to destination
+ """
+ dest_dict = {}
+ source_dict = {}
+ srcfile = ''
+ if isinstance(source_file, list):
+ for i in source_file:
+ srcfile = srcfile + ' ' + i
+ else:
+ srcfile = source_file
+
+ source = (srcfile.replace("\\", "/")).strip()
+ source_dict['source_file'] = {'source_file': '\"{}\"'.format(source)}
+ dest_dict['dest_file'] = {'dest_file': '{}'.format(dest_file)}
+ for cmd in _build_set_cmds(source_dict):
+ self.run_tcl(cmd)
+ for cmd in _build_set_cmds(dest_dict):
+ self.run_tcl(cmd)
+ self.run_tcl('copyFileResults $source_file $dest_file')
+ return dest_dict['dest_file']
def send_rfc2544_back2back(self, traffic=None, tests=1, duration=2,
lossrate=0.0):
@@ -411,9 +443,12 @@ class IxNet(trafficgen.ITrafficGenerator):
# 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, tests, duration, lossrate)
-
- return self.wait_rfc2544_back2back()
+ b2b_results_file = self.start_rfc2544_back2back(traffic, tests, duration, lossrate)
+ b2b_run_result = self.wait_rfc2544_back2back()
+ dest_file_name = 'Traffic_Item_Statistics_' + str(random.randrange(1, 100)) + '.csv'
+ self.copy_results_file(b2b_results_file,
+ os.path.join(settings.getValue('RESULTS_PATH'), dest_file_name))
+ return b2b_run_result
def start_rfc2544_back2back(self, traffic=None, tests=1, duration=2,
lossrate=0.0):
@@ -453,15 +488,18 @@ class IxNet(trafficgen.ITrafficGenerator):
'An error occured when connecting to IxNetwork machine...')
raise RuntimeError('Ixia failed to initialise.')
- self.run_tcl('startRfc2544Test $config $traffic')
+ results_file = self.run_tcl('startRfc2544Test $config $traffic')
if output:
self._logger.critical(
'Failed to start RFC2544 test')
raise RuntimeError('RFC2544 test failed to start.')
+ return results_file
+
def wait_rfc2544_back2back(self):
"""Wait for results.
"""
+
def parse_result_string(results):
"""Get path to results file from output
@@ -487,7 +525,7 @@ class IxNet(trafficgen.ITrafficGenerator):
# transform path into something useful
path = result_path.group(1).replace('\\', '/')
- path = os.path.join(path, 'iteration.csv')
+ path = os.path.join(path, 'AggregateResults.csv')
path = path.replace(
settings.getValue('TRAFFICGEN_IXNET_TESTER_RESULT_DIR'),
settings.getValue('TRAFFICGEN_IXNET_DUT_RESULT_DIR'))
@@ -511,11 +549,11 @@ class IxNet(trafficgen.ITrafficGenerator):
for row in reader:
# if back2back count higher than previously found, store it
# Note: row[N] here refers to the Nth column of a row
- if float(row[14]) <= self._params['config']['lossrate']:
- if int(row[12]) > \
+ if float(row[10]) <= self._params['config']['lossrate']:
+ if int(float(row[8])) > \
int(results[ResultsConstants.B2B_FRAMES]):
- results[ResultsConstants.B2B_FRAMES] = int(row[12])
- results[ResultsConstants.B2B_FRAME_LOSS_PERCENT] = float(row[14])
+ results[ResultsConstants.B2B_FRAMES] = int(float(row[8]))
+ results[ResultsConstants.B2B_FRAME_LOSS_PERCENT] = float(row[10])
return results
@@ -526,7 +564,7 @@ class IxNet(trafficgen.ITrafficGenerator):
# datatype), parse it to find the path of the results file then parse
# the results file
- return parse_ixnet_rfc_results(parse_result_string(output[0]))
+ return parse_ixnet_rfc_results(parse_result_string(output))
def send_burst_traffic(self, traffic=None, duration=20):
return NotImplementedError('IxNet does not implement send_burst_traffic')
diff --git a/tools/pkt_gen/testcenter/testcenter-rfc2544-rest.py b/tools/pkt_gen/testcenter/testcenter-rfc2544-rest.py
index 2f0cb0b4..8089ef42 100644
--- a/tools/pkt_gen/testcenter/testcenter-rfc2544-rest.py
+++ b/tools/pkt_gen/testcenter/testcenter-rfc2544-rest.py
@@ -691,6 +691,11 @@ def main():
lab_server_resultsdb = stc.get(
"system1.project.TestResultSetting", "CurrentResultFileName")
+ if not lab_server_resultsdb or 'Results' not in lab_server_resultsdb:
+ _LOGGER.info("Failed to find results.")
+ stc.end_session()
+ return
+
if args.verbose:
_LOGGER.debug("The lab server results database is %s",
lab_server_resultsdb)
@@ -811,6 +816,7 @@ def main():
args.results_dir, args.csv_results_file_prefix, resultsdict)
except RuntimeError as e:
+ stc.end_session()
_LOGGER.error(e)
if args.verbose:
diff --git a/tools/pkt_gen/testcenter/testcenter.py b/tools/pkt_gen/testcenter/testcenter.py
index f01069e2..a15c502c 100644
--- a/tools/pkt_gen/testcenter/testcenter.py
+++ b/tools/pkt_gen/testcenter/testcenter.py
@@ -338,6 +338,8 @@ class TestCenter(trafficgen.ITrafficGenerator):
Reads the CSV file and return the results
"""
result = {}
+ if not os.path.exists(filename):
+ return result
with open(filename, "r") as csvfile:
csvreader = csv.DictReader(csvfile)
for row in csvreader:
@@ -436,11 +438,13 @@ class TestCenter(trafficgen.ITrafficGenerator):
if traffic['imix']['enabled']:
if traffic['imix']['type'] == 'genome':
genome = traffic['imix']['genome']
- args.append('--imix' + ' ' + genome)
+ args.append('--imix')
+ args.append(genome)
if settings.getValue("TRAFFICGEN_STC_LIVE_RESULTS") == "True":
args.append('--live_results')
- args.append('--logfile' + ' ' + self._liveresults_file)
+ args.append('--logfile')
+ args.append(self._liveresults_file)
if settings.getValue("TRAFFICGEN_STC_VERBOSE") == "True":
args.append("--verbose")
diff --git a/tools/pkt_gen/trex/trex.py b/tools/pkt_gen/trex/trex_client.py
index d37a52c4..3d6836d8 100644
--- a/tools/pkt_gen/trex/trex.py
+++ b/tools/pkt_gen/trex/trex_client.py
@@ -26,7 +26,7 @@ import re
from collections import OrderedDict
# pylint: disable=unused-import
import netaddr
-import zmq
+#import zmq
from conf import settings
from conf import merge_spec
from core.results.results_constants import ResultsConstants
@@ -35,7 +35,7 @@ try:
# pylint: disable=wrong-import-position, import-error
sys.path.append(settings.getValue('PATHS')['trafficgen']['Trex']['src']['path'])
from trex_stl_lib.api import *
- from trex_stl_lib import trex_stl_exceptions
+ # from trex_stl_lib import trex_stl_exceptions
except ImportError:
# VSPERF performs detection of T-Rex api during testcase initialization. So if
# T-Rex is requsted and API is not available it will fail before this code
@@ -160,7 +160,7 @@ class Trex(ITrafficGenerator):
try:
self._stlclient = STLClient(username=self._trex_user, server=self._trex_host_ip_addr,
- verbose_level=0)
+ verbose_level='info')
self._stlclient.connect()
except STLError:
raise RuntimeError('T-Rex: Cannot connect to T-Rex server. Please check if it is '
@@ -594,9 +594,14 @@ class Trex(ITrafficGenerator):
:return: passing stats as dictionary
"""
threshold = settings.getValue('TRAFFICGEN_TREX_RFC2544_TPUT_THRESHOLD')
+ max_repeat = settings.getValue('TRAFFICGEN_TREX_RFC2544_MAX_REPEAT')
+ loss_verification = settings.getValue('TRAFFICGEN_TREX_RFC2544_BINARY_SEARCH_LOSS_VERIFICATION')
+ if loss_verification:
+ self._logger.info("Running Binary Search with Loss Verification")
stats_ok = _EMPTY_STATS
new_params = copy.deepcopy(traffic)
iteration = 1
+ repeat = 0
left = boundaries['left']
right = boundaries['right']
center = boundaries['center']
@@ -620,11 +625,20 @@ class Trex(ITrafficGenerator):
if test_lossrate == 0.0 and new_params['frame_rate'] == traffic['frame_rate']:
return copy.deepcopy(stats)
elif test_lossrate > lossrate:
+ if loss_verification:
+ if repeat < max_repeat:
+ repeat += 1
+ iteration += 1
+ continue
+ else:
+ repeat = 0
right = center
center = (left + right) / 2
new_params = copy.deepcopy(traffic)
new_params['frame_rate'] = center
else:
+ if loss_verification:
+ repeat = 0
stats_ok = copy.deepcopy(stats)
left = center
center = (left + right) / 2