summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorHanoh Haim <hhaim@cisco.com>2016-02-11 18:06:29 +0200
committerHanoh Haim <hhaim@cisco.com>2016-02-11 18:06:29 +0200
commit06dbed66bb0302f0a4c11fe5b7e65ee323498d55 (patch)
tree8e3c4883debcd05ee5d11de3d4cc194cc9ce8af9
parentb136fa9aa47aa0623683bfe733b46e28eeccd1da (diff)
support split by var
-rw-r--r--scripts/automation/regression/unit_tests/functional_tests/stl_basic_tests.py4
-rw-r--r--scripts/automation/trex_control_plane/stl/trex_stl_lib/trex_stl_packet_builder_scapy.py12
-rw-r--r--scripts/exp/udp_1pkt_tuple_gen_split.pcapbin0 -> 252 bytes
-rw-r--r--scripts/stl/udp_1pkt_tuple_gen_split.py48
4 files changed, 61 insertions, 3 deletions
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 9670b795..9d7534ec 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
@@ -147,7 +147,7 @@ class CStlBasic_Test(functional_general_test.CGeneralFunctional_Test):
self.golden_run("basic_tuple_gen", "imix_tuple_gen", "-m 50kpps --limit 500 --cores 8", silent = False)
def test_stl_profiles (self):
- p = [
+ p0 = [
["udp_1pkt_1mac_override.py","-m 1 -l 50",True],
["syn_attack.py","-m 1 -l 50",False], # can't compare random now
["udp_1pkt_1mac.py","-m 1 -l 50",True],
@@ -178,7 +178,7 @@ class CStlBasic_Test(functional_general_test.CGeneralFunctional_Test):
];
- p0 =[ ["udp_1pkt_pcap_relative_path.py","-m 1 -l 3",True] ]
+ p1 = [ ["udp_1pkt_tuple_gen_split.py","-m 1 -l 3",True] ]
for obj in p:
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 0b90d3e1..f1462ede 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
@@ -153,12 +153,14 @@ class CTRexScTrimPacketSize(CTRexScriptsBase):
if min_pkt_size > max_pkt_size:
raise CTRexPacketBuildException(-11, 'CTRexScTrimPacketSize min_pkt_size is bigger than max_pkt_size ');
+
class CTRexScRaw(CTRexScriptsBase):
"""
raw instructions
"""
- def __init__(self,list_of_commands=None):
+ def __init__(self,list_of_commands=None,split_by_field=None):
super(CTRexScRaw, self).__init__()
+ self.split_by_field = split_by_field
if list_of_commands==None:
self.commands =[]
else:
@@ -819,6 +821,14 @@ class CScapyTRexPktBuilder(CTrexPktBuilderInterface):
for desc in obj.commands:
self.vm_low_level.add_ins(desc.get_obj());
+ # set split_by_var
+ if obj.split_by_field :
+ assert type(obj.split_by_field)==str, "type of split by var should be string"
+ #if not vars.has_key(obj.split_by_field):
+ # raise CTRexPacketBuildException(-11,("variable %s does not exists. change split_by_var args ") % (var_name) );
+
+ self.vm_low_level.split_by_var = obj.split_by_field
+
def _pkt_layer_offset (self,layer_name):
assert self.pkt != None, 'empty packet'
diff --git a/scripts/exp/udp_1pkt_tuple_gen_split.pcap b/scripts/exp/udp_1pkt_tuple_gen_split.pcap
new file mode 100644
index 00000000..8ad8d994
--- /dev/null
+++ b/scripts/exp/udp_1pkt_tuple_gen_split.pcap
Binary files differ
diff --git a/scripts/stl/udp_1pkt_tuple_gen_split.py b/scripts/stl/udp_1pkt_tuple_gen_split.py
new file mode 100644
index 00000000..5a6feb4d
--- /dev/null
+++ b/scripts/stl/udp_1pkt_tuple_gen_split.py
@@ -0,0 +1,48 @@
+from trex_stl_lib.api import *
+
+
+# split the range of IP to cores
+#
+class STLS1(object):
+
+ def __init__ (self):
+ self.fsize =64;
+
+ def create_stream (self):
+ # create a base packet and pad it to size
+ size = self.fsize - 4; # no FCS
+
+ base_pkt = Ether()/IP(src="16.0.0.1",dst="48.0.0.1")/UDP(dport=12,sport=1025)
+
+ pad = max(0, size - len(base_pkt)) * 'x'
+
+ vm = CTRexScRaw( [ STLVmTupleGen ( ip_min="16.0.0.1", ip_max="16.0.0.10",
+ port_min=1025, port_max=65535,
+ name="tuple"), # define tuple gen
+
+ STLVmWrFlowVar (fv_name="tuple.ip", pkt_offset= "IP.src" ), # write ip to packet IP.src
+ STLVmFixIpv4(offset = "IP"), # fix checksum
+ STLVmWrFlowVar (fv_name="tuple.port", pkt_offset= "UDP.sport" ) #write udp.port
+ ]
+ ,split_by_field = "tuple" # split to cores base on the tuple generator
+ );
+
+ pkt = STLPktBuilder(pkt = base_pkt/pad,
+ vm = vm)
+
+ return STLStream(packet = pkt,
+ mode = STLTXCont())
+
+
+
+ def get_streams (self, direction = 0):
+ # create 1 stream
+ return [ self.create_stream() ]
+
+
+# dynamic load - used for trex console or simulator
+def register():
+ return STLS1()
+
+
+