diff options
author | Ido Barnea <ibarnea@cisco.com> | 2016-12-21 17:15:04 +0200 |
---|---|---|
committer | Ido Barnea <ibarnea@cisco.com> | 2016-12-22 10:18:40 +0200 |
commit | d99346269fed5539d483113a4b37928619c6640a (patch) | |
tree | 29785f11d04e444181f7161b03ea73352deb3b4d | |
parent | e528048b2a9c99899cf1f69a2c11f51a383384db (diff) |
UDP NAT --learn mode 1,3 support - doc + regression tests
Signed-off-by: Ido Barnea <ibarnea@cisco.com>
-rwxr-xr-x | doc/trex_book.asciidoc | 6 | ||||
-rw-r--r-- | scripts/automation/regression/setups/kiwi02/benchmark.yaml | 3 | ||||
-rw-r--r-- | scripts/automation/regression/setups/trex-dan/benchmark.yaml | 2 | ||||
-rw-r--r-- | scripts/automation/regression/setups/trex25/benchmark.yaml | 2 | ||||
-rwxr-xr-x | scripts/automation/regression/stateful_tests/trex_nat_test.py | 16 | ||||
-rw-r--r-- | src/main_dpdk.cpp | 17 |
6 files changed, 30 insertions, 16 deletions
diff --git a/doc/trex_book.asciidoc b/doc/trex_book.asciidoc index ffb3e474..a2cdde1e 100755 --- a/doc/trex_book.asciidoc +++ b/doc/trex_book.asciidoc @@ -1056,12 +1056,12 @@ sudo ./t-rex-64 -f cap2/dns.yaml --client_cfg my_cfg.yaml TRex can learn dynamic NAT/PAT translation. To enable this feature add `--learn-mode <mode>` to the command line. To learn the NAT translation, TRex must embed information describing the flow a packet belongs to, in the first -packet of each flow. This can be done in two different methods, depending on the chosen <mode>. +packet of each flow. This can be done in different methods, depending on the chosen <mode>. *mode 1:*:: -Flow info is embedded in the ACK of the first TCP SYN. -In this mode, there is a limitation that bidirectional UDP templates (for example, DNS) are not supported. +In case of TCP flow, flow info is embedded in the ACK of the first TCP SYN. + +In case of UDP flow, flow info is embedded in the IP identification field of the first packet in the flow. + This mode was developed for testing NAT with firewalls (which usually do not work with mode 2). In this mode, TRex also learn and compensate for TCP sequence number randomization that might be done by the DUT. TRex can learn and compensate for seq num randomization in both directions of the connection. diff --git a/scripts/automation/regression/setups/kiwi02/benchmark.yaml b/scripts/automation/regression/setups/kiwi02/benchmark.yaml index 41688906..6369b76a 100644 --- a/scripts/automation/regression/setups/kiwi02/benchmark.yaml +++ b/scripts/automation/regression/setups/kiwi02/benchmark.yaml @@ -71,6 +71,9 @@ test_nat_simple_mode2: *test_nat_simple test_nat_simple_mode3: *test_nat_simple +test_nat_simple_mode1_udp: *test_nat_simple +test_nat_simple_mode3_udp: *test_nat_simple + test_nat_learning: << : *test_nat_simple nat_opened : 100000 diff --git a/scripts/automation/regression/setups/trex-dan/benchmark.yaml b/scripts/automation/regression/setups/trex-dan/benchmark.yaml index de56089b..84bcd9ae 100644 --- a/scripts/automation/regression/setups/trex-dan/benchmark.yaml +++ b/scripts/automation/regression/setups/trex-dan/benchmark.yaml @@ -70,6 +70,8 @@ test_nat_simple_mode1: &test_nat_simple test_nat_simple_mode2: *test_nat_simple test_nat_simple_mode3: *test_nat_simple +test_nat_simple_mode1_udp: *test_nat_simple +test_nat_simple_mode3_udp: *test_nat_simple test_nat_learning: << : *test_nat_simple diff --git a/scripts/automation/regression/setups/trex25/benchmark.yaml b/scripts/automation/regression/setups/trex25/benchmark.yaml index ccbdf6f5..f8fd0bee 100644 --- a/scripts/automation/regression/setups/trex25/benchmark.yaml +++ b/scripts/automation/regression/setups/trex25/benchmark.yaml @@ -71,6 +71,8 @@ test_nat_simple_mode1: &test_nat_simple test_nat_simple_mode2: *test_nat_simple test_nat_simple_mode3: *test_nat_simple +test_nat_simple_mode1_udp: *test_nat_simple +test_nat_simple_mode3_udp: *test_nat_simple test_nat_learning: << : *test_nat_simple diff --git a/scripts/automation/regression/stateful_tests/trex_nat_test.py b/scripts/automation/regression/stateful_tests/trex_nat_test.py index c23f67c4..3da1dc79 100755 --- a/scripts/automation/regression/stateful_tests/trex_nat_test.py +++ b/scripts/automation/regression/stateful_tests/trex_nat_test.py @@ -88,15 +88,21 @@ class CTRexNat_Test(CTRexGeneral_Test):#(unittest.TestCase): def test_nat_simple_mode1(self): - self.nat_simple_helper(learn_mode=1) + self.nat_simple_helper(learn_mode=1, traffic_file='cap2/http_simple.yaml') def test_nat_simple_mode2(self): - self.nat_simple_helper(learn_mode=2) + self.nat_simple_helper(learn_mode=2, traffic_file='cap2/http_simple.yaml') def test_nat_simple_mode3(self): - self.nat_simple_helper(learn_mode=3) + self.nat_simple_helper(learn_mode=3, traffic_file='cap2/http_simple.yaml') - def nat_simple_helper(self, learn_mode=1): + def test_nat_simple_mode1_udp(self): + self.nat_simple_helper(learn_mode=1, traffic_file='cap2/dns.yaml') + + def test_nat_simple_mode3_udp(self): + self.nat_simple_helper(learn_mode=3, traffic_file='cap2/dns.yaml') + + def nat_simple_helper(self, learn_mode=1, traffic_file='cap2/http_simple.yaml'): # test initializtion self.router.configure_basic_interfaces() @@ -119,7 +125,7 @@ class CTRexNat_Test(CTRexGeneral_Test):#(unittest.TestCase): m = mult, learn_mode = learn_mode, d = 100, - f = 'cap2/http_simple.yaml', + f = traffic_file, l = 1000) trex_res = self.trex.sample_to_run_finish() diff --git a/src/main_dpdk.cpp b/src/main_dpdk.cpp index c9b182af..250d0911 100644 --- a/src/main_dpdk.cpp +++ b/src/main_dpdk.cpp @@ -780,22 +780,23 @@ static int usage(){ printf(" --ipv6 : Work in ipv6 mode \n"); printf(" -k <num> : Run 'warm up' traffic for num seconds before starting the test. \n"); printf(" -l <rate> : In parallel to the test, run latency check, sending packets at rate/sec from each interface \n"); + printf(" --l-pkt-mode <0-3> : Set mode for sending latency packets \n"); + printf(" 0 (default) send SCTP packets \n"); + printf(" 1 Send ICMP request packets \n"); + printf(" 2 Send ICMP requests from client side, and response from server side (for working with firewall) \n"); + printf(" 3 Send ICMP requests with sequence ID 0 from both sides \n"); printf(" Rate of zero means no latency check \n"); printf(" --learn (deprecated). Replaced by --learn-mode. To get older behaviour, use --learn-mode 2 \n"); - printf(" --learn-mode [1-3] : Work in NAT environments, learn the dynamic NAT translation and ALG \n"); - printf(" 1 Use TCP ACK in first SYN to pass NAT translation information. Will work only for TCP streams. Initial SYN packet must be first packet in stream \n"); - printf(" 2 Add special IP option to pass NAT translation information. Will not work on certain firewalls if they drop packets with IP options \n"); + printf(" --learn-mode [1-3] : Used for working in NAT environments. Dynamically learn the NAT translation done by the DUT \n"); + printf(" 1 In case of TCP flow, use TCP ACK in first SYN to pass NAT translation information. Initial SYN packet must be first packet in the TCP flow \n"); + printf(" In case of UDP stream, NAT translation information will pass in IP ID field of first packet in flow. This means that this field is changed by TRex\n"); + printf(" 2 Add special IP option to pass NAT translation information to first packet of each flow. Will not work on certain firewalls if they drop packets with IP options \n"); printf(" 3 Like 1, but without support for sequence number randomization in server->clien direction. Performance (flow/second) better than 1 \n"); printf(" --learn-verify : Test the NAT translation mechanism. Should be used when there is no NAT in the setup \n"); printf(" --limit-ports : Limit number of ports used. Must be even number (TRex always uses port pairs) \n"); printf(" --lm : Hex mask of cores that should send traffic \n"); printf(" For example: Value of 0x5 will cause only ports 0 and 2 to send traffic \n"); printf(" --lo : Only run latency test \n"); - printf(" --l-pkt-mode <0-3> : Set mode for sending latency packets \n"); - printf(" 0 (default) send SCTP packets \n"); - printf(" 1 Send ICMP request packets \n"); - printf(" 2 Send ICMP requests from client side, and response from server side (for working with firewall) \n"); - printf(" 3 Send ICMP requests with sequence ID 0 from both sides \n"); printf(" -m <num> : Rate multiplier. Multiply basic rate of templates by this number \n"); printf(" --mbuf-factor : Factor for packet memory \n"); printf(" --nc : If set, will not wait for all flows to be closed, before terminating - see manual for more information \n"); |