diff options
author | 2016-02-14 10:41:49 +0200 | |
---|---|---|
committer | 2016-02-14 10:41:49 +0200 | |
commit | b7200880fe61d91f95a3ba1e3510faa5da2e83b2 (patch) | |
tree | 2589442c50464e8a35fb49bbbd928fe6d42ac71c | |
parent | d152e9c2c08335cf81d2d2d4eb3faa1959bebad3 (diff) |
add vxlan example
-rw-r--r-- | scripts/automation/regression/unit_tests/functional_tests/stl_basic_tests.py | 7 | ||||
-rw-r--r-- | scripts/exp/udp_1pkt_vxlan.pcap | bin | 0 -> 2064 bytes | |||
-rw-r--r-- | scripts/external_libs/scapy-2.3.1/scapy/fields.py | 4 | ||||
-rw-r--r-- | scripts/stl/udp_1pkt_vxlan.py | 48 |
4 files changed, 56 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 280a95ec..393fdbff 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 @@ -148,7 +148,7 @@ class CStlBasic_Test(functional_general_test.CGeneralFunctional_Test): def test_stl_profiles (self): - p = [ + p1 = [ ["udp_1pkt_1mac_override.py","-m 1 -l 50",True], ["syn_attack.py","-m 1 -l 50",False], # can't compare random now ["udp_1pkt_1mac.py","-m 1 -l 50",True], @@ -176,12 +176,13 @@ class CStlBasic_Test(functional_general_test.CGeneralFunctional_Test): #["udp_1pkt_simple.py","-m 1 -l 3",True], ["udp_1pkt_pcap_relative_path.py","-m 1 -l 3",True], ["udp_1pkt_tuple_gen_split.py","-m 1 -c 2 -l 100",True], - ["udp_1pkt_range_clients_split.py","-m 1 -c 2 -l 100",True] + ["udp_1pkt_range_clients_split.py","-m 1 -c 2 -l 100",True], + ]; - p1 = [ ["udp_1pkt_range_clients_split.py","-m 1 -c 2 -l 100",True] ] + p = [ ["udp_1pkt_vxlan.py","-m 1 -c 1 -l 17",True] ] for obj in p: diff --git a/scripts/exp/udp_1pkt_vxlan.pcap b/scripts/exp/udp_1pkt_vxlan.pcap Binary files differnew file mode 100644 index 00000000..601185a0 --- /dev/null +++ b/scripts/exp/udp_1pkt_vxlan.pcap diff --git a/scripts/external_libs/scapy-2.3.1/scapy/fields.py b/scripts/external_libs/scapy-2.3.1/scapy/fields.py index 1b8d8604..8bb8c970 100644 --- a/scripts/external_libs/scapy-2.3.1/scapy/fields.py +++ b/scripts/external_libs/scapy-2.3.1/scapy/fields.py @@ -282,6 +282,10 @@ class X3BytesField(XByteField): def getfield(self, pkt, s): return s[3:], self.m2i(pkt, struct.unpack(self.fmt, "\x00"+s[:3])[0]) +class ThreeBytesField(X3BytesField, ByteField): + def i2repr(self, pkt, x): + return ByteField.i2repr(self, pkt, x) + class ShortField(Field): def __init__(self, name, default): diff --git a/scripts/stl/udp_1pkt_vxlan.py b/scripts/stl/udp_1pkt_vxlan.py new file mode 100644 index 00000000..3cb3dfbb --- /dev/null +++ b/scripts/stl/udp_1pkt_vxlan.py @@ -0,0 +1,48 @@ +from trex_stl_lib.api import * + +# Adding header that does not exists yet in Scapy +# This was taken from pull request of Scapy +# + + +# RFC 7348 - Virtual eXtensible Local Area Network (VXLAN): +# A Framework for Overlaying Virtualized Layer 2 Networks over Layer 3 Networks +# http://tools.ietf.org/html/rfc7348 +_VXLAN_FLAGS = ['R' for i in range(0, 24)] + ['R', 'R', 'R', 'I', 'R', 'R', 'R', 'R', 'R'] + +class VXLAN(Packet): + name = "VXLAN" + fields_desc = [FlagsField("flags", 0x08000000, 32, _VXLAN_FLAGS), + ThreeBytesField("vni", 0), + XByteField("reserved", 0x00)] + + def mysummary(self): + return self.sprintf("VXLAN (vni=%VXLAN.vni%)") + +bind_layers(UDP, VXLAN, dport=4789) +bind_layers(VXLAN, Ether) + + +class STLS1(object): + + def __init__ (self): + pass; + + def create_stream (self): + pkt = Ether()/IP()/UDP(sport=1337,dport=4789)/VXLAN(vni=42)/Ether()/IP()/('x'*20) + pkt.show2() + + # burst of 17 packets + return STLStream(packet = STLPktBuilder(pkt = pkt ,vm = []), + mode = STLTXSingleBurst( pps = 1, total_pkts = 17) ) + + + def get_streams (self, direction = 0): + # create 1 stream + return [ self.create_stream() ] + +def register(): + return STLS1() + + + |