summaryrefslogtreecommitdiffstats
path: root/tests
AgeCommit message (Expand)AuthorFilesLines
2016-08-30Adds ability to power off nodes in cleanTim Rozet3-6/+108
2016-08-11Making NetworkEnvironment a dictDan Radez1-2/+2
2016-08-10Merge "Making NetworkSettings a dict"Dan Radez1-2/+2
2016-08-09Making NetworkSettings a dictDan Radez1-2/+2
2016-08-04Fix network_isolation argparse issueFeng Pan1-1/+1
2016-08-03Adds configuring vpp/hc on all nodesTim Rozet1-1/+3
2016-07-19Merge "Allows specifying nic order for overcloud nodes in network settings"Dan Radez5-4/+489
2016-07-18Allows specifying nic order for overcloud nodes in network settingsTim Rozet5-4/+489
2016-07-15Merge "Scripts for running smoke tests on the undercloud VM. Tested against A...Tim Rozet4-0/+34
2016-07-14add onos SFC feature config filebob zhou1-1/+2
2016-07-06Scripts for running smoke tests on the undercloud VM.spisarski4-0/+34
2016-06-30Syntax updates and new testsDan Radez4-14/+95
2016-06-14Fixes unit testsTim Rozet1-13/+23
2016-06-10converting apex ip_utils unit tests to noseDan Radez7-90/+304
2016-06-07Enabling python coverage tests in build.shDan Radez2-9/+76
2016-06-02Migrates network environment parsing to pythonTim Rozet1-1/+1
2016-05-28Adding python tests and updating for conventionsDan Radez1-0/+23
kn { color: #f92672 } /* Keyword.Namespace */ .highlight .kp { color: #66d9ef } /* Keyword.Pseudo */ .highlight .kr { color: #66d9ef } /* Keyword.Reserved */ .highlight .kt { color: #66d9ef } /* Keyword.Type */ .highlight .ld { color: #e6db74 } /* Literal.Date */ .highlight .m { color: #ae81ff } /* Literal.Number */ .highlight .s { color: #e6db74 } /* Literal.String */ .highlight .na { color: #a6e22e } /* Name.Attribute */ .highlight .nb { color: #f8f8f2 } /* Name.Builtin */ .highlight .nc { color: #a6e22e } /* Name.Class */ .highlight .no { color: #66d9ef } /* Name.Constant */ .highlight .nd { color: #a6e22e } /* Name.Decorator */ .highlight .ni { color: #f8f8f2 } /* Name.Entity */ .highlight .ne { color: #a6e22e } /* Name.Exception */ .highlight .nf { color: #a6e22e } /* Name.Function */ .highlight .nl { color: #f8f8f2 } /* Name.Label */ .highlight .nn { color: #f8f8f2 } /* Name.Namespace */ .highlight .nx { color: #a6e22e } /* Name.Other */ .highlight .py { color: #f8f8f2 } /* Name.Property */ .highlight .nt { color: #f92672 } /* Name.Tag */ .highlight .nv { color: #f8f8f2 } /* Name.Variable */ .highlight .ow { color: #f92672 } /* Operator.Word */ .highlight .w { color: #f8f8f2 } /* Text.Whitespace */ .highlight .mb { color: #ae81ff } /* Literal.Number.Bin */ .highlight .mf { color: #ae81ff } /* Literal.Number.Float */ .highlight .mh { color: #ae81ff } /* Literal.Number.Hex */ .highlight .mi { color: #ae81ff } /* Literal.Number.Integer */ .highlight .mo { color: #ae81ff } /* Literal.Number.Oct */ .highlight .sa { color: #e6db74 } /* Literal.String.Affix */ .highlight .sb { color: #e6db74 } /* Literal.String.Backtick */ .highlight .sc { color: #e6db74 } /* Literal.String.Char */ .highlight .dl { color: #e6db74 } /* Literal.String.Delimiter */ .highlight .sd { color: #e6db74 } /* Literal.String.Doc */ .highlight .s2 { color: #e6db74 } /* Literal.String.Double */ .highlight .se { color: #ae81ff } /* Literal.String.Escape */ .highlight .sh { color: #e6db74 } /* Literal.String.Heredoc */ .highlight .si { color: #e6db74 } /* Literal.String.Interpol */ .highlight .sx { color: #e6db74 } /* Literal.String.Other */ .highlight .sr { color: #e6db74 } /* Literal.String.Regex */ .highlight .s1 { color: #e6db74 } /* Literal.String.Single */ .highlight .ss { color: #e6db74 } /* Literal.String.Symbol */ .highlight .bp { color: #f8f8f2 } /* Name.Builtin.Pseudo */ .highlight .fm { color: #a6e22e } /* Name.Function.Magic */ .highlight .vc { color: #f8f8f2 } /* Name.Variable.Class */ .highlight .vg { color: #f8f8f2 } /* Name.Variable.Global */ .highlight .vi { color: #f8f8f2 } /* Name.Variable.Instance */ .highlight .vm { color: #f8f8f2 } /* Name.Variable.Magic */ .highlight .il { color: #ae81ff } /* Literal.Number.Integer.Long */ } @media (prefers-color-scheme: light) { .highlight .hll { background-color: #ffffcc } .highlight .c { color: #888888 } /* Comment */ .highlight .err { color: #a61717; background-color: #e3d2d2 } /* Error */ .highlight .k { color: #008800; font-weight: bold } /* Keyword */ .highlight .ch { color: #888888 } /* Comment.Hashbang */ .highlight .cm { color: #888888 } /* Comment.Multiline */ .highlight .cp { color: #cc0000; font-weight: bold } /* Comment.Preproc */ .highlight .cpf { color: #888888 } /* Comment.PreprocFile */ .highlight .c1 { color: #888888 } /* Comment.Single */ .highlight .cs { color: #cc0000; font-weight: bold; background-color: #fff0f0 } /* Comment.Special */ .highlight .gd { color: #000000; background-color: #ffdddd } /* Generic.Deleted */ .highlight .ge { font-style: italic } /* Generic.Emph */ .highlight .gr { color: #aa0000 } /* Generic.Error */ .highlight .gh { color: #333333 } /* Generic.Heading */ .highlight .gi { color: #000000; background-color: #ddffdd } /* Generic.Inserted */ .highlight .go { color: #888888 } /* Generic.Output */ .highlight .gp { color: #555555 } /* Generic.Prompt */ .highlight .gs { font-weight: bold } /* Generic.Strong */ .highlight .gu { color: #666666 } /* Generic.Subheading */ .highlight .gt { color: #aa0000 } /* Generic.Traceback */ .highlight .kc { color: #008800; font-weight: bold } /* Keyword.Constant */ .highlight .kd { color: #008800; font-weight: bold } /* Keyword.Declaration */ .highlight .kn { color: #008800; font-weight: bold } /* Keyword.Namespace */ .highlight .kp { color: #008800 } /* Keyword.Pseudo */ .highlight .kr { color: #008800; font-weight: bold } /* Keyword.Reserved */ .highlight .kt { color: #888888; font-weight: bold } /* Keyword.Type */ .highlight .m { color: #0000DD; font-weight: bold } /* Literal.Number */ .highlight .s { color: #dd2200; background-color: #fff0f0 } /* Literal.String */ .highlight .na { color: #336699 } /* Name.Attribute */ .highlight .nb { color: #003388 } /* Name.Builtin */ .highlight .nc { color: #bb0066; font-weight: bold } /* Name.Class */ .highlight .no { color: #003366; font-weight: bold } /* Name.Constant */ .highlight .nd { color: #555555 } /* Name.Decorator */ .highlight .ne { color: #bb0066; font-weight: bold } /* Name.Exception */ .highlight .nf { color: #0066bb; font-weight: bold } /* Name.Function */ .highlight .nl { color: #336699; font-style: italic } /* Name.Label */ .highlight .nn { color: #bb0066; font-weight: bold } /* Name.Namespace */ .highlight .py { color: #336699; font-weight: bold } /* Name.Property */ .highlight .nt { color: #bb0066; font-weight: bold } /* Name.Tag */ .highlight .nv { color: #336699 } /* Name.Variable */ .highlight .ow { color: #008800 } /* Operator.Word */ .highlight .w { color: #bbbbbb } /* Text.Whitespace */ .highlight .mb { color: #0000DD; font-weight: bold } /* Literal.Number.Bin */ .highlight .mf { color: #0000DD; font-weight: bold } /* Literal.Number.Float */ .highlight .mh { color: #0000DD; font-weight: bold } /* Literal.Number.Hex */ .highlight .mi { color: #0000DD; font-weight: bold } /* Literal.Number.Integer */ .highlight .mo { color: #0000DD; font-weight: bold } /* Literal.Number.Oct */ .highlight .sa { color: #dd2200; background-color: #fff0f0 } /* Literal.String.Affix */ .highlight .sb { color: #dd2200; background-color: #fff0f0 } /* Literal.String.Backtick */ .highlight .sc { color: #dd2200; background-color: #fff0f0 } /* Literal.String.Char */ .highlight .dl { color: #dd2200; background-color: #fff0f0 } /* Literal.String.Delimiter */ .highlight .sd { color: #dd2200; background-color: #fff0f0 } /* Literal.String.Doc */ .highlight .s2 { color: #dd2200; background-color: #fff0f0 } /* Literal.String.Double */ .highlight .se { color: #0044dd; background-color: #fff0f0 } /* Literal.String.Escape */ .highlight .sh { color: #dd2200; background-color: #fff0f0 } /* Literal.String.Heredoc */ .highlight .si { color: #3333bb; background-color: #fff0f0 } /* Literal.String.Interpol */ .highlight .sx { color: #22bb22; background-color: #f0fff0 } /* Literal.String.Other */ .highlight .sr { color: #008800; background-color: #fff0ff } /* Literal.String.Regex */ .highlight .s1 { color: #dd2200; background-color: #fff0f0 } /* Literal.String.Single */ .highlight .ss { color: #aa6600; background-color: #fff0f0 } /* Literal.String.Symbol */ .highlight .bp { color: #003388 } /* Name.Builtin.Pseudo */ .highlight .fm { color: #0066bb; font-weight: bold } /* Name.Function.Magic */ .highlight .vc { color: #336699 } /* Name.Variable.Class */ .highlight .vg { color: #dd7700 } /* Name.Variable.Global */ .highlight .vi { color: #3333bb } /* Name.Variable.Instance */ .highlight .vm { color: #336699 } /* Name.Variable.Magic */ .highlight .il { color: #0000DD; font-weight: bold } /* Literal.Number.Integer.Long */ }
#!/usr/bin/perl

##
## Copyright (c) 2010-2017 Intel Corporation
##
## Licensed under the Apache License, Version 2.0 (the "License");
## you may not use this file except in compliance with the License.
## You may obtain a copy of the License at
##
##     http://www.apache.org/licenses/LICENSE-2.0
##
## Unless required by applicable law or agreed to in writing, software
## distributed under the License is distributed on an "AS IS" BASIS,
## WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
## See the License for the specific language governing permissions and
## limitations under the License.
##

=head1 NAME

ipv6_tun_bindings.pl

=head1 SYNOPSIS

 ipv6_tun_bindings.pl [-n <num_entries>] [-tun_ip <ipv6>] [-mac <next_hop_mac>] 
                      [-pub_ip <ipv4>] [-port <begin>-<end>] [-set <num_ports>]
                      [-suffix <suffix>] [-test <num_entries>] [-sym|-nosym]
                      [-help]

=head1 DESCRIPTION

This script can be used to generate a binding table for the IPv6 Tunnel
task implemented in PROX (ipv6_encap and ipv6_decap).
The entries in this table bind a specific tunnel endpoint (lwB4 in lw4over6
architecture) to a public IPv4 address and port set.
The port set is actually derived from the port specified in the table
and a port bitmask in the PROX task configuration ("lookup port mask").

The ipv6_encap task uses the binding table to know where to tunnel IPv4
traffic to. The ipv6_decap task uses the table to verify tunnel packets
have a valid public IPv4 and port combination for the originating tunnel.   

The table uses the Lua syntax so it can be loaded into PROX. Example:
return {
   {ip6 = ip6("fe80:0000:0000:0000:0200:00ff:fe00:0000"), mac = mac("fe:80:00:00:00:00"), ip = ip("171.205.239.1"), port = 4608},
   {ip6 = ip6("fe80:0000:0000:0000:0200:00ff:fe00:0001"), mac = mac("fe:80:00:00:00:00"), ip = ip("171.205.239.1"), port = 4672},
   {ip6 = ip6("fe80:0000:0000:0000:0200:00ff:fe00:0002"), mac = mac("fe:80:00:00:00:00"), ip = ip("171.205.239.1"), port = 4736},
   {ip6 = ip6("fe80:0000:0000:0000:0200:00ff:fe00:0003"), mac = mac("fe:80:00:00:00:00"), ip = ip("171.205.239.1"), port = 4800},
}

The script generates consecutive entries, starting from a given IP address
and assigning ports within a given range, increasing the port number by a
fixed amount which should correspond to the port lookup mask being used.

UDF table: In addition to the binding table itself, the script can optionally
generate accompanying UDF tables for generating test traffic matching the
binding table. Such UDF tables can then be used in a traffic generation tool.  

=head1 OPTIONS

=over 22

=item -n <num_entries>

How many entries in the binding table

=item -tun_ip <ipv6>

Starting tunnel endpoint IPv6 address (will be incremented)

=item -mac <next_hop_mac>

MAC address of the next hop to reach the tunnel endpoints

=item -pub_ip <ipv4>

Starting public IPv4 address 

=item -port <begin>-<end>

Range of ports where to assign Port Sets

=item -set <num_ports>

Number of ports in set (should be a power of 2 because bitmasking is used
in lwAFTR)

=item -suffix <suffix>

Filename suffix to use for the generated file(s)

=item -test <num_entries>

Number of random entries to put into test UDF table

=item -sym

Whether the same random entry from the table should be inserted into both
traffic sides or if different entries should be used

=item -help

Shows the full script documentation.

=back

=head1 AUTHOR

 Copyright(c) 2010-2017 Intel Corporation.
 All rights reserved.

=cut


use strict vars;
use Getopt::Long;
use Pod::Usage;
use Socket qw(AF_INET AF_INET6 inet_ntop inet_pton);

sub parse_ip
{
        my ($str, $ip_ref, $family) = @_;

        my $packed = inet_pton($family, $str);
        return 0 if (!defined($packed));

        if ($family == AF_INET6) {
                #print unpack("H*", $packed). "\n";
                my @w = unpack("NNNN", $packed);
                my ($high, $low) = (($w[0] << 32) | $w[1], ($w[2] << 32) | $w[3]);
                @$ip_ref = ($high, $low);
        }
        else {
                $$ip_ref = unpack("N", $packed);
        }
        return 1;
}

sub ntop6
{
        my ($in) = @_;
        my $packed = pack('NNNN', $in->[0] >> 32, $in->[0] & 0xffffffff,
                                  $in->[1] >> 32, $in->[1] & 0xffffffff);
        return inet_ntop(AF_INET6, $packed);
}

sub ntop6_expanded
{
        my ($in) = @_;
        return sprintf('%04x:%04x:%04x:%04x:%04x:%04x:%04x:%04x',
                        ($in->[0] >> 48) & 0xffff, ($in->[0] >> 32) & 0xffff,
                        ($in->[0] >> 16) & 0xffff, ($in->[0]      ) & 0xffff,
                        ($in->[1] >> 48) & 0xffff, ($in->[1] >> 32) & 0xffff,
                        ($in->[1] >> 16) & 0xffff, ($in->[1]      ) & 0xffff);
}

my ($tun_ip_str, $pub_ip_str, $ports_str);

GetOptions(
        'help'     => sub () { Pod::Usage::pod2usage( -verbose => 2 ); exit; },
        'n=i'      => \(my $num_B4s = 10),
        'tun_ip=s' => \(my $tun_ip_str = 'fe80:0000:0000:0000:0200:00ff:0000:0000'),
        'pub_ip=s' => \(my $pub_ip_str = '171.205.239.1'),
        'mac=s'    => \(my $next_hop_mac = 'fe:80:00:00:00:00'),
        'port=s'   => \(my $ports_str='4608-11968'),
        'set=n'    => \(my $port_set_sz = 64),
        'suffix=s' => \(my $suffix = ''),
        'test=n'   => \(my $num_test_lines = 200000),
        'sym!'     => \(my $symmetric_traffic = TRUE),
) or pod2usage(-verbose => 1) && exit;

my @tun_ip;
parse_ip($tun_ip_str, \@tun_ip, AF_INET6) or print("Invalid starting tunnel IP: $tun_ip_str\n") && pod2usage(-verbose => 1) && exit;
parse_ip($pub_ip_str, \(my $pub_ip), AF_INET) or print("Invalid starting public IP: $pub_ip_str\n") && pod2usage(-verbose => 1) && exit;
my @port_range;
if ($ports_str =~ /^([^d]+)\s*\-\s*([^d]+)$/) {
        @port_range = ($1, $2);
}
else { print "Invalid port range: $ports_str\n"; pod2usage(-verbose => 1); exit }

# Summary of input data
print "File suffix: $suffix\n" if ($suffix);
print "Starting Tunnel IP: " . ntop6(\@tun_ip) . "\n";
print "Starting Public IP: ".inet_ntop(AF_INET, pack("N", $pub_ip)) . "\n";
print "Public Port Range: $port_range[0]-$port_range[1] by blocks of $port_set_sz\n";

my @data;  # Holds generated binding table, so we can later generate test traffic for it

# Binding table for PROX IPv6 Tunnel
my $filename = 'ip6_tun_bind'.$suffix.'.lua';
print "\nGenerating binding table with $num_B4s entries into $filename ... ";
open(my $fh, '>', $filename) or die "Could not open file '$filename' $!";
print $fh "-- Bindings for lwaftr: lwB4 IPv6 address, next hop MAC address\n";
print $fh "-- towards lwB4, IPv4 Public address, IPv4 Public Port Set\n";
print $fh "\n";
print $fh "return {" . "\n";
my $port = $port_range[0];
for (my $B4_id = 0; $B4_id < $num_B4s; $B4_id++) {
        $data[$B4_id]{'b4_ipv6'} = ntop6_expanded(\@tun_ip);
        $data[$B4_id]{'pub_ipv4'} = "" . (($pub_ip >> 24) & 0xff) . "." . (($pub_ip >> 16) & 0xff) . "." . (($pub_ip >> 8) & 0xff) . "." . ($pub_ip & 0xff);
        $data[$B4_id]{'pub_port'} = $port;
        $data[$B4_id]{'next_hop_mac'} = $next_hop_mac;

        print $fh "   {";
        print $fh "ip6 = ip6(\"" . $data[$B4_id]{'b4_ipv6'} . "\")";
        print $fh ", mac = mac(\"" . $data[$B4_id]{'next_hop_mac'} . "\")";
        print $fh ", ip = ip(\"" . $data[$B4_id]{'pub_ipv4'} . "\")";
        print $fh ", port = " . $data[$B4_id]{'pub_port'};
        print $fh "},\n";

        $port += $port_set_sz;
        if ($port > $port_range[1]) {
                $pub_ip++;
                $port = $port_range[0];
        }
        
        # Move to next Tunnel address
        if (@tun_ip[1] < 0xffffffffffffffff) {
                @tun_ip[1]++;
        } else {
                @tun_ip[0]++;
                @tun_ip[1] = 0;
        }
}
print $fh "}" . "\n";
close $fh;
print "[DONE]\n";

# Test traffic "UDF Tables"
if ($num_test_lines) {
        print "Generating $num_test_lines lines of test UDF table into lwAFTR_tun|inet".$suffix.".csv ... ";

        # Tunnel Packets from B4 to lwAFTR 
        my $filename = 'lwAFTR_tun' . $suffix . '.csv';
        open(my $fh_tun, '>', $filename) or die "Could not open file '$filename' $!";
        print $fh_tun "b4_ip,pub_ip,pub_port\n";
        print $fh_tun "22,66,74\n";  # Offsets
        print $fh_tun "16,4,2\n";    # Sizes
        print $fh_tun "6,5,3\n";     # Format (IPv6, IPv4, Decimal)
        print $fh_tun ",,\n";
        
        # Internet Packets towards the lwAFTR, to be sent to corresp lwB4 over tunnel 
        my $filename = 'lwAFTR_inet' . $suffix . '.csv';
        open(my $fh_inet, '>', $filename) or die "Could not open file '$filename' $!";
        print $fh_inet "pub_ip,pub_port\n";
        print $fh_inet "30,36\n";  # Offsets
        print $fh_inet "4,2\n";    # Sizes
        print $fh_inet "5,3\n";     # Format (IPv6, IPv4, Decimal)
        print $fh_inet ",,\n";

        for (my $i = 0; $i < $num_test_lines; $i++) {
                my $B4_id = int(rand($num_B4s));
                my $port = $data[$B4_id]{'pub_port'} + int(rand($port_set_sz)); 
                printf $fh_tun $data[$B4_id]{'b4_ipv6'} . "," . $data[$B4_id]{'pub_ipv4'} . "," . $port . "\n";
                
                if (! $symmetric_traffic) {
                        $B4_id = int(rand($num_B4s));
                        $port = $data[$B4_id]{'pub_port'} + int(rand($port_set_sz)); 
                }
                printf $fh_inet $data[$B4_id]{'pub_ipv4'} . "," . $port . "\n";
        }
        
        close $fh_tun;
        close $fh_inet;
        print "[DONE]\n";
}