aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--docs/testing/user/userguide/advanced.rst76
-rwxr-xr-xnfvbench/cfg.default.yaml6
-rw-r--r--nfvbench/nfvbench.py5
-rwxr-xr-xnfvbench/traffic_client.py10
-rw-r--r--nfvbench/traffic_gen/dummy.py3
-rw-r--r--nfvbench/traffic_gen/trex_gen.py14
-rw-r--r--test/test_nfvbench.py3
7 files changed, 112 insertions, 5 deletions
diff --git a/docs/testing/user/userguide/advanced.rst b/docs/testing/user/userguide/advanced.rst
index e49cfab..b36f01e 100644
--- a/docs/testing/user/userguide/advanced.rst
+++ b/docs/testing/user/userguide/advanced.rst
@@ -350,3 +350,79 @@ Example of run:
#
The --force-cleanup option will do the same but without prompting for confirmation.
+
+Service mode for TRex
+---------------------
+
+The ``--service-mode`` option allows you to capture traffic on a TRex window during the NFVBench test. Thus, you will be
+able to capture packets generated by TRex to observe many information on it.
+
+Example of use :
+
+.. code-block:: bash
+
+ nfvbench ``--service-mode``
+
+.. note:: It is preferable to define the minimum rate (2002 pps) to have a better capture
+
+In another bash window, you should connect to the TRex console doing :
+
+.. code-block:: bash
+
+ cd /opt/trex/vX.XX/ #use completion here to find your corresponding TRex version
+ ./trex-console -r
+ capture start monitor --rx [port number] -v
+
+Start this capture once you have started the NFVBench test, and you will observe packets on the TRex console :
+
+.. code-block:: bash
+
+ #26342 Port: 0 ◀── RX
+
+ trex(read-only)>
+
+ Type: UDP, Size: 66 B, TS: 26.30 [sec]
+
+ trex(read-only)>
+ ###[ Ethernet ]###
+ dst = a0:36:9f:7a:58:8e
+ src = fa:16:3e:57:8f:df
+ type = 0x8100
+ ###[ 802.1Q ]###
+ prio = 0
+ id = 0
+ vlan = 1093
+ type = 0x800
+ ###[ IP ]###
+ version = 4
+ ihl = 5
+ tos = 0x1
+ len = 46
+ id = 65535
+ flags =
+ frag = 0
+ ttl = 63
+ proto = udp
+ chksum = 0x8425
+ src = 120.0.0.0
+ dst = 110.0.17.153
+ \options \
+ ###[ UDP ]###
+ sport = 53
+ dport = 53
+ len = 26
+ chksum = 0xfd83
+ ###[ Raw ]###
+ load = "xx\xab'\x01\x00?s\x00\x00\xbci\xf0_{U~\x00"
+ ###[ Padding ]###
+ load = '6\x85'
+
+Check on the NFVBench window that the following log appears just before the testing phase :
+
+.. code-block:: bash
+
+ 2019-10-21 09:38:51,532 INFO Starting to generate traffic...
+ 2019-10-21 09:38:51,532 INFO Running traffic generator
+ 2019-10-21 09:38:51,541 INFO ``Service mode is enabled``
+ 2019-10-21 09:38:52,552 INFO TX: 2004; RX: 2003; Est. Dropped: 1; Est. Drop rate: 0.0499%
+ 2019-10-21 09:38:53,559 INFO TX: 4013; RX: 4011; Est. Dropped: 2; Est. Drop rate: 0.0498% \ No newline at end of file
diff --git a/nfvbench/cfg.default.yaml b/nfvbench/cfg.default.yaml
index 8e94eac..9a4a815 100755
--- a/nfvbench/cfg.default.yaml
+++ b/nfvbench/cfg.default.yaml
@@ -687,3 +687,9 @@ user_label:
# Can be overriden by --no-vswitch-access
# Should be left to the default value (false)
no_vswitch_access: false
+
+
+# Enable service mode for trafic capture from TRex console (for debugging purpose)
+# Can be overriden by --service-mode
+# Should be left to the default value (false)
+service_mode: false
diff --git a/nfvbench/nfvbench.py b/nfvbench/nfvbench.py
index 050017e..80b9a93 100644
--- a/nfvbench/nfvbench.py
+++ b/nfvbench/nfvbench.py
@@ -439,6 +439,11 @@ def _parse_opts_from_cli():
default='0',
help='Specify the FE cache size (default: 0, flow-count if < 0)')
+ parser.add_argument('--service-mode', dest='service_mode',
+ action='store_true',
+ default=False,
+ help='Enable T-Rex service mode for debugging only')
+
opts, unknown_opts = parser.parse_known_args()
return opts, unknown_opts
diff --git a/nfvbench/traffic_client.py b/nfvbench/traffic_client.py
index 8992d51..7591062 100755
--- a/nfvbench/traffic_client.py
+++ b/nfvbench/traffic_client.py
@@ -46,12 +46,13 @@ class TrafficClientException(Exception):
class TrafficRunner(object):
"""Serialize various steps required to run traffic."""
- def __init__(self, client, duration_sec, interval_sec=0):
+ def __init__(self, client, duration_sec, interval_sec=0, service_mode=False):
"""Create a traffic runner."""
self.client = client
self.start_time = None
self.duration_sec = duration_sec
self.interval_sec = interval_sec
+ self.service_mode = service_mode
def run(self):
"""Clear stats and instruct the traffic generator to start generating traffic."""
@@ -59,6 +60,10 @@ class TrafficRunner(object):
return None
LOG.info('Running traffic generator')
self.client.gen.clear_stats()
+ # Debug use only : new '--service-mode' option available for the NFVBench command line.
+ # A read-only mode TRex console would be able to capture the generated traffic.
+ self.client.gen.set_service_mode(enabled=self.service_mode)
+ LOG.info('Service mode is %sabled', 'en' if self.service_mode else 'dis')
self.client.gen.start_traffic()
self.start_time = time.time()
return self.poll_stats()
@@ -486,7 +491,8 @@ class TrafficClient(object):
self.notifier = notifier
self.interval_collector = None
self.iteration_collector = None
- self.runner = TrafficRunner(self, self.config.duration_sec, self.config.interval_sec)
+ self.runner = TrafficRunner(self, self.config.duration_sec, self.config.interval_sec,
+ self.config.service_mode)
self.config.frame_sizes = self._get_frame_sizes()
self.run_config = {
'l2frame_size': None,
diff --git a/nfvbench/traffic_gen/dummy.py b/nfvbench/traffic_gen/dummy.py
index 120a99b..ef7f272 100644
--- a/nfvbench/traffic_gen/dummy.py
+++ b/nfvbench/traffic_gen/dummy.py
@@ -201,6 +201,9 @@ class DummyTG(AbstractTrafficGenerator):
def set_mode(self):
pass
+ def set_service_mode(self, enabled=True):
+ pass
+
def resolve_arp(self):
"""Resolve ARP sucessfully."""
def get_macs(port, scc):
diff --git a/nfvbench/traffic_gen/trex_gen.py b/nfvbench/traffic_gen/trex_gen.py
index 0f51188..b8e32e3 100644
--- a/nfvbench/traffic_gen/trex_gen.py
+++ b/nfvbench/traffic_gen/trex_gen.py
@@ -693,7 +693,10 @@ class TRex(AbstractTrafficGenerator):
chain_count)
break
- self.client.set_service_mode(ports=self.port_handle, enabled=False)
+ # if the capture from the TRex console was started before the arp request step,
+ # it keeps 'service_mode' enabled, otherwise, it disables the 'service_mode'
+ if not self.config.service_mode:
+ self.client.set_service_mode(ports=self.port_handle, enabled=False)
if len(arp_dest_macs) == len(self.port_handle):
return arp_dest_macs
return None
@@ -835,7 +838,10 @@ class TRex(AbstractTrafficGenerator):
if self.capture_id:
self.client.stop_capture(capture_id=self.capture_id['id'])
self.capture_id = None
- self.client.set_service_mode(ports=self.port_handle, enabled=False)
+ # if the capture from TRex console was started before the connectivity step,
+ # it keeps 'service_mode' enabled, otherwise, it disables the 'service_mode'
+ if not self.config.service_mode:
+ self.client.set_service_mode(ports=self.port_handle, enabled=False)
def cleanup(self):
"""Cleanup Trex driver."""
@@ -846,3 +852,7 @@ class TRex(AbstractTrafficGenerator):
except STLError:
# TRex does not like a reset while in disconnected state
pass
+
+ def set_service_mode(self, enabled=True):
+ """Enable/disable the 'service_mode'."""
+ self.client.set_service_mode(ports=self.port_handle, enabled=enabled)
diff --git a/test/test_nfvbench.py b/test/test_nfvbench.py
index e41ab33..04e3191 100644
--- a/test/test_nfvbench.py
+++ b/test/test_nfvbench.py
@@ -331,7 +331,8 @@ def _get_dummy_tg_config(chain_type, rate, scc=1, fc=10, step_ip='0.0.0.1',
'cores': None,
'mbuf_factor': None,
'disable_hdrh': None,
- 'mbuf_64': None
+ 'mbuf_64': None,
+ 'service_mode': False
})