diff options
author | Hanoh Haim <hhaim@cisco.com> | 2016-03-14 14:08:29 +0200 |
---|---|---|
committer | Hanoh Haim <hhaim@cisco.com> | 2016-03-14 14:08:29 +0200 |
commit | 9a3228de830a3517d52ab60a9ec2832dd69f62f9 (patch) | |
tree | e9794106b20a43e9ddd0e507006d52954c1a6f40 /scripts/automation | |
parent | 22f33006471cfed556e6987f88d3d9f7e532687a (diff) |
add packet builder doc
Diffstat (limited to 'scripts/automation')
3 files changed, 79 insertions, 38 deletions
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 index 271ff058..8b192491 100644 --- a/scripts/automation/trex_control_plane/doc_stl/api/field_engine.rst +++ b/scripts/automation/trex_control_plane/doc_stl/api/field_engine.rst @@ -27,7 +27,7 @@ for example this snippet will create SYN Attack:: # 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"), @@ -57,12 +57,12 @@ for example this snippet will create SYN Attack:: -CTRexScRaw class +STLScVmRaw class ---------------- Aggregate a raw instructions objects -.. autoclass:: trex_stl_lib.trex_stl_packet_builder_scapy.CTRexScRaw +.. autoclass:: trex_stl_lib.trex_stl_packet_builder_scapy.STLScVmRaw :members: :member-order: bysource @@ -70,27 +70,21 @@ Aggregate a raw instructions objects STLVmFlowVar ------------ -It is alias for CTRexVmDescFlowVar - -.. autoclass:: trex_stl_lib.trex_stl_packet_builder_scapy.CTRexVmDescFlowVar +.. autoclass:: trex_stl_lib.trex_stl_packet_builder_scapy.STLVmFlowVar :members: :member-order: bysource STLVmWrMaskFlowVar ------------------ -It is alias for CTRexVmDescWrMaskFlowVar - -.. autoclass:: trex_stl_lib.trex_stl_packet_builder_scapy.CTRexVmDescWrMaskFlowVar +.. autoclass:: trex_stl_lib.trex_stl_packet_builder_scapy.STLVmWrMaskFlowVar :members: :member-order: bysource STLVmFixIpv4 ------------------ -It is alias for CTRexVmDescFixIpv4 - -.. autoclass:: trex_stl_lib.trex_stl_packet_builder_scapy.CTRexVmDescFixIpv4 +.. autoclass:: trex_stl_lib.trex_stl_packet_builder_scapy.STLVmFixIpv4 :members: :member-order: bysource @@ -98,27 +92,14 @@ It is alias for CTRexVmDescFixIpv4 STLVmTrimPktSize ------------------ -It is alias for CTRexVmDescTrimPktSize - -.. autoclass:: trex_stl_lib.trex_stl_packet_builder_scapy.CTRexVmDescTrimPktSize +.. autoclass:: trex_stl_lib.trex_stl_packet_builder_scapy.STLVmTrimPktSize :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 +.. autoclass:: trex_stl_lib.trex_stl_packet_builder_scapy.STLVmTupleGen :members: :member-order: bysource @@ -134,12 +115,14 @@ Example1:: 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 + 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 - STLVmWrFlowVar (fv_name="tuple.ip", pkt_offset= "IP.src" ), # write ip to packet IP.src - STLVmFixIpv4(offset = "IP"), # fix checksum + # write ip to packet IP.src + STLVmWrFlowVar (fv_name="tuple.ip", pkt_offset= "IP.src" ), + + STLVmFixIpv4(offset = "IP"), # fix checksum STLVmWrFlowVar (fv_name="tuple.port", pkt_offset= "UDP.sport" ) #write udp.port ] ); @@ -156,9 +139,15 @@ Example2:: 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) - ] - ) + 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) + ] + ) 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 733a896d..6e189114 100644 --- a/scripts/automation/trex_control_plane/doc_stl/api/index.rst +++ b/scripts/automation/trex_control_plane/doc_stl/api/index.rst @@ -9,7 +9,7 @@ TRex Stateless API Reference client_code -**TRex Traffic profile: STLProfile,STLStream ** +**TRex Traffic profile STLProfile,STLStream** .. toctree:: :maxdepth: 4 @@ -17,7 +17,15 @@ TRex Stateless API Reference profile_code -**TRex Field Engine: ** +**Packet builder** + +.. toctree:: + :maxdepth: 4 + + scapy_builder + + +**TRex Field Engine** .. toctree:: :maxdepth: 4 diff --git a/scripts/automation/trex_control_plane/doc_stl/api/scapy_builder.rst b/scripts/automation/trex_control_plane/doc_stl/api/scapy_builder.rst new file mode 100644 index 00000000..5544df63 --- /dev/null +++ b/scripts/automation/trex_control_plane/doc_stl/api/scapy_builder.rst @@ -0,0 +1,44 @@ + +Packet builder modules +======================= + +The packet builder module objective is to build a template packet for a stream and to create a Field engine program to change fields in the packet. + +**Some examples for what can be done:** + +* Build a IP/UDP/DNS packet and create a range of src_ip = 10.0.0.1-10.0.0.255 +* Build a IP/UDP packets in IMIX sizes + + +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") + + pkt = STLPktBuilder(pkt = base_pkt) + + return STLStream(packet = pkt, #<<<<< set packet builder inside the stream + mode = STLTXCont()) + + + + +STLPktBuilder class +-------------------- + +Aggregate a raw instructions objects + +.. autoclass:: trex_stl_lib.trex_stl_packet_builder_scapy.STLPktBuilder + :members: + :member-order: bysource + + + + + |