diff options
author | 2016-03-07 12:54:33 +0200 | |
---|---|---|
committer | 2016-03-07 12:54:33 +0200 | |
commit | fadf9cb9e331f70157b90f79d9e2b10a0471013e (patch) | |
tree | f05647626e0446c9f8691659c4a51060a3918805 /scripts | |
parent | 1f6826dda8ffa724f8ba8c3dc4b22883d5c99603 (diff) | |
parent | ea61eabf9f76ef4dea1ad2a4f0cd5cd8f367bd02 (diff) |
Merge scapy remove crypto. for ADS server
Diffstat (limited to 'scripts')
20 files changed, 155 insertions, 127 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 Binary files differindex 34a2e9b6..b13275ee 100644 --- a/scripts/exp/pcap.pcap +++ b/scripts/exp/pcap.pcap diff --git a/scripts/exp/pcap_with_vm.pcap b/scripts/exp/pcap_with_vm.pcap Binary files differindex a278dd8e..a7a2d2ba 100644 --- a/scripts/exp/pcap_with_vm.pcap +++ b/scripts/exp/pcap_with_vm.pcap diff --git a/scripts/exp/syn_attack.pcap b/scripts/exp/syn_attack.pcap Binary files differindex aa420d2c..84da36a7 100644 --- a/scripts/exp/syn_attack.pcap +++ b/scripts/exp/syn_attack.pcap diff --git a/scripts/exp/udp_1pkt_range_clients_split_garp.pcap b/scripts/exp/udp_1pkt_range_clients_split_garp.pcap Binary files differindex dde0c6dd..627bcd54 100644 --- a/scripts/exp/udp_1pkt_range_clients_split_garp.pcap +++ b/scripts/exp/udp_1pkt_range_clients_split_garp.pcap 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: [ |