def clusterSanity(): "Sanity check for cluster mode" topo = SingleSwitchTopo() net = MininetCluster( topo=topo ) net.start() CLI( net ) net.stop()
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()
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()
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()
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')