summaryrefslogtreecommitdiffstats
path: root/scripts
diff options
context:
space:
mode:
Diffstat (limited to 'scripts')
-rw-r--r--scripts/automation/regression/unit_tests/functional_tests/stl_basic_tests.py9
-rw-r--r--scripts/automation/trex_control_plane/stl/trex_stl_lib/api.py1
-rw-r--r--scripts/automation/trex_control_plane/stl/trex_stl_lib/trex_stl_packet_builder_scapy.py47
-rw-r--r--scripts/exp/udp_1pkt_mac_mask1.pcapbin0 -> 1544 bytes
-rw-r--r--scripts/exp/udp_1pkt_mac_mask2.pcapbin0 -> 1544 bytes
-rw-r--r--scripts/exp/udp_1pkt_mac_mask3.pcapbin0 -> 1544 bytes
-rw-r--r--scripts/exp/udp_1pkt_mpls_vm.pcapbin8624 -> 8624 bytes
-rw-r--r--scripts/exp/udp_64B_mask1-ex.pcapbin0 -> 1544 bytes
-rw-r--r--scripts/exp/udp_64B_vm_mask1-ex.pcapbin0 -> 1544 bytes
-rw-r--r--scripts/exp/udp_64B_vm_mask2-ex.pcapbin0 -> 1544 bytes
-rw-r--r--scripts/exp/udp_64B_vm_mask3-ex.pcapbin0 -> 1544 bytes
-rw-r--r--scripts/exp/udp_64B_vm_mask4-ex.pcapbin0 -> 1544 bytes
-rw-r--r--scripts/exp/udp_64B_vm_mask5-ex.pcapbin0 -> 1544 bytes
-rw-r--r--scripts/exp/udp_64B_vm_mask6-ex.pcapbin0 -> 1544 bytes
-rw-r--r--scripts/stl/udp_1pkt_1mac_step.py35
-rw-r--r--scripts/stl/udp_1pkt_mac_mask1.py35
-rw-r--r--scripts/stl/udp_1pkt_mac_mask2.py35
-rw-r--r--scripts/stl/udp_1pkt_mac_mask3.py35
-rw-r--r--scripts/stl/udp_1pkt_mpls_vm.py2
-rw-r--r--scripts/stl/yaml/imix_1pkt_vm_minus.yaml33
20 files changed, 229 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 03dbcf82..e6a82cf1 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
@@ -177,12 +177,17 @@ class CStlBasic_Test(functional_general_test.CGeneralFunctional_Test):
["udp_1pkt_simple_mac_dst.py","-m 1 -l 1 ",True],
["udp_1pkt_simple_mac_src.py","-m 1 -l 1 ",True],
["udp_1pkt_simple_mac_dst_src.py","-m 1 -l 1 ",True],
- ["burst_3st_loop_x_times.py","-m 1 -l 20 ",True]
+ ["burst_3st_loop_x_times.py","-m 1 -l 20 ",True],
+ ["udp_1pkt_mac_step.py","-m 1 -l 20 ",True],
+ ["udp_1pkt_mac_mask1.py","-m 1 -l 20 ",True] ,
+ ["udp_1pkt_mac_mask2.py","-m 1 -l 20 ",True],
+ ["udp_1pkt_mac_mask3.py","-m 1 -l 20 ",True]
+
];
- p1 = [ ["udp_1pkt_mac_step.py","-m 1 -l 20 ",True] ]
+ p1 = [ ["udp_1pkt_mpls_vm.py","-m 1 ",True] ]
for obj in p:
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 9ce9f7f1..d19dcaf0 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
@@ -16,6 +16,7 @@ STLPktBuilder = CScapyTRexPktBuilder
# VM
STLVmFlowVar = CTRexVmDescFlowVar
STLVmWrFlowVar = CTRexVmDescWrFlowVar
+STLVmWrMaskFlowVar = CTRexVmDescWrMaskFlowVar
STLVmFixIpv4 = CTRexVmDescFixIpv4
STLVmTrimPktSize = CTRexVmDescTrimPktSize
STLVmTupleGen = CTRexVmDescTupleGen
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 e028d6d5..24a7301b 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
@@ -234,6 +234,22 @@ class CTRexVmInsWrFlowVar(CTRexVmInsBase):
self.is_big_endian = is_big_endian
assert type(is_big_endian)==bool, 'type of is_big_endian is not bool'
+class CTRexVmInsWrMaskFlowVar(CTRexVmInsBase):
+ def __init__(self, fv_name, pkt_offset,pkt_cast_size,mask,shift, is_big_endian=True):
+ super(CTRexVmInsWrMaskFlowVar, self).__init__("write_mask_flow_var")
+ self.name = fv_name
+ assert type(fv_name)==str, 'type of fv_name is not str'
+ self.pkt_offset = pkt_offset
+ assert type(pkt_offset)==int, 'type of pkt_offset is not int'
+ self.pkt_cast_size = pkt_cast_size
+ assert type(pkt_cast_size)==int, 'type of pkt_cast_size is not int'
+ self.mask = mask
+ assert type(mask)==int, 'type of mask is not int'
+ self.shift = shift
+ assert type(shift)==int, 'type of shift is not int'
+ self.is_big_endian = is_big_endian
+ assert type(is_big_endian)==bool, 'type of is_big_endian is not bool'
+
class CTRexVmInsTrimPktSize(CTRexVmInsBase):
def __init__(self,fv_name):
super(CTRexVmInsTrimPktSize, self).__init__("trim_pkt_size")
@@ -562,6 +578,37 @@ class CTRexVmDescWrFlowVar(CTRexVmDescBase):
t=parent._name_to_offset(self.pkt_offset)
self.pkt_offset = t[0]
+class CTRexVmDescWrMaskFlowVar(CTRexVmDescBase):
+ def __init__(self, fv_name, pkt_offset, pkt_cast_size=1, mask=0xff, shift=0, offset_fixup=0, is_big=True):
+ super(CTRexVmDescWrMaskFlowVar, self).__init__()
+ self.name =fv_name
+ assert type(fv_name)==str, 'type of fv_name is not str'
+ self.offset_fixup =offset_fixup
+ assert type(offset_fixup)==int, 'type of offset_fixup is not int'
+ self.pkt_offset =pkt_offset
+ self.pkt_cast_size =pkt_cast_size
+ assert type(pkt_cast_size)==int,'type of pkt_cast_size is not int'
+ if not (pkt_cast_size in [1,2,4]):
+ raise CTRexPacketBuildException(-10,"not valid cast size");
+
+ self.mask = mask
+ assert type(mask)==int,'type of mask is not int'
+ self.shift = shift
+ assert type(shift)==int,'type of shift is not int'
+ self.is_big =is_big;
+ assert type(is_big)==bool,'type of is_big_endian is not bool'
+
+ def get_var_ref (self):
+ return self.name
+
+ def get_obj (self):
+ return CTRexVmInsWrMaskFlowVar(self.name,self.pkt_offset+self.offset_fixup,self.pkt_cast_size,self.mask,self.shift,self.is_big)
+
+ def compile(self,parent):
+ if type(self.pkt_offset)==str:
+ t=parent._name_to_offset(self.pkt_offset)
+ self.pkt_offset = t[0]
+
class CTRexVmDescTrimPktSize(CTRexVmDescBase):
def __init__(self,fv_name):
diff --git a/scripts/exp/udp_1pkt_mac_mask1.pcap b/scripts/exp/udp_1pkt_mac_mask1.pcap
new file mode 100644
index 00000000..65adb5eb
--- /dev/null
+++ b/scripts/exp/udp_1pkt_mac_mask1.pcap
Binary files differ
diff --git a/scripts/exp/udp_1pkt_mac_mask2.pcap b/scripts/exp/udp_1pkt_mac_mask2.pcap
new file mode 100644
index 00000000..07b00113
--- /dev/null
+++ b/scripts/exp/udp_1pkt_mac_mask2.pcap
Binary files differ
diff --git a/scripts/exp/udp_1pkt_mac_mask3.pcap b/scripts/exp/udp_1pkt_mac_mask3.pcap
new file mode 100644
index 00000000..d168dee0
--- /dev/null
+++ b/scripts/exp/udp_1pkt_mac_mask3.pcap
Binary files differ
diff --git a/scripts/exp/udp_1pkt_mpls_vm.pcap b/scripts/exp/udp_1pkt_mpls_vm.pcap
index f205b334..23fdc7fe 100644
--- a/scripts/exp/udp_1pkt_mpls_vm.pcap
+++ b/scripts/exp/udp_1pkt_mpls_vm.pcap
Binary files differ
diff --git a/scripts/exp/udp_64B_mask1-ex.pcap b/scripts/exp/udp_64B_mask1-ex.pcap
new file mode 100644
index 00000000..41005eeb
--- /dev/null
+++ b/scripts/exp/udp_64B_mask1-ex.pcap
Binary files differ
diff --git a/scripts/exp/udp_64B_vm_mask1-ex.pcap b/scripts/exp/udp_64B_vm_mask1-ex.pcap
new file mode 100644
index 00000000..80d4e370
--- /dev/null
+++ b/scripts/exp/udp_64B_vm_mask1-ex.pcap
Binary files differ
diff --git a/scripts/exp/udp_64B_vm_mask2-ex.pcap b/scripts/exp/udp_64B_vm_mask2-ex.pcap
new file mode 100644
index 00000000..89e43ebe
--- /dev/null
+++ b/scripts/exp/udp_64B_vm_mask2-ex.pcap
Binary files differ
diff --git a/scripts/exp/udp_64B_vm_mask3-ex.pcap b/scripts/exp/udp_64B_vm_mask3-ex.pcap
new file mode 100644
index 00000000..e8f7afee
--- /dev/null
+++ b/scripts/exp/udp_64B_vm_mask3-ex.pcap
Binary files differ
diff --git a/scripts/exp/udp_64B_vm_mask4-ex.pcap b/scripts/exp/udp_64B_vm_mask4-ex.pcap
new file mode 100644
index 00000000..4275b196
--- /dev/null
+++ b/scripts/exp/udp_64B_vm_mask4-ex.pcap
Binary files differ
diff --git a/scripts/exp/udp_64B_vm_mask5-ex.pcap b/scripts/exp/udp_64B_vm_mask5-ex.pcap
new file mode 100644
index 00000000..a738c780
--- /dev/null
+++ b/scripts/exp/udp_64B_vm_mask5-ex.pcap
Binary files differ
diff --git a/scripts/exp/udp_64B_vm_mask6-ex.pcap b/scripts/exp/udp_64B_vm_mask6-ex.pcap
new file mode 100644
index 00000000..d791abc5
--- /dev/null
+++ b/scripts/exp/udp_64B_vm_mask6-ex.pcap
Binary files differ
diff --git a/scripts/stl/udp_1pkt_1mac_step.py b/scripts/stl/udp_1pkt_1mac_step.py
new file mode 100644
index 00000000..bab46fb7
--- /dev/null
+++ b/scripts/stl/udp_1pkt_1mac_step.py
@@ -0,0 +1,35 @@
+from trex_stl_lib.api import *
+
+
+# step is not 1.
+class STLS1(object):
+
+ def __init__ (self):
+ self.fsize =64; # the size of the packet
+
+ 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( [ 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
+ ]
+ )
+
+ return STLStream(packet = STLPktBuilder(pkt = base_pkt/pad,vm = vm),
+ mode = STLTXCont( pps=10 ))
+
+ 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()
+
+
+
diff --git a/scripts/stl/udp_1pkt_mac_mask1.py b/scripts/stl/udp_1pkt_mac_mask1.py
new file mode 100644
index 00000000..37f5079d
--- /dev/null
+++ b/scripts/stl/udp_1pkt_mac_mask1.py
@@ -0,0 +1,35 @@
+from trex_stl_lib.api import *
+
+
+# step is not 1.
+class STLS1(object):
+
+ def __init__ (self):
+ self.fsize =64; # the size of the packet
+
+ 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( [ 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
+ ]
+ )
+
+ return STLStream(packet = STLPktBuilder(pkt = base_pkt/pad,vm = vm),
+ mode = STLTXCont( pps=10 ))
+
+ 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()
+
+
+
diff --git a/scripts/stl/udp_1pkt_mac_mask2.py b/scripts/stl/udp_1pkt_mac_mask2.py
new file mode 100644
index 00000000..b72f0c3b
--- /dev/null
+++ b/scripts/stl/udp_1pkt_mac_mask2.py
@@ -0,0 +1,35 @@
+from trex_stl_lib.api import *
+
+
+# step is not 1.
+class STLS1(object):
+
+ def __init__ (self):
+ self.fsize =64; # the size of the packet
+
+ 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( [ 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
+ ]
+ )
+
+ return STLStream(packet = STLPktBuilder(pkt = base_pkt/pad,vm = vm),
+ mode = STLTXCont( pps=10 ))
+
+ 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()
+
+
+
diff --git a/scripts/stl/udp_1pkt_mac_mask3.py b/scripts/stl/udp_1pkt_mac_mask3.py
new file mode 100644
index 00000000..ef5bc4f0
--- /dev/null
+++ b/scripts/stl/udp_1pkt_mac_mask3.py
@@ -0,0 +1,35 @@
+from trex_stl_lib.api import *
+
+
+# step is not 1.
+class STLS1(object):
+
+ def __init__ (self):
+ self.fsize =64; # the size of the packet
+
+ 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( [ 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
+ ]
+ )
+
+ return STLStream(packet = STLPktBuilder(pkt = base_pkt/pad,vm = vm),
+ mode = STLTXCont( pps=10 ))
+
+ 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()
+
+
+
diff --git a/scripts/stl/udp_1pkt_mpls_vm.py b/scripts/stl/udp_1pkt_mpls_vm.py
index 262a662f..57cfb7ee 100644
--- a/scripts/stl/udp_1pkt_mpls_vm.py
+++ b/scripts/stl/udp_1pkt_mpls_vm.py
@@ -12,7 +12,7 @@ class STLS1(object):
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
- STLVmWrFlowVar(fv_name="mlabel", pkt_offset= "MPLS:1.label") # LABEL is 20 bits expected is val*8 as 3 LSB are off, 16,32,64 .. using new instruction it will be possible to write to any bits
+ 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/yaml/imix_1pkt_vm_minus.yaml b/scripts/stl/yaml/imix_1pkt_vm_minus.yaml
new file mode 100644
index 00000000..bf67c83c
--- /dev/null
+++ b/scripts/stl/yaml/imix_1pkt_vm_minus.yaml
@@ -0,0 +1,33 @@
+### Single stream UDP packet, 64B ###
+#####################################
+- name: udp_64B
+ stream:
+ self_start: True
+ packet:
+ pcap: udp_64B_no_crc.pcap # pcap should not include CRC
+ mode:
+ type: continuous
+ pps: 100
+ rx_stats: []
+
+ vm:
+ instructions: [
+ {
+ "init_value" : 500,
+ "max_value" : 75000,
+ "min_value" : 1000,
+ "name" : "l3_src",
+ "op" : "inc",
+ "size" : 2,
+ "type" : "flow_var"
+ },
+ {
+ "add_value" : 1,
+ "is_big_endian" : false,
+ "name" : "l3_src",
+ "pkt_offset" : 34,
+ "type" : "write_flow_var"
+ }
+ ]
+ split_by_var: "l3_src"
+