diff options
Diffstat (limited to 'resources')
-rw-r--r-- | resources/libraries/python/IPv6Setup.py | 21 | ||||
-rw-r--r-- | resources/libraries/python/TrafficGenerator.py | 13 | ||||
-rw-r--r-- | resources/libraries/robot/performance.robot | 36 | ||||
-rw-r--r-- | resources/templates/vat/add_ip_neighbor.vat | 2 | ||||
-rwxr-xr-x | resources/tools/t-rex/t-rex-stateless.py | 123 |
5 files changed, 181 insertions, 14 deletions
diff --git a/resources/libraries/python/IPv6Setup.py b/resources/libraries/python/IPv6Setup.py index c016423f32..6b5d8a5f66 100644 --- a/resources/libraries/python/IPv6Setup.py +++ b/resources/libraries/python/IPv6Setup.py @@ -210,6 +210,27 @@ class IPv6Setup(object): sw_if_index=sw_if_index, state='admin-down') + + @staticmethod + def vpp_set_ipv6_neighbor(node, interface, ipaddr, macaddr): + """Set IPv6 neighbor. + + :param node: VPP node. + :param interface: Interface name. + :param ip_address: IPv6 address. + :param mac_address: mac address. + :type node: dict + :type interface: str + :type ip_address: str + :type mac_address: str + """ + sw_if_index = Topology.get_interface_sw_index(node, interface) + VatExecutor.cmd_from_template(node, + 'add_ip_neighbor.vat', + sw_if_index=sw_if_index, + ip_address=ipaddr, + mac_address=macaddr) + @staticmethod def vpp_ra_suppress_link_layer(node, interface): """Suppress ICMPv6 router advertisement message for link scope address. diff --git a/resources/libraries/python/TrafficGenerator.py b/resources/libraries/python/TrafficGenerator.py index adc22b3de6..b125a0b53d 100644 --- a/resources/libraries/python/TrafficGenerator.py +++ b/resources/libraries/python/TrafficGenerator.py @@ -236,6 +236,19 @@ class TrafficGenerator(object): "--p{4}_dst_start_ip 10.10.10.2'".\ format(duration, rate, framesize, _p0, _p1),\ timeout=int(duration)+60) + elif traffic_type in ["3-node-IPv6"]: + (ret, stdout, stderr) = ssh.exec_command( + "sh -c '/tmp/openvpp-testing/resources/tools/t-rex/" + "t-rex-stateless.py " + "-d {0} -r {1} -s {2} -6 " + "--p{3}_src_start_ip 2001:1::2 " + "--p{3}_src_end_ip 2001:1::FE " + "--p{3}_dst_start_ip 2001:2::2 " + "--p{4}_src_start_ip 2001:2::2 " + "--p{4}_src_end_ip 2001:2::FE " + "--p{4}_dst_start_ip 2001:1::2'".\ + format(duration, rate, framesize, _p0, _p1),\ + timeout=int(duration)+60) else: raise NotImplementedError('Unsupported traffic type') diff --git a/resources/libraries/robot/performance.robot b/resources/libraries/robot/performance.robot index a2c8acde27..d43073d30d 100644 --- a/resources/libraries/robot/performance.robot +++ b/resources/libraries/robot/performance.robot @@ -12,14 +12,18 @@ # limitations under the License. *** Settings *** +| Library | resources.libraries.python.topology.Topology +| Library | resources.libraries.python.NodePath +| Library | resources.libraries.python.InterfaceUtil +| Library | resources.libraries.python.TrafficGenerator +| Library | resources.libraries.python.TrafficGenerator.TGDropRateSearchImpl | Resource | resources/libraries/robot/default.robot | Resource | resources/libraries/robot/interfaces.robot +| Resource | resources/libraries/robot/counters.robot +| Resource | resources/libraries/robot/bridge_domain.robot | Resource | resources/libraries/robot/l2_xconnect.robot | Resource | resources/libraries/robot/ipv4.robot -| Resource | resources/libraries/robot/bridge_domain.robot -| Resource | resources/libraries/robot/counters.robot -| Library | resources.libraries.python.TrafficGenerator -| Library | resources.libraries.python.TrafficGenerator.TGDropRateSearchImpl +| Resource | resources/libraries/robot/ipv6.robot | Documentation | Performance suite keywords *** Keywords *** @@ -95,6 +99,29 @@ | | dut2_v4.set_route | 10.10.10.0 | 24 | 1.1.1.1 | ${dut2_if1} | | All Vpp Interfaces Ready Wait | ${nodes} +| IPv6 forwarding initialized in a 3-node circular topology +| | [Documentation] | Custom setup of IPv6 topology on all DUT nodes +| | ${prefix}= | Set Variable | 64 +| | ${tg1_if1_mac}= | Get Interface MAC | ${tg} | ${tg_if1} +| | ${tg1_if2_mac}= | Get Interface MAC | ${tg} | ${tg_if2} +| | ${dut1_if2_mac}= | Get Interface MAC | ${dut1} | ${dut1_if2} +| | ${dut2_if1_mac}= | Get Interface MAC | ${dut2} | ${dut1_if1} +| | VPP Set If IPv6 Addr | ${dut1} | ${dut1_if1} | 2001:1::1 | ${prefix} +| | VPP Set If IPv6 Addr | ${dut1} | ${dut1_if2} | 2001:3::1 | ${prefix} +| | VPP Set If IPv6 Addr | ${dut2} | ${dut2_if1} | 2001:3::2 | ${prefix} +| | VPP Set If IPv6 Addr | ${dut2} | ${dut2_if2} | 2001:2::1 | ${prefix} +| | Vpp nodes ra suppress link layer | ${nodes} +| | Vpp set IPv6 neighbor | ${dut1} | ${dut1_if1} | 2001:1::2 +| | ... | ${tg1_if1_mac} +| | Vpp set IPv6 neighbor | ${dut2} | ${dut2_if2} | 2001:2::2 +| | ... | ${tg1_if2_mac} +| | Vpp set IPv6 neighbor | ${dut1} | ${dut1_if2} | 2001:3::2 +| | ... | ${dut2_if1_mac} +| | Vpp set IPv6 neighbor | ${dut2} | ${dut2_if1} | 2001:3::1 +| | ... | ${dut1_if2_mac} +| | Vpp Route Add | ${dut1} | 2001:2::0 | ${prefix} | 2001:3::2 | ${dut1_if2} +| | Vpp Route Add | ${dut2} | 2001:1::0 | ${prefix} | 2001:3::1 | ${dut2_if1} + | L2 xconnect initialized in a 3-node circular topology | | [Documentation] | Custom setup of L2 xconnect topology | | L2 setup xconnect on DUT | ${dut1} | ${dut1_if1} | ${dut1_if2} @@ -150,6 +177,7 @@ | | ... | ${topology_type} | ${min_rate} | ${max_rate} | ${threshold} | | Set Duration | 60 | | Set Search Rate Boundaries | ${max_rate} | ${min_rate} +| | Set Search Frame Size | ${framesize} | | Set Search Rate Type pps | | Set Binary Convergence Threshold | ${threshold} | | Binary Search | ${binary_min} | ${binary_max} | ${topology_type} diff --git a/resources/templates/vat/add_ip_neighbor.vat b/resources/templates/vat/add_ip_neighbor.vat index e8587b28ca..cbea0e14a6 100644 --- a/resources/templates/vat/add_ip_neighbor.vat +++ b/resources/templates/vat/add_ip_neighbor.vat @@ -1 +1 @@ -ip_neighbor_add_del sw_if_index {sw_if_index} dst {ip_address} mac {mac_address}
\ No newline at end of file +ip_neighbor_add_del sw_if_index {sw_if_index} dst {ip_address} mac {mac_address}
diff --git a/resources/tools/t-rex/t-rex-stateless.py b/resources/tools/t-rex/t-rex-stateless.py index d32fd96dd7..97ccc97304 100755 --- a/resources/tools/t-rex/t-rex-stateless.py +++ b/resources/tools/t-rex/t-rex-stateless.py @@ -42,7 +42,9 @@ Functionality: """ import json +import socket import string +import struct import sys, getopt sys.path.insert(0, "/opt/trex-core-2.00/scripts/automation/"+\ @@ -51,11 +53,11 @@ from trex_stl_lib.api import * def generate_payload(length): - """Generate random payload. + """Generate payload. :param length: Length of payload. :type length: int - :return: Payload filled with random chars. + :return: Payload filled with chars. :rtype string """ @@ -66,6 +68,38 @@ def generate_payload(length): return word + +def get_start_end_ipv6(start_ip, end_ip): + """Get start and end host from IPv6 as integer. + + :param start_ip: Start IPv6. + :param end_ip: End IPv6. + :type start_ip: string + :type end_ip: string + :return: Start host, end host. + :rtype int + """ + + try: + ip1 = socket.inet_pton(socket.AF_INET6, start_ip) + ip2 = socket.inet_pton(socket.AF_INET6, end_ip) + + hi1, lo1 = struct.unpack('!QQ', ip1) + hi2, lo2 = struct.unpack('!QQ', ip2) + + if ((hi1 << 64) | lo1) > ((hi2 << 64) | lo2): + print "IPv6: start_ip is greater then end_ip" + sys.exit(2) + + max_p1 = abs(int(lo1) - int(lo2)) + 1 + base_p1 = lo1 + except AddressValueError as ex_error: + print ex_error + sys.exit(2) + + return base_p1, max_p1 + + def create_packets(traffic_options, frame_size=64): """Create two IP packets to be used in stream. @@ -103,7 +137,6 @@ def create_packets(traffic_options, frame_size=64): STLVmWrFlowVar(fv_name="src", pkt_offset="IP.src"), STLVmFixIpv4(offset="IP"), ], split_by_field="src") - # The following code applies raw instructions to packet (IP src increment). # It splits the generated traffic by "ip_src" variable to cores and fix # IPv4 header checksum. @@ -116,12 +149,73 @@ def create_packets(traffic_options, frame_size=64): ], split_by_field="src") pkt_a = STLPktBuilder(pkt=base_pkt_a/generate_payload( + fsize_no_fcs-len(base_pkt_a)), vm=vm1) + pkt_b = STLPktBuilder(pkt=base_pkt_b/generate_payload( + fsize_no_fcs-len(base_pkt_b)), vm=vm2) + + return(pkt_a, pkt_b) + + +def create_packets_v6(traffic_options, frame_size=78): + """Create two IPv6 packets to be used in stream. + + :param traffic_options: Parameters for packets. + :param frame_size: Size of L2 frame. + :type traffic_options: List + :type frame_size: int + :return: Packet instances. + :rtype STLPktBuilder + """ + + if frame_size < 78: + print "Packet min. size is 78B" + sys.exit(2) + + fsize_no_fcs = frame_size - 4 # no FCS + + p1_src_start_ip = traffic_options['p1_src_start_ip'] + p1_src_end_ip = traffic_options['p1_src_end_ip'] + p1_dst_start_ip = traffic_options['p1_dst_start_ip'] + p2_src_start_ip = traffic_options['p2_src_start_ip'] + p2_src_end_ip = traffic_options['p2_src_end_ip'] + p2_dst_start_ip = traffic_options['p2_dst_start_ip'] + + base_p1, max_p1 = get_start_end_ipv6(p1_src_start_ip, p1_src_end_ip) + base_p2, max_p2 = get_start_end_ipv6(p2_src_start_ip, p2_src_end_ip) + + base_pkt_a = Ether()/IPv6(src=p1_src_start_ip, dst=p1_dst_start_ip) + base_pkt_b = Ether()/IPv6(src=p2_src_start_ip, dst=p2_dst_start_ip) + + # The following code applies raw instructions to packet (IP src increment). + # It splits the generated traffic by "ip_src" variable to cores + vm1 = STLScVmRaw([STLVmFlowVar(name="ipv6_src", + min_value=base_p1, + max_value=max_p1+base_p1, + size=8, op="inc"), + STLVmWrFlowVar(fv_name="ipv6_src", pkt_offset="IPv6.src", + offset_fixup=8) + ] + , split_by_field="ipv6_src") + + # The following code applies raw instructions to packet (IP src increment). + # It splits the generated traffic by "ip_src" variable to cores + vm2 = STLScVmRaw([STLVmFlowVar(name="ipv6_src", + min_value=base_p2, + max_value=max_p2+base_p2, + size=8, op="inc"), + STLVmWrFlowVar(fv_name="ipv6_src", pkt_offset="IPv6.src", + offset_fixup=8) + ] + , split_by_field="ipv6_src") + + pkt_a = STLPktBuilder(pkt=base_pkt_a/generate_payload( max(0, fsize_no_fcs-len(base_pkt_a))), vm=vm1) pkt_b = STLPktBuilder(pkt=base_pkt_b/generate_payload( max(0, fsize_no_fcs-len(base_pkt_b))), vm=vm2) return(pkt_a, pkt_b) + def simple_burst(pkt_a, pkt_b, duration=10, rate="1mpps", warmup_time=5): """Run the traffic with specific parameters. @@ -159,7 +253,6 @@ def simple_burst(pkt_a, pkt_b, duration=10, rate="1mpps", warmup_time=5): isg=10.0, mode=STLTXCont(pps=100)) - # connect to server client.connect() @@ -174,7 +267,7 @@ def simple_burst(pkt_a, pkt_b, duration=10, rate="1mpps", warmup_time=5): if warmup_time is not None: client.clear_stats() client.start(ports=[0, 1], mult=rate, duration=warmup_time) - client.wait_on_traffic(ports=[0, 1], timeout=(duration+30)) + client.wait_on_traffic(ports=[0, 1], timeout=(warmup_time+30)) stats = client.get_stats() print stats print "#####warmup statistics#####" @@ -189,6 +282,10 @@ def simple_burst(pkt_a, pkt_b, duration=10, rate="1mpps", warmup_time=5): # clear the stats before injecting client.clear_stats() + total_rcvd = 0 + total_sent = 0 + lost_a = 0 + lost_b = 0 # choose rate and start traffic client.start(ports=[0, 1], mult=rate, duration=duration) @@ -227,6 +324,7 @@ def print_help(): print "args: [-h] -d <duration> -s <size of frame in bytes>"+\ " [-r] <traffic rate with unit: %, mpps> "+\ + " [-6] Use of ipv6 "+\ "--p1_src_mac <port1_src_mac> "+\ "--p1_dst_mac <port1_dst_mac> "+\ "--p1_src_start_ip <port1_src_start_ip> "+\ @@ -240,6 +338,7 @@ def print_help(): "--p2_dst_start_ip <port2_dst_start_ip> "+\ "--p2_dst_end_ip <port2_dst_end_ip>" + def print_error(msg): """Print error message on stderr. @@ -258,9 +357,10 @@ def main(argv): _frame_size = 64 _rate = '1mpps' _traffic_options = {} + _use_ipv6 = False try: - opts, _ = getopt.getopt(argv, "hd:s:r:o:", + opts, _ = getopt.getopt(argv, "hd:s:r:6o:", ["help", "p1_src_mac=", "p1_dst_mac=", @@ -287,6 +387,8 @@ def main(argv): _frame_size = int(arg) elif opt == '-r': _rate = arg + elif opt == '-6': + _use_ipv6 = True elif opt.startswith("--p"): _traffic_options[opt[2:]] = arg @@ -296,11 +398,14 @@ def main(argv): print_help() sys.exit(1) - pkt_a, pkt_b = create_packets(_traffic_options, - frame_size=_frame_size) + if _use_ipv6: + pkt_a, pkt_b = create_packets_v6(_traffic_options, + frame_size=_frame_size) + else: + pkt_a, pkt_b = create_packets(_traffic_options, + frame_size=_frame_size) simple_burst(pkt_a, pkt_b, duration=_duration, rate=_rate) if __name__ == "__main__": main(sys.argv[1:]) - |