コード例 #1
0
 def __init__(self, name, tmpdir, controller_intf,
              ctl_privkey, ctl_cert, ca_certs,
              ports_sock, port, **kwargs):
     name = 'faucet-%u' % os.getpid()
     self.tmpdir = tmpdir
     self.controller_intf = controller_intf
     # pylint: disable=no-member
     self.controller_ipv4 = netifaces.ifaddresses(
         self.controller_intf)[socket.AF_INET][0]['addr']
     self.ofctl_port, _ = faucet_mininet_test_util.find_free_port(
         ports_sock)
     command = 'PYTHONPATH=../ ryu-manager ryu.app.ofctl_rest faucet.faucet'
     cargs = ' '.join((
         '--verbose',
         '--use-stderr',
         '--wsapi-host=127.0.0.1',
         '--wsapi-port=%u' % self.ofctl_port,
         '--ofp-listen-host=%s' % self.controller_ipv4,
         '--ofp-tcp-listen-port=%s',
         self._tls_cargs(port, ctl_privkey, ctl_cert, ca_certs)))
     Controller.__init__(
         self,
         name,
         cdir=faucet_mininet_test_util.FAUCET_DIR,
         command=command,
         cargs=cargs,
         port=port,
         **kwargs)
コード例 #2
0
    def run_internet(self, host):
        host.cmd('echo "This is a text file on a webserver" > index.txt')
        self.ws_port = faucet_mininet_test_util.find_free_port(
            self.ports_sock, self._test_name())

        host.cmd('python -m SimpleHTTPServer {0} &'.format(self.ws_port))

        self.start_dhcp_server(host, gw='10.0.0.2', dns='8.8.8.8')
コード例 #3
0
 def build(self, ports_sock, dpid=0, n_tagged=0, tagged_vid=100, n_untagged=0):
     port, ports_served = faucet_mininet_test_util.find_free_port(ports_sock)
     sid_prefix = self._get_sid_prefix(ports_served)
     for host_n in range(n_tagged):
         self._add_tagged_host(sid_prefix, tagged_vid, host_n)
     for host_n in range(n_untagged):
         self._add_untagged_host(sid_prefix, host_n)
     switch = self._add_faucet_switch(sid_prefix, port, dpid)
     for host in self.hosts():
         self.addLink(host, switch)
コード例 #4
0
 def build(self, dpid=0, n_tagged=0, tagged_vid=100, n_untagged=0):
     port, ports_served = faucet_mininet_test_util.find_free_port()
     sid_prefix = self._get_sid_prefix(ports_served)
     for host_n in range(n_tagged):
         self._add_tagged_host(sid_prefix, tagged_vid, host_n)
     for host_n in range(n_untagged):
         self._add_untagged_host(sid_prefix, host_n)
     switch = self._add_faucet_switch(sid_prefix, port, dpid)
     for host in self.hosts():
         self.addLink(host, switch)
コード例 #5
0
 def __init__(
     self,
     name,
     cdir=faucet_mininet_test_util.FAUCET_DIR,
     command="timeout 180s ryu-manager ryu.app.ofctl_rest faucet.py",
     cargs="--ofp-tcp-listen-port=%s --verbose --use-stderr",
     **kwargs
 ):
     name = "faucet-%u" % os.getpid()
     self.ofctl_port, _ = faucet_mininet_test_util.find_free_port()
     cargs = "--wsapi-port=%u %s" % (self.ofctl_port, cargs)
     Controller.__init__(self, name, cdir=cdir, command=command, cargs=cargs, **kwargs)
コード例 #6
0
 def build(self, dpid=0, n_tagged=0, tagged_vid=100, n_untagged=0):
     port, ports_served = faucet_mininet_test_util.find_free_port()
     sid_prefix = self._get_sid_prefix(ports_served)
     for host_n in range(n_tagged):
         self._add_tagged_host(sid_prefix, tagged_vid, host_n)
     for host_n in range(n_untagged):
         self._add_untagged_host(sid_prefix, host_n)
     dpid = str(int(dpid) + 1)
     print "remap switch will use DPID %s (%x)" % (dpid, int(dpid))
     switch = self._add_faucet_switch(sid_prefix, port, dpid)
     for host in self.hosts():
         self.addLink(host, switch)
コード例 #7
0
 def build(self, dpid=0, n_tagged=0, tagged_vid=100, n_untagged=0):
     port, ports_served = faucet_mininet_test_util.find_free_port()
     sid_prefix = self._get_sid_prefix(ports_served)
     for host_n in range(n_tagged):
         self._add_tagged_host(sid_prefix, tagged_vid, host_n)
     for host_n in range(n_untagged):
         self._add_untagged_host(sid_prefix, host_n)
     dpid = str(int(dpid) + 1)
     print 'remap switch will use DPID %s (%x)' % (dpid, int(dpid))
     switch = self._add_faucet_switch(sid_prefix, port, dpid)
     for host in self.hosts():
         self.addLink(host, switch)
コード例 #8
0
    def build(self,
              ports_sock,
              dpids,
              n_tagged=0,
              tagged_vid=100,
              n_untagged=0,
              test_name=None):
        """String of datapaths each with hosts with a single FAUCET controller.

                               Hosts
                               ||||
                               ||||
                 +----+       +----+       +----+
              ---+1   |       |1234|       |   1+---
        Hosts ---+2   |       |    |       |   2+--- Hosts
              ---+3   |       |    |       |   3+---
              ---+4  5+-------+5  6+-------+5  4+---
                 +----+       +----+       +----+

                 Faucet-1     Faucet-2     Faucet-3

                   |            |            |
                   |            |            |
                   +-------- controller -----+

        * s switches (above S = 3; for S > 3, switches are added to the chain)
        * (n_tagged + n_untagged) hosts per switch
        * (n_tagged + n_untagged + 1) links on switches 0 and s-1,
          with final link being inter-switch
        * (n_tagged + n_untagged + 2) links on switches 0 < n < s-1,
          with final two links being inter-switch
        """
        last_switch = None
        for dpid in dpids:
            port, ports_served = faucet_mininet_test_util.find_free_port(
                ports_sock, test_name)
            sid_prefix = self._get_sid_prefix(ports_served)
            hosts = []
            for host_n in range(n_tagged):
                hosts.append(
                    self._add_tagged_host(sid_prefix, tagged_vid, host_n))
            for host_n in range(n_untagged):
                hosts.append(self._add_untagged_host(sid_prefix, host_n))
            switch = self._add_faucet_switch(sid_prefix, port, dpid)
            for host in hosts:
                self.addLink(host, switch)
            # Add a switch-to-switch link with the previous switch,
            # if this isn't the first switch in the topology.
            if last_switch is not None:
                self.addLink(last_switch, switch)
            last_switch = switch
コード例 #9
0
 def build(self, ports_sock, dpid=0, n_tagged=0, tagged_vid=100, n_untagged=0):
     port, ports_served = faucet_mininet_test_util.find_free_port(ports_sock)
     sid_prefix = self._get_sid_prefix(ports_served)
     for host_n in range(n_tagged):
         self._add_tagged_host(sid_prefix, tagged_vid, host_n)
     for host_n in range(n_untagged):
         self._add_untagged_host(sid_prefix, host_n)
     remap_dpid = str(int(dpid) + 1)
     print('bridging hardware switch DPID %s (%x) dataplane via OVS DPID %s (%x)' % (
         dpid, int(dpid), remap_dpid, int(remap_dpid)))
     dpid = remap_dpid
     switch = self._add_faucet_switch(sid_prefix, port, dpid)
     for host in self.hosts():
         self.addLink(host, switch)
コード例 #10
0
 def __init__(self,
              name,
              cdir=faucet_mininet_test_util.FAUCET_DIR,
              command='ryu-manager ryu.app.ofctl_rest faucet.py',
              cargs='--ofp-tcp-listen-port=%s --verbose --use-stderr',
              **kwargs):
     name = 'faucet-%u' % os.getpid()
     self.ofctl_port, _ = faucet_mininet_test_util.find_free_port()
     cargs = '--wsapi-port=%u %s' % (self.ofctl_port, cargs)
     Controller.__init__(self,
                         name,
                         cdir=cdir,
                         command=command,
                         cargs=cargs,
                         **kwargs)
コード例 #11
0
 def __init__(self, name, tmpdir, controller_intf, env, ctl_privkey,
              ctl_cert, ca_certs, ports_sock, port, **kwargs):
     self.ofctl_port, _ = faucet_mininet_test_util.find_free_port(
         ports_sock)
     cargs = ' '.join(
         ('--wsapi-host=127.0.0.1', '--wsapi-port=%u' % self.ofctl_port,
          self._tls_cargs(port, ctl_privkey, ctl_cert, ca_certs)))
     super(FAUCET, self).__init__(name,
                                  tmpdir,
                                  controller_intf,
                                  cargs=cargs,
                                  command=self._command(
                                      env, tmpdir, name,
                                      'ryu.app.ofctl_rest faucet.faucet'),
                                  port=port,
                                  **kwargs)
コード例 #12
0
 def __init__(self, name, tmpdir, controller_intf, env, ctl_privkey,
              ctl_cert, ca_certs, ports_sock, port, test_name, **kwargs):
     self.ofctl_port = faucet_mininet_test_util.find_free_port(
         ports_sock, test_name)
     cargs = ' '.join(
         ('--wsapi-host=%s' % faucet_mininet_test_util.LOCALHOST,
          '--wsapi-port=%u' % self.ofctl_port,
          self._tls_cargs(port, ctl_privkey, ctl_cert, ca_certs)))
     super(FAUCET,
           self).__init__(name,
                          tmpdir,
                          controller_intf,
                          cargs=cargs,
                          command=self._command(env, tmpdir, name,
                                                ' '.join(self.RYUAPPS)),
                          port=port,
                          **kwargs)
コード例 #13
0
 def verify_ipv4_routing(self,
                         first_host,
                         first_host_routed_ip,
                         second_host,
                         second_host_routed_ip,
                         with_group_table=False):
     """Verify one host can IPV4 route to another via FAUCET."""
     self.host_ipv4_alias(first_host, first_host_routed_ip)
     self.host_ipv4_alias(second_host, second_host_routed_ip)
     self.add_host_route(first_host, second_host_routed_ip,
                         self.FAUCET_VIPV4.ip)
     self.add_host_route(second_host, first_host_routed_ip,
                         self.FAUCET_VIPV4.ip)
     self.net.ping(hosts=(first_host, second_host))
     self.wait_for_route_as_flow(first_host.MAC(),
                                 first_host_routed_ip.network,
                                 with_group_table=with_group_table)
     self.wait_for_route_as_flow(second_host.MAC(),
                                 second_host_routed_ip.network,
                                 with_group_table=with_group_table)
     self.one_ipv4_ping(first_host, second_host_routed_ip.ip)
     self.one_ipv4_ping(second_host, first_host_routed_ip.ip)
     self.verify_ipv4_host_learned_host(first_host, second_host)
     self.verify_ipv4_host_learned_host(second_host, first_host)
     # verify at least 1M iperf
     for client_host, server_host, server_ip in ((first_host, second_host,
                                                  second_host_routed_ip.ip),
                                                 (second_host, first_host,
                                                  first_host_routed_ip.ip)):
         iperf_port, _ = faucet_mininet_test_util.find_free_port(
             self.ports_sock)
         iperf_mbps = self.iperf(client_host, server_host, server_ip,
                                 iperf_port, 5)
         print('%u mbps to %s' % (iperf_mbps, server_ip))
         self.assertGreater(iperf_mbps, 1)
     # verify packets matched routing flows
     self.wait_for_route_as_flow(first_host.MAC(),
                                 first_host_routed_ip.network,
                                 with_group_table=with_group_table,
                                 nonzero_packets=True)
     self.wait_for_route_as_flow(second_host.MAC(),
                                 second_host_routed_ip.network,
                                 with_group_table=with_group_table,
                                 nonzero_packets=True)
コード例 #14
0
 def verify_ipv6_routing(self,
                         first_host,
                         first_host_ip,
                         first_host_routed_ip,
                         second_host,
                         second_host_ip,
                         second_host_routed_ip,
                         with_group_table=False):
     """Verify one host can IPV6 route to another via FAUCET."""
     self.one_ipv6_ping(first_host, second_host_ip.ip)
     self.one_ipv6_ping(second_host, first_host_ip.ip)
     self.add_host_route(first_host, second_host_routed_ip,
                         self.FAUCET_VIPV6.ip)
     self.add_host_route(second_host, first_host_routed_ip,
                         self.FAUCET_VIPV6.ip)
     self.wait_for_route_as_flow(first_host.MAC(),
                                 first_host_routed_ip.network,
                                 with_group_table=with_group_table)
     self.wait_for_route_as_flow(second_host.MAC(),
                                 second_host_routed_ip.network,
                                 with_group_table=with_group_table)
     self.one_ipv6_controller_ping(first_host)
     self.one_ipv6_controller_ping(second_host)
     self.one_ipv6_ping(first_host, second_host_routed_ip.ip)
     # verify at least 1M iperf
     for client_host, server_host, server_ip in ((first_host, second_host,
                                                  second_host_routed_ip.ip),
                                                 (second_host, first_host,
                                                  first_host_routed_ip.ip)):
         iperf_port, _ = faucet_mininet_test_util.find_free_port(
             self.ports_sock)
         iperf_mbps = self.iperf(client_host, server_host, server_ip,
                                 iperf_port, 5)
         print('%u mbps to %s' % (iperf_mbps, server_ip))
         self.assertGreater(iperf_mbps, 1)
     self.one_ipv6_ping(first_host, second_host_ip.ip)
     self.verify_ipv6_host_learned_mac(first_host, second_host_ip.ip,
                                       second_host.MAC())
     self.one_ipv6_ping(second_host, first_host_ip.ip)
     self.verify_ipv6_host_learned_mac(second_host, first_host_ip.ip,
                                       first_host.MAC())
コード例 #15
0
 def verify_iperf_min(self, hosts_switch_ports, min_mbps, server_ip):
     """Verify minimum performance and OF counters match iperf approximately."""
     seconds = 5
     prop = 0.1
     iperf_port, _ = faucet_mininet_test_util.find_free_port(
         self.ports_sock)
     start_port_stats = self.get_host_port_stats(hosts_switch_ports)
     hosts = []
     for host, _ in hosts_switch_ports:
         hosts.append(host)
     client_host, server_host = hosts
     iperf_mbps = self.iperf(client_host, server_host, server_ip,
                             iperf_port, seconds)
     self.assertTrue(iperf_mbps > min_mbps)
     # TODO: account for drops.
     for _ in range(3):
         end_port_stats = self.get_host_port_stats(hosts_switch_ports)
         approx_match = True
         for host in hosts:
             of_rx_mbps = self.of_bytes_mbps(start_port_stats[host],
                                             end_port_stats[host],
                                             'rx_bytes', seconds)
             of_tx_mbps = self.of_bytes_mbps(start_port_stats[host],
                                             end_port_stats[host],
                                             'tx_bytes', seconds)
             print of_rx_mbps, of_tx_mbps
             max_of_mbps = float(max(of_rx_mbps, of_tx_mbps))
             iperf_to_max = iperf_mbps / max_of_mbps
             msg = 'iperf: %fmbps, of: %fmbps (%f)' % (
                 iperf_mbps, max_of_mbps, iperf_to_max)
             print(msg)
             if ((iperf_to_max < (1.0 - prop)) or (iperf_to_max >
                                                   (1.0 + prop))):
                 approx_match = False
         if approx_match:
             return
         time.sleep(1)
     self.fail(msg=msg)