summaryrefslogtreecommitdiffstats
path: root/tools/pkt_gen/xena/xena.py
diff options
context:
space:
mode:
Diffstat (limited to 'tools/pkt_gen/xena/xena.py')
-rwxr-xr-xtools/pkt_gen/xena/xena.py57
1 files changed, 30 insertions, 27 deletions
diff --git a/tools/pkt_gen/xena/xena.py b/tools/pkt_gen/xena/xena.py
index 194de343..7dd4b90b 100755
--- a/tools/pkt_gen/xena/xena.py
+++ b/tools/pkt_gen/xena/xena.py
@@ -30,6 +30,8 @@ import sys
from time import sleep
import xml.etree.ElementTree as ET
from collections import OrderedDict
+# scapy imports
+import scapy.layers.inet as inet
# VSPerf imports
from conf import settings
@@ -48,10 +50,6 @@ from tools.pkt_gen.xena.XenaDriver import (
XenaManager,
)
-# scapy imports
-import scapy.layers.inet as inet
-
-
class Xena(ITrafficGenerator):
"""
Xena Traffic generator wrapper class
@@ -94,11 +92,11 @@ class Xena(ITrafficGenerator):
if test_type == 'Throughput':
results = OrderedDict()
- results[ResultsConstants.THROUGHPUT_RX_FPS] = int(
- root[0][1][0][0].get('PortRxPps')) + int(
+ results[ResultsConstants.THROUGHPUT_RX_FPS] = float(
+ root[0][1][0][0].get('PortRxPps')) + float(
root[0][1][0][1].get('PortRxPps'))
- results[ResultsConstants.THROUGHPUT_RX_MBPS] = (int(
- root[0][1][0][0].get('PortRxBpsL1')) + int(
+ results[ResultsConstants.THROUGHPUT_RX_MBPS] = (float(
+ root[0][1][0][0].get('PortRxBpsL1')) + float(
root[0][1][0][1].get('PortRxBpsL1')))/ 1000000
results[ResultsConstants.THROUGHPUT_RX_PERCENT] = (
100 - int(root[0][1][0].get('TotalLossRatioPcnt'))) * float(
@@ -288,14 +286,23 @@ class Xena(ITrafficGenerator):
1, settings.getValue("TRAFFICGEN_XENA_PORT1_IP"),
settings.getValue("TRAFFICGEN_XENA_PORT1_CIDR"),
settings.getValue("TRAFFICGEN_XENA_PORT1_GATEWAY"))
- j_file.set_test_options(
- packet_sizes=self._params['traffic']['l2']['framesize'],
- iterations=trials, loss_rate=loss_rate,
- duration=self._duration, micro_tpld=True if self._params[
- 'traffic']['l2']['framesize'] == 64 else False)
+
if testtype == '2544_throughput':
+ j_file.set_test_options_tput(
+ packet_sizes=self._params['traffic']['l2']['framesize'],
+ iterations=trials, loss_rate=loss_rate,
+ duration=self._duration, micro_tpld=True if self._params[
+ 'traffic']['l2']['framesize'] == 64 else False)
j_file.enable_throughput_test()
+
elif testtype == '2544_b2b':
+ j_file.set_test_options_back2back(
+ packet_sizes=self._params['traffic']['l2']['framesize'],
+ iterations=trials, duration=self._duration,
+ startvalue=self._params['traffic']['frame_rate'],
+ endvalue=self._params['traffic']['frame_rate'],
+ micro_tpld=True if self._params[
+ 'traffic']['l2']['framesize'] == 64 else False)
j_file.enable_back2back_test()
j_file.set_header_layer2(
@@ -485,22 +492,18 @@ class Xena(ITrafficGenerator):
def send_burst_traffic(self, traffic=None, numpkts=100, duration=20):
"""Send a burst of traffic.
- Send a ``numpkts`` packets of traffic, using ``traffic``
- configuration, with a timeout of ``time``.
+ See ITrafficGenerator for description
+ """
+ self._duration = duration
- Attributes:
- :param traffic: Detailed "traffic" spec, i.e. IP address, VLAN tags
- :param numpkts: Number of packets to send
- :param duration: Time to wait to receive packets
+ self._params.clear()
+ self._params['traffic'] = self.traffic_defaults.copy()
+ if traffic:
+ self._params['traffic'] = merge_spec(self._params['traffic'],
+ traffic)
- :returns: dictionary of strings with following data:
- - List of Tx Frames,
- - List of Rx Frames,
- - List of Tx Bytes,
- - List of List of Rx Bytes,
- - Payload Errors and Sequence Errors.
- """
- raise NotImplementedError('Xena burst traffic not implemented')
+ self._start_traffic_api(numpkts)
+ return self._stop_api_traffic()
def send_cont_traffic(self, traffic=None, duration=20):
"""Send a continuous flow of traffic.