summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rwxr-xr-xscripts/automation/regression/unit_tests/functional_tests/hltapi_stream_builder_test.py22
-rw-r--r--scripts/automation/regression/unit_tests/functional_tests/scapy_pkt_builder_test.py23
-rw-r--r--scripts/automation/regression/unit_tests/functional_tests/stl_basic_tests.py65
-rw-r--r--scripts/automation/trex_control_plane/stl/examples/stl_flow_stats.py (renamed from scripts/automation/trex_control_plane/stl/examples/stl_rx_stream.py)10
-rw-r--r--scripts/automation/trex_control_plane/stl/trex_stl_lib/__init__.py10
-rw-r--r--scripts/automation/trex_control_plane/stl/trex_stl_lib/trex_stl_async_client.py2
-rw-r--r--scripts/automation/trex_control_plane/stl/trex_stl_lib/trex_stl_client.py6
-rwxr-xr-xscripts/automation/trex_control_plane/stl/trex_stl_lib/trex_stl_hltapi.py1
-rw-r--r--scripts/automation/trex_control_plane/stl/trex_stl_lib/trex_stl_packet_builder_scapy.py14
-rw-r--r--scripts/automation/trex_control_plane/stl/trex_stl_lib/trex_stl_sim.py43
-rw-r--r--scripts/automation/trex_control_plane/stl/trex_stl_lib/trex_stl_stats.py36
-rw-r--r--scripts/automation/trex_control_plane/stl/trex_stl_lib/trex_stl_streams.py36
-rw-r--r--scripts/exp/pcap.pcapbin476 -> 476 bytes
-rw-r--r--scripts/exp/pcap_with_vm.pcapbin2284 -> 2284 bytes
-rw-r--r--scripts/exp/syn_attack.pcapbin3824 -> 3824 bytes
-rw-r--r--scripts/exp/udp_1pkt_range_clients_split_garp.pcapbin3824 -> 3824 bytes
-rw-r--r--scripts/stl/flow_stats.py (renamed from scripts/stl/rx_stats.py)2
-rw-r--r--scripts/stl/yaml/imix_1pkt_2.yaml8
-rw-r--r--scripts/stl/yaml/imix_1pkt_vm.yaml2
-rw-r--r--scripts/stl/yaml/imix_1pkt_vm_minus.yaml2
-rw-r--r--src/flow_stat.cpp38
-rw-r--r--src/gtest/rpc_test.cpp2
-rw-r--r--src/main_dpdk.cpp20
-rw-r--r--src/main_dpdk.h1
-rw-r--r--src/rpc-server/commands/trex_rpc_cmd_stream.cpp6
-rw-r--r--src/stateless/cp/trex_stream.h2
26 files changed, 196 insertions, 155 deletions
diff --git a/scripts/automation/regression/unit_tests/functional_tests/hltapi_stream_builder_test.py b/scripts/automation/regression/unit_tests/functional_tests/hltapi_stream_builder_test.py
index 54ffddb5..c6b477aa 100755
--- a/scripts/automation/regression/unit_tests/functional_tests/hltapi_stream_builder_test.py
+++ b/scripts/automation/regression/unit_tests/functional_tests/hltapi_stream_builder_test.py
@@ -53,7 +53,7 @@ class CTRexHltApi_Test(unittest.TestCase):
packet:
binary: AAAAAAAAAAABAAABCABFAAAyAAAAAEAGusUAAAAAwAAAAQQAAFAAAAABAAAAAVAAD+U1/QAAISEhISEhISEhIQ==
meta: ''
- rx_stats:
+ flow_stats:
enabled: false
self_start: true
vm:
@@ -109,7 +109,7 @@ TBD
packet:
binary: AAAAAAAAAAABAAABCABFAAAyAAAAAEAGrxPAqAEBBQUFBQQAAFAAAAABAAAAAVAAD+UqSwAAISEhISEhISEhIQ==
meta: ''
- rx_stats:
+ flow_stats:
enabled: false
self_start: true
vm:
@@ -168,7 +168,7 @@ TBD
packet:
binary: AAAAAAAAAAABAAABCABFAAAyAAAAAEAGusUAAAAAwAAAAQQABNIAAAABAAAAAVAAD+UxewAAISEhISEhISEhIQ==
meta: ''
- rx_stats:
+ flow_stats:
enabled: false
self_start: true
vm:
@@ -246,7 +246,7 @@ TBD
packet:
binary: AAAAAAAAAAABAAABCABFAAAyAAAAAEARuroAAAAAwAAAAQTSBNIAHsmgISEhISEhISEhISEhISEhISEhISEhIQ==
meta: ''
- rx_stats:
+ flow_stats:
enabled: false
self_start: true
vm:
@@ -307,7 +307,7 @@ TBD
packet:
binary: AAAAAAAAAAABAAABCABFAAuqAAAAAEAGr00AAAAAwAAAAQQAAFAAAAABAAAAAVAAD+UwiwAAISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEh
meta: ''
- rx_stats:
+ flow_stats:
enabled: false
self_start: true
vm:
@@ -353,7 +353,7 @@ TBD
packet:
binary: AAAAAAAAAAABAAABCABFAAGQAAAAAEARuVwAAAAAwAAAAQQAAFABfCaTISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEh
meta: ''
- rx_stats:
+ flow_stats:
enabled: false
self_start: true
vm:
@@ -407,7 +407,7 @@ TBD
packet:
binary: AAAAAAAAAAABAAABgQAwAAgARQAALgAAAABABrrJAAAAAMAAAAEEAABQAAAAAQAAAAFQAA/leEMAACEhISEhIQ==
meta: ''
- rx_stats:
+ flow_stats:
enabled: false
self_start: true
vm:
@@ -439,7 +439,7 @@ TBD
packet:
binary: AAAAAAAAAAABAAABgQAwAYEAMAKBADADgQAwBAgARQAARgAAAABABrqxAAAAAMAAAAEEAABQAAAAAQAAAAFQAA/l6p0AACEhISEhISEhISEhISEhISEhISEhISEhISEhISEhIQ==
meta: ''
- rx_stats:
+ flow_stats:
enabled: false
self_start: true
vm:
@@ -471,7 +471,7 @@ TBD
packet:
binary: AAAAAAAAAAABAAABgQAwAYEAMAKBADPogQAwBIEAMAUIAEUAAEIAAAAAQAa6tQAAAADAAAABBAAAUAAAAAEAAAABUAAP5SzkAAAhISEhISEhISEhISEhISEhISEhISEhISEhIQ==
meta: ''
- rx_stats:
+ flow_stats:
enabled: false
self_start: true
vm:
@@ -553,7 +553,7 @@ TBD
packet:
binary: AAAAAAAAAAABAAABht1gAAAAAG4GQP6AAAAAAAAAAAAAAAAAABL+gAAAAAAAAAAAAAAAAAAiBAAAUAAAAAEAAAABUAAP5ctLAAAhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISE=
meta: ''
- rx_stats:
+ flow_stats:
enabled: false
self_start: true
vm:
@@ -583,7 +583,7 @@ TBD
packet:
binary: AAAAAAAAAAABAAABht1gAAAAAG4RQBERIiIzM0REVVVmZnd3iIgRERERERERERERERERERERBAAAUABucjohISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISE=
meta: ''
- rx_stats:
+ flow_stats:
enabled: false
self_start: true
vm:
diff --git a/scripts/automation/regression/unit_tests/functional_tests/scapy_pkt_builder_test.py b/scripts/automation/regression/unit_tests/functional_tests/scapy_pkt_builder_test.py
index 79ef4364..7e2f6271 100644
--- a/scripts/automation/regression/unit_tests/functional_tests/scapy_pkt_builder_test.py
+++ b/scripts/automation/regression/unit_tests/functional_tests/scapy_pkt_builder_test.py
@@ -308,18 +308,17 @@ class CTRexPktBuilderSanitySCapy_Test(pkt_bld_general_test.CGeneralPktBld_Test):
def test_simple_pkt_loader1(self):
- pass;
- #pkt_builder = CScapyTRexPktBuilder(pkt = "stl/golden/udp_590.cap");
- #print ""
- #pkt_builder.dump_as_hex()
- #r = pkt_builder.pkt_raw
- #assert_equal(ord(r[1]),0x50)
- #assert_equal(ord(r[0]),0x00)
- #assert_equal(ord(r[0x240]),0x16)
- #assert_equal(ord(r[0x24d]),0x79)
- #assert_equal(len(r),590)
-
- #print len(r)
+ pkt_builder = CScapyTRexPktBuilder(pkt = "stl/golden/udp_590.cap", build_raw = False);
+ print ""
+ pkt_builder.dump_as_hex()
+ r = pkt_builder.pkt_raw
+ assert_equal(ord(r[1]),0x50)
+ assert_equal(ord(r[0]),0x00)
+ assert_equal(ord(r[0x240]),0x16)
+ assert_equal(ord(r[0x24d]),0x79)
+ assert_equal(len(r),590)
+
+ print len(r)
def test_simple_pkt_loader2(self):
diff --git a/scripts/automation/regression/unit_tests/functional_tests/stl_basic_tests.py b/scripts/automation/regression/unit_tests/functional_tests/stl_basic_tests.py
index 88a6983f..cd653895 100644
--- a/scripts/automation/regression/unit_tests/functional_tests/stl_basic_tests.py
+++ b/scripts/automation/regression/unit_tests/functional_tests/stl_basic_tests.py
@@ -8,10 +8,12 @@ from nose.tools import nottest
from nose.plugins.attrib import attr
from unit_tests.trex_general_test import CTRexScenario
from dpkt import pcap
-
+from trex_stl_lib import trex_stl_sim
import sys
import os
import subprocess
+import shlex
+from threading import Thread
@attr('run_on_trex')
class CStlBasic_Test(functional_general_test.CGeneralFunctional_Test):
@@ -36,7 +38,9 @@ class CStlBasic_Test(functional_general_test.CGeneralFunctional_Test):
for k, v in self.profiles.iteritems():
self.verify_exists(v)
- self.valgrind_profiles = [ self.profiles['imix_3pkt_vm'], self.profiles['random_size_9k'], self.profiles['imix_tuple_gen']]
+ self.valgrind_profiles = [ self.profiles['imix_3pkt_vm'],
+ self.profiles['random_size_9k'],
+ self.profiles['imix_tuple_gen'] ]
self.golden_path = os.path.join(self.test_path,"stl/golden/")
@@ -81,39 +85,21 @@ class CStlBasic_Test(functional_general_test.CGeneralFunctional_Test):
- def run_sim (self, yaml, output, options = "", silent = False):
+ def run_sim (self, yaml, output, options = "", silent = False, obj = None):
if output:
user_cmd = "-f {0} -o {1} {2}".format(yaml, output, options)
else:
user_cmd = "-f {0} {1}".format(yaml, options)
- cmd = "{0} {1}".format(self.stl_sim,
- user_cmd)
-
if silent:
- devnull = open('/dev/null', 'w')
- rc = subprocess.call(cmd, shell = True, stdout = devnull)
- else:
- print cmd
- rc = subprocess.call(cmd, shell = True)
-
- return (rc == 0)
+ user_cmd += " --silent"
+ rc = trex_stl_sim.main(args = shlex.split(user_cmd))
+ if obj:
+ obj['rc'] = (rc == 0)
- def golden_run (self, testname, profile, options, silent = False):
-
- output_cap = os.path.join("/tmp/", "{0}_test.cap".format(testname))
- golden_cap = os.path.join(self.test_path, "stl/golden/{0}_golden.cap".format(testname))
- if os.path.exists(output_cap):
- os.unlink(output_cap)
- try:
- rc = self.run_sim(self.profiles[profile], output_cap, options, silent)
- assert_equal(rc, True)
+ return (rc == 0)
- self.compare_caps(output_cap, golden_cap)
-
- finally:
- os.unlink(output_cap)
def run_py_profile_path (self, profile, options,silent = False, do_no_remove=False,compare =True, test_generated=True):
@@ -170,8 +156,8 @@ class CStlBasic_Test(functional_general_test.CGeneralFunctional_Test):
["udp_inc_len_9k.py","-m 1 -l 100",True],
["udp_1pkt_range_clients.py","-m 1 -l 100",True],
["multi_burst_2st_1000pkt.py","-m 1 -l 100",True],
- #["pcap.py", "-m 1", True],
- #["pcap_with_vm.py", "-m 1", True],
+ ["pcap.py", "-m 1", True],
+ ["pcap_with_vm.py", "-m 1", True],
# YAML test
["yaml/burst_1000_pkt.yaml","-m 1 -l 100",True],
@@ -202,7 +188,7 @@ class CStlBasic_Test(functional_general_test.CGeneralFunctional_Test):
["udp_1pkt_simple_test2.py","-m 1 -l 10 ",True], # test split of packet with ip option
["udp_1pkt_simple_test.py","-m 1 -l 10 ",True],
["udp_1pkt_mac_mask5.py","-m 1 -l 30 ",True],
- #["udp_1pkt_range_clients_split_garp.py","-m 1 -l 50",True]
+ ["udp_1pkt_range_clients_split_garp.py","-m 1 -l 50",True]
];
@@ -247,13 +233,26 @@ class CStlBasic_Test(functional_general_test.CGeneralFunctional_Test):
for obj in p:
self.run_py_profile_path (obj[0], obj[1], compare =obj[2], do_no_remove=True)
- # valgrind tests
+ # valgrind tests - this runs in multi thread as it safe (no output)
def test_valgrind_various_profiles (self):
print "\n"
+ threads = []
for profile in self.valgrind_profiles:
- print "\n*** testing profile '{0}' ***\n".format(profile)
- rc = self.run_sim(profile, output = None, options = "--cores 8 --limit 20 --valgrind", silent = False)
- assert_equal(rc, True)
+ print "\n*** VALGRIND: testing profile '{0}' ***\n".format(profile)
+ obj = {'t': None, 'rc': None}
+ t = Thread(target = self.run_sim,
+ kwargs = {'obj': obj, 'yaml': profile, 'output':None, 'options': "--cores 8 --limit 20 --valgrind", 'silent': True})
+ obj['t'] = t
+
+ threads.append(obj)
+ t.start()
+
+ for obj in threads:
+ obj['t'].join()
+
+ for obj in threads:
+ assert_equal(obj['rc'], True)
+
diff --git a/scripts/automation/trex_control_plane/stl/examples/stl_rx_stream.py b/scripts/automation/trex_control_plane/stl/examples/stl_flow_stats.py
index 023b9a75..3708834e 100644
--- a/scripts/automation/trex_control_plane/stl/examples/stl_rx_stream.py
+++ b/scripts/automation/trex_control_plane/stl/examples/stl_flow_stats.py
@@ -18,7 +18,7 @@ def rx_example (tx_port, rx_port, burst_size):
total_pkts = burst_size
s1 = STLStream(name = 'rx',
packet = pkt,
- rx_stats = STLRxStats(user_id = 5),
+ flow_stats = STLFlowStats(pg_id = 5),
mode = STLTXSingleBurst(total_pkts = total_pkts, bps_L2 = 250000000))
# connect to server
@@ -36,11 +36,11 @@ def rx_example (tx_port, rx_port, burst_size):
c.wait_on_traffic(ports = [tx_port])
# no error check - just an example... should be 5
- rx_stats = c.get_stats()['rx_stats'][5]
+ flow_stats = c.get_stats()['flow_stats'][5]
- tx_pkts = rx_stats['tx-pkts'][tx_port]
- tx_bytes = rx_stats['tx-bytes'][tx_port]
- rx_pkts = rx_stats['rx-pkts'][rx_port]
+ tx_pkts = flow_stats['tx_pkts'][tx_port]
+ tx_bytes = flow_stats['tx_bytes'][tx_port]
+ rx_pkts = flow_stats['rx_pkts'][rx_port]
if tx_pkts != total_pkts:
print "TX pkts mismatch - got: {0}, expected: {1}".format(tx_pkts, total_pkts)
diff --git a/scripts/automation/trex_control_plane/stl/trex_stl_lib/__init__.py b/scripts/automation/trex_control_plane/stl/trex_stl_lib/__init__.py
index 60bf7be8..8488a80a 100644
--- a/scripts/automation/trex_control_plane/stl/trex_stl_lib/__init__.py
+++ b/scripts/automation/trex_control_plane/stl/trex_stl_lib/__init__.py
@@ -1 +1,11 @@
+import sys
+
+if sys.version_info < (2, 7):
+ print("\n**** TRex STL pacakge requires Python version >= 2.7 ***\n")
+ exit(-1)
+
+if sys.version_info >= (3, 0):
+ print("\n**** TRex STL pacakge does not support Python 3 (yet) ***\n")
+ exit(-1)
+
import trex_stl_ext
diff --git a/scripts/automation/trex_control_plane/stl/trex_stl_lib/trex_stl_async_client.py b/scripts/automation/trex_control_plane/stl/trex_stl_lib/trex_stl_async_client.py
index f75d2003..36103cae 100644
--- a/scripts/automation/trex_control_plane/stl/trex_stl_lib/trex_stl_async_client.py
+++ b/scripts/automation/trex_control_plane/stl/trex_stl_lib/trex_stl_async_client.py
@@ -281,7 +281,7 @@ class CTRexAsyncClient():
elif name == "trex-barrier":
self.handle_async_barrier(type, data)
- elif name == "rx-stats":
+ elif name == "flow_stats":
self.event_handler.handle_async_rx_stats_event(data)
else:
diff --git a/scripts/automation/trex_control_plane/stl/trex_stl_lib/trex_stl_client.py b/scripts/automation/trex_control_plane/stl/trex_stl_lib/trex_stl_client.py
index 6ff007b1..a4e0b519 100644
--- a/scripts/automation/trex_control_plane/stl/trex_stl_lib/trex_stl_client.py
+++ b/scripts/automation/trex_control_plane/stl/trex_stl_lib/trex_stl_client.py
@@ -156,7 +156,7 @@ class AsyncEventHandler(object):
def handle_async_rx_stats_event (self, data):
- self.client.rx_stats.update(data)
+ self.client.flow_stats.update(data)
# handles an async stats update from the subscriber
@@ -439,7 +439,7 @@ class STLClient(object):
self.stats_generator = trex_stl_stats.CTRexInfoGenerator(self.global_stats,
self.ports)
- self.rx_stats = trex_stl_stats.CRxStats()
+ self.flow_stats = trex_stl_stats.CRxStats()
############# private functions - used by the class itself ###########
@@ -746,7 +746,7 @@ class STLClient(object):
stats['total'] = total
- stats['rx_stats'] = self.rx_stats.get_stats()
+ stats['flow_stats'] = self.flow_stats.get_stats()
return stats
diff --git a/scripts/automation/trex_control_plane/stl/trex_stl_lib/trex_stl_hltapi.py b/scripts/automation/trex_control_plane/stl/trex_stl_lib/trex_stl_hltapi.py
index 2f08cc48..a74824d2 100755
--- a/scripts/automation/trex_control_plane/stl/trex_stl_lib/trex_stl_hltapi.py
+++ b/scripts/automation/trex_control_plane/stl/trex_stl_lib/trex_stl_hltapi.py
@@ -795,7 +795,6 @@ def STLHltStream(**user_kwargs):
#enabled = True,
#self_start = True,
mode = transmit_mode_class,
- #rx_stats = rx_stats,
stream_id = kwargs['stream_id'],
name = kwargs['name'],
)
diff --git a/scripts/automation/trex_control_plane/stl/trex_stl_lib/trex_stl_packet_builder_scapy.py b/scripts/automation/trex_control_plane/stl/trex_stl_lib/trex_stl_packet_builder_scapy.py
index a3430c79..6a2e268f 100644
--- a/scripts/automation/trex_control_plane/stl/trex_stl_lib/trex_stl_packet_builder_scapy.py
+++ b/scripts/automation/trex_control_plane/stl/trex_stl_lib/trex_stl_packet_builder_scapy.py
@@ -950,20 +950,18 @@ class CScapyTRexPktBuilder(CTrexPktBuilderInterface):
# for buffer, promote to a scapy packet
if self.pkt_raw:
self.pkt = Ether(self.pkt_raw)
- if self.remove_fcs and self.pkt.lastlayer().name == 'Padding':
- self.pkt.lastlayer().underlayer.remove_payload()
- self.pkt.build()
self.pkt_raw = None
# regular scapy packet
- elif self.pkt:
- self.pkt.build()
-
- else:
+ elif not self.pkt:
# should not reach here
raise CTRexPacketBuildException(-11, 'empty packet')
-
+ if self.remove_fcs and self.pkt.lastlayer().name == 'Padding':
+ self.pkt.lastlayer().underlayer.remove_payload()
+ if len(self.pkt) < 60: # simulator can write padding with non-zeros, set it explicit
+ self.pkt /= Padding('\x00' * (60 - len(self.pkt)))
+ self.pkt.build()
self.is_pkt_built = True
def _pkt_layer_offset (self,layer_name):
diff --git a/scripts/automation/trex_control_plane/stl/trex_stl_lib/trex_stl_sim.py b/scripts/automation/trex_control_plane/stl/trex_stl_lib/trex_stl_sim.py
index 9db34737..614d8b77 100644
--- a/scripts/automation/trex_control_plane/stl/trex_stl_lib/trex_stl_sim.py
+++ b/scripts/automation/trex_control_plane/stl/trex_stl_lib/trex_stl_sim.py
@@ -121,9 +121,10 @@ class STLSim(object):
pkt_limit = 5000,
mult = "1",
duration = -1,
- mode = 'none'):
+ mode = 'none',
+ silent = False):
- if not mode in ['none', 'gdb', 'valgrind', 'json', 'yaml','pkt']:
+ if not mode in ['none', 'gdb', 'valgrind', 'json', 'yaml','pkt','native']:
raise STLArgumentError('mode', mode)
# listify
@@ -211,6 +212,9 @@ class STLSim(object):
elif mode == 'pkt':
print STLProfile(stream_list).dump_as_pkt();
return
+ elif mode == 'native':
+ print STLProfile(stream_list).dump_to_code()
+ return
# start simulation
@@ -222,6 +226,7 @@ class STLSim(object):
self.mult = mult
self.duration = duration,
self.mode = mode
+ self.silent = silent
self.__run(cmds_json)
@@ -282,7 +287,13 @@ class STLSim(object):
cmd = ['/usr/bin/gdb', '--args'] + cmd
print "executing command: '{0}'".format(" ".join(cmd))
- rc = subprocess.call(cmd)
+
+ if self.silent:
+ FNULL = open(os.devnull, 'w')
+ rc = subprocess.call(cmd, stdout=FNULL)
+ else:
+ rc = subprocess.call(cmd)
+
if rc != 0:
raise STLError('simulation has failed with error code {0}'.format(rc))
@@ -355,6 +366,11 @@ def setParserOptions():
default = False)
+ parser.add_argument("-s", "--silent",
+ help = "runs on silent mode (no stdout) [default is False]",
+ action = "store_true",
+ default = False)
+
parser.add_argument("-l", "--limit",
help = "limit test total packet count [default is 5000]",
default = 5000,
@@ -406,6 +422,11 @@ def setParserOptions():
action = "store_true",
default = False)
+ group.add_argument("--native",
+ help = "generate Python code with stateless profile from input file [default is False]",
+ action = "store_true",
+ default = False)
+
return parser
@@ -420,9 +441,9 @@ def validate_args (parser, options):
parser.error("limit cannot be lower than number of DP cores")
-def main ():
+def main (args = None):
parser = setParserOptions()
- options = parser.parse_args()
+ options = parser.parse_args(args = args)
validate_args(parser, options)
@@ -436,6 +457,8 @@ def main ():
mode = 'json'
elif options.yaml:
mode = 'yaml'
+ elif options.native:
+ mode = 'native'
elif options.pkt:
mode = 'pkt'
else:
@@ -452,17 +475,19 @@ def main ():
pkt_limit = options.limit,
mult = options.mult,
duration = options.duration,
- mode = mode)
+ mode = mode,
+ silent = options.silent)
except KeyboardInterrupt as e:
print "\n\n*** Caught Ctrl + C... Exiting...\n\n"
- exit(1)
+ return (-1)
except STLError as e:
print e
- exit(1)
+ return (-1)
+
+ return (0)
- exit(0)
if __name__ == '__main__':
main()
diff --git a/scripts/automation/trex_control_plane/stl/trex_stl_lib/trex_stl_stats.py b/scripts/automation/trex_control_plane/stl/trex_stl_lib/trex_stl_stats.py
index eca7fd7a..c2e318bc 100644
--- a/scripts/automation/trex_control_plane/stl/trex_stl_lib/trex_stl_stats.py
+++ b/scripts/automation/trex_control_plane/stl/trex_stl_lib/trex_stl_stats.py
@@ -131,10 +131,10 @@ class CTRexInfoGenerator(object):
("ipackets", []),
("obytes", []),
("ibytes", []),
- ("tx-bytes", []),
- ("rx-bytes", []),
- ("tx-pkts", []),
- ("rx-pkts", []),
+ ("tx_bytes", []),
+ ("rx_bytes", []),
+ ("tx_pkts", []),
+ ("rx_pkts", []),
("-----", []),
("oerrors", []),
@@ -627,10 +627,10 @@ class CPortStats(CTRexStats):
"obytes" : self.get_rel("obytes"),
"ibytes" : self.get_rel("ibytes"),
- "tx-bytes": self.get_rel("obytes", format = True, suffix = "B"),
- "rx-bytes": self.get_rel("ibytes", format = True, suffix = "B"),
- "tx-pkts": self.get_rel("opackets", format = True, suffix = "pkts"),
- "rx-pkts": self.get_rel("ipackets", format = True, suffix = "pkts"),
+ "tx_bytes": self.get_rel("obytes", format = True, suffix = "B"),
+ "rx_bytes": self.get_rel("ibytes", format = True, suffix = "B"),
+ "tx_pkts": self.get_rel("opackets", format = True, suffix = "pkts"),
+ "rx_pkts": self.get_rel("ipackets", format = True, suffix = "pkts"),
"oerrors" : format_num(self.get_rel("oerrors"),
compact = False,
@@ -645,28 +645,28 @@ class CPortStats(CTRexStats):
class CRxStats(object):
def __init__(self):
- self.rx_stats = {}
+ self.flow_stats = {}
def update (self, snapshot):
- self.rx_stats = snapshot
+ self.flow_stats = snapshot
def get_stats (self):
stats = {}
- for user_id, user_id_data in self.rx_stats.iteritems():
- # ignore non user ID keys
+ for pg_id, pg_id_data in self.flow_stats.iteritems():
+ # ignore non pg ID keys
try:
- user_id = int(user_id)
+ pg_id = int(pg_id)
except ValueError:
continue
- # handle user id
- stats[user_id] = {}
- for field, per_port_data in user_id_data.iteritems():
- stats[user_id][field] = {}
+ # handle pg id
+ stats[pg_id] = {}
+ for field, per_port_data in pg_id_data.iteritems():
+ stats[pg_id][field] = {}
for port, value in per_port_data.iteritems():
- stats[user_id][field][int(port)] = value
+ stats[pg_id][field][int(port)] = value
return stats
diff --git a/scripts/automation/trex_control_plane/stl/trex_stl_lib/trex_stl_streams.py b/scripts/automation/trex_control_plane/stl/trex_stl_lib/trex_stl_streams.py
index c41fa0c2..7fc132b1 100644
--- a/scripts/automation/trex_control_plane/stl/trex_stl_lib/trex_stl_streams.py
+++ b/scripts/automation/trex_control_plane/stl/trex_stl_lib/trex_stl_streams.py
@@ -124,12 +124,12 @@ STLStreamDstMAC_PKT =1
STLStreamDstMAC_ARP =2
# RX stats class
-class STLRxStats(object):
- def __init__ (self, user_id):
+class STLFlowStats(object):
+ def __init__ (self, pg_id):
self.fields = {}
self.fields['enabled'] = True
- self.fields['stream_id'] = user_id
+ self.fields['stream_id'] = pg_id
self.fields['seq_enabled'] = False
self.fields['latency_enabled'] = False
@@ -150,7 +150,7 @@ class STLStream(object):
enabled = True,
self_start = True,
isg = 0.0,
- rx_stats = None,
+ flow_stats = None,
next = None,
stream_id = None,
action_count = 0,
@@ -241,10 +241,10 @@ class STLStream(object):
# this is heavy, calculate lazy
self.packet_desc = None
- if not rx_stats:
- self.fields['rx_stats'] = STLRxStats.defaults()
+ if not flow_stats:
+ self.fields['flow_stats'] = STLFlowStats.defaults()
else:
- self.fields['rx_stats'] = rx_stats.to_json()
+ self.fields['flow_stats'] = flow_stats.to_json()
def __str__ (self):
@@ -344,8 +344,6 @@ class STLStream(object):
imports_arr = []
if 'MPLS(' in packet_command:
imports_arr.append('from scapy.contrib.mpls import MPLS')
- if 'VXLAN(' in packet_command:
- imports_arr.append('from scapy.contrib.mpls import MPLS')
imports = '\n'.join(imports_arr)
if payload:
@@ -393,8 +391,8 @@ class STLStream(object):
stream_params_list.append('self_start = %s' % self.fields['self_start'])
if default_STLStream.fields['isg'] != self.fields['isg']:
stream_params_list.append('isg = %s' % self.fields['isg'])
- if default_STLStream.fields['rx_stats'] != self.fields['rx_stats']:
- stream_params_list.append('rx_stats = STLRxStats(%s)' % self.fields['rx_stats']['stream_id'])
+ if default_STLStream.fields['flow_stats'] != self.fields['flow_stats']:
+ stream_params_list.append('flow_stats = STLFlowStats(%s)' % self.fields['flow_stats']['stream_id'])
if default_STLStream.next != self.next:
stream_params_list.append('next = %s' % STLStream.__add_quotes(self.next))
if default_STLStream.id != self.id:
@@ -515,17 +513,17 @@ class YAMLLoader(object):
- def __parse_rx_stats (self, rx_stats_obj):
+ def __parse_flow_stats (self, flow_stats_obj):
# no such object
- if not rx_stats_obj or rx_stats_obj.get('enabled') == False:
+ if not flow_stats_obj or flow_stats_obj.get('enabled') == False:
return None
- user_id = rx_stats_obj.get('stream_id')
- if user_id == None:
+ pg_id = flow_stats_obj.get('stream_id')
+ if pg_id == None:
raise STLError("enabled RX stats section must contain 'stream_id' field")
- return STLRxStats(user_id = user_id)
+ return STLFlowStats(pg_id = pg_id)
def __parse_stream (self, yaml_object):
@@ -543,7 +541,7 @@ class YAMLLoader(object):
mode = self.__parse_mode(s_obj.get('mode'))
# rx stats
- rx_stats = self.__parse_rx_stats(s_obj.get('rx_stats'))
+ flow_stats = self.__parse_flow_stats(s_obj.get('flow_stats'))
defaults = default_STLStream
@@ -551,7 +549,7 @@ class YAMLLoader(object):
stream = STLStream(name = yaml_object.get('name'),
packet = builder,
mode = mode,
- rx_stats = rx_stats,
+ flow_stats = flow_stats,
enabled = s_obj.get('enabled', defaults.fields['enabled']),
self_start = s_obj.get('self_start', defaults.fields['self_start']),
isg = s_obj.get('isg', defaults.fields['isg']),
@@ -764,4 +762,4 @@ def register():
def __len__ (self):
return len(self.streams)
-default_STLStream = STLStream() \ No newline at end of file
+default_STLStream = STLStream()
diff --git a/scripts/exp/pcap.pcap b/scripts/exp/pcap.pcap
index 34a2e9b6..b13275ee 100644
--- a/scripts/exp/pcap.pcap
+++ b/scripts/exp/pcap.pcap
Binary files differ
diff --git a/scripts/exp/pcap_with_vm.pcap b/scripts/exp/pcap_with_vm.pcap
index a278dd8e..a7a2d2ba 100644
--- a/scripts/exp/pcap_with_vm.pcap
+++ b/scripts/exp/pcap_with_vm.pcap
Binary files differ
diff --git a/scripts/exp/syn_attack.pcap b/scripts/exp/syn_attack.pcap
index aa420d2c..84da36a7 100644
--- a/scripts/exp/syn_attack.pcap
+++ b/scripts/exp/syn_attack.pcap
Binary files differ
diff --git a/scripts/exp/udp_1pkt_range_clients_split_garp.pcap b/scripts/exp/udp_1pkt_range_clients_split_garp.pcap
index dde0c6dd..627bcd54 100644
--- a/scripts/exp/udp_1pkt_range_clients_split_garp.pcap
+++ b/scripts/exp/udp_1pkt_range_clients_split_garp.pcap
Binary files differ
diff --git a/scripts/stl/rx_stats.py b/scripts/stl/flow_stats.py
index 892fe1a0..05d7a9f7 100644
--- a/scripts/stl/rx_stats.py
+++ b/scripts/stl/flow_stats.py
@@ -7,7 +7,7 @@ class STLS1(object):
def get_streams (self, direction = 0):
return [STLStream(packet = STLPktBuilder(pkt ="stl/yaml/udp_64B_no_crc.pcap"), # path relative to pwd
mode = STLTXCont(pps=10),
- rx_stats = STLRxStats(user_id = 7))
+ flow_stats = STLFlowStats(pg_id = 7))
]
diff --git a/scripts/stl/yaml/imix_1pkt_2.yaml b/scripts/stl/yaml/imix_1pkt_2.yaml
index dc1a457b..014ffdbc 100644
--- a/scripts/stl/yaml/imix_1pkt_2.yaml
+++ b/scripts/stl/yaml/imix_1pkt_2.yaml
@@ -8,7 +8,7 @@
mode:
type: continuous
pps: 100
- rx_stats: []
+ flow_stats: []
vm: []
- name: udp_64B_2
stream:
@@ -18,7 +18,7 @@
mode:
type: continuous
pps: 100
- rx_stats: []
+ flow_stats: []
vm: []
- name: udp_64B_3
stream:
@@ -28,7 +28,7 @@
mode:
type: continuous
pps: 100
- rx_stats: []
+ flow_stats: []
vm: []
- name: udp_64B_4
stream:
@@ -38,5 +38,5 @@
mode:
type: continuous
pps: 100
- rx_stats: []
+ flow_stats: []
vm: []
diff --git a/scripts/stl/yaml/imix_1pkt_vm.yaml b/scripts/stl/yaml/imix_1pkt_vm.yaml
index 698d3e60..5d9da5af 100644
--- a/scripts/stl/yaml/imix_1pkt_vm.yaml
+++ b/scripts/stl/yaml/imix_1pkt_vm.yaml
@@ -8,7 +8,7 @@
mode:
type: continuous
pps: 100
- rx_stats: []
+ flow_stats: []
vm:
instructions: [
diff --git a/scripts/stl/yaml/imix_1pkt_vm_minus.yaml b/scripts/stl/yaml/imix_1pkt_vm_minus.yaml
index bf67c83c..e83cfdd0 100644
--- a/scripts/stl/yaml/imix_1pkt_vm_minus.yaml
+++ b/scripts/stl/yaml/imix_1pkt_vm_minus.yaml
@@ -8,7 +8,7 @@
mode:
type: continuous
pps: 100
- rx_stats: []
+ flow_stats: []
vm:
instructions: [
diff --git a/src/flow_stat.cpp b/src/flow_stat.cpp
index 5c3c7462..700c584b 100644
--- a/src/flow_stat.cpp
+++ b/src/flow_stat.cpp
@@ -391,7 +391,7 @@ std::ostream& operator<<(std::ostream& os, const CFlowStatRuleMgr& cf) {
int CFlowStatRuleMgr::compile_stream(const TrexStream * stream, Cxl710Parser &parser) {
#ifdef __DEBUG_FUNC_ENTRY__
- std::cout << __METHOD_NAME__ << " user id:" << stream->m_rx_check.m_user_id << " en:";
+ std::cout << __METHOD_NAME__ << " user id:" << stream->m_rx_check.m_pg_id << " en:";
std::cout << stream->m_rx_check.m_enabled << std::endl;
#endif
@@ -428,7 +428,7 @@ int CFlowStatRuleMgr::compile_stream(const TrexStream * stream, Cxl710Parser &pa
int CFlowStatRuleMgr::add_stream(const TrexStream * stream) {
#ifdef __DEBUG_FUNC_ENTRY__
- std::cout << __METHOD_NAME__ << " user id:" << stream->m_rx_check.m_user_id << std::endl;
+ std::cout << __METHOD_NAME__ << " user id:" << stream->m_rx_check.m_pg_id << std::endl;
#endif
if (! m_api ) {
@@ -468,12 +468,12 @@ int CFlowStatRuleMgr::add_stream(const TrexStream * stream) {
return -1;
}
- return m_user_id_map.add_stream(stream->m_rx_check.m_user_id, l4_proto);
+ return m_user_id_map.add_stream(stream->m_rx_check.m_pg_id, l4_proto);
}
int CFlowStatRuleMgr::del_stream(const TrexStream * stream) {
#ifdef __DEBUG_FUNC_ENTRY__
- std::cout << __METHOD_NAME__ << " user id:" << stream->m_rx_check.m_user_id << std::endl;
+ std::cout << __METHOD_NAME__ << " user id:" << stream->m_rx_check.m_pg_id << std::endl;
#endif
if (no_stat_supported)
@@ -483,7 +483,7 @@ int CFlowStatRuleMgr::del_stream(const TrexStream * stream) {
return 0;
}
- return m_user_id_map.del_stream(stream->m_rx_check.m_user_id);
+ return m_user_id_map.del_stream(stream->m_rx_check.m_pg_id);
}
// called on all streams, when stream start to transmit
@@ -494,7 +494,7 @@ int CFlowStatRuleMgr::del_stream(const TrexStream * stream) {
// Might change the IP ID of the stream packet
int CFlowStatRuleMgr::start_stream(TrexStream * stream, uint16_t &ret_hw_id) {
#ifdef __DEBUG_FUNC_ENTRY__
- std::cout << __METHOD_NAME__ << " user id:" << stream->m_rx_check.m_user_id << std::endl;
+ std::cout << __METHOD_NAME__ << " user id:" << stream->m_rx_check.m_pg_id << std::endl;
#endif
Cxl710Parser parser;
@@ -523,8 +523,8 @@ int CFlowStatRuleMgr::start_stream(TrexStream * stream, uint16_t &ret_hw_id) {
}
// from here, we know the stream need rx stat
- if (m_user_id_map.is_started(stream->m_rx_check.m_user_id)) {
- m_user_id_map.start_stream(stream->m_rx_check.m_user_id); // just increase ref count;
+ if (m_user_id_map.is_started(stream->m_rx_check.m_pg_id)) {
+ m_user_id_map.start_stream(stream->m_rx_check.m_pg_id); // just increase ref count;
} else {
uint16_t hw_id = m_hw_id_map.find_free_hw_id();
if (hw_id > m_max_hw_id) {
@@ -534,14 +534,14 @@ int CFlowStatRuleMgr::start_stream(TrexStream * stream, uint16_t &ret_hw_id) {
printf("Error: %s failed finding free hw_id\n", __func__);
return -1;
} else {
- uint32_t user_id = stream->m_rx_check.m_user_id;
+ uint32_t user_id = stream->m_rx_check.m_pg_id;
m_user_id_map.start_stream(user_id, hw_id);
m_hw_id_map.map(hw_id, user_id);
add_hw_rule(hw_id, m_user_id_map.l4_proto(user_id));
}
}
- uint16_t hw_id = m_user_id_map.get_hw_id(stream->m_rx_check.m_user_id); // can't fail if we got here
+ uint16_t hw_id = m_user_id_map.get_hw_id(stream->m_rx_check.m_pg_id); // can't fail if we got here
parser.set_ip_id(IP_ID_RESERVE_BASE + hw_id);
ret_hw_id = hw_id;
@@ -563,7 +563,7 @@ int CFlowStatRuleMgr::add_hw_rule(uint16_t hw_id, uint8_t proto) {
int CFlowStatRuleMgr::stop_stream(const TrexStream * stream) {
#ifdef __DEBUG_FUNC_ENTRY__
- std::cout << __METHOD_NAME__ << " user id:" << stream->m_rx_check.m_user_id << std::endl;
+ std::cout << __METHOD_NAME__ << " user id:" << stream->m_rx_check.m_pg_id << std::endl;
#endif
if (no_stat_supported)
return -ENOTSUP;
@@ -572,11 +572,11 @@ int CFlowStatRuleMgr::stop_stream(const TrexStream * stream) {
return 0;
}
- if (m_user_id_map.stop_stream(stream->m_rx_check.m_user_id) == 0) {
+ if (m_user_id_map.stop_stream(stream->m_rx_check.m_pg_id) == 0) {
// last stream associated with the entry stopped transmittig.
// remove user_id <--> hw_id mapping
- uint8_t proto = m_user_id_map.l4_proto(stream->m_rx_check.m_user_id);
- uint16_t hw_id = m_user_id_map.get_hw_id(stream->m_rx_check.m_user_id);
+ uint8_t proto = m_user_id_map.l4_proto(stream->m_rx_check.m_pg_id);
+ uint16_t hw_id = m_user_id_map.get_hw_id(stream->m_rx_check.m_pg_id);
if (hw_id >= MAX_FLOW_STATS) {
fprintf(stderr, "Error: %s got wrong hw_id %d from unmap\n", __func__, hw_id);
return -1;
@@ -592,7 +592,7 @@ int CFlowStatRuleMgr::stop_stream(const TrexStream * stream) {
p_user_id->set_rx_counter(port, rx_counter);
p_user_id->set_tx_counter(port, tx_counter);
}
- m_user_id_map.unmap(stream->m_rx_check.m_user_id);
+ m_user_id_map.unmap(stream->m_rx_check.m_pg_id);
m_hw_id_map.unmap(hw_id);
}
}
@@ -610,7 +610,7 @@ bool CFlowStatRuleMgr::dump_json(std::string & json) {
if (m_user_id_map.is_empty()) {
return false;
}
- root["name"] = "rx-stats";
+ root["name"] = "flow_stats";
root["type"] = 0;
Json::Value &data_section = root["data"];
@@ -650,12 +650,12 @@ bool CFlowStatRuleMgr::dump_json(std::string & json) {
std::string str_port = static_cast<std::ostringstream*>( &(std::ostringstream() << int(port) ) )->str();
if (user_id_info->get_rx_counter(port) != 0) {
- data_section[str_user_id]["rx-pkts"][str_port] = Json::Value::UInt64(user_id_info->get_rx_counter(port));
+ data_section[str_user_id]["rx_pkts"][str_port] = Json::Value::UInt64(user_id_info->get_rx_counter(port));
ret = true;
}
if (user_id_info->get_tx_counter(port).get_pkts() != 0) {
- data_section[str_user_id]["tx-pkts"][str_port] = Json::Value::UInt64(user_id_info->get_tx_counter(port).get_pkts());
- data_section[str_user_id]["tx-bytes"][str_port] = Json::Value::UInt64(user_id_info->get_tx_counter(port).get_bytes());
+ data_section[str_user_id]["tx_pkts"][str_port] = Json::Value::UInt64(user_id_info->get_tx_counter(port).get_pkts());
+ data_section[str_user_id]["tx_bytes"][str_port] = Json::Value::UInt64(user_id_info->get_tx_counter(port).get_bytes());
ret = true;
}
}
diff --git a/src/gtest/rpc_test.cpp b/src/gtest/rpc_test.cpp
index 34bb02a8..49a52071 100644
--- a/src/gtest/rpc_test.cpp
+++ b/src/gtest/rpc_test.cpp
@@ -462,7 +462,7 @@ create_simple_stream(Json::Value &obj) {
}
obj["vm"] = Json::arrayValue;
- obj["rx_stats"]["enabled"] = false;
+ obj["flow_stats"]["enabled"] = false;
}
static bool
diff --git a/src/main_dpdk.cpp b/src/main_dpdk.cpp
index 57b3719b..92bfda09 100644
--- a/src/main_dpdk.cpp
+++ b/src/main_dpdk.cpp
@@ -1472,6 +1472,10 @@ void CPhyEthIF::update_link_status(){
rte_eth_link_get(m_port_id, &m_link);
}
+void CPhyEthIF::update_link_status_nowait(){
+ rte_eth_link_get_nowait(m_port_id, &m_link);
+}
+
void CPhyEthIF::add_mac(char * mac){
struct ether_addr mac_addr;
int i=0;
@@ -2645,6 +2649,7 @@ public:
void get_stats(CGlobalStats & stats);
void dump_post_test_stats(FILE *fd);
void dump_config(FILE *fd);
+ void dump_links_status(FILE *fd);
public:
port_cfg_t m_port_cfg;
@@ -2942,10 +2947,6 @@ int CGlobalTRex::ixgbe_start(void){
_if->disable_flow_control();
}
- _if->update_link_status();
-
- _if->dump_link(stdout);
-
_if->add_mac((char *)CGlobalInfo::m_options.get_src_mac_addr(i));
fflush(stdout);
@@ -2956,6 +2957,7 @@ int CGlobalTRex::ixgbe_start(void){
get_ex_drv()->wait_for_stable_link();
if ( !is_all_links_are_up(true) ){
+ dump_links_status(stdout);
rte_exit(EXIT_FAILURE, " "
" one of the link is down \n");
}
@@ -2963,6 +2965,8 @@ int CGlobalTRex::ixgbe_start(void){
get_ex_drv()->wait_after_link_up();
}
+ dump_links_status(stdout);
+
ixgbe_rx_queue_flush();
@@ -3209,6 +3213,14 @@ void CGlobalTRex::dump_config(FILE *fd){
}
+void CGlobalTRex::dump_links_status(FILE *fd){
+ for (int i=0; i<m_max_ports; i++) {
+ CPhyEthIF * _if=&m_ports[i];
+ _if->update_link_status_nowait();
+ _if->dump_link(fd);
+ }
+}
+
void CGlobalTRex::dump_post_test_stats(FILE *fd){
uint64_t pkt_out=0;
diff --git a/src/main_dpdk.h b/src/main_dpdk.h
index 33615636..a475d321 100644
--- a/src/main_dpdk.h
+++ b/src/main_dpdk.h
@@ -89,6 +89,7 @@ class CPhyEthIF {
void start();
void stop();
void update_link_status();
+ void update_link_status_nowait();
bool is_link_up(){
return (m_link.link_status?true:false);
}
diff --git a/src/rpc-server/commands/trex_rpc_cmd_stream.cpp b/src/rpc-server/commands/trex_rpc_cmd_stream.cpp
index cf11f8c6..68bebeb6 100644
--- a/src/rpc-server/commands/trex_rpc_cmd_stream.cpp
+++ b/src/rpc-server/commands/trex_rpc_cmd_stream.cpp
@@ -81,7 +81,7 @@ TrexRpcCmdAddStream::_run(const Json::Value &params, Json::Value &result) {
stream->m_pkt.len = std::max(pkt_binary.size(), 60UL);
/* allocate and init to zero ( with () ) */
- stream->m_pkt.binary = new uint8_t[pkt_binary.size()]();
+ stream->m_pkt.binary = new uint8_t[stream->m_pkt.len]();
if (!stream->m_pkt.binary) {
generate_internal_err(result, "unable to allocate memory");
}
@@ -101,7 +101,7 @@ TrexRpcCmdAddStream::_run(const Json::Value &params, Json::Value &result) {
parse_vm(vm, stream, result);
/* parse RX info */
- const Json::Value &rx = parse_object(section, "rx_stats", result);
+ const Json::Value &rx = parse_object(section, "flow_stats", result);
stream->m_rx_check.m_enabled = parse_bool(rx, "enabled", result);
@@ -114,7 +114,7 @@ TrexRpcCmdAddStream::_run(const Json::Value &params, Json::Value &result) {
generate_parse_err(result, "RX stats is not supported on this interface");
}
- stream->m_rx_check.m_user_id = parse_int(rx, "stream_id", result);
+ stream->m_rx_check.m_pg_id = parse_int(rx, "stream_id", result);
stream->m_rx_check.m_seq_enabled = parse_bool(rx, "seq_enabled", result);
stream->m_rx_check.m_latency = parse_bool(rx, "latency_enabled", result);
}
diff --git a/src/stateless/cp/trex_stream.h b/src/stateless/cp/trex_stream.h
index 1abf0c04..ded6363e 100644
--- a/src/stateless/cp/trex_stream.h
+++ b/src/stateless/cp/trex_stream.h
@@ -513,7 +513,7 @@ public:
bool m_enabled;
bool m_seq_enabled;
bool m_latency;
- uint32_t m_user_id;
+ uint32_t m_pg_id;
uint16_t m_hw_id;
} m_rx_check;