summaryrefslogtreecommitdiffstats
path: root/src/plugins/nat/extras
diff options
context:
space:
mode:
Diffstat (limited to 'src/plugins/nat/extras')
-rw-r--r--src/plugins/nat/extras/README33
-rw-r--r--src/plugins/nat/extras/nat_100ks.py35
-rw-r--r--src/plugins/nat/extras/nat_10Ms.py35
-rw-r--r--src/plugins/nat/extras/nat_10ks.py35
-rw-r--r--src/plugins/nat/extras/nat_1Ms.py35
-rw-r--r--src/plugins/nat/extras/nat_dynamic9
-rw-r--r--src/plugins/nat/extras/nat_out2in_100ks.py35
-rw-r--r--src/plugins/nat/extras/nat_out2in_10Ms.py35
-rw-r--r--src/plugins/nat/extras/nat_out2in_10ks.py35
-rw-r--r--src/plugins/nat/extras/nat_out2in_1Ms.py35
-rw-r--r--src/plugins/nat/extras/nat_ses_open.py58
-rwxr-xr-xsrc/plugins/nat/extras/nat_static_gen_cfg.py25
-rw-r--r--src/plugins/nat/extras/trex_cfg.yaml21
13 files changed, 426 insertions, 0 deletions
diff --git a/src/plugins/nat/extras/README b/src/plugins/nat/extras/README
new file mode 100644
index 00000000000..0c9c392eb85
--- /dev/null
+++ b/src/plugins/nat/extras/README
@@ -0,0 +1,33 @@
+NAT44 performance testing with TRex
+
+Setup:
+
+ TRex host VPP host
+---------------------------- ---------------------------------------------
+| | | |
+| 04:00.0/172.16.1.2/port 0|<---->|04:00.1/172.16.1.1/TenGigabitEthernet4/0/1 |
+| | | |
+| 04:00.1/172.16.2.2/port 1|<---->|04:00.0/172.16.2.2/TenGigabitEthernet4/0/0 |
+| | | |
+---------------------------- ---------------------------------------------
+
+How to use TRex:
+1) Copy configuration file to /etc/trex_cfg.yaml or use --cfg option in next step
+2) Start TRex as a server 'sudo ./t-rex-64 -i'
+3) Connect with console './trex-console'
+4) Resolve destination addresses 'reset ; service ; arp ; service --off'
+5) Start traffic to open sessions in2out 'start -f stl/nat_10ks.py -m 10mbps -p 1' or out2in 'start -f stl/nat_out2in_10ks.py -m 10mbps -p 0'
+6) After all sessions are opened update stream rate to 100% 'update -a -m 100%'
+7) Show dynamic statistic 'tui'
+8) Exit dynamic statistic 'q'
+9) Stop traffic 'stop -a'
+10) Sessions per second (slowpath) test 'reset ; service ; arp ; service --off; start -f stl/nat_ses_open.py -m 100% -p 1 -d 1' and 'show nat44' in VPP CLI to see number of opened sessions
+
+VPP config files:
+in2out testing nat_dynamic
+for out2in testing generate config using 'nat_static_gen_cfg.py N'
+
+References:
+https://github.com/cisco-system-traffic-generator/trex-core/blob/master/doc/trex_stateless.asciidoc
+https://github.com/cisco-system-traffic-generator/trex-core/blob/master/doc/trex_console.asciidoc
+https://wiki.fd.io/view/VPP/NAT#NAT44
diff --git a/src/plugins/nat/extras/nat_100ks.py b/src/plugins/nat/extras/nat_100ks.py
new file mode 100644
index 00000000000..f54a6e8342d
--- /dev/null
+++ b/src/plugins/nat/extras/nat_100ks.py
@@ -0,0 +1,35 @@
+from trex_stl_lib.api import *
+
+class STLS1(object):
+
+ def create_stream (self):
+ base_pkt = Ether()/IP(dst="2.2.0.1")/UDP(dport=12)
+
+ pad = Padding()
+ if len(base_pkt) < 64:
+ pad_len = 64 - len(base_pkt)
+ pad.load = '\x00' * pad_len
+
+ vm = STLVM()
+
+ vm.tuple_var(name="tuple", ip_min="10.0.0.3", ip_max="10.0.3.234", port_min=1025, port_max=1124, limit_flows = 100000)
+
+ vm.write(fv_name="tuple.ip", pkt_offset="IP.src")
+ vm.fix_chksum()
+
+ vm.write(fv_name="tuple.port", pkt_offset="UDP.sport")
+
+ pkt = STLPktBuilder(pkt=base_pkt/pad, vm=vm)
+
+ return STLStream(packet=pkt, mode=STLTXCont())
+
+ def get_streams (self, direction = 0, **kwargs):
+ return [self.create_stream()]
+
+
+# dynamic load - used for trex console or simulator
+def register():
+ return STLS1()
+
+
+
diff --git a/src/plugins/nat/extras/nat_10Ms.py b/src/plugins/nat/extras/nat_10Ms.py
new file mode 100644
index 00000000000..068ca5b54ba
--- /dev/null
+++ b/src/plugins/nat/extras/nat_10Ms.py
@@ -0,0 +1,35 @@
+from trex_stl_lib.api import *
+
+class STLS1(object):
+
+ def create_stream (self):
+ base_pkt = Ether()/IP(dst="2.2.0.1")/UDP(dport=12)
+
+ pad = Padding()
+ if len(base_pkt) < 64:
+ pad_len = 64 - len(base_pkt)
+ pad.load = '\x00' * pad_len
+
+ vm = STLVM()
+
+ vm.tuple_var(name="tuple", ip_min="10.0.0.3", ip_max="10.1.134.162", port_min=1025, port_max=1124, limit_flows=10000000)
+
+ vm.write(fv_name="tuple.ip", pkt_offset="IP.src")
+ vm.fix_chksum()
+
+ vm.write(fv_name="tuple.port", pkt_offset="UDP.sport")
+
+ pkt = STLPktBuilder(pkt=base_pkt/pad, vm=vm)
+
+ return STLStream(packet=pkt, mode=STLTXCont())
+
+ def get_streams (self, direction = 0, **kwargs):
+ return [self.create_stream()]
+
+
+# dynamic load - used for trex console or simulator
+def register():
+ return STLS1()
+
+
+
diff --git a/src/plugins/nat/extras/nat_10ks.py b/src/plugins/nat/extras/nat_10ks.py
new file mode 100644
index 00000000000..9bd7d8ffd6d
--- /dev/null
+++ b/src/plugins/nat/extras/nat_10ks.py
@@ -0,0 +1,35 @@
+from trex_stl_lib.api import *
+
+class STLS1(object):
+
+ def create_stream (self):
+ base_pkt = Ether()/IP(dst="2.2.0.1")/UDP(dport=12)
+
+ pad = Padding()
+ if len(base_pkt) < 64:
+ pad_len = 64 - len(base_pkt)
+ pad.load = '\x00' * pad_len
+
+ vm = STLVM()
+
+ vm.tuple_var(name="tuple", ip_min="10.0.0.3", ip_max="10.0.0.102", port_min=1025, port_max=1124, limit_flows = 10000)
+
+ vm.write(fv_name="tuple.ip", pkt_offset="IP.src")
+ vm.fix_chksum()
+
+ vm.write(fv_name="tuple.port", pkt_offset="UDP.sport")
+
+ pkt = STLPktBuilder(pkt=base_pkt/pad, vm=vm)
+
+ return STLStream(packet=pkt, mode=STLTXCont())
+
+ def get_streams (self, direction = 0, **kwargs):
+ return [self.create_stream()]
+
+
+# dynamic load - used for trex console or simulator
+def register():
+ return STLS1()
+
+
+
diff --git a/src/plugins/nat/extras/nat_1Ms.py b/src/plugins/nat/extras/nat_1Ms.py
new file mode 100644
index 00000000000..acee676043b
--- /dev/null
+++ b/src/plugins/nat/extras/nat_1Ms.py
@@ -0,0 +1,35 @@
+from trex_stl_lib.api import *
+
+class STLS1(object):
+
+ def create_stream (self):
+ base_pkt = Ether()/IP(dst="2.2.0.1")/UDP(dport=12)
+
+ pad = Padding()
+ if len(base_pkt) < 64:
+ pad_len = 64 - len(base_pkt)
+ pad.load = '\x00' * pad_len
+
+ vm = STLVM()
+
+ vm.tuple_var(name="tuple", ip_min="10.0.0.3", ip_max="10.0.39.18", port_min=1025, port_max=1124, limit_flows = 1000000)
+
+ vm.write(fv_name="tuple.ip", pkt_offset="IP.src")
+ vm.fix_chksum()
+
+ vm.write(fv_name="tuple.port", pkt_offset="UDP.sport")
+
+ pkt = STLPktBuilder(pkt=base_pkt/pad, vm=vm)
+
+ return STLStream(packet=pkt, mode=STLTXCont())
+
+ def get_streams (self, direction = 0, **kwargs):
+ return [self.create_stream()]
+
+
+# dynamic load - used for trex console or simulator
+def register():
+ return STLS1()
+
+
+
diff --git a/src/plugins/nat/extras/nat_dynamic b/src/plugins/nat/extras/nat_dynamic
new file mode 100644
index 00000000000..f723b918a9c
--- /dev/null
+++ b/src/plugins/nat/extras/nat_dynamic
@@ -0,0 +1,9 @@
+set int ip address TenGigabitEthernet4/0/0 172.16.2.1/24
+set int ip address TenGigabitEthernet4/0/1 172.16.1.1/24
+set int state TenGigabitEthernet4/0/0 up
+set int state TenGigabitEthernet4/0/1 up
+ip route add 2.2.0.0/16 via 172.16.1.2 TenGigabitEthernet4/0/1
+ip route add 10.0.0.0/16 via 172.16.2.2 TenGigabitEthernet4/0/0
+set int nat44 in TenGigabitEthernet4/0/0 out TenGigabitEthernet4/0/1
+nat44 add address 172.16.1.3 - 172.16.1.163
+
diff --git a/src/plugins/nat/extras/nat_out2in_100ks.py b/src/plugins/nat/extras/nat_out2in_100ks.py
new file mode 100644
index 00000000000..c1d42195f37
--- /dev/null
+++ b/src/plugins/nat/extras/nat_out2in_100ks.py
@@ -0,0 +1,35 @@
+from trex_stl_lib.api import *
+
+class STLS1(object):
+
+ def create_stream (self):
+ base_pkt = Ether()/IP(src="2.2.0.1")/UDP(sport=12)
+
+ pad = Padding()
+ if len(base_pkt) < 64:
+ pad_len = 64 - len(base_pkt)
+ pad.load = '\x00' * pad_len
+
+ vm = STLVM()
+
+ vm.tuple_var(name="tuple", ip_min="173.16.1.3", ip_max="173.16.4.234", port_min=1025, port_max=1124, limit_flows = 100000)
+
+ vm.write(fv_name="tuple.ip", pkt_offset="IP.dst")
+ vm.fix_chksum()
+
+ vm.write(fv_name="tuple.port", pkt_offset="UDP.dport")
+
+ pkt = STLPktBuilder(pkt=base_pkt/pad, vm=vm)
+
+ return STLStream(packet=pkt, mode=STLTXCont())
+
+ def get_streams (self, direction = 0, **kwargs):
+ return [self.create_stream()]
+
+
+# dynamic load - used for trex console or simulator
+def register():
+ return STLS1()
+
+
+
diff --git a/src/plugins/nat/extras/nat_out2in_10Ms.py b/src/plugins/nat/extras/nat_out2in_10Ms.py
new file mode 100644
index 00000000000..fbd0643569a
--- /dev/null
+++ b/src/plugins/nat/extras/nat_out2in_10Ms.py
@@ -0,0 +1,35 @@
+from trex_stl_lib.api import *
+
+class STLS1(object):
+
+ def create_stream (self):
+ base_pkt = Ether()/IP(src="2.2.0.1")/UDP(sport=12)
+
+ pad = Padding()
+ if len(base_pkt) < 64:
+ pad_len = 64 - len(base_pkt)
+ pad.load = '\x00' * pad_len
+
+ vm = STLVM()
+
+ vm.tuple_var(name="tuple", ip_min="173.16.1.3", ip_max="173.17.135.162", port_min=1025, port_max=1124, limit_flows = 10000000)
+
+ vm.write(fv_name="tuple.ip", pkt_offset="IP.dst")
+ vm.fix_chksum()
+
+ vm.write(fv_name="tuple.port", pkt_offset="UDP.dport")
+
+ pkt = STLPktBuilder(pkt=base_pkt/pad, vm=vm)
+
+ return STLStream(packet=pkt, mode=STLTXCont())
+
+ def get_streams (self, direction = 0, **kwargs):
+ return [self.create_stream()]
+
+
+# dynamic load - used for trex console or simulator
+def register():
+ return STLS1()
+
+
+
diff --git a/src/plugins/nat/extras/nat_out2in_10ks.py b/src/plugins/nat/extras/nat_out2in_10ks.py
new file mode 100644
index 00000000000..661381e8ec7
--- /dev/null
+++ b/src/plugins/nat/extras/nat_out2in_10ks.py
@@ -0,0 +1,35 @@
+from trex_stl_lib.api import *
+
+class STLS1(object):
+
+ def create_stream (self):
+ base_pkt = Ether()/IP(src="2.2.0.1")/UDP(sport=12)
+
+ pad = Padding()
+ if len(base_pkt) < 64:
+ pad_len = 64 - len(base_pkt)
+ pad.load = '\x00' * pad_len
+
+ vm = STLVM()
+
+ vm.tuple_var(name="tuple", ip_min="173.16.1.3", ip_max="173.16.1.102", port_min=1025, port_max=1124, limit_flows = 100000)
+
+ vm.write(fv_name="tuple.ip", pkt_offset="IP.dst")
+ vm.fix_chksum()
+
+ vm.write(fv_name="tuple.port", pkt_offset="UDP.dport")
+
+ pkt = STLPktBuilder(pkt=base_pkt/pad, vm=vm)
+
+ return STLStream(packet=pkt, mode=STLTXCont())
+
+ def get_streams (self, direction = 0, **kwargs):
+ return [self.create_stream()]
+
+
+# dynamic load - used for trex console or simulator
+def register():
+ return STLS1()
+
+
+
diff --git a/src/plugins/nat/extras/nat_out2in_1Ms.py b/src/plugins/nat/extras/nat_out2in_1Ms.py
new file mode 100644
index 00000000000..54ca5d5bd11
--- /dev/null
+++ b/src/plugins/nat/extras/nat_out2in_1Ms.py
@@ -0,0 +1,35 @@
+from trex_stl_lib.api import *
+
+class STLS1(object):
+
+ def create_stream (self):
+ base_pkt = Ether()/IP(src="2.2.0.1")/UDP(sport=12)
+
+ pad = Padding()
+ if len(base_pkt) < 64:
+ pad_len = 64 - len(base_pkt)
+ pad.load = '\x00' * pad_len
+
+ vm = STLVM()
+
+ vm.tuple_var(name="tuple", ip_min="173.16.1.3", ip_max="173.16.40.18", port_min=1025, port_max=1124, limit_flows = 1000000)
+
+ vm.write(fv_name="tuple.ip", pkt_offset="IP.dst")
+ vm.fix_chksum()
+
+ vm.write(fv_name="tuple.port", pkt_offset="UDP.dport")
+
+ pkt = STLPktBuilder(pkt=base_pkt/pad, vm=vm)
+
+ return STLStream(packet=pkt, mode=STLTXCont())
+
+ def get_streams (self, direction = 0, **kwargs):
+ return [self.create_stream()]
+
+
+# dynamic load - used for trex console or simulator
+def register():
+ return STLS1()
+
+
+
diff --git a/src/plugins/nat/extras/nat_ses_open.py b/src/plugins/nat/extras/nat_ses_open.py
new file mode 100644
index 00000000000..9f0f77e23f9
--- /dev/null
+++ b/src/plugins/nat/extras/nat_ses_open.py
@@ -0,0 +1,58 @@
+from trex_stl_lib.api import *
+
+class STLS1(object):
+
+ def __init__ (self):
+ self.ip_range = {'local': {'start': "10.0.0.3", 'end': "10.1.255.255"},
+ 'external': {'start': "172.16.1.3", 'end': "172.16.1.3"},
+ 'remote': {'start': "2.2.0.1", 'end': "2.2.0.1"}}
+ self.port_range = {'local': {'start': 1025, 'end': 65535},
+ 'remote': {'start': 12, 'end': 12}}
+
+ def create_stream (self, vm):
+ base_pkt = Ether()/IP()/UDP()
+
+ if len(base_pkt) < 64:
+ pad_len = 64 - len(base_pkt)
+ pad = Padding()
+ pad.load = '\x00' * pad_len
+ base_pkt = base_pkt/pad
+
+ pkt = STLPktBuilder(pkt=base_pkt, vm=vm)
+ return STLStream(packet=pkt, mode=STLTXCont())
+
+ def get_streams (self, direction = 0, **kwargs):
+ if direction == 0:
+ ip_src = self.ip_range['remote']
+ ip_dst = self.ip_range['external']
+ src_port = self.port_range['remote']
+ dst_port = self.port_range['local']
+ else:
+ ip_src = self.ip_range['local']
+ ip_dst = self.ip_range['remote']
+ src_port = self.port_range['local']
+ dst_port = self.port_range['remote']
+
+ vm = STLVM()
+
+ vm.var(name="ip_src", min_value=ip_src['start'], max_value=ip_src['end'], size=4, op="random")
+ vm.var(name="ip_dst", min_value=ip_dst['start'], max_value=ip_dst['end'], size=4, op="random")
+ vm.var(name="src_port", min_value=src_port['start'], max_value=src_port['end'], size=2, op="random")
+ vm.var(name="dst_port", min_value=dst_port['start'], max_value=dst_port['end'], size=2, op="random")
+
+ vm.write(fv_name="ip_src", pkt_offset="IP.src")
+ vm.write(fv_name="ip_dst", pkt_offset="IP.dst")
+ vm.write(fv_name="src_port", pkt_offset="UDP.sport")
+ vm.write(fv_name="dst_port", pkt_offset="UDP.dport")
+
+ vm.fix_chksum()
+
+ return [ self.create_stream(vm) ]
+
+
+# dynamic load - used for trex console or simulator
+def register():
+ return STLS1()
+
+
+
diff --git a/src/plugins/nat/extras/nat_static_gen_cfg.py b/src/plugins/nat/extras/nat_static_gen_cfg.py
new file mode 100755
index 00000000000..ff6312aecf6
--- /dev/null
+++ b/src/plugins/nat/extras/nat_static_gen_cfg.py
@@ -0,0 +1,25 @@
+#! /usr/bin/python
+import ipaddress
+import argparse
+
+parser = argparse.ArgumentParser(description='Generate NAT plugin config.')
+parser.add_argument('static_map_num', metavar='N', type=int, nargs=1,
+ help='number of static mappings')
+args = parser.parse_args()
+
+file_name = 'nat_static_%s' % (args.static_map_num[0])
+outfile = open(file_name, 'w')
+
+outfile.write('set int ip address TenGigabitEthernet4/0/0 172.16.2.1/24\n')
+outfile.write('set int ip address TenGigabitEthernet4/0/1 173.16.1.1/24\n')
+outfile.write('set int state TenGigabitEthernet4/0/0 up\n')
+outfile.write('set int state TenGigabitEthernet4/0/1 up\n')
+outfile.write('ip route add 2.2.0.0/16 via 173.16.1.2 TenGigabitEthernet4/0/1\n')
+outfile.write('ip route add 10.0.0.0/24 via 172.16.2.2 TenGigabitEthernet4/0/0\n')
+outfile.write('set int nat44 in TenGigabitEthernet4/0/0 out TenGigabitEthernet4/0/1\n')
+
+for i in range (0, args.static_map_num[0]):
+ local = str(ipaddress.IPv4Address(u'10.0.0.3') + i)
+ external = str(ipaddress.IPv4Address(u'173.16.1.3') + i)
+ outfile.write('nat44 add static mapping local %s external %s\n' % (local, external))
+
diff --git a/src/plugins/nat/extras/trex_cfg.yaml b/src/plugins/nat/extras/trex_cfg.yaml
new file mode 100644
index 00000000000..6fd1ab007d8
--- /dev/null
+++ b/src/plugins/nat/extras/trex_cfg.yaml
@@ -0,0 +1,21 @@
+### Config file generated by dpdk_setup_ports.py ###
+
+- port_limit: 2
+ version: 2
+ interfaces: ['04:00.0', '04:00.1']
+ c: 4
+ port_info:
+ - ip: 172.16.1.2
+ default_gw: 172.16.1.1
+ - ip: 172.16.2.2
+ default_gw: 172.16.2.1
+
+ platform:
+ master_thread_id: 0
+ latency_thread_id: 8
+ dual_if:
+ - socket: 0
+ threads: [1,2,3,4,5,6,7]
+ - socket: 1
+ threads: [9,10,11,12,13,14,15]
+