summaryrefslogtreecommitdiffstats
path: root/scripts/stl
diff options
context:
space:
mode:
authorYaroslav Brustinov <ybrustin@cisco.com>2016-02-11 18:24:48 +0200
committerYaroslav Brustinov <ybrustin@cisco.com>2016-02-11 18:24:48 +0200
commitd152e9c2c08335cf81d2d2d4eb3faa1959bebad3 (patch)
tree278dc3d919fecf29f95bfd0e62df8731d973945e /scripts/stl
parent2312f48f6cee5c9aa2448ec5dcd41be32bbe5ead (diff)
parent83f29366ff01ec99d40c1146c57d3f9e6e33ee71 (diff)
Merge remote-tracking branch 'origin/master'
Diffstat (limited to 'scripts/stl')
-rw-r--r--scripts/stl/udp_1pkt_range_clients_split.py50
1 files changed, 50 insertions, 0 deletions
diff --git a/scripts/stl/udp_1pkt_range_clients_split.py b/scripts/stl/udp_1pkt_range_clients_split.py
new file mode 100644
index 00000000..7aee009d
--- /dev/null
+++ b/scripts/stl/udp_1pkt_range_clients_split.py
@@ -0,0 +1,50 @@
+from trex_stl_lib.api import *
+
+
+# x clients override the LSB of destination
+#Base src ip : 55.55.1.1, dst ip: Fixed
+#Increment src ipt portion starting at 55.55.1.1 for 'n' number of clients (55.55.1.1, 55.55.1.2)
+#Src MAC: start with 0000.dddd.0001, increment mac in steps of 1
+#Dst MAC: Fixed (will be taken from trex_conf.yaml
+
+
+class STLS1(object):
+
+ def __init__ (self):
+ self.num_clients =30000; # max is 16bit
+ self.fsize =64
+
+ def create_stream (self):
+
+ # create a base packet and pad it to size
+ size = self.fsize - 4; # no FCS
+ base_pkt = Ether()/IP(src="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
+ STLVmFlowVar(name="mac_src_wa", min_value=0x0000dddd, max_value=0x0000dddd, size=4, op="inc"), # workaround hardcoded the src MAC MSB, will be solved as an option in the stream
+
+ STLVmWrFlowVar(fv_name="mac_src_wa", pkt_offset= 6), # write constrant 0000.ddddd
+ 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"),
+
+
+ ]
+ ,split_by_field = "mac_src" # split
+ )
+
+ 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()
+
+
+