summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorHanoh Haim <hhaim@cisco.com>2016-03-14 13:37:44 +0200
committerHanoh Haim <hhaim@cisco.com>2016-03-14 13:37:44 +0200
commitd82201e2da3beb0e81e0c8ba30600d87f1b8276f (patch)
tree0fadfe1cbedba4c0a56b0aba49cf54c531c4f02e
parent33386099a94c8940616cdd9c3f674f0ee63d8af6 (diff)
some cleanup for API doc
-rw-r--r--scripts/automation/regression/functional_tests/scapy_pkt_builder_test.py60
-rw-r--r--scripts/automation/trex_control_plane/doc_stl/api/client_code.rst31
-rw-r--r--scripts/automation/trex_control_plane/doc_stl/api/field_engine.rst164
-rw-r--r--scripts/automation/trex_control_plane/doc_stl/api/index.rst20
-rw-r--r--scripts/automation/trex_control_plane/doc_stl/api/profile_code.rst128
-rw-r--r--scripts/automation/trex_control_plane/doc_stl/index.rst2
-rw-r--r--scripts/automation/trex_control_plane/stl/trex_stl_lib/api.py12
-rw-r--r--scripts/automation/trex_control_plane/stl/trex_stl_lib/trex_stl_client.py22
-rwxr-xr-xscripts/automation/trex_control_plane/stl/trex_stl_lib/trex_stl_hltapi.py104
-rw-r--r--scripts/automation/trex_control_plane/stl/trex_stl_lib/trex_stl_packet_builder_scapy.py331
-rw-r--r--scripts/automation/trex_control_plane/stl/trex_stl_lib/trex_stl_port.py4
-rw-r--r--scripts/automation/trex_control_plane/stl/trex_stl_lib/trex_stl_std.py2
-rw-r--r--scripts/automation/trex_control_plane/stl/trex_stl_lib/trex_stl_streams.py55
-rw-r--r--scripts/stl/burst_split.py2
-rw-r--r--scripts/stl/syn_attack.py2
-rw-r--r--scripts/stl/udp_1pkt_1mac.py2
-rw-r--r--scripts/stl/udp_1pkt_1mac_override.py2
-rw-r--r--scripts/stl/udp_1pkt_1mac_step.py2
-rw-r--r--scripts/stl/udp_1pkt_ipv6_in_ipv4.py2
-rw-r--r--scripts/stl/udp_1pkt_mac.py2
-rw-r--r--scripts/stl/udp_1pkt_mac_mask1.py2
-rw-r--r--scripts/stl/udp_1pkt_mac_mask2.py2
-rw-r--r--scripts/stl/udp_1pkt_mac_mask3.py2
-rw-r--r--scripts/stl/udp_1pkt_mac_mask5.py2
-rw-r--r--scripts/stl/udp_1pkt_mac_step.py2
-rw-r--r--scripts/stl/udp_1pkt_mpls_vm.py2
-rw-r--r--scripts/stl/udp_1pkt_range_clients.py2
-rw-r--r--scripts/stl/udp_1pkt_range_clients_split.py2
-rw-r--r--scripts/stl/udp_1pkt_range_clients_split_garp.py2
-rw-r--r--scripts/stl/udp_1pkt_simple_test.py2
-rw-r--r--scripts/stl/udp_1pkt_simple_test2.py2
-rw-r--r--scripts/stl/udp_1pkt_tuple_gen.py2
-rw-r--r--scripts/stl/udp_1pkt_tuple_gen_split.py2
-rw-r--r--scripts/stl/udp_inc_len_9k.py2
-rw-r--r--scripts/stl/udp_rand_len_9k.py2
35 files changed, 792 insertions, 187 deletions
diff --git a/scripts/automation/regression/functional_tests/scapy_pkt_builder_test.py b/scripts/automation/regression/functional_tests/scapy_pkt_builder_test.py
index eaff9530..14f0014c 100644
--- a/scripts/automation/regression/functional_tests/scapy_pkt_builder_test.py
+++ b/scripts/automation/regression/functional_tests/scapy_pkt_builder_test.py
@@ -26,12 +26,12 @@ class CTRexPktBuilderSanitySCapy_Test(pkt_bld_general_test.CGeneralPktBld_Test):
pass
def test_simple_vm1(self):
- raw1 = CTRexScRaw( [ CTRexVmDescFlowVar(name="a",min_value="16.0.0.1",max_value="16.0.0.10",init_value="16.0.0.1",size=4,op="inc"),
- CTRexVmDescWrFlowVar (fv_name="a",pkt_offset= "IP.src"),
- CTRexVmDescFixIpv4(offset = "IP")]
+ raw1 = STLScVmRaw( [ STLVmFlowVar(name="a",min_value="16.0.0.1",max_value="16.0.0.10",init_value="16.0.0.1",size=4,op="inc"),
+ STLVmWrFlowVar(fv_name="a",pkt_offset= "IP.src"),
+ STLVmFixIpv4(offset = "IP")]
);
- pkt_builder = CScapyTRexPktBuilder();
+ pkt_builder = STLPktBuilder();
py='5'*128
pkt=Ether()/ \
@@ -53,7 +53,7 @@ class CTRexPktBuilderSanitySCapy_Test(pkt_bld_general_test.CGeneralPktBld_Test):
def test_simple_no_vm1(self):
- pkt_builder = CScapyTRexPktBuilder();
+ pkt_builder = STLPktBuilder();
py='5'*128
pkt=Ether()/ \
@@ -78,21 +78,21 @@ class CTRexPktBuilderSanitySCapy_Test(pkt_bld_general_test.CGeneralPktBld_Test):
pkt = Ether()/IP()/UDP()
- pkt_builder = CScapyTRexPktBuilder(pkt = pkt);
+ pkt_builder = STLPktBuilder(pkt = pkt);
assert_equal( pkt_builder.is_default_src_mac () ,True)
assert_equal( pkt_builder.is_default_dst_mac () ,True)
pkt = Ether(src="00:00:00:00:00:01")/IP()/UDP()
- pkt_builder = CScapyTRexPktBuilder(pkt = pkt);
+ pkt_builder = STLPktBuilder(pkt = pkt);
assert_equal( pkt_builder.is_default_src_mac (), False)
assert_equal( pkt_builder.is_default_dst_mac (), True)
pkt = Ether(dst="00:00:00:00:00:01")/IP()/UDP()
- pkt_builder = CScapyTRexPktBuilder(pkt = pkt);
+ pkt_builder = STLPktBuilder(pkt = pkt);
assert_equal( pkt_builder.is_default_src_mac (),True)
assert_equal( pkt_builder.is_default_dst_mac (),False)
@@ -193,12 +193,12 @@ class CTRexPktBuilderSanitySCapy_Test(pkt_bld_general_test.CGeneralPktBld_Test):
def test_simple_vm2(self):
- raw1 = CTRexScRaw( [ CTRexVmDescFlowVar(name="my_valn",min_value=0,max_value=10,init_value=2,size=1,op="inc"),
- CTRexVmDescWrFlowVar (fv_name="my_valn",pkt_offset= "802|1Q.vlan" ,offset_fixup=3) # fix the offset as valn is bitfield and not supported right now
+ raw1 = STLScVmRaw( [ STLVmFlowVar(name="my_valn",min_value=0,max_value=10,init_value=2,size=1,op="inc"),
+ STLVmWrFlowVar (fv_name="my_valn",pkt_offset= "802|1Q.vlan" ,offset_fixup=3) # fix the offset as valn is bitfield and not supported right now
]
);
- pkt_builder = CScapyTRexPktBuilder();
+ pkt_builder = STLPktBuilder();
py='5'*128
pkt=Ether()/ \
@@ -217,12 +217,12 @@ class CTRexPktBuilderSanitySCapy_Test(pkt_bld_general_test.CGeneralPktBld_Test):
def test_simple_vm3(self):
try:
- raw1 = CTRexScRaw( [ CTRexVmDescFlowVar(name="my_valn",min_value=0,max_value=10,init_value=2,size=1,op="inc"),
- CTRexVmDescWrFlowVar (fv_name="my_valn_err",pkt_offset= "802|1Q.vlan" ,offset_fixup=3) # fix the offset as valn is bitfield and not supported right now
+ raw1 = STLScVmRaw( [ STLVmFlowVar(name="my_valn",min_value=0,max_value=10,init_value=2,size=1,op="inc"),
+ STLVmWrFlowVar(fv_name="my_valn_err",pkt_offset= "802|1Q.vlan" ,offset_fixup=3) # fix the offset as valn is bitfield and not supported right now
]
);
- pkt_builder = CScapyTRexPktBuilder();
+ pkt_builder = STLPktBuilder();
py='5'*128
pkt=Ether()/ \
@@ -241,13 +241,13 @@ class CTRexPktBuilderSanitySCapy_Test(pkt_bld_general_test.CGeneralPktBld_Test):
assert_equal(str(e), "[errcode:-11] 'variable my_valn_err does not exists '")
def test_simple_tuple_gen(self):
- vm = CTRexScRaw( [ CTRexVmDescTupleGen (name="tuple"), # define tuple gen
- CTRexVmDescWrFlowVar (fv_name="tuple.ip", pkt_offset= "IP.src" ), # write ip to packet IP.src
- CTRexVmDescFixIpv4(offset = "IP"), # fix checksum
- CTRexVmDescWrFlowVar (fv_name="tuple.port", pkt_offset= "UDP.sport" ) #write udp.port
- ]
- );
- pkt_builder = CScapyTRexPktBuilder();
+ vm = STLScVmRaw( [ STLVmTupleGen(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
+ ]
+ );
+ pkt_builder = STLPktBuilder();
py='5'*128
pkt=Ether()/ \
@@ -278,14 +278,14 @@ class CTRexPktBuilderSanitySCapy_Test(pkt_bld_general_test.CGeneralPktBld_Test):
l3_len_fix =-(len(p_l2));
l4_len_fix =-(len(p_l2/p_l3));
- vm = CTRexScRaw( [ CTRexVmDescFlowVar(name="fv_rand", min_value=64, max_value=len(pkt), size=2, op="random"),
- CTRexVmDescTrimPktSize("fv_rand"), # total packet size
- CTRexVmDescWrFlowVar(fv_name="fv_rand", pkt_offset= "IP.len", add_val=l3_len_fix),
- CTRexVmDescFixIpv4(offset = "IP"), # fix checksum
- CTRexVmDescWrFlowVar(fv_name="fv_rand", pkt_offset= "UDP.len", add_val=l4_len_fix)
+ vm = STLScVmRaw( [ STLVmFlowVar(name="fv_rand", min_value=64, max_value=len(pkt), size=2, op="random"),
+ STLVmTrimPktSize("fv_rand"), # total packet size
+ STLVmWrFlowVar(fv_name="fv_rand", pkt_offset= "IP.len", add_val=l3_len_fix),
+ STLVmFixIpv4(offset = "IP"), # fix checksum
+ STLVmWrFlowVar(fv_name="fv_rand", pkt_offset= "UDP.len", add_val=l4_len_fix)
]
)
- pkt_builder = CScapyTRexPktBuilder();
+ pkt_builder = STLPktBuilder();
# set packet
pkt_builder.set_packet(pkt);
@@ -308,7 +308,7 @@ class CTRexPktBuilderSanitySCapy_Test(pkt_bld_general_test.CGeneralPktBld_Test):
def test_simple_pkt_loader1(self):
- pkt_builder = CScapyTRexPktBuilder(pkt = "functional_tests/golden/udp_590.cap", build_raw = False);
+ pkt_builder = STLPktBuilder(pkt = "functional_tests/golden/udp_590.cap", build_raw = False);
print ""
pkt_builder.dump_as_hex()
r = pkt_builder.pkt_raw
@@ -322,12 +322,12 @@ class CTRexPktBuilderSanitySCapy_Test(pkt_bld_general_test.CGeneralPktBld_Test):
def test_simple_pkt_loader2(self):
- pkt_builder = CScapyTRexPktBuilder(pkt = "functional_tests/golden/basic_imix_golden.cap");
+ pkt_builder = STLPktBuilder(pkt = "functional_tests/golden/basic_imix_golden.cap");
assert_equal(pkt_builder.pkt_layers_desc (), "Ethernet:IP:UDP:Raw");
def test_simple_pkt_loader3(self):
- #pkt_builder = CScapyTRexPktBuilder(pkt = "stl/golden/basic_imix_golden.cap");
+ #pkt_builder = STLPktBuilder(pkt = "stl/golden/basic_imix_golden.cap");
#r = pkt_builder.pkt_raw
#print ""
#hexdump(str(r))
diff --git a/scripts/automation/trex_control_plane/doc_stl/api/client_code.rst b/scripts/automation/trex_control_plane/doc_stl/api/client_code.rst
index 29d524e1..bc9d521a 100644
--- a/scripts/automation/trex_control_plane/doc_stl/api/client_code.rst
+++ b/scripts/automation/trex_control_plane/doc_stl/api/client_code.rst
@@ -1,6 +1,6 @@
-Module documentation
-================================
+TRex Client Module
+==================
TRex Client is an object to access TRex server. It is per user. Each user can own number of interfaces.
Multi user can interact with one TRex server each user should own a different set of interfaces.
@@ -11,6 +11,31 @@ The API has two type of API
1. Normal API
2. xx_line: this api get a line like the Console and parse it and call the low level api
+Example1::
+
+ c = STLClient()
+
+ try:
+ # connect to server
+ c.connect()
+
+ # prepare our ports (my machine has 0 <--> 1 with static route)
+ c.reset(ports = [0, 1])
+
+ # add both streams to ports
+ c.add_streams(s1, ports = [0])
+
+ # clear the stats before injecting
+ c.clear_stats()
+
+ c.start(ports = [0, 1], mult = "5mpps", duration = 10)
+
+ # block until done
+ c.wait_on_traffic(ports = [0, 1])
+
+ finally:
+ c.disconnect()
+
STLClient class
---------------
@@ -125,7 +150,7 @@ Example3: Console like::
Example4: Load profile from a file::
-def simple ():
+ def simple ():
# create client
#verbose_level = LoggerApi.VERBOSE_HIGH
diff --git a/scripts/automation/trex_control_plane/doc_stl/api/field_engine.rst b/scripts/automation/trex_control_plane/doc_stl/api/field_engine.rst
new file mode 100644
index 00000000..271ff058
--- /dev/null
+++ b/scripts/automation/trex_control_plane/doc_stl/api/field_engine.rst
@@ -0,0 +1,164 @@
+
+Field Engine modules
+=======================
+
+The Field Engine (FE) has limited number of instructions/operation for supporting most use cases.
+There is a plan to add LuaJIT to be more flexible at the cost of performance.
+The FE can allocate stream variables in a Stream context, write a stream variable to a packet offset, change packet size, etc.
+
+*Some examples for what can be done:*
+
+* Change ipv4.tos 1-10
+* Change packet size to be random in the range 64-9K
+* Create range of flows (change src_ip, dest_ip, src_port, dest_port)
+* Update IPv4 checksum
+
+
+for example this snippet will create SYN Attack::
+
+ # create attack from random src_ip from 16.0.0.0-18.0.0.254 and random src_port 1025-65000
+ # attack 48.0.0.1 server
+
+ def create_stream (self):
+
+
+ # TCP SYN
+ base_pkt = Ether()/IP(dst="48.0.0.1")/TCP(dport=80,flags="S")
+
+
+ # vm
+ vm = CTRexScRaw( [ STLVmFlowVar(name="ip_src",
+ min_value="16.0.0.0",
+ max_value="18.0.0.254",
+ size=4, op="random"),
+
+ STLVmFlowVar(name="src_port",
+ min_value=1025,
+ max_value=65000,
+ size=2, op="random"),
+
+ STLVmWrFlowVar(fv_name="ip_src", pkt_offset= "IP.src" ),
+
+ STLVmFixIpv4(offset = "IP"), # fix checksum
+
+ STLVmWrFlowVar(fv_name="src_port",
+ pkt_offset= "TCP.sport") # fix udp len
+
+ ]
+ )
+
+ pkt = STLPktBuilder(pkt = base_pkt,
+ vm = vm)
+
+ return STLStream(packet = pkt,
+ random_seed = 0x1234,# can be remove. will give the same random value any run
+ mode = STLTXCont())
+
+
+
+
+CTRexScRaw class
+----------------
+
+Aggregate a raw instructions objects
+
+.. autoclass:: trex_stl_lib.trex_stl_packet_builder_scapy.CTRexScRaw
+ :members:
+ :member-order: bysource
+
+
+STLVmFlowVar
+------------
+
+It is alias for CTRexVmDescFlowVar
+
+.. autoclass:: trex_stl_lib.trex_stl_packet_builder_scapy.CTRexVmDescFlowVar
+ :members:
+ :member-order: bysource
+
+STLVmWrMaskFlowVar
+------------------
+
+It is alias for CTRexVmDescWrMaskFlowVar
+
+.. autoclass:: trex_stl_lib.trex_stl_packet_builder_scapy.CTRexVmDescWrMaskFlowVar
+ :members:
+ :member-order: bysource
+
+STLVmFixIpv4
+------------------
+
+It is alias for CTRexVmDescFixIpv4
+
+.. autoclass:: trex_stl_lib.trex_stl_packet_builder_scapy.CTRexVmDescFixIpv4
+ :members:
+ :member-order: bysource
+
+
+STLVmTrimPktSize
+------------------
+
+It is alias for CTRexVmDescTrimPktSize
+
+.. autoclass:: trex_stl_lib.trex_stl_packet_builder_scapy.CTRexVmDescTrimPktSize
+ :members:
+ :member-order: bysource
+
+STLVmTupleGen
+------------------
+
+It is alias for CTRexVmDescTupleGen
+
+.. autoclass:: trex_stl_lib.trex_stl_packet_builder_scapy.CTRexVmDescTupleGen
+ :members:
+ :member-order: bysource
+
+STLVmTupleGen
+------------------
+
+It is alias for STLVmTupleGen
+
+.. autoclass:: trex_stl_lib.trex_stl_packet_builder_scapy.CTRexVmDescTupleGen
+ :members:
+ :member-order: bysource
+
+
+
+Field Engine snippet
+--------------------
+
+Example1::
+
+
+ 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.2",
+ 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
+ ]
+ );
+
+ pkt = STLPktBuilder(pkt = base_pkt/pad,
+ vm = vm)
+
+
+
+Example2::
+
+ #range of source mac-addr
+
+ 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( [ STLVmFlowVar(name="mac_src", min_value=1, max_value=30, size=2, op="dec",step=1),
+ STLVmWrMaskFlowVar(fv_name="mac_src", pkt_offset= 11,pkt_cast_size=1, mask=0xff)
+ ]
+ )
+
+
diff --git a/scripts/automation/trex_control_plane/doc_stl/api/index.rst b/scripts/automation/trex_control_plane/doc_stl/api/index.rst
index 4e4be230..733a896d 100644
--- a/scripts/automation/trex_control_plane/doc_stl/api/index.rst
+++ b/scripts/automation/trex_control_plane/doc_stl/api/index.rst
@@ -2,12 +2,28 @@
TRex Stateless API Reference
============================
-**TRex Modules**
+**TRex Client: STLClient**
.. toctree::
:maxdepth: 4
client_code
-**TRex JSON Template**
+**TRex Traffic profile: STLProfile,STLStream **
+
+.. toctree::
+ :maxdepth: 4
+
+ profile_code
+
+
+**TRex Field Engine: **
+
+.. toctree::
+ :maxdepth: 4
+
+ field_engine
+
+
+
diff --git a/scripts/automation/trex_control_plane/doc_stl/api/profile_code.rst b/scripts/automation/trex_control_plane/doc_stl/api/profile_code.rst
new file mode 100644
index 00000000..9484f565
--- /dev/null
+++ b/scripts/automation/trex_control_plane/doc_stl/api/profile_code.rst
@@ -0,0 +1,128 @@
+
+Traffic profile modules
+=======================
+
+TRex STLProfile profile include a list of STLStream. The profile is a ``program`` of streams with a relation betwean the streams.
+Each stream can trigger another stream. Stream can be given a name for a full examples see here Manual_.
+
+.. _Manual: ../draft_trex_stateless1.html
+
+
+for example::
+
+ 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)
+ base_pkt1 = Ether()/IP(src="16.0.0.2",dst="48.0.0.1")/UDP(dport=12,sport=1025)
+ base_pkt2 = Ether()/IP(src="16.0.0.3",dst="48.0.0.1")/UDP(dport=12,sport=1025)
+ pad = max(0, size - len(base_pkt)) * 'x'
+
+
+ return STLProfile( [ STLStream( isg = 1.0, # star in delay in usec
+ packet = STLPktBuilder(pkt = base_pkt/pad),
+ mode = STLTXCont( pps = 10),
+ ),
+
+ STLStream( isg = 2.0,
+ packet = STLPktBuilder(pkt = base_pkt1/pad),
+ mode = STLTXCont( pps = 20),
+ ),
+
+ STLStream( isg = 3.0,
+ packet = STLPktBuilder(pkt = base_pkt2/pad),
+ mode = STLTXCont( pps = 30)
+
+ )
+ ]).get_streams()
+
+
+STLProfile class
+----------------
+
+.. autoclass:: trex_stl_lib.trex_stl_streams.STLProfile
+ :members:
+ :member-order: bysource
+
+STLStream
+---------
+
+.. autoclass:: trex_stl_lib.trex_stl_streams.STLStream
+ :members:
+ :member-order: bysource
+
+
+STLStream modes
+----------------
+
+.. autoclass:: trex_stl_lib.trex_stl_streams.STLTXMode
+ :members:
+ :member-order: bysource
+
+.. autoclass:: trex_stl_lib.trex_stl_streams.STLTXCont
+ :members:
+ :member-order: bysource
+
+.. autoclass:: trex_stl_lib.trex_stl_streams.STLTXSingleBurst
+ :members:
+ :member-order: bysource
+
+.. autoclass:: trex_stl_lib.trex_stl_streams.STLTXMultiBurst
+ :members:
+ :member-order: bysource
+
+.. autoclass:: trex_stl_lib.trex_stl_streams.STLFlowStats
+ :members:
+ :member-order: bysource
+
+
+STLProfile snippet
+------------------
+
+
+Example1::
+
+ 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)
+ base_pkt1 = Ether()/IP(src="16.0.0.2",dst="48.0.0.1")/UDP(dport=12,sport=1025)
+ base_pkt2 = Ether()/IP(src="16.0.0.3",dst="48.0.0.1")/UDP(dport=12,sport=1025)
+ pad = max(0, size - len(base_pkt)) * 'x'
+
+
+ return STLProfile( [ STLStream( isg = 10.0, # star in delay
+ name ='S0',
+ packet = STLPktBuilder(pkt = base_pkt/pad),
+ mode = STLTXSingleBurst( pps = 10, total_pkts = 10),
+ next = 'S1'), # point to next stream
+
+ STLStream( self_start = False, # stream is disabled enable trow S0
+ name ='S1',
+ packet = STLPktBuilder(pkt = base_pkt1/pad),
+ mode = STLTXSingleBurst( pps = 10, total_pkts = 20),
+ next = 'S2' ),
+
+ STLStream( self_start = False, # stream is disabled enable trow S0
+ name ='S2',
+ packet = STLPktBuilder(pkt = base_pkt2/pad),
+ mode = STLTXSingleBurst( pps = 10, total_pkts = 30 )
+ )
+ ]).get_streams()
+
+
+Example2::
+
+ class STLS1(object):
+
+ def get_streams (self, direction = 0):
+ return [STLStream(packet = STLPktBuilder(pkt ="stl/yaml/udp_64B_no_crc.pcap"),
+ mode = STLTXCont(pps=1000),
+ flow_stats = STLFlowStats(pg_id = 7)),
+
+ STLStream(packet = STLPktBuilder(pkt ="stl/yaml/udp_594B_no_crc.pcap"),
+ mode = STLTXCont(pps=5000),
+ flow_stats = STLFlowStats(pg_id = 12))
+ ]
+
+
+
diff --git a/scripts/automation/trex_control_plane/doc_stl/index.rst b/scripts/automation/trex_control_plane/doc_stl/index.rst
index 5437f1f9..b8a1a8e5 100644
--- a/scripts/automation/trex_control_plane/doc_stl/index.rst
+++ b/scripts/automation/trex_control_plane/doc_stl/index.rst
@@ -16,7 +16,7 @@ How to Install
.. toctree::
:maxdepth: 2
-* TODO[]
+* **TODO**
API Reference
diff --git a/scripts/automation/trex_control_plane/stl/trex_stl_lib/api.py b/scripts/automation/trex_control_plane/stl/trex_stl_lib/api.py
index d19dcaf0..9b8f9f79 100644
--- a/scripts/automation/trex_control_plane/stl/trex_stl_lib/api.py
+++ b/scripts/automation/trex_control_plane/stl/trex_stl_lib/api.py
@@ -10,18 +10,6 @@ from trex_stl_streams import *
from trex_stl_packet_builder_scapy import *
from scapy.all import *
-# packet builder
-STLPktBuilder = CScapyTRexPktBuilder
-
-# VM
-STLVmFlowVar = CTRexVmDescFlowVar
-STLVmWrFlowVar = CTRexVmDescWrFlowVar
-STLVmWrMaskFlowVar = CTRexVmDescWrMaskFlowVar
-STLVmFixIpv4 = CTRexVmDescFixIpv4
-STLVmTrimPktSize = CTRexVmDescTrimPktSize
-STLVmTupleGen = CTRexVmDescTupleGen
-STLVmTrimPktSize = CTRexVmDescTrimPktSize
-
# simulator
from trex_stl_sim import STLSim
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 c7503ab0..1d109988 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
@@ -406,11 +406,25 @@ class STLClient(object):
async_port : int
the ASYNC port
- :return:
- None
+ For example::
- :raises:
- None
+ # connect to local TRex server
+ c = STLClient()
+
+ # connect to remote server trex-remote-server
+ c = STLClient(server = "trex-remote-server" )
+
+ c = STLClient(server = "10.0.0.10" )
+
+ # verbose mode
+ c = STLClient(server = "10.0.0.10", verbose_level = LoggerApi.VERBOSE_HIGH )
+
+ # change user name
+ c = STLClient(username = "root",server = "10.0.0.10", verbose_level = LoggerApi.VERBOSE_HIGH )
+
+ c.connect()
+
+ c.disconnect()
"""
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 a74824d2..81676df8 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
@@ -846,7 +846,7 @@ def generate_packet(**user_kwargs):
add_val = mac_src - 0x7fffffff
var_name = '%s_%s_%s_%s' % ('inc', 4, count, step)
if var_name not in vm_variables_cache:
- vm_cmds.append(CTRexVmDescFlowVar(name = var_name, size = 4, op = 'inc', step = step,
+ vm_cmds.append(STLVmFlowVar(name = var_name, size = 4, op = 'inc', step = step,
min_value = 0x7fffffff,
max_value = 0x7fffffff + count * step))
vm_variables_cache[var_name] = True
@@ -854,17 +854,17 @@ def generate_packet(**user_kwargs):
add_val = mac_src - 0x7fffffff
var_name = '%s_%s_%s_%s' % ('dec', 4, count, step)
if var_name not in vm_variables_cache:
- vm_cmds.append(CTRexVmDescFlowVar(name = var_name, size = 4, op = 'dec', step = step,
+ vm_cmds.append(STLVmFlowVar(name = var_name, size = 4, op = 'dec', step = step,
min_value = 0x7fffffff - count * step,
max_value = 0x7fffffff))
vm_variables_cache[var_name] = True
elif kwargs['mac_src_mode'] == 'random':
add_val = 0
var_name = 'mac_src_random'
- vm_cmds.append(CTRexVmDescFlowVar(name = var_name, size = 4, op = 'random', max_value = 0xffffffff))
+ vm_cmds.append(STLVmFlowVar(name = var_name, size = 4, op = 'random', max_value = 0xffffffff))
else:
raise STLError('mac_src_mode %s is not supported' % kwargs['mac_src_mode'])
- vm_cmds.append(CTRexVmDescWrFlowVar(fv_name = var_name, pkt_offset = 'Ethernet.src', offset_fixup = 2, add_val = add_val))
+ vm_cmds.append(STLVmWrFlowVar(fv_name = var_name, pkt_offset = 'Ethernet.src', offset_fixup = 2, add_val = add_val))
if kwargs['mac_dst_mode'] != 'fixed':
count = int(kwargs['mac_dst_count']) - 1
@@ -881,7 +881,7 @@ def generate_packet(**user_kwargs):
add_val = mac_dst - 0x7fffffff
var_name = '%s_%s_%s_%s' % ('inc', 4, count, step)
if var_name not in vm_variables_cache:
- vm_cmds.append(CTRexVmDescFlowVar(name = var_name, size = 4, op = 'inc', step = step,
+ vm_cmds.append(STLVmFlowVar(name = var_name, size = 4, op = 'inc', step = step,
min_value = 0x7fffffff,
max_value = 0x7fffffff + count * step))
vm_variables_cache[var_name] = True
@@ -889,17 +889,17 @@ def generate_packet(**user_kwargs):
add_val = mac_dst - 0x7fffffff
var_name = '%s_%s_%s_%s' % ('dec', 4, count, step)
if var_name not in vm_variables_cache:
- vm_cmds.append(CTRexVmDescFlowVar(name = var_name, size = 4, op = 'dec', step = step,
+ vm_cmds.append(STLVmFlowVar(name = var_name, size = 4, op = 'dec', step = step,
min_value = 0x7fffffff - count * step,
max_value = 0x7fffffff))
vm_variables_cache[var_name] = True
elif kwargs['mac_dst_mode'] == 'random':
add_val = 0
var_name = 'mac_dst_random'
- vm_cmds.append(CTRexVmDescFlowVar(name = var_name, size = 4, op = 'random', max_value = 0xffffffff))
+ vm_cmds.append(STLVmFlowVar(name = var_name, size = 4, op = 'random', max_value = 0xffffffff))
else:
raise STLError('mac_dst_mode %s is not supported' % kwargs['mac_dst_mode'])
- vm_cmds.append(CTRexVmDescWrFlowVar(fv_name = var_name, pkt_offset = 'Ethernet.dst', offset_fixup = 2, add_val = add_val))
+ vm_cmds.append(STLVmWrFlowVar(fv_name = var_name, pkt_offset = 'Ethernet.dst', offset_fixup = 2, add_val = add_val))
if kwargs['l2_encap'] == 'ethernet_ii_vlan' or (kwargs['l2_encap'] == 'ethernet_ii' and vlan_in_args(user_kwargs)):
#fields_desc = [ BitField("prio", 0, 3),
@@ -933,7 +933,7 @@ def generate_packet(**user_kwargs):
add_val = vlan_id - 0x7fff
var_name = '%s_%s_%s_%s' % ('dec', 2, count, step)
if var_name not in vm_variables_cache:
- vm_cmds.append(CTRexVmDescFlowVar(name = var_name, size = 2, op = 'inc', step = step,
+ vm_cmds.append(STLVmFlowVar(name = var_name, size = 2, op = 'inc', step = step,
min_value = 0x7fff,
max_value = 0x7fff + count * step))
vm_variables_cache[var_name] = True
@@ -941,14 +941,14 @@ def generate_packet(**user_kwargs):
add_val = vlan_id - 0x7fff
var_name = '%s_%s_%s_%s' % ('dec', 2, count, step)
if var_name not in vm_variables_cache:
- vm_cmds.append(CTRexVmDescFlowVar(name = var_name, size = 2, op = 'dec', step = step,
+ vm_cmds.append(STLVmFlowVar(name = var_name, size = 2, op = 'dec', step = step,
min_value = 0x7fff - count * step,
max_value = 0x7fff))
vm_variables_cache[var_name] = True
elif vlan_id_mode == 'random':
add_val = 0
var_name = 'vlan_id_random'
- vm_cmds.append(CTRexVmDescFlowVar(name = var_name, size = 2, op = 'random', max_value = 0xffff))
+ vm_cmds.append(STLVmFlowVar(name = var_name, size = 2, op = 'random', max_value = 0xffff))
else:
raise STLError('vlan_id_mode %s is not supported' % vlan_id_mode)
vm_cmds.append(STLVmWrMaskFlowVar(fv_name = var_name, pkt_offset = '802|1Q:%s.vlan' % i,
@@ -1005,7 +1005,7 @@ def generate_packet(**user_kwargs):
add_val = ip_src_addr - 0x7fffffff
var_name = '%s_%s_%s_%s' % ('inc', 4, count, step)
if var_name not in vm_variables_cache:
- vm_cmds.append(CTRexVmDescFlowVar(name = var_name, size = 4, op = 'inc', step = step,
+ vm_cmds.append(STLVmFlowVar(name = var_name, size = 4, op = 'inc', step = step,
min_value = 0x7fffffff,
max_value = 0x7fffffff + count * step))
vm_variables_cache[var_name] = True
@@ -1013,17 +1013,17 @@ def generate_packet(**user_kwargs):
add_val = ip_src_addr - 0x7fffffff
var_name = '%s_%s_%s_%s' % ('dec', 4, count, step)
if var_name not in vm_variables_cache:
- vm_cmds.append(CTRexVmDescFlowVar(name = var_name, size = 4, op = 'dec', step = step,
+ vm_cmds.append(STLVmFlowVar(name = var_name, size = 4, op = 'dec', step = step,
min_value = 0x7fffffff - count * step,
max_value = 0x7fffffff))
vm_variables_cache[var_name] = True
elif kwargs['ip_src_mode'] == 'random':
add_val = 0
var_name = 'ip_src_random'
- vm_cmds.append(CTRexVmDescFlowVar(name = var_name, size = 4, op = 'random', max_value = 0xffffffff))
+ vm_cmds.append(STLVmFlowVar(name = var_name, size = 4, op = 'random', max_value = 0xffffffff))
else:
raise STLError('ip_src_mode %s is not supported' % kwargs['ip_src_mode'])
- vm_cmds.append(CTRexVmDescWrFlowVar(fv_name = var_name, pkt_offset = 'IP.src', add_val = add_val))
+ vm_cmds.append(STLVmWrFlowVar(fv_name = var_name, pkt_offset = 'IP.src', add_val = add_val))
if kwargs['ip_dst_mode'] != 'fixed':
count = int(kwargs['ip_dst_count']) - 1
@@ -1043,7 +1043,7 @@ def generate_packet(**user_kwargs):
add_val = ip_dst_addr - 0x7fffffff
var_name = '%s_%s_%s_%s' % ('inc', 4, count, step)
if var_name not in vm_variables_cache:
- vm_cmds.append(CTRexVmDescFlowVar(name = var_name, size = 4, op = 'inc', step = step,
+ vm_cmds.append(STLVmFlowVar(name = var_name, size = 4, op = 'inc', step = step,
min_value = 0x7fffffff,
max_value = 0x7fffffff + count * step))
vm_variables_cache[var_name] = True
@@ -1051,17 +1051,17 @@ def generate_packet(**user_kwargs):
add_val = ip_dst_addr - 0x7fffffff
var_name = '%s_%s_%s_%s' % ('dec', 4, count, step)
if var_name not in vm_variables_cache:
- vm_cmds.append(CTRexVmDescFlowVar(name = var_name, size = 4, op = 'dec', step = step,
+ vm_cmds.append(STLVmFlowVar(name = var_name, size = 4, op = 'dec', step = step,
min_value = 0x7fffffff - count * step,
max_value = 0x7fffffff))
vm_variables_cache[var_name] = True
elif kwargs['ip_dst_mode'] == 'random':
add_val = 0
var_name = 'ip_dst_random'
- vm_cmds.append(CTRexVmDescFlowVar(name = var_name, size = 4, op = 'random', max_value = 0xffffffff))
+ vm_cmds.append(STLVmFlowVar(name = var_name, size = 4, op = 'random', max_value = 0xffffffff))
else:
raise STLError('ip_dst_mode %s is not supported' % kwargs['ip_dst_mode'])
- vm_cmds.append(CTRexVmDescWrFlowVar(fv_name = var_name, pkt_offset = 'IP.dst', add_val = add_val))
+ vm_cmds.append(STLVmWrFlowVar(fv_name = var_name, pkt_offset = 'IP.dst', add_val = add_val))
elif kwargs['l3_protocol'] == 'ipv6':
#fields_desc = [ BitField("version" , 6 , 4),
@@ -1099,7 +1099,7 @@ def generate_packet(**user_kwargs):
add_val = ipv6_src_addr_num - 0x7fffffff
var_name = '%s_%s_%s_%s' % ('inc', 4, count, step)
if var_name not in vm_variables_cache:
- vm_cmds.append(CTRexVmDescFlowVar(name = var_name, size = 4, op = 'inc', step = step,
+ vm_cmds.append(STLVmFlowVar(name = var_name, size = 4, op = 'inc', step = step,
min_value = 0x7fffffff,
max_value = 0x7fffffff + count * step))
vm_variables_cache[var_name] = True
@@ -1107,17 +1107,17 @@ def generate_packet(**user_kwargs):
add_val = ipv6_src_addr_num - 0x7fffffff
var_name = '%s_%s_%s_%s' % ('dec', 4, count, step)
if var_name not in vm_variables_cache:
- vm_cmds.append(CTRexVmDescFlowVar(name = var_name, size = 4, op = 'dec', step = step,
+ vm_cmds.append(STLVmFlowVar(name = var_name, size = 4, op = 'dec', step = step,
min_value = 0x7fffffff - count * step,
max_value = 0x7fffffff))
vm_variables_cache[var_name] = True
elif kwargs['ipv6_src_mode'] == 'random':
add_val = 0
var_name = 'ipv6_src_random'
- vm_cmds.append(CTRexVmDescFlowVar(name = var_name, size = 4, op = 'random', max_value = 0xffffffff))
+ vm_cmds.append(STLVmFlowVar(name = var_name, size = 4, op = 'random', max_value = 0xffffffff))
else:
raise STLError('ipv6_src_mode %s is not supported' % kwargs['ipv6_src_mode'])
- vm_cmds.append(CTRexVmDescWrFlowVar(fv_name = var_name, pkt_offset = 'IPv6.src', offset_fixup = 12, add_val = add_val))
+ vm_cmds.append(STLVmWrFlowVar(fv_name = var_name, pkt_offset = 'IPv6.src', offset_fixup = 12, add_val = add_val))
if kwargs['ipv6_dst_mode'] != 'fixed':
count = int(kwargs['ipv6_dst_count']) - 1
@@ -1134,7 +1134,7 @@ def generate_packet(**user_kwargs):
add_val = ipv6_dst_addr_num - 0x7fffffff
var_name = '%s_%s_%s_%s' % ('inc', 4, count, step)
if var_name not in vm_variables_cache:
- vm_cmds.append(CTRexVmDescFlowVar(name = var_name, size = 4, op = 'inc', step = step,
+ vm_cmds.append(STLVmFlowVar(name = var_name, size = 4, op = 'inc', step = step,
min_value = 0x7fffffff,
max_value = 0x7fffffff + count * step))
vm_variables_cache[var_name] = True
@@ -1142,17 +1142,17 @@ def generate_packet(**user_kwargs):
add_val = ipv6_dst_addr_num - 0x7fffffff
var_name = '%s_%s_%s_%s' % ('dec', 4, count, step)
if var_name not in vm_variables_cache:
- vm_cmds.append(CTRexVmDescFlowVar(name = var_name, size = 4, op = 'dec', step = step,
+ vm_cmds.append(STLVmFlowVar(name = var_name, size = 4, op = 'dec', step = step,
min_value = 0x7fffffff - count * step,
max_value = 0x7fffffff))
vm_variables_cache[var_name] = True
elif kwargs['ipv6_dst_mode'] == 'random':
add_val = 0
var_name = 'ipv6_dst_random'
- vm_cmds.append(CTRexVmDescFlowVar(name = var_name, size = 4, op = 'random', max_value = 0xffffffff))
+ vm_cmds.append(STLVmFlowVar(name = var_name, size = 4, op = 'random', max_value = 0xffffffff))
else:
raise STLError('ipv6_dst_mode %s is not supported' % kwargs['ipv6_dst_mode'])
- vm_cmds.append(CTRexVmDescWrFlowVar(fv_name = var_name, pkt_offset = 'IPv6.dst', offset_fixup = 12, add_val = add_val))
+ vm_cmds.append(STLVmWrFlowVar(fv_name = var_name, pkt_offset = 'IPv6.dst', offset_fixup = 12, add_val = add_val))
elif kwargs['l3_protocol'] is not None:
raise NotImplementedError("l3_protocol '%s' is not supported by TRex yet." % kwargs['l3_protocol'])
@@ -1206,7 +1206,7 @@ def generate_packet(**user_kwargs):
add_val = kwargs['tcp_src_port'] - 0x7fff
var_name = '%s_%s_%s_%s' % ('inc', 2, count, step)
if var_name not in vm_variables_cache:
- vm_cmds.append(CTRexVmDescFlowVar(name = var_name, size = 2, op = 'inc', step = step,
+ vm_cmds.append(STLVmFlowVar(name = var_name, size = 2, op = 'inc', step = step,
min_value = 0x7fff,
max_value = 0x7fff + count * step))
vm_variables_cache[var_name] = True
@@ -1214,17 +1214,17 @@ def generate_packet(**user_kwargs):
add_val = kwargs['tcp_src_port'] - 0x7fff
var_name = '%s_%s_%s_%s' % ('dec', 2, count, step)
if var_name not in vm_variables_cache:
- vm_cmds.append(CTRexVmDescFlowVar(name = var_name, size = 2, op = 'dec', step = step,
+ vm_cmds.append(STLVmFlowVar(name = var_name, size = 2, op = 'dec', step = step,
min_value = 0x7fff - count * step,
max_value = 0x7fff))
vm_variables_cache[var_name] = True
elif kwargs['tcp_src_port_mode'] == 'random':
add_val = 0
var_name = 'tcp_src_random'
- vm_cmds.append(CTRexVmDescFlowVar(name = var_name, size = 2, op = 'random', max_value = 0xffff))
+ vm_cmds.append(STLVmFlowVar(name = var_name, size = 2, op = 'random', max_value = 0xffff))
else:
raise STLError('tcp_src_port_mode %s is not supported' % kwargs['tcp_src_port_mode'])
- vm_cmds.append(CTRexVmDescWrFlowVar(fv_name = var_name, pkt_offset = 'TCP.sport', add_val = add_val))
+ vm_cmds.append(STLVmWrFlowVar(fv_name = var_name, pkt_offset = 'TCP.sport', add_val = add_val))
if kwargs['tcp_dst_port_mode'] != 'fixed':
count = int(kwargs['tcp_dst_port_count']) - 1
@@ -1239,7 +1239,7 @@ def generate_packet(**user_kwargs):
add_val = kwargs['tcp_dst_port'] - 0x7fff
var_name = '%s_%s_%s_%s' % ('inc', 2, count, step)
if var_name not in vm_variables_cache:
- vm_cmds.append(CTRexVmDescFlowVar(name = var_name, size = 2, op = 'inc', step = step,
+ vm_cmds.append(STLVmFlowVar(name = var_name, size = 2, op = 'inc', step = step,
min_value = 0x7fff,
max_value = 0x7fff + count * step))
vm_variables_cache[var_name] = True
@@ -1247,17 +1247,17 @@ def generate_packet(**user_kwargs):
add_val = kwargs['tcp_dst_port'] - 0x7fff
var_name = '%s_%s_%s_%s' % ('dec', 2, count, step)
if var_name not in vm_variables_cache:
- vm_cmds.append(CTRexVmDescFlowVar(name = var_name, size = 2, op = 'dec', step = step,
+ vm_cmds.append(STLVmFlowVar(name = var_name, size = 2, op = 'dec', step = step,
min_value = 0x7fff - count * step,
max_value = 0x7fff))
vm_variables_cache[var_name] = True
elif kwargs['tcp_dst_port_mode'] == 'random':
add_val = 0
var_name = 'tcp_dst_random'
- vm_cmds.append(CTRexVmDescFlowVar(name = var_name, size = 2, op = 'random', max_value = 0xffff))
+ vm_cmds.append(STLVmFlowVar(name = var_name, size = 2, op = 'random', max_value = 0xffff))
else:
raise STLError('tcp_dst_port_mode %s is not supported' % kwargs['tcp_dst_port_mode'])
- vm_cmds.append(CTRexVmDescWrFlowVar(fv_name = var_name, pkt_offset = 'TCP.dport', add_val = add_val))
+ vm_cmds.append(STLVmWrFlowVar(fv_name = var_name, pkt_offset = 'TCP.dport', add_val = add_val))
elif kwargs['l4_protocol'] == 'udp':
assert kwargs['l3_protocol'] in ('ipv4', 'ipv6'), 'UDP must be over ipv4/ipv6'
@@ -1282,7 +1282,7 @@ def generate_packet(**user_kwargs):
add_val = kwargs['udp_src_port'] - 0x7fff
var_name = '%s_%s_%s_%s' % ('inc', 2, count, step)
if var_name not in vm_variables_cache:
- vm_cmds.append(CTRexVmDescFlowVar(name = var_name, size = 2, op = 'inc', step = step,
+ vm_cmds.append(STLVmFlowVar(name = var_name, size = 2, op = 'inc', step = step,
min_value = 0x7fff,
max_value = 0x7fff + count * step))
vm_variables_cache[var_name] = True
@@ -1290,17 +1290,17 @@ def generate_packet(**user_kwargs):
add_val = kwargs['udp_src_port'] - 0x7fff
var_name = '%s_%s_%s_%s' % ('dec', 2, count, step)
if var_name not in vm_variables_cache:
- vm_cmds.append(CTRexVmDescFlowVar(name = var_name, size = 2, op = 'dec', step = step,
+ vm_cmds.append(STLVmFlowVar(name = var_name, size = 2, op = 'dec', step = step,
min_value = 0x7fff - count * step,
max_value = 0x7fff))
vm_variables_cache[var_name] = True
elif kwargs['udp_src_port_mode'] == 'random':
add_val = 0
var_name = 'udp_src_random'
- vm_cmds.append(CTRexVmDescFlowVar(name = var_name, size = 2, op = 'random', max_value = 0xffff))
+ vm_cmds.append(STLVmFlowVar(name = var_name, size = 2, op = 'random', max_value = 0xffff))
else:
raise STLError('udp_src_port_mode %s is not supported' % kwargs['udp_src_port_mode'])
- vm_cmds.append(CTRexVmDescWrFlowVar(fv_name = var_name, pkt_offset = 'UDP.sport', add_val = add_val))
+ vm_cmds.append(STLVmWrFlowVar(fv_name = var_name, pkt_offset = 'UDP.sport', add_val = add_val))
if kwargs['udp_dst_port_mode'] != 'fixed':
count = int(kwargs['udp_dst_port_count']) - 1
@@ -1315,23 +1315,23 @@ def generate_packet(**user_kwargs):
add_val = kwargs['udp_dst_port'] - 0x7fff
var_name = '%s_%s_%s_%s' % ('inc', 2, count, step)
if var_name not in vm_variables_cache:
- vm_cmds.append(CTRexVmDescFlowVar(name = var_name, size = 2, op = 'inc', step = step,
+ vm_cmds.append(STLVmFlowVar(name = var_name, size = 2, op = 'inc', step = step,
min_value = 0x7fff,
max_value = 0x7fff + count * step))
elif kwargs['udp_dst_port_mode'] == 'decrement':
add_val = kwargs['udp_dst_port'] - 0x7fff
var_name = '%s_%s_%s_%s' % ('dec', 2, count, step)
if var_name not in vm_variables_cache:
- vm_cmds.append(CTRexVmDescFlowVar(name = var_name, size = 2, op = 'dec', step = step,
+ vm_cmds.append(STLVmFlowVar(name = var_name, size = 2, op = 'dec', step = step,
min_value = 0x7fff - count * step,
max_value = 0x7fff))
elif kwargs['udp_dst_port_mode'] == 'random':
add_val = 0
var_name = 'udp_dst_random'
- vm_cmds.append(CTRexVmDescFlowVar(name = var_name, size = 2, op = 'random', max_value = 0xffff))
+ vm_cmds.append(STLVmFlowVar(name = var_name, size = 2, op = 'random', max_value = 0xffff))
else:
raise STLError('udp_dst_port_mode %s is not supported' % kwargs['udp_dst_port_mode'])
- vm_cmds.append(CTRexVmDescWrFlowVar(fv_name = var_name, pkt_offset = 'UDP.dport', add_val = add_val))
+ vm_cmds.append(STLVmWrFlowVar(fv_name = var_name, pkt_offset = 'UDP.dport', add_val = add_val))
elif kwargs['l4_protocol'] is not None:
raise NotImplementedError("l4_protocol '%s' is not supported by TRex yet." % kwargs['l4_protocol'])
if l4_layer is not None:
@@ -1358,10 +1358,10 @@ def generate_packet(**user_kwargs):
raise STLError('frame_size_min is bigger than frame_size_max')
if kwargs['frame_size_min'] != kwargs['frame_size_max']:
fix_ipv4_checksum = True
- vm_cmds.append(CTRexVmDescFlowVar(name = 'pkt_len', size = 2, op = trim_dict[length_mode], step = kwargs['frame_size_step'],
+ vm_cmds.append(STLVmFlowVar(name = 'pkt_len', size = 2, op = trim_dict[length_mode], step = kwargs['frame_size_step'],
min_value = kwargs['frame_size_min'],
max_value = kwargs['frame_size_max']))
- vm_cmds.append(CTRexVmDescTrimPktSize('pkt_len'))
+ vm_cmds.append(STLVmTrimPktSize('pkt_len'))
payload_len = kwargs['frame_size_max'] - len(base_pkt)
else: # size is determined by L3
if kwargs['l3_length_min'] < 40 or kwargs['l3_length_max'] < 40:
@@ -1370,16 +1370,16 @@ def generate_packet(**user_kwargs):
raise STLError('l3_length_min is bigger than l3_length_max')
if kwargs['l3_length_min'] != kwargs['l3_length_max']:
fix_ipv4_checksum = True
- vm_cmds.append(CTRexVmDescFlowVar(name = 'pkt_len', size = 2, op = trim_dict[length_mode], step = kwargs['l3_length_step'],
+ vm_cmds.append(STLVmFlowVar(name = 'pkt_len', size = 2, op = trim_dict[length_mode], step = kwargs['l3_length_step'],
min_value = kwargs['l3_length_min'] + len(l2_layer),
max_value = kwargs['l3_length_max'] + len(l2_layer)))
payload_len = kwargs['l3_length_max'] + len(l2_layer) - len(base_pkt)
- vm_cmds.append(CTRexVmDescTrimPktSize('pkt_len'))
+ vm_cmds.append(STLVmTrimPktSize('pkt_len'))
if (l3_layer and l3_layer.name == 'IP'):
- vm_cmds.append(CTRexVmDescWrFlowVar(fv_name = 'pkt_len', pkt_offset = 'IP.len', add_val = -len(l2_layer)))
+ vm_cmds.append(STLVmWrFlowVar(fv_name = 'pkt_len', pkt_offset = 'IP.len', add_val = -len(l2_layer)))
if (l4_layer and l4_layer.name == 'UDP'):
- vm_cmds.append(CTRexVmDescWrFlowVar(fv_name = 'pkt_len', pkt_offset = 'UDP.len', add_val = -len(l2_layer) - len(l3_layer)))
+ vm_cmds.append(STLVmWrFlowVar(fv_name = 'pkt_len', pkt_offset = 'UDP.len', add_val = -len(l2_layer) - len(l3_layer)))
else:
raise STLError('length_mode should be one of the following: %s' % ['auto', 'fixed'] + trim_dict.keys())
@@ -1390,13 +1390,13 @@ def generate_packet(**user_kwargs):
pkt = STLPktBuilder()
pkt.set_packet(base_pkt)
if fix_ipv4_checksum and l3_layer.name == 'IP' and kwargs['ip_checksum'] is None:
- vm_cmds.append(CTRexVmDescFixIpv4(offset = 'IP'))
+ vm_cmds.append(STLVmFixIpv4(offset = 'IP'))
if vm_cmds:
split_by_field = None
if kwargs['split_by_cores'] == 'split':
max_length = 0
for cmd in vm_cmds:
- if isinstance(cmd, CTRexVmDescFlowVar):
+ if isinstance(cmd, STLVmFlowVar):
if cmd.op not in ('inc', 'dec'):
continue
length = float(cmd.max_value - cmd.min_value) / cmd.step
@@ -1410,7 +1410,7 @@ def generate_packet(**user_kwargs):
raise STLError("split_by_cores 'single' not implemented yet")
elif kwargs['split_by_cores'] != 'duplicate':
raise STLError("split_by_cores '%s' is not supported" % kwargs['split_by_cores'])
- pkt.add_command(CTRexScRaw(vm_cmds, split_by_field))
+ pkt.add_command(STLScVmRaw(vm_cmds, split_by_field))
# debug (only the base packet, without VM)
debug_filename = kwargs.get('save_to_pcap')
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 eac12ebb..35326590 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
@@ -172,12 +172,12 @@ class CTRexScTrimPacketSize(CTRexScriptsBase):
raise CTRexPacketBuildException(-11, 'CTRexScTrimPacketSize min_pkt_size is bigger than max_pkt_size ');
-class CTRexScRaw(CTRexScriptsBase):
+class STLScVmRaw(CTRexScriptsBase):
"""
raw instructions
"""
def __init__(self,list_of_commands=None,split_by_field=None):
- super(CTRexScRaw, self).__init__()
+ super(STLScVmRaw, self).__init__()
self.split_by_field = split_by_field
if list_of_commands==None:
self.commands =[]
@@ -526,16 +526,62 @@ def check_for_int (val):
assert type(val)==int, 'type of vcal is not int'
-class CTRexVmDescFlowVar(CTRexVmDescBase):
- """
- flow var instruction
- """
+class STLVmFlowVar(CTRexVmDescBase):
def __init__(self, name, init_value=None, min_value=0, max_value=255, size=4, step=1,op="inc"):
"""
-
+ Flow variable instruction. Allocate a variable on a stream context. The size of the variable could be determined
+ The operation can be inc, dec and random. In case of increment and decrement operation, it is possible to set the "step" size.
+ Initialization value, minimum and maximum value could be set too.
+
+ :parameters:
+ name : string
+ The name of the stream variable
+
+ init_value : int
+ The init value of the variable. in case of None it will be min_value
+
+ min_value : int
+ The min value
+
+ max_value : int
+ The max value
+
+ size : int
+ the number of bytes of the variable. could be 1,2,4,8 for uint8_t, uint16_t, uint32_t, uint64_t
+
+ step : int
+ step in case of "inc","dec" operation
+
+ op : string
+ could be "inc", "dec", "random"
+
+ For example::
+
+ # input
+ STLVmFlowVar(min_value=0, max_value=3, size=1,op="inc")
+
+ # output 0,1,2,3,0,1,2,3 ..
+
+ # input
+ STLVmFlowVar(min_value=0, max_value=3, size=1,op="dec")
+
+ # output 0,3,2,1,0,3,2,1 ..
+
+
+ # input
+ STLVmFlowVar(min_value=0, max_value=3, size=1,op="random")
+
+ # output 1,1,2,3,1,2,1,0 ..
+
+ # input
+ STLVmFlowVar(min_value=0, max_value=10, size=1,op="inc",step=3)
+
+ # output 0,3,6,9,0,3,6,9,0..
+
+
"""
- super(CTRexVmDescFlowVar, self).__init__()
+ super(STLVmFlowVar, self).__init__()
self.name = name;
assert type(name)==str, 'type of name is not str'
self.size =size
@@ -562,9 +608,32 @@ class CTRexVmDescFlowVar(CTRexVmDescBase):
return [self.name]
-class CTRexVmDescFixIpv4(CTRexVmDescBase):
+class STLVmFixIpv4(CTRexVmDescBase):
def __init__(self, offset):
- super(CTRexVmDescFixIpv4, self).__init__()
+ """
+ Fix IPv4 header checksum. should be added if the packet header was changed and there is a need to fix he checksum
+
+ :parameters:
+ offset : uint16_t or string
+ **IPv4 header** offset from packet start. It is **not** the offset of the checksum field itself.
+ in could be string in case of scapy packet. format IP[:[id]]
+
+ For example::
+
+ pkt = Ether()/IP(src="16.0.0.1",dst="48.0.0.1")/UDP(dport=12,sport=1025)
+
+ # by offset
+ STLVmFixIpv4(offset=14)
+
+ # in case of scapy packet can be defined by header name
+ STLVmFixIpv4(offset="IP")
+
+ # string for second "IP" header in the packet is IP:1
+ STLVmFixIpv4(offset="IP:1")
+
+ """
+
+ super(STLVmFixIpv4, self).__init__()
self.offset = offset; # could be a name of offset
def get_obj (self):
@@ -574,9 +643,48 @@ class CTRexVmDescFixIpv4(CTRexVmDescBase):
if type(self.offset)==str:
self.offset = parent._pkt_layer_offset(self.offset);
-class CTRexVmDescWrFlowVar(CTRexVmDescBase):
+class STLVmWrFlowVar(CTRexVmDescBase):
def __init__(self, fv_name, pkt_offset, offset_fixup=0, add_val=0, is_big=True):
- super(CTRexVmDescWrFlowVar, self).__init__()
+ """
+ Write a stream variable into a packet field.
+ The write is done in size of the stream variable.
+ In case there is a need to change the write have a look into the command `STLVmWrMaskFlowVar`.
+ The Field name/offset can be given by name in this format ``header[:id].field``.
+
+
+ :parameters:
+ fv_name : string
+ the stream variable to write to a packet offset
+
+ pkt_offset : string or in
+ the name of the field or offset in byte from packet start.
+
+ offset_fixup : int
+ how many bytes to go forward. In case of a negative value go backward
+
+ add_val : int
+ value to add to stream variable before writing it to packet field. can be used as a constant offset
+
+ is_big : bool
+ how to write the variable to the the packet. is it big-edian or little edian
+
+ For example::
+
+ pkt = Ether()/IP(src="16.0.0.1",dst="48.0.0.1")/UDP(dport=12,sport=1025)
+
+
+ # write to ip.src offset
+ STLVmWrFlowVar (fv_name="tuple", pkt_offset= "IP.src" )
+
+ # packet offset is varible
+ STLVmWrFlowVar (fv_name="tuple", pkt_offset= 26 )
+
+ # add l3_len_fix before writing fv_rand into IP.len field
+ STLVmWrFlowVar(fv_name="fv_rand", pkt_offset= "IP.len", add_val=l3_len_fix)
+
+ """
+
+ super(STLVmWrFlowVar, self).__init__()
self.name =fv_name
assert type(fv_name)==str, 'type of fv_name is not str'
self.offset_fixup =offset_fixup
@@ -598,9 +706,9 @@ class CTRexVmDescWrFlowVar(CTRexVmDescBase):
t=parent._name_to_offset(self.pkt_offset)
self.pkt_offset = t[0]
-class CTRexVmDescWrMaskFlowVar(CTRexVmDescBase):
+class STLVmWrMaskFlowVar(CTRexVmDescBase):
def __init__(self, fv_name, pkt_offset, pkt_cast_size=1, mask=0xff, shift=0, add_value=0, offset_fixup=0, is_big=True):
- super(CTRexVmDescWrMaskFlowVar, self).__init__()
+ super(STLVmWrMaskFlowVar, self).__init__()
self.name =fv_name
assert type(fv_name)==str, 'type of fv_name is not str'
self.offset_fixup =offset_fixup
@@ -633,9 +741,61 @@ class CTRexVmDescWrMaskFlowVar(CTRexVmDescBase):
self.pkt_offset = t[0]
-class CTRexVmDescTrimPktSize(CTRexVmDescBase):
+class STLVmTrimPktSize(CTRexVmDescBase):
+ """
+ Trim packet size by stream variable size. This instruction will only change the total packet size and will not fix up the fields to match the new size.
+
+
+ :parameters:
+ fv_name : string
+ the stream variable name. the value from this variable would be the new total packet size.
+
+
+
+ For example::
+
+ def create_stream (self):
+ # pkt
+ p_l2 = Ether();
+ p_l3 = IP(src="16.0.0.1",dst="48.0.0.1")
+ p_l4 = UDP(dport=12,sport=1025)
+ pyld_size = max(0, self.max_pkt_size_l3 - len(p_l3/p_l4));
+ base_pkt = p_l2/p_l3/p_l4/('\x55'*(pyld_size))
+
+ l3_len_fix =-(len(p_l2));
+ l4_len_fix =-(len(p_l2/p_l3));
+
+
+ # vm
+ vm = STLScVmRaw( [ STLVmFlowVar(name="fv_rand", min_value=64,
+ max_value=len(base_pkt),
+ size=2, op="inc"),
+
+ STLVmTrimPktSize("fv_rand"), # change total packet size <<<
+
+ STLVmWrFlowVar(fv_name="fv_rand",
+ pkt_offset= "IP.len",
+ add_val=l3_len_fix), # fix ip len
+
+ STLVmFixIpv4(offset = "IP"), # fix checksum
+
+ STLVmWrFlowVar(fv_name="fv_rand",
+ pkt_offset= "UDP.len",
+ add_val=l4_len_fix) # fix udp len
+ ]
+ )
+
+ pkt = STLPktBuilder(pkt = base_pkt,
+ vm = vm)
+
+ return STLStream(packet = pkt,
+ mode = STLTXCont())
+
+
+ """
+
def __init__(self,fv_name):
- super(CTRexVmDescTrimPktSize, self).__init__()
+ super(STLVmTrimPktSize, self).__init__()
self.name = fv_name
assert type(fv_name)==str, 'type of fv_name is not str'
@@ -647,9 +807,116 @@ class CTRexVmDescTrimPktSize(CTRexVmDescBase):
-class CTRexVmDescTupleGen(CTRexVmDescBase):
+class STLVmTupleGen(CTRexVmDescBase):
def __init__(self,name, ip_min="0.0.0.1", ip_max="0.0.0.10", port_min=1025, port_max=65535, limit_flows=100000, flags=0):
- super(CTRexVmDescTupleGen, self).__init__()
+ """
+ Generate a struct with two varibles. ``var_name.ip`` as uint32_t and ``var_name.port`` as uint16_t
+ The variable are dependent. When the ip variable is wrapped the port is getting increment.
+
+ For:
+
+ * ip_min = 10.0.0.1
+ * ip_max = 10.0.0.5
+ * port_min = 1025
+ * port_max = 1028
+ * limit_flows = 10
+
+ The result:
+
+ +------------+------------+-----------+
+ | ip | port | flow_id |
+ +============+============+===========+
+ | 10.0.0.1 | 1025 | 1 |
+ +------------+------------+-----------+
+ | 10.0.0.2 | 1025 | 2 |
+ +------------+------------+-----------+
+ | 10.0.0.3 | 1025 | 3 |
+ +------------+------------+-----------+
+ | 10.0.0.4 | 1025 | 4 |
+ +------------+------------+-----------+
+ | 10.0.0.5 | 1025 | 5 |
+ +------------+------------+-----------+
+ | 10.0.0.1 | 1026 | 6 |
+ +------------+------------+-----------+
+ | 10.0.0.2 | 1026 | 7 |
+ +------------+------------+-----------+
+ | 10.0.0.3 | 1026 | 8 |
+ +------------+------------+-----------+
+ | 10.0.0.4 | 1026 | 9 |
+ +------------+------------+-----------+
+ | 10.0.0.5 | 1026 | 10 |
+ +------------+------------+-----------+
+ | 10.0.0.1 | 1025 | 1 |
+ +------------+------------+-----------+
+
+
+ :parameters:
+ name : string
+ The name of the stream struct.
+
+ ip_min : string or int
+ The min value of the ip value. It can be in IPv4 format
+
+ ip_max : string or int
+ The max value of the ip value. It can be in IPv4 format
+
+ port_min : int
+ min value for port variable
+
+ port_max : int
+ max value for port variable
+
+ limit_flows : int
+ The limit of number of flows
+
+ flags : 0
+
+ ="0.0.0.10", port_min=1025, port_max=65535, limit_flows=100000, flags=0
+
+
+ For example::
+
+ def create_stream (self):
+ # pkt
+ p_l2 = Ether();
+ p_l3 = IP(src="16.0.0.1",dst="48.0.0.1")
+ p_l4 = UDP(dport=12,sport=1025)
+ pyld_size = max(0, self.max_pkt_size_l3 - len(p_l3/p_l4));
+ base_pkt = p_l2/p_l3/p_l4/('\x55'*(pyld_size))
+
+ l3_len_fix =-(len(p_l2));
+ l4_len_fix =-(len(p_l2/p_l3));
+
+
+ # vm
+ vm = STLScVmRaw( [ STLVmFlowVar(name="fv_rand", min_value=64,
+ max_value=len(base_pkt),
+ size=2, op="inc"),
+
+ STLVmTrimPktSize("fv_rand"), # change total packet size <<<
+
+ STLVmWrFlowVar(fv_name="fv_rand",
+ pkt_offset= "IP.len",
+ add_val=l3_len_fix), # fix ip len
+
+ STLVmFixIpv4(offset = "IP"), # fix checksum
+
+ STLVmWrFlowVar(fv_name="fv_rand",
+ pkt_offset= "UDP.len",
+ add_val=l4_len_fix) # fix udp len
+ ]
+ )
+
+ pkt = STLPktBuilder(pkt = base_pkt,
+ vm = vm)
+
+ return STLStream(packet = pkt,
+ mode = STLTXCont())
+
+
+ """
+
+ super(STLVmTupleGen, self).__init__()
self.name = name
assert type(name)==str, 'type of fv_name is not str'
self.ip_min = convert_val(ip_min);
@@ -672,22 +939,22 @@ class CTRexVmDescTupleGen(CTRexVmDescBase):
################################################################################################
-class CScapyTRexPktBuilder(CTrexPktBuilderInterface):
- """
- This class defines the TRex API of building a packet and Field engine using scapy package.
- Using this class the user can also define how TRex will handle the packet by specifying the Field engine setting.
- pkt could be Scapy pkt or pcap file name
- When path_relative_to_profile is a True load pcap file from a path relative to the profile
- """
+class STLPktBuilder(CTrexPktBuilderInterface):
def __init__(self, pkt = None, pkt_buffer = None, vm = None, path_relative_to_profile = False, build_raw = False, remove_fcs = True):
"""
+
+ This class defines a way to build a template packet, and Field Engine using scapy package.
+ Using this class the user can also define how TRex will handle the packet by specifying the Field engine setting.
+ pkt could be Scapy pkt or pcap file name
+ When path_relative_to_profile is a True load pcap file from a path relative to the profile
+
Instantiate a CTRexPktBuilder object
:parameters:
- pkt : Scapy or pcap file filename
- a scapy packet
+ pkt : string,
+ Scapy or pcap file filename a scapy packet
pkt_buffer : string
a packet as buffer
@@ -717,7 +984,7 @@ class CScapyTRexPktBuilder(CTrexPktBuilderInterface):
path_relative_to_profile = True)
- vm = CTRexScRaw( [ STLVmTupleGen ( ip_min="16.0.0.1", ip_max="16.0.0.2",
+ vm = STLScVmRaw( [ STLVmTupleGen ( ip_min="16.0.0.1", ip_max="16.0.0.2",
port_min=1025, port_max=65535,
name="tuple"), # define tuple gen
@@ -735,7 +1002,7 @@ class CScapyTRexPktBuilder(CTrexPktBuilderInterface):
"""
- super(CScapyTRexPktBuilder, self).__init__()
+ super(STLPktBuilder, self).__init__()
self.pkt = None # as input
self.pkt_raw = None # from raw pcap file
@@ -760,10 +1027,10 @@ class CScapyTRexPktBuilder(CTrexPktBuilderInterface):
# process VM
if vm != None:
- if not isinstance(vm, (CTRexScRaw, list)):
+ if not isinstance(vm, (STLScVmRaw, list)):
raise CTRexPacketBuildException(-14, "bad value for variable vm")
- self.add_command(vm if isinstance(vm, CTRexScRaw) else CTRexScRaw(vm))
+ self.add_command(vm if isinstance(vm, STLScVmRaw) else STLScVmRaw(vm))
# raw source build to see MAC presence/ fields offset by name in VM
if build_raw and self.pkt_raw and not self.pkt:
@@ -928,7 +1195,7 @@ class CScapyTRexPktBuilder(CTrexPktBuilderInterface):
# compile the VM
for sc in self.vm_scripts:
- if isinstance(sc, CTRexScRaw):
+ if isinstance(sc, STLScVmRaw):
self._compile_raw(sc)
def get_pkt_len (self):
diff --git a/scripts/automation/trex_control_plane/stl/trex_stl_lib/trex_stl_port.py b/scripts/automation/trex_control_plane/stl/trex_stl_lib/trex_stl_port.py
index 4529efa9..2a8bedb8 100644
--- a/scripts/automation/trex_control_plane/stl/trex_stl_lib/trex_stl_port.py
+++ b/scripts/automation/trex_control_plane/stl/trex_stl_lib/trex_stl_port.py
@@ -1,7 +1,7 @@
from collections import namedtuple, OrderedDict
-from trex_stl_packet_builder_scapy import CScapyTRexPktBuilder
+from trex_stl_packet_builder_scapy import STLPktBuilder
from trex_stl_streams import STLStream
import base64
import trex_stl_stats
@@ -576,7 +576,7 @@ class Port(object):
# lazy build scapy repr.
if not 'pkt_type' in obj:
- obj['pkt_type'] = CScapyTRexPktBuilder.pkt_layers_desc_from_buffer(obj['pkt'])
+ obj['pkt_type'] = STLPktBuilder.pkt_layers_desc_from_buffer(obj['pkt'])
data[id] = OrderedDict([ ('id', id),
('packet_type', obj['pkt_type']),
diff --git a/scripts/automation/trex_control_plane/stl/trex_stl_lib/trex_stl_std.py b/scripts/automation/trex_control_plane/stl/trex_stl_lib/trex_stl_std.py
index d582b499..8596bbfe 100644
--- a/scripts/automation/trex_control_plane/stl/trex_stl_lib/trex_stl_std.py
+++ b/scripts/automation/trex_control_plane/stl/trex_stl_lib/trex_stl_std.py
@@ -12,7 +12,7 @@ def stl_map_ports (client, ports = None):
client.reset(ports)
# generate streams
- base_pkt = CScapyTRexPktBuilder(pkt = Ether()/IP())
+ base_pkt = STLPktBuilder(pkt = Ether()/IP())
# send something initial to calm down switches with arps etc.
stream = STLStream(packet = base_pkt,
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 2a99be8d..939c8ed5 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
@@ -3,7 +3,7 @@
from trex_stl_exceptions import *
from trex_stl_types import verify_exclusive_arg, validate_type
from trex_stl_packet_builder_interface import CTrexPktBuilderInterface
-from trex_stl_packet_builder_scapy import CScapyTRexPktBuilder, Ether, IP, UDP, TCP, RawPcapReader
+from trex_stl_packet_builder_scapy import STLPktBuilder, Ether, IP, UDP, TCP, RawPcapReader
from collections import OrderedDict, namedtuple
from scapy.utils import ltoa
@@ -200,6 +200,14 @@ STLStreamDstMAC_ARP =2
# RX stats class
class STLFlowStats(object):
+ """ Define per stream stats
+
+ For example::
+
+ flow_stats = STLFlowStats(pg_id = 7)
+
+ """
+
def __init__ (self, pg_id):
self.fields = {}
@@ -210,6 +218,7 @@ class STLFlowStats(object):
def to_json (self):
+ """ dump as json"""
return dict(self.fields)
@staticmethod
@@ -220,6 +229,7 @@ class STLStream(object):
""" One stream object, include mode, Field Engine mode packet template and Rx stats
For example::
+
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'
@@ -229,6 +239,7 @@ class STLStream(object):
mode = STLTXSingleBurst( pps = 10, total_pkts = 1),
next = 'S1'), # point to next stream
+
"""
def __init__ (self,
@@ -257,7 +268,7 @@ class STLStream(object):
packet : STLPktBuilder
The template packet and field engine program e.g. packet = STLPktBuilder(pkt = base_pkt/pad)
- mode : STLTXCont or STLTXSingleBurst or STLTXMultiBurst
+ mode : :class:`trex_stl_lib.trex_stl_streams.STLTXCont` or :class:`trex_stl_lib.trex_stl_streams.STLTXSingleBurst` or :class:`trex_stl_lib.trex_stl_streams.STLTXMultiBurst`
enabled : bool
if the stream is enabled.
@@ -268,7 +279,7 @@ class STLStream(object):
isg : float
Inter stream gap in usec. time to wait until stream will send the first packet
- flow_stats : STLFlowStats
+ flow_stats : :class:`trex_stl_lib.trex_stl_streams.STLFlowStats`
Per stream statistic object see STLFlowStats
next : string
@@ -288,14 +299,6 @@ class STLStream(object):
mac_dst_override_mode=None : STLStreamDstMAC_xx
Template packet will set dst MAC
-
-
- :return:
- None
-
- :raises:
- None
-
"""
@@ -366,7 +369,7 @@ class STLStream(object):
self.fields['vm'] = {}
if not packet:
- packet = CScapyTRexPktBuilder(pkt = Ether()/IP())
+ packet = STLPktBuilder(pkt = Ether()/IP())
self.scapy_pkt_builder = packet
# packet builder
@@ -429,7 +432,7 @@ class STLStream(object):
def get_pkt_type (self):
""" Get packet description for example IP:UDP """
if self.packet_desc == None:
- self.packet_desc = CScapyTRexPktBuilder.pkt_layers_desc_from_buffer(self.get_pkt())
+ self.packet_desc = STLPktBuilder.pkt_layers_desc_from_buffer(self.get_pkt())
return self.packet_desc
@@ -459,7 +462,7 @@ class STLStream(object):
if self.name:
print "Stream Name: ",self.name
scapy_b = self.scapy_pkt_builder;
- if scapy_b and isinstance(scapy_b,CScapyTRexPktBuilder):
+ if scapy_b and isinstance(scapy_b,STLPktBuilder):
scapy_b.to_pkt_dump()
else:
print "Nothing to dump"
@@ -517,25 +520,25 @@ class STLStream(object):
vm_list = []
for inst in self.fields['vm']['instructions']:
if inst['type'] == 'flow_var':
- vm_list.append("CTRexVmDescFlowVar(name='{name}', size={size}, op='{op}', init_value={init_value}, min_value={min_value}, max_value={max_value}, step={step})".format(**inst))
+ vm_list.append("STLVmFlowVar(name='{name}', size={size}, op='{op}', init_value={init_value}, min_value={min_value}, max_value={max_value}, step={step})".format(**inst))
elif inst['type'] == 'write_flow_var':
- vm_list.append("CTRexVmDescWrFlowVar(fv_name='{name}', pkt_offset={pkt_offset}, add_val={add_value}, is_big={is_big_endian})".format(**inst))
+ vm_list.append("STLVmWrFlowVar(fv_name='{name}', pkt_offset={pkt_offset}, add_val={add_value}, is_big={is_big_endian})".format(**inst))
elif inst['type'] == 'write_mask_flow_var':
inst = copy.copy(inst)
inst['mask'] = hex(inst['mask'])
- vm_list.append("CTRexVmDescWrMaskFlowVar(fv_name='{name}', pkt_offset={pkt_offset}, pkt_cast_size={pkt_cast_size}, mask={mask}, shift={shift}, add_value={add_value}, is_big={is_big_endian})".format(**inst))
+ vm_list.append("STLVmWrMaskFlowVar(fv_name='{name}', pkt_offset={pkt_offset}, pkt_cast_size={pkt_cast_size}, mask={mask}, shift={shift}, add_value={add_value}, is_big={is_big_endian})".format(**inst))
elif inst['type'] == 'fix_checksum_ipv4':
- vm_list.append("CTRexVmDescFixIpv4(offset={pkt_offset})".format(**inst))
+ vm_list.append("STLVmFixIpv4(offset={pkt_offset})".format(**inst))
elif inst['type'] == 'trim_pkt_size':
- vm_list.append("CTRexVmDescTrimPktSize(fv_name='{name}')".format(**inst))
+ vm_list.append("STLVmTrimPktSize(fv_name='{name}')".format(**inst))
elif inst['type'] == 'tuple_flow_var':
inst = copy.copy(inst)
inst['ip_min'] = ltoa(inst['ip_min'])
inst['ip_max'] = ltoa(inst['ip_max'])
- vm_list.append("CTRexVmDescTupleGen(name='{name}', ip_min='{ip_min}', ip_max='{ip_max}', port_min={port_min}, port_max={port_max}, limit_flows={limit_flows}, flags={flags})".format(**inst))
- vm_code = 'vm = CTRexScRaw([' + ',\n '.join(vm_list) + '], split_by_field = %s)' % STLStream.__add_quotes(self.fields['vm'].get('split_by_var'))
+ vm_list.append("STLVmTupleGen(name='{name}', ip_min='{ip_min}', ip_max='{ip_max}', port_min={port_min}, port_max={port_max}, limit_flows={limit_flows}, flags={flags})".format(**inst))
+ vm_code = 'vm = STLScVmRaw([' + ',\n '.join(vm_list) + '], split_by_field = %s)' % STLStream.__add_quotes(self.fields['vm'].get('split_by_var'))
stream_params_list = []
- stream_params_list.append('packet = CScapyTRexPktBuilder(pkt = packet, vm = vm)')
+ stream_params_list.append('packet = STLPktBuilder(pkt = packet, vm = vm)')
if default_STLStream.name != self.name:
stream_params_list.append('name = %s' % STLStream.__add_quotes(self.name))
if default_STLStream.fields['enabled'] != self.fields['enabled']:
@@ -618,7 +621,7 @@ class YAMLLoader(object):
except TypeError:
raise STLError("'binary' field is not a valid packet format")
- builder = CScapyTRexPktBuilder(pkt_buffer = pkt_str)
+ builder = STLPktBuilder(pkt_buffer = pkt_str)
elif 'pcap' in packet_type:
pcap = os.path.join(self.yaml_path, packet_dict['pcap'])
@@ -626,7 +629,7 @@ class YAMLLoader(object):
if not os.path.exists(pcap):
raise STLError("'pcap' - cannot find '{0}'".format(pcap))
- builder = CScapyTRexPktBuilder(pkt = pcap)
+ builder = STLPktBuilder(pkt = pcap)
return builder
@@ -769,7 +772,7 @@ class STLProfile(object):
:parameters:
- streams : list of STLStream
+ streams : list of :class:`trex_stl_lib.trex_stl_streams.STLStream`
a list of stream objects
@@ -901,7 +904,7 @@ class STLProfile(object):
streams.append(STLStream(name = i,
- packet = CScapyTRexPktBuilder(pkt_buffer = cap, vm = vm),
+ packet = STLPktBuilder(pkt_buffer = cap, vm = vm),
mode = STLTXSingleBurst(total_pkts = 1, percentage = 100),
self_start = True if (i == 1) else False,
isg = (ts_usec - last_ts_usec), # seconds to usec
diff --git a/scripts/stl/burst_split.py b/scripts/stl/burst_split.py
index 3f8593f5..393ea70e 100644
--- a/scripts/stl/burst_split.py
+++ b/scripts/stl/burst_split.py
@@ -12,7 +12,7 @@ class STLS1(object):
base_pkt = Ether()/IP(dst="48.0.0.1")/TCP(dport=80,flags="S")
- vm = CTRexScRaw( [ STLVmFlowVar(name="ip_src",
+ vm = STLScVmRaw( [ STLVmFlowVar(name="ip_src",
min_value="16.0.0.0",
max_value="18.0.0.254",
size=4, op="inc"),
diff --git a/scripts/stl/syn_attack.py b/scripts/stl/syn_attack.py
index 55abadf1..f6edcdd2 100644
--- a/scripts/stl/syn_attack.py
+++ b/scripts/stl/syn_attack.py
@@ -14,7 +14,7 @@ class STLS1(object):
# vm
- vm = CTRexScRaw( [ STLVmFlowVar(name="ip_src",
+ vm = STLScVmRaw( [ STLVmFlowVar(name="ip_src",
min_value="16.0.0.0",
max_value="18.0.0.254",
size=4, op="random"),
diff --git a/scripts/stl/udp_1pkt_1mac.py b/scripts/stl/udp_1pkt_1mac.py
index 0d2a01a8..0eeb2147 100644
--- a/scripts/stl/udp_1pkt_1mac.py
+++ b/scripts/stl/udp_1pkt_1mac.py
@@ -13,7 +13,7 @@ class STLS1(object):
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( [ STLVmFlowVar(name="mac_src", min_value=1, max_value=1, size=1, op="inc"), # 1 byte varible, range 1-1 ( workaround)
+ vm = STLScVmRaw( [ STLVmFlowVar(name="mac_src", min_value=1, max_value=1, size=1, op="inc"), # 1 byte varible, range 1-1 ( workaround)
STLVmWrFlowVar(fv_name="mac_src", pkt_offset= 11) # write it to LSB of SRC offset it 11
]
)
diff --git a/scripts/stl/udp_1pkt_1mac_override.py b/scripts/stl/udp_1pkt_1mac_override.py
index c00d906d..00d7a97e 100644
--- a/scripts/stl/udp_1pkt_1mac_override.py
+++ b/scripts/stl/udp_1pkt_1mac_override.py
@@ -17,7 +17,7 @@ class STLS1(object):
base_pkt = Ether(src="00:bb:12:34:56:01")/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( [ STLVmFlowVar(name="dyn_mac_src", min_value=1, max_value=10, size=1, op="inc"), # 1 byte varible, range 1-1 ( workaround)
+ vm = STLScVmRaw( [ STLVmFlowVar(name="dyn_mac_src", min_value=1, max_value=10, size=1, op="inc"), # 1 byte varible, range 1-1 ( workaround)
STLVmWrFlowVar(fv_name="dyn_mac_src", pkt_offset= 11)
]
)
diff --git a/scripts/stl/udp_1pkt_1mac_step.py b/scripts/stl/udp_1pkt_1mac_step.py
index bab46fb7..1dc001c5 100644
--- a/scripts/stl/udp_1pkt_1mac_step.py
+++ b/scripts/stl/udp_1pkt_1mac_step.py
@@ -14,7 +14,7 @@ class STLS1(object):
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( [ STLVmFlowVar(name="mac_src", min_value=1, max_value=30, size=1, op="dec",step=7),
+ vm = STLScVmRaw( [ STLVmFlowVar(name="mac_src", min_value=1, max_value=30, size=1, op="dec",step=7),
STLVmWrFlowVar(fv_name="mac_src", pkt_offset= 11) # write it to LSB of SRC offset it 11
]
)
diff --git a/scripts/stl/udp_1pkt_ipv6_in_ipv4.py b/scripts/stl/udp_1pkt_ipv6_in_ipv4.py
index 6f0eff26..fd862394 100644
--- a/scripts/stl/udp_1pkt_ipv6_in_ipv4.py
+++ b/scripts/stl/udp_1pkt_ipv6_in_ipv4.py
@@ -7,7 +7,7 @@ class STLS1(object):
# Teredo Ipv6 over Ipv4
pkt = Ether()/IP(src="16.0.0.1",dst="48.0.0.1")/UDP(dport=3797,sport=3544)/IPv6(dst="2001:0:4137:9350:8000:f12a:b9c8:2815",src="2001:4860:0:2001::68")/UDP(dport=12,sport=1025)/ICMPv6Unknown()
- vm = CTRexScRaw( [
+ vm = STLScVmRaw( [
# tuple gen for inner Ipv6
STLVmTupleGen ( ip_min="16.0.0.1", ip_max="16.0.0.2",
port_min=1025, port_max=65535,
diff --git a/scripts/stl/udp_1pkt_mac.py b/scripts/stl/udp_1pkt_mac.py
index a15c286c..94c92117 100644
--- a/scripts/stl/udp_1pkt_mac.py
+++ b/scripts/stl/udp_1pkt_mac.py
@@ -14,7 +14,7 @@ class STLS1(object):
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( [ STLVmFlowVar(name="mac_src", min_value=1, max_value=10, size=1, op="inc"), # 1 byte varible, range 1-10
+ vm = STLScVmRaw( [ STLVmFlowVar(name="mac_src", min_value=1, max_value=10, size=1, op="inc"), # 1 byte varible, range 1-10
STLVmWrFlowVar(fv_name="mac_src", pkt_offset= 11) # write it to LSB of SRC
]
)
diff --git a/scripts/stl/udp_1pkt_mac_mask1.py b/scripts/stl/udp_1pkt_mac_mask1.py
index 37f5079d..cc8dd407 100644
--- a/scripts/stl/udp_1pkt_mac_mask1.py
+++ b/scripts/stl/udp_1pkt_mac_mask1.py
@@ -14,7 +14,7 @@ class STLS1(object):
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( [ STLVmFlowVar(name="mac_src", min_value=1, max_value=30, size=2, op="dec",step=1),
+ vm = STLScVmRaw( [ STLVmFlowVar(name="mac_src", min_value=1, max_value=30, size=2, op="dec",step=1),
STLVmWrMaskFlowVar(fv_name="mac_src", pkt_offset= 11,pkt_cast_size=1, mask=0xff) # mask command ->write it as one byte
]
)
diff --git a/scripts/stl/udp_1pkt_mac_mask2.py b/scripts/stl/udp_1pkt_mac_mask2.py
index b72f0c3b..c3b242e9 100644
--- a/scripts/stl/udp_1pkt_mac_mask2.py
+++ b/scripts/stl/udp_1pkt_mac_mask2.py
@@ -14,7 +14,7 @@ class STLS1(object):
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( [ STLVmFlowVar(name="mac_src", min_value=1, max_value=30, size=2, op="dec",step=1),
+ vm = STLScVmRaw( [ STLVmFlowVar(name="mac_src", min_value=1, max_value=30, size=2, op="dec",step=1),
STLVmWrMaskFlowVar(fv_name="mac_src", pkt_offset= 10,pkt_cast_size=2, mask=0xff00,shift=8) # take the var shift it 8 (x256) write only to LSB
]
)
diff --git a/scripts/stl/udp_1pkt_mac_mask3.py b/scripts/stl/udp_1pkt_mac_mask3.py
index ef5bc4f0..47b8a63d 100644
--- a/scripts/stl/udp_1pkt_mac_mask3.py
+++ b/scripts/stl/udp_1pkt_mac_mask3.py
@@ -14,7 +14,7 @@ class STLS1(object):
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( [ STLVmFlowVar(name="mac_src", min_value=1, max_value=30, size=2, op="dec",step=1),
+ vm = STLScVmRaw( [ STLVmFlowVar(name="mac_src", min_value=1, max_value=30, size=2, op="dec",step=1),
STLVmWrMaskFlowVar(fv_name="mac_src", pkt_offset= 10,pkt_cast_size=1, mask=0x1,shift=-1) # take var mac_src>>1 and write the LSB every two packet there should be a change
]
)
diff --git a/scripts/stl/udp_1pkt_mac_mask5.py b/scripts/stl/udp_1pkt_mac_mask5.py
index 07c83897..ed09cbae 100644
--- a/scripts/stl/udp_1pkt_mac_mask5.py
+++ b/scripts/stl/udp_1pkt_mac_mask5.py
@@ -14,7 +14,7 @@ class STLS1(object):
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( [ STLVmFlowVar(name="mac_src", min_value=0, max_value=10, size=2, op="inc",step=1),
+ vm = STLScVmRaw( [ STLVmFlowVar(name="mac_src", min_value=0, max_value=10, size=2, op="inc",step=1),
STLVmWrMaskFlowVar(fv_name="mac_src", pkt_offset= 10,pkt_cast_size=1, mask=0xff,add_value=5,shift=0) # range is 5-15
]
)
diff --git a/scripts/stl/udp_1pkt_mac_step.py b/scripts/stl/udp_1pkt_mac_step.py
index 077a162b..5e46b8ad 100644
--- a/scripts/stl/udp_1pkt_mac_step.py
+++ b/scripts/stl/udp_1pkt_mac_step.py
@@ -14,7 +14,7 @@ class STLS1(object):
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( [ STLVmFlowVar(name="mac_src", min_value=1, max_value=100, size=1,step=2, op="inc"),
+ vm = STLScVmRaw( [ STLVmFlowVar(name="mac_src", min_value=1, max_value=100, size=1,step=2, op="inc"),
STLVmWrFlowVar(fv_name="mac_src", pkt_offset= 11) # write it to LSB of SRC offset it 11
]
)
diff --git a/scripts/stl/udp_1pkt_mpls_vm.py b/scripts/stl/udp_1pkt_mpls_vm.py
index 57cfb7ee..01ad5fec 100644
--- a/scripts/stl/udp_1pkt_mpls_vm.py
+++ b/scripts/stl/udp_1pkt_mpls_vm.py
@@ -11,7 +11,7 @@ class STLS1(object):
# 2 MPLS label the internal with s=1 (last one)
pkt = Ether()/MPLS(label=17,cos=1,s=0,ttl=255)/MPLS(label=0,cos=1,s=1,ttl=12)/IP(src="16.0.0.1",dst="48.0.0.1")/UDP(dport=12,sport=1025)/('x'*20)
- vm = CTRexScRaw( [ STLVmFlowVar(name="mlabel", min_value=1, max_value=2000, size=2, op="inc"), # 2 bytes var
+ vm = STLScVmRaw( [ STLVmFlowVar(name="mlabel", min_value=1, max_value=2000, size=2, op="inc"), # 2 bytes var
STLVmWrMaskFlowVar(fv_name="mlabel", pkt_offset= "MPLS:1.label",pkt_cast_size=4, mask=0xFFFFF000,shift=12) # write to 20bit MSB
]
)
diff --git a/scripts/stl/udp_1pkt_range_clients.py b/scripts/stl/udp_1pkt_range_clients.py
index 92b98e72..2754b3aa 100644
--- a/scripts/stl/udp_1pkt_range_clients.py
+++ b/scripts/stl/udp_1pkt_range_clients.py
@@ -21,7 +21,7 @@ class STLS1(object):
base_pkt = Ether(src="00:00:dd:dd:00:01")/IP(src="55.55.1.1",dst="58.0.0.1")/UDP(dport=12,sport=1025)
pad = max(0, size - len(base_pkt)) * 'x'
- vm = CTRexScRaw( [ STLVmFlowVar(name="mac_src", min_value=1, max_value=self.num_clients, size=2, op="inc"), # 1 byte varible, range 1-10
+ vm = STLScVmRaw( [ STLVmFlowVar(name="mac_src", min_value=1, max_value=self.num_clients, size=2, op="inc"), # 1 byte varible, range 1-10
STLVmWrFlowVar(fv_name="mac_src", pkt_offset= 10), # write it to LSB of ethernet.src
STLVmWrFlowVar(fv_name="mac_src" ,pkt_offset="IP.src",offset_fixup=2), # it is 2 byte so there is a need to fixup in 2 bytes
STLVmFixIpv4(offset = "IP")
diff --git a/scripts/stl/udp_1pkt_range_clients_split.py b/scripts/stl/udp_1pkt_range_clients_split.py
index 7df6d0d9..69c2dfcb 100644
--- a/scripts/stl/udp_1pkt_range_clients_split.py
+++ b/scripts/stl/udp_1pkt_range_clients_split.py
@@ -21,7 +21,7 @@ class STLS1(object):
base_pkt = Ether(src="00:00:dd:dd:00:01")/IP(src="55.55.1.1",dst="58.0.0.1")/UDP(dport=12,sport=1025)
pad = max(0, size - len(base_pkt)) * 'x'
- vm = CTRexScRaw( [ STLVmFlowVar(name="mac_src", min_value=1, max_value=self.num_clients, size=2, op="inc"), # 1 byte varible, range 1-10
+ vm = STLScVmRaw( [ STLVmFlowVar(name="mac_src", min_value=1, max_value=self.num_clients, size=2, op="inc"), # 1 byte varible, range 1-10
STLVmWrFlowVar(fv_name="mac_src", pkt_offset= 10), # write it to LSB of ethernet.src
STLVmWrFlowVar(fv_name="mac_src" ,pkt_offset="IP.src",offset_fixup=2), # it is 2 byte so there is a need to fixup in 2 bytes
STLVmFixIpv4(offset = "IP")
diff --git a/scripts/stl/udp_1pkt_range_clients_split_garp.py b/scripts/stl/udp_1pkt_range_clients_split_garp.py
index 3b9c8363..6e20edea 100644
--- a/scripts/stl/udp_1pkt_range_clients_split_garp.py
+++ b/scripts/stl/udp_1pkt_range_clients_split_garp.py
@@ -13,7 +13,7 @@ class STLS1(object):
# create a base packet and pad it to size
base_pkt = Ether(src="00:00:dd:dd:00:01",dst="ff:ff:ff:ff:ff:ff")/ARP(psrc="55.55.1.1",hwsrc="00:00:dd:dd:00:01", hwdst="00:00:dd:dd:00:01", pdst="55.55.1.1")
- vm = CTRexScRaw( [ STLVmFlowVar(name="mac_src", min_value=1, max_value=self.num_clients, size=2, op="inc"),
+ vm = STLScVmRaw( [ STLVmFlowVar(name="mac_src", min_value=1, max_value=self.num_clients, size=2, op="inc"),
STLVmWrFlowVar(fv_name="mac_src", pkt_offset= 10),
STLVmWrFlowVar(fv_name="mac_src" ,pkt_offset="ARP.psrc",offset_fixup=2),
STLVmWrFlowVar(fv_name="mac_src" ,pkt_offset="ARP.hwsrc",offset_fixup=4),
diff --git a/scripts/stl/udp_1pkt_simple_test.py b/scripts/stl/udp_1pkt_simple_test.py
index eb11d4e3..843d9bcf 100644
--- a/scripts/stl/udp_1pkt_simple_test.py
+++ b/scripts/stl/udp_1pkt_simple_test.py
@@ -14,7 +14,7 @@ class STLS1(object):
fsize_no_fcs = 129
base_pkt_a = Ether()/IP(dst="48.0.0.1",options=IPOption('\x01\x01\x01\x00'))/UDP(dport=12,sport=1025)
- vm1 = CTRexScRaw([
+ vm1 = STLScVmRaw([
STLVmFlowVar(name="src",min_value="10.0.0.1",max_value="10.0.0.10",size=4,op="inc"),
STLVmWrFlowVar(fv_name="src",pkt_offset= "IP.src"),
# checksum
diff --git a/scripts/stl/udp_1pkt_simple_test2.py b/scripts/stl/udp_1pkt_simple_test2.py
index c8da758d..52c93a7c 100644
--- a/scripts/stl/udp_1pkt_simple_test2.py
+++ b/scripts/stl/udp_1pkt_simple_test2.py
@@ -14,7 +14,7 @@ class STLS1(object):
fsize_no_fcs = 129
base_pkt_a = Ether()/IP()/IPv6()/IP(dst="48.0.0.1",options=IPOption('\x01\x01\x01\x00'))/UDP(dport=12,sport=1025)
- vm1 = CTRexScRaw([
+ vm1 = STLScVmRaw([
STLVmFlowVar(name="src",min_value="10.0.0.1",max_value="10.0.0.10",size=4,op="inc"),
STLVmWrFlowVar(fv_name="src",pkt_offset= "IP:1.src"),
# checksum
diff --git a/scripts/stl/udp_1pkt_tuple_gen.py b/scripts/stl/udp_1pkt_tuple_gen.py
index 08732f4c..a278e4bf 100644
--- a/scripts/stl/udp_1pkt_tuple_gen.py
+++ b/scripts/stl/udp_1pkt_tuple_gen.py
@@ -13,7 +13,7 @@ class STLS1(object):
pad = max(0, size - len(base_pkt)) * 'x'
- vm = CTRexScRaw( [ STLVmTupleGen ( ip_min="16.0.0.1", ip_max="16.0.0.2",
+ vm = STLScVmRaw( [ STLVmTupleGen ( ip_min="16.0.0.1", ip_max="16.0.0.2",
port_min=1025, port_max=65535,
name="tuple"), # define tuple gen
diff --git a/scripts/stl/udp_1pkt_tuple_gen_split.py b/scripts/stl/udp_1pkt_tuple_gen_split.py
index 3ab87b80..c7a98942 100644
--- a/scripts/stl/udp_1pkt_tuple_gen_split.py
+++ b/scripts/stl/udp_1pkt_tuple_gen_split.py
@@ -16,7 +16,7 @@ class STLS1(object):
pad = max(0, size - len(base_pkt)) * 'x'
- vm = CTRexScRaw( [ STLVmTupleGen ( ip_min="16.0.0.1", ip_max="16.0.0.10",
+ vm = STLScVmRaw( [ STLVmTupleGen ( ip_min="16.0.0.1", ip_max="16.0.0.10",
port_min=1025, port_max=65535,
name="tuple"), # define tuple gen
diff --git a/scripts/stl/udp_inc_len_9k.py b/scripts/stl/udp_inc_len_9k.py
index 09df305a..b76b9fb7 100644
--- a/scripts/stl/udp_inc_len_9k.py
+++ b/scripts/stl/udp_inc_len_9k.py
@@ -18,7 +18,7 @@ class STLS1(object):
# vm
- vm = CTRexScRaw( [ STLVmFlowVar(name="fv_rand", min_value=64, max_value=len(base_pkt), size=2, op="inc"),
+ vm = STLScVmRaw( [ STLVmFlowVar(name="fv_rand", min_value=64, max_value=len(base_pkt), size=2, op="inc"),
STLVmTrimPktSize("fv_rand"), # total packet size
STLVmWrFlowVar(fv_name="fv_rand", pkt_offset= "IP.len", add_val=l3_len_fix), # fix ip len
STLVmFixIpv4(offset = "IP"), # fix checksum
diff --git a/scripts/stl/udp_rand_len_9k.py b/scripts/stl/udp_rand_len_9k.py
index 335a6b33..c9339d2d 100644
--- a/scripts/stl/udp_rand_len_9k.py
+++ b/scripts/stl/udp_rand_len_9k.py
@@ -18,7 +18,7 @@ class STLS1(object):
# vm
- vm = CTRexScRaw( [ STLVmFlowVar(name="fv_rand", min_value=64, max_value=len(base_pkt), size=2, op="random"),
+ vm = STLScVmRaw( [ STLVmFlowVar(name="fv_rand", min_value=64, max_value=len(base_pkt), size=2, op="random"),
STLVmTrimPktSize("fv_rand"), # total packet size
STLVmWrFlowVar(fv_name="fv_rand", pkt_offset= "IP.len", add_val=l3_len_fix), # fix ip len
STLVmFixIpv4(offset = "IP"), # fix checksum