diff options
author | 2016-09-29 14:00:35 +0300 | |
---|---|---|
committer | 2016-09-29 16:50:29 +0300 | |
commit | bb8100ae7487eca126c8312198a75ebab9acd41a (patch) | |
tree | 3e0bb2da653e686cfe8bb83c29fd072e9133480b | |
parent | 4f91be3fe9e751b8f264efe989f367976f3349ad (diff) |
add simple example for FixHwChecksum instruction
-rw-r--r-- | scripts/stl/syn_attack_fix_cs_hw.py | 60 |
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() + + + |