test_snat module

class test_snat.TestSNAT(methodName='runTest')

Bases: framework.VppTestCase

SNAT Test Cases

clear_snat()

Clear SNAT configuration.

create_stream_in(in_if, out_if)

Create packet stream for inside network

Parameters:
  • in_if – Inside interface
  • out_if – Outside interface
create_stream_out(out_if, dst_ip=None)

Create packet stream for outside network

Parameters:
  • out_if – Outside interface
  • dst_ip – Destination IP address (Default use global SNAT address)
classmethod setUpClass()
snat_add_address(ip, is_add=1)

Add/delete S-NAT address

Parameters:
  • ip – IP address
  • is_add – 1 if add, 0 if delete (Default add)
snat_add_static_mapping(local_ip, external_ip, local_port=0, external_port=0, vrf_id=0, is_add=1)

Add/delete S-NAT static mapping

Parameters:
  • local_ip – Local IP address
  • external_ip – External IP address
  • local_port – Local port number (Optional)
  • external_port – External port number (Optional)
  • vrf_id – VRF ID (Default 0)
  • is_add – 1 if add, 0 if delete (Default add)
tearDown()
test_dynamic()

SNAT dynamic translation test

test_hairpinning()

SNAT hairpinning

test_inside_overlapping_interfaces()

SNAT multiple inside interfaces with overlapping address space

test_max_translations_per_user()

MAX translations per user - recycle the least recently used

test_multiple_inside_interfaces()

SNAT multiple inside interfaces with non-overlapping address space

test_static_in()

SNAT 1:1 NAT initialized from inside network

test_static_out()

SNAT 1:1 NAT initialized from outside network

test_static_vrf_aware()

SNAT 1:1 NAT VRF awareness

test_static_with_port_in()

SNAT 1:1 NAT with port initialized from inside network

test_static_with_port_out()

SNAT 1:1 NAT with port initialized from outside network

verify_capture_in(capture, in_if, packet_num=3)

Verify captured packets on inside network

Parameters:
  • capture – Captured packets
  • in_if – Inside interface
  • packet_num – Expected number of packets (Default 3)
verify_capture_out(capture, nat_ip=None, same_port=False, packet_num=3)

Verify captured packets on outside network

Parameters:
  • capture – Captured packets
  • nat_ip – Translated IP address (Default use global SNAT address)
  • same_port – Sorce port number is not translated (Default False)
  • packet_num – Expected number of packets (Default 3)