示例#1
0
def clusterSanity():
    "Sanity check for cluster mode"
    topo = SingleSwitchTopo()
    net = MininetCluster( topo=topo ) 
    net.start()
    CLI( net )
    net.stop()
示例#2
0
def run(args):
    run_id = mk_run_id(args)
    sock = setupControlerCommandChannel(args.ctrl_cmd_local_port)
    ctrlPrepare(sock, run_id, args.ctrl_ip, args.ctrl_cmd_port)
    # k switches n hosts
    topo = LinearTopo(k=args.switches,
                      n=args.hosts,
                      sopts={'protocols': 'OpenFlow13'})
    controller = RemoteController('c0',
                                  ip=args.ctrl_ip,
                                  port=args.ctrl_of_port)
    net = MininetCluster(topo=topo,
                         servers=args.mn_hosts,
                         controller=controller)
    net.start()
    createDirs(run_id, net, args.mn_hosts)
    try:
        pairs = designatePairs(net.hosts)
        setUpHostsFiles(run_id, pairs)
        info("**** CURRENT RUN ID: %s\n" % run_id)
        [generatePairSysConfigs(p, args.iterations) for p in pairs]
        [runPassiveHosts(p) for p in pairs]
        [ensurePassiveStarted(p, args.sleep_time) for p in pairs]
        [runActiveHosts(p) for p in pairs]
        waitForFinish(pairs, args.sleep_time)
    except Exception, arg:
        error("ERROR: %s \n" % arg)
示例#3
0
def demo():
    "Simple Demo of Cluster Mode"
    servers = [ 'localhost', 'ubuntu2', 'ubuntu3' ]
    topo = TreeTopo( depth=3, fanout=3 )
    net = MininetCluster( topo=topo, servers=servers,
                          placement=SwitchBinPlacer )
    net.start()
    CLI( net )
    net.stop()
示例#4
0
 def __init__(self, topo, port=6653, controller_port=6653, servers=None):
     self.clear()
     self.controller = Controller(controller_port)
     if not servers:
         self.network = Mininet(topo=topo,
                                controller=RemoteController(
                                    self.controller.name, port=port))
     else:
         self.network = MininetCluster(topo=topo,
                                       servers=servers,
                                       placement=SwitchBinPlacer,
                                       controller=RemoteController(
                                           self.controller.name, port=port))
     self.dpctl = DPCTL(self.network.switches)
     self.traffic_manager = TrafficManager(self.network)
示例#5
0
def clusterSanity():
    "Sanity check for cluster mode"
    topo = SingleSwitchTopo()
    net = MininetCluster( topo=topo )
    net.start()
    CLI( net )
    net.stop()
示例#6
0
def demo():
    "Simple Demo of Cluster Mode"
    servers = ['localhost', 'ubuntu2', 'ubuntu3']
    topo = TreeTopo(depth=3, fanout=3)
    net = MininetCluster(topo=topo, servers=servers, placement=SwitchBinPlacer)
    net.start()
    CLI(net)
    net.stop()
示例#7
0
def run():
    servers = ['localhost', 'mn2']
    topo = LinearTopo(k=2, n=2, sopts={'protocols': 'OpenFlow13'})
    controller = RemoteController('c0', ip='192.168.56.1', port=6653)
    net = MininetCluster(topo=topo, servers=servers, controller=controller)
    net.start()
    h1 = net.hosts[0]
    h2 = net.hosts[1]
    setupIperfPair(h1, h2)
    # CLI (net)
    net.stop()
示例#8
0
class OpenFlowTestbed:
    def __init__(self, topo, port=6653, controller_port=6653, servers=None):
        self.clear()
        self.controller = Controller(controller_port)
        if not servers:
            self.network = Mininet(topo=topo,
                                   controller=RemoteController(
                                       self.controller.name, port=port))
        else:
            self.network = MininetCluster(topo=topo,
                                          servers=servers,
                                          placement=SwitchBinPlacer,
                                          controller=RemoteController(
                                              self.controller.name, port=port))
        self.dpctl = DPCTL(self.network.switches)
        self.traffic_manager = TrafficManager(self.network)

    def __enter__(self):
        self._start()
        self._configure_network()
        return self

    def __exit__(self, exc_type, exc_val, exc_tb):
        self._stop()

    def switches(self):
        return [s.dpid for s in self.network.switches]

    def switch_num(self):
        return len(self.network.switches)

    def rules(self):
        return self.dpctl.dump_flows()

    def rule_num(self):
        return self.dpctl.rule_num(count_zero=True)

    def hosts(self):
        return self.network.hosts

    def add_flow(self, bandwidth):
        self.traffic_manager.add_random_flow(bandwidth=bandwidth)

    def delete_flow(self):
        self.traffic_manager.delete_random_flow()

    def flow_num(self):
        return len(self.traffic_manager.flows)

    def network_load(self):
        return self.traffic_manager.network_load()

    def _start(self):
        self.controller.start()
        self.network.start()

    def _stop(self):
        self.controller.stop()
        self.network.stop()

    def _configure_network(self):
        # Disable IPv6
        for node in self.network.hosts + self.network.switches:
            for intf in ['all', 'default', 'lo']:
                node.cmd('sysctl -w net.ipv6.conf.%s.disable_ipv6=1' % intf)

    def cli(self):
        CLI(self.network)

    @staticmethod
    def clear():
        os.popen('sudo pkill iperf3')
        os.popen('sudo mn -c > /dev/null 2>&1')
        os.popen('sudo pkill ryu')