summaryrefslogtreecommitdiffstats
path: root/scripts/stl
diff options
context:
space:
mode:
authorHanoh Haim <hhaim@cisco.com>2016-09-29 14:00:35 +0300
committerHanoh Haim <hhaim@cisco.com>2016-09-29 16:50:29 +0300
commitbb8100ae7487eca126c8312198a75ebab9acd41a (patch)
tree3e0bb2da653e686cfe8bb83c29fd072e9133480b /scripts/stl
parent4f91be3fe9e751b8f264efe989f367976f3349ad (diff)
add simple example for FixHwChecksum instruction
Diffstat (limited to 'scripts/stl')
-rw-r--r--scripts/stl/syn_attack_fix_cs_hw.py60
1 files changed, 60 insertions, 0 deletions
diff --git a/scripts/stl/syn_attack_fix_cs_hw.py b/scripts/stl/syn_attack_fix_cs_hw.py
new file mode 100644
index 00000000..694a97a3
--- /dev/null
+++ b/scripts/stl/syn_attack_fix_cs_hw.py
@@ -0,0 +1,60 @@
+from trex_stl_lib.api import *
+
+class STLS1(object):
+ """ attack 48.0.0.1 at port 80
+ """
+
+ def __init__ (self):
+ self.max_pkt_size_l3 =9*1024;
+
+ def create_stream (self):
+
+ # TCP SYN
+ base_pkt = Ether()/IP(dst="48.0.0.1")/TCP(dport=80,flags="S")
+
+
+ # vm
+ vm = STLScVmRaw( [ 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" ),
+
+
+ STLVmWrFlowVar(fv_name="src_port",
+ pkt_offset= "TCP.sport"), # fix udp len
+
+ # must be last
+ STLVmFixChecksumHw(l3_offset = "IP",
+ l4_offset = "TCP",
+ l4_type = CTRexVmInsFixHwCs.L4_TYPE_TCP )# hint, TRex can know that
+
+ ]
+ )
+
+ 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())
+
+
+
+ def get_streams (self, direction = 0, **kwargs):
+ # create 1 stream
+ return [ self.create_stream() ]
+
+
+# dynamic load - used for trex console or simulator
+def register():
+ return STLS1()
+
+
+