def emptyNet(): "Create an empty network and add nodes to it." net = Mininet( controller=Controller) info( '*** Adding controller\n' ) ctrlRemote = RemoteController( 'c0', ip=ipControladorOF ) net.addController(ctrlRemote) info('--> remote IP controller - c0:' + ctrlRemote.IP() +'\n') #ctrlLocal = RemoteController('c1', port=6633, ip="127.0.0.1") ctrlLocal = Controller('c1', port=6634) net.addController(ctrlLocal) info('--> local IP controller - c1:' + ctrlLocal.IP() +'\n') info( '*** Adding hosts\n' ) lanH1 = net.addHost('h1', ip='10.0.0.1') lanH2 = net.addHost('h2', ip='10.0.0.2') lanIDS = net.addHost('h3', ip='10.0.0.3') lanRouter = net.addHost('h4') wanH1 = net.addHost('h5', ip='192.168.0.5') wanH2 = net.addHost('h6', ip='192.168.0.6') info( '*** Adding switch\n' ) lanSw = net.addSwitch('s1') wanSw = net.addSwitch('s2') info( '*** Creating links\n' ) net.addLink(lanH1, lanSw) net.addLink(lanH2, lanSw) net.addLink(lanIDS, lanSw) net.addLink(lanRouter, lanSw) net.addLink(lanRouter, wanSw) net.addLink(wanH1, wanSw) net.addLink(wanH2, wanSw) info( '*** Starting network\n') net.start() info('*** Starting controllers and switches') #link remote controller to s0 internal network swith ctrlRemote.start() #use remote controller lanSw.start([ctrlRemote]) #use local controller #info('\n\n\n************ using local controller for swLAN') #lanSw.start([ctrlLocal]) #start local controller to switch from s1 external network ctrlLocal.start() wanSw.start([ctrlLocal]) info( '*** Executing hosts scripts\n') execCmds(net) sleep(5) # wai 5 seconds to start IDS! #log tests in files, the name of file and directory will be composed by date/time of start execution of test hst1 = net.getNodeByName('h1') hst1.cmdPrint('mkdir /var/log/tcpdump/'+date) arquivo = open('/var/log/tcpdump/'+date+'/teste.txt', 'w') textoTeste = """ Test - \n Begin at:\n """ data = datetime.datetime.now() textoTeste=textoTeste+"%s/%s/%s as %s:%s:%s:%s\n"%(data.year,data.month,data.day,data.hour,data.minute,data.second,data.microsecond) arquivo.write(textoTeste) ### Tests # # Start the testes here! # # Select the test to run. For that uncomment the line of the desired test. info( '*** Executing Tests\n') textoTeste = textoTeste =teste1(net) #textoTeste = testeIperf(net) #textoTeste = testeIDSWakeupExternoInterno(net) #textoTeste = testeDDoSExtInt(net) #textoTeste = testeDDoSIntExt(net) #textoTeste = testeDDoSIntInt(net) # record attack test! textoTeste = textoTeste+""" put comment of test here """ arquivo.write(textoTeste) ### end of test! # register the time that test was finished data = datetime.datetime.now() textoTeste=' \nFinished at:\n '+"%s/%s/%s as %s:%s:%s:%s\n"%(data.year,data.month,data.day,data.hour,data.minute,data.second,data.microsecond) arquivo.write(textoTeste) arquivo.close() info( '*** Running CLI\n' ) #Uncomment below line for execute the test with CLI console #CLI( net ) sleep(5) info('*** Stoping IDS process\n') desligarIDS(net,'h3') #thIds.join() info( '*** Stopping network\n' ) lanSw.stop() ctrlRemote.stop() net.stop() exit()