def main(): setLogLevel('info') topo = EvalTetraTopo() net = Containernet(controller=RemoteController, topo=topo, build=False, autoSetMacs=True, link=TCLink) net.start() print() print("**Wiping log dir.") for root, dirs, files in os.walk(LoggingReceiveAction.LOG_DIR): for file in files: os.remove(os.path.join(root, file)) print("**Starting containernet REST Server.") thr = threading.Thread(target=start_rest, args=(net, )) # comma behind net is on purpose thr.daemon = True thr.start() # wait for connection with controller time.sleep(3) hosts = net.hosts # send arp from reqHost to every other host -> required by ONOS HostService to resolve hosts (i.e. map MAC<->IP) reqHost = hosts[0] for host in hosts: if (host is not reqHost): startARP(reqHost, reqHost.IP(), reqHost.MAC(), host.IP(), reqHost.intf()) CLI(net) ## set up UDP servers to join group for host in hosts: if host.name in ['tbs10host', 'tbs11host', 'tbs4host', 'tbs21host']: startUDPServer(host, GROUP_IP, host.IP()) CLI(net) ## send data startUDPClient(net.getNodeByName('tbs17host'), GROUP_IP, UDP_MESSAGE_SIZE_BYTES, count=PACKET_COUNT, rate=PACKETS_PER_SECOND) CLI(net) net.stop()
def main(): parser = argparse.ArgumentParser( description= 'Starts a containernet topology and a REST server for VNF instantiation from controller.' ) parser.add_argument('topology', metavar='T', type=str, nargs=1, help="the topology to start") parser.add_argument('--hw', action='store_true') args = parser.parse_args() topo = topoInstance(args.topology[0], args.hw) setLogLevel('info') net = Containernet(controller=RemoteController, topo=topo, build=True, autoSetMacs=True, link=TCLink) if args.hw: addDummyHost(net, topo) net.start() # for VNF mgmt startREST(net) # wait for connection with controller time.sleep(3) # ARP if args.hw: arpHw(net) else: arpEmulated(net) # dummy if args.hw: setUpDummy(net) # plot shost = net.getNodeByName('shost') plotter_proc = startPing(shost) # whack a mole if args.hw: startWhackAMole(shost, None) else: clients = [net.getNodeByName('c1host'), net.getNodeByName('c2host')] startWhackAMole(shost, clients) # standby CLI(net) # cleanup plotter_proc.kill() net.stop()