Ejemplo n.º 1
0
def RunTest(net=None, remoteController=False, enableNAT=True):
    mgntController, mgntSwitch = ManagementNet(net)

    if enableNAT:
        root = connectToGateway(net, switch='mgnt0')

    net.build()
    info('*** Starting controller\n')
    for controller in net.controllers:
        controller.start()
    info('*** Starting %s switches\n' % len(net.switches))
    for switch in net.switches:
        info(switch.name + ' ')
        if switch.name != "mgnt0":
            switch.start([net.controllers[0]])
    mgntSwitch.start([mgntController])
    info('\n')

    if enableNAT:
        startNAT(root)
        establishRoutes(net)
        startSSH(net)

    # wait for the switches to connect to the controller
    info('** Waiting for switches to connect to the controller\n')
    sleep(5)
    if remoteController:
        sleep(30)

    #CLI(net)

    hosts = net.hosts

    #sleep(30)
    #net.pingAll()
    #net.pingAll()
    net.ping(hosts=hosts, timeout="1")
    if remoteController:
        net.ping(hosts=hosts, timeout="1")
        net.ping(hosts=hosts, timeout="1")

    #CLI(net)

    HadoopTest(hosts)
    #IperfTest(hosts)

    #CLI(net)

    if enableNAT:
        stopNAT(root)
        stopSSH(net)

    net.stop()
Ejemplo n.º 2
0
def RunTest(net=None, remoteController=False, enableNAT=True):
	mgntController, mgntSwitch = ManagementNet(net)

	if enableNAT:
		root = connectToGateway(net, switch='mgnt0')

	net.build()
	info( '*** Starting controller\n' )
	for controller in net.controllers:
		controller.start()
	info( '*** Starting %s switches\n' % len( net.switches ) )
	for switch in net.switches:
		info( switch.name + ' ')
		if switch.name != "mgnt0":
			switch.start( [net.controllers[0]])
	mgntSwitch.start([mgntController])
	info( '\n' )

	if enableNAT:
		startNAT(root)
		establishRoutes(net)
		startSSH(net)

	# wait for the switches to connect to the controller
	info('** Waiting for switches to connect to the controller\n')
	sleep(5)
	if remoteController:
		sleep(30)

	#CLI(net)

	hosts = net.hosts

	#sleep(30)
	#net.pingAll()
	#net.pingAll()
	net.ping(hosts=hosts, timeout="1")
	if remoteController:
		net.ping(hosts=hosts, timeout="1")
		net.ping(hosts=hosts, timeout="1")

	#CLI(net)

	HadoopTest(hosts)
	#IperfTest(hosts)

	#CLI(net)

	if enableNAT:
		stopNAT(root)
		stopSSH(net)

	net.stop()
Ejemplo n.º 3
0
                r.intf(iface_name).setMAC(iface_mac)
            j = j + 1

        # Configure hosts (ifconfig + set correct router as gw)
        info('*** Configuring application server network stacks\n')
        hosts = [h0, h1]
        g = 0
        for h in hosts:
            iface_name = 'h' + str(g) + '-eth0'
            host_mac = '00:00:00:00:00:0' + str(g + 1)
            host_ip = '10.0.' + str(g + 4) + '.2'
            router_ip = '10.0.' + str(g + 4) + '.1'
            h.intf(iface_name).setMAC(host_mac)
            h.cmd('ifconfig %(iface)s %(ip)s netmask 255.255.255.255 broadcast 10.255.255.255'\
                  % {'iface': iface_name, 'ip': host_ip})
            h.cmd( 'route add -host %(ip)s dev %(iface)s' \
                   % {'ip': router_ip, 'iface': iface_name})
            h.cmd( 'route add default gw %(ip)s %(iface)s' \
                   % {'ip': router_ip, 'iface': iface_name})
            g = g + 1

    # Give student a mininet prompt (so they can start xterms in each host and
    # their router code, etc)
    info('*** Initialisation complete\n')
    CLI(net)

    info('*** Stopping mininet\n')
    if (not args.nointernet):
        stopNAT(rootnode)
    net.stop()
Ejemplo n.º 4
0
    
    # Configure hosts (ifconfig + set correct router as gw)
    info( '*** Configuring application server network stacks\n' )
    hosts = [h0, h1]
    i=0
    for h in hosts:
        iface_name = 'h'+str(i)+'-eth0'
        host_mac = '00:00:00:00:00:0'+str(i+1)
        host_ip = '10.0.'+str(i+2)+'.2'
        router_ip = '10.0.'+str(i+2)+'.1'
        h.intf(iface_name).setMAC( host_mac )
        h.cmd('ifconfig %(iface)s %(ip)s netmask 255.255.255.255 broadcast 10.255.255.255'\
                   % {'iface': iface_name, 'ip': host_ip})
        h.cmd( 'route add -host %(ip)s dev %(iface)s' \
                   % {'ip': router_ip, 'iface': iface_name})
        h.cmd( 'route add default gw %(ip)s %(iface)s' \
                   % {'ip': router_ip, 'iface': iface_name})
        i = i+1
	
    # Give student a mininet prompt (so they can start xterms in each host and
    # their router code, etc)
    
    info( '*** Initialisation complete\n' )
    CLI( net )

    info( '*** Stopping net\n' )
    if (not args.nointernet):
        stopNAT( rootnode )
    net.stop()