예제 #1
0
 def buildFromTopo(self, topo=None):
     print self.hosts
     print '*** Adding controllers:\n'
     for controllerName in topo.controllers():
         self.addController(controllerName, **topo.nodeInfo(controllerName))
         print controllerName + ' '
     Mininext.buildFromTopo(self, topo)
예제 #2
0
def startNetwork():
    "instantiates a topo, then starts the network and prints debug information"

    info('** Creating Quagga network topology\n')
    topo = QuaggaTopo()

    info('** Starting the network\n')
    global net
    net = MiniNExT(topo, controller=OVSController)
    net.start()

    Script()
    QuestionB2()

    QuestionB3()
    # info('** Dumping host connections\n')
    # dumpNodeConnections(net.hosts)

    # info('** Testing network connectivity\n')
    # net.ping(net.hosts)

    # info('** Dumping host processes\n')
    # for host in net.hosts:
    #     host.cmdPrint("ps aux")

    info('** Running CLI\n')
    CLI(net)
예제 #3
0
파일: start.py 프로젝트: arsheth/mininet
def startNetwork():
    "instantiates a topo, then starts the network and prints debug information"

    info('** Creating Quagga network topology\n')
    topo = QuaggaTopo()

    info('** Starting the network\n')
    global net
    net = MiniNExT(topo, controller=OVSController)
    net.start()


   # h1, h2, r1, r2, r3, r4 = net.get('host1', 'host2', 'router1', 'router2', 'router3', 'router4')

    #h1intf = h1.defaultIntf()
    #h1intf.setIP('192.168.1.1/24')
	
    #h2intf = h2.defaultIntf()
    #h2intf.setIP('192.168.2.1/24')

    info('** Dumping host connections\n')
    dumpNodeConnections(net.hosts)

    info('** Testing network connectivity\n')
    net.ping(net.hosts)

    info('** Dumping host processes\n')
    for host in net.hosts:
        host.cmdPrint("ps aux")

    info('** Running CLI\n')
    CLI(net)
예제 #4
0
def startNetwork():
    info( '** Creating Quagga network topology\n' )
    topo = QuaggaTopo()
    global net
    net = Mininext(topo=topo, 
                controller=lambda name: RemoteController( name, ip='127.0.0.1' ),listenPort=6633)
    
    info( '** Starting the network\n' )
    net.start()
    
    #info( '** Dumping host connections\n' )
    #dumpNodeConnections(net.hosts)

    info( '** psaux dumps on all hosts\n' )
    for lr in net.hosts:
        if lr.name != 'exabgp':
            lr.cmdPrint("ps aux")
    
    #info( '** Dumping host connections\n' )
    #dumpNodeConnections(net.hosts)

    info( '**Adding Network Interfaces for SDX Setup\n' )    
    addInterfacesForSDXNetwork(net)
    
    info( '** Running CLI\n' )
    CLI( net )
예제 #5
0
def startNetwork():
    "instantiates a topo, then starts the network and prints debug information"

    info('** Creating Quagga network topology\n')
    topo = QuaggaTopo()

    info('** Starting the network\n')
    global net
    net = MiniNExT(topo, controller=OVSController, autoSetMacs=True)
    net.start()

    info('** Dumping host connections\n')
    dumpNodeConnections(net.hosts)

    # net['R1'].setIP('192.168.1.65', prefixLen = 24, intf = 'R1-eth1')
    # net['R1'].setIP('192.168.1.129', prefixLen = 24, intf = 'R1-eth2')
    # net['R1'].setIP('192.168.1.193', prefixLen = 24, intf = 'R1-eth3')

    # net['S1'].setIP('192.168.1.65', prefixLen = 24, intf = 'S1-eth1')
    # net['S1'].setIP('192.168.1.129', prefixLen = 24, intf = 'S1-eth2')
    # net['S1'].setIP('192.168.1.193', prefixLen = 24, intf = 'S1-eth3')

    # H1: Add static routes
    # net['H1'].cmd('ip route add default via 192.168.1.2 dev H1-eth0')

    # H2: Add static routes
    # net['H2'].cmd('ip route add default via 192.168.1.65 dev H2-eth0')

    # H3: Add static routes
    # net['H3'].cmd('ip route add default via 192.168.1.129 dev H3-eth0')

    # H4: Add static routes
    # net['H4'].cmd('ip route add default via 192.168.1.193 dev H4-eth0')

    # R1: Add static routes
    # net['R1'].cmd('ip route add 192.168.1.1/26 via 192.168.1.2 dev R1-eth0')
    # net['R1'].cmd('ip route add 192.168.1.64/26 via 192.168.1.65 dev R1-eth1')
    # net['R1'].cmd('ip route add 192.168.1.128/26 via 192.168.1.129 dev R1-eth2')
    # net['R1'].cmd('ip route add 192.168.1.192/26 via 192.168.1.193 dev R1-eth3')

    # net['S1'].cmd('ip route add 192.168.1.1 via 192.168.1.2 dev S1-eth0')
    # net['S1'].cmd('ip route add 192.168.1.64 via 192.168.1.65 dev S1-eth1')
    # net['S1'].cmd('ip route add 192.168.1.128 via 192.168.1.129 dev S1-eth2')
    # net['S1'].cmd('ip route add 192.168.1.192 via 192.168.1.193 dev S1-eth3')

    # S1: Configure IP forwarding
    # net['S1'].cmd('sysctl -w net.ipv4.ip_forward=1')

    info('** Testing network connectivity\n')
    # net.ping(net.hosts)

    info('** Dumping host processes\n')
    for host in net.hosts:
        host.cmdPrint("ps aux")

    # net['H2'].cmdPrint('ping 192.168.1.2')
    info('** Running CLI\n')
    CLI(net)
def startNetwork():
    info('** Creating Quagga network topology\n')
    topo = QuaggaTopo()
    global net
    net = Mininext(topo=topo, controller=lambda name: RemoteController(name, ip='127.0.0.1' ), link=TCLink)

    info('** Starting the network\n')
    net.start()

    info('**Adding Network Interfaces for RouteOPS Setup\n')
    addInterfacesForNetwork(net)

    info('** Running CLI\n')
    CLI(net)
def startNetwork():
    info( '** Creating Quagga network topology\n' )
    topo = QuaggaTopo()
    global net
    net = Mininext(topo=topo)

    info( '** Starting the network\n' )
    net.start()

    info( '**Adding Network Interfaces for SDX Setup\n' )
    addInterfacesForNetwork(net)

    info( '** Running CLI\n' )
    CLI( net )
예제 #8
0
def startNetwork():
    "instantiates a topo, then starts the network and prints debug information"

    info('** Creating Quagga network topology\n')
    topo = QuaggaTopo()

    info('** Starting the network\n')
    global net
    net = MiniNExT(topo, controller=OVSController)
    net.start()

    # Manually add interface IP addresses
    print '** Adding interface IP addresses\n'
    r1 = net.getNodeByName('r1')
    r1.setIP('172.0.2.1/24', 24, 'r1-eth1')
    r1.setIP('172.0.3.1/24', 24, 'r1-eth2')

    r2 = net.getNodeByName('r2')
    r2.setIP('172.0.4.1/24', 24, 'r2-eth1')

    r3 = net.getNodeByName('r3')
    r3.setIP('172.0.5.1/24', 24, 'r3-eth1')

    r4 = net.getNodeByName('r4')
    r4.setIP('172.0.5.2/24', 24, 'r4-eth1')
    r4.setIP('172.0.6.1/24', 24, 'r4-eth2')

    h1 = net.getNodeByName('h1')
    h2 = net.getNodeByName('h2')

    # Enable forwarding on each host
    r1.cmd('sysctl net.ipv4.ip_forward=1')
    r2.cmd('sysctl net.ipv4.ip_forward=1')
    r3.cmd('sysctl net.ipv4.ip_forward=1')
    r4.cmd('sysctl net.ipv4.ip_forward=1')
    h1.cmd('sysctl net.ipv4.ip_forward=1')
    h2.cmd('sysctl net.ipv4.ip_forward=1')

    # Start servers
    info('** Starting servers on port 800\n')
    r1.cmd(
        'python rip_lite_server.py "h1,r2,r3" "172.0.1.1,172.0.2.2,172.0.3.2" &'
    )
    r2.cmd('python rip_lite_server.py "r1,r4" "172.0.2.1,172.0.4.2" &')
    r3.cmd('python rip_lite_server.py "r1,r4" "172.0.3.1,172.0.5.2" &')
    r4.cmd(
        'python rip_lite_server.py "r2,r3,h2" "172.0.4.1,172.0.5.1,172.0.6.2" &'
    )
    h1.cmd('python rip_lite_server.py "r1" "172.0.1.2" &')
    h2.cmd('python rip_lite_server.py "r4" "172.0.6.1" &')

    # Start CLI
    info('** Running CLI\n')
    CLI(net)
예제 #9
0
def startNetwork():
    info('** Creating Quagga network topology\n')
    topo = QuaggaTopo()
    global net
    net = Mininext(
        topo=topo,
        controller=lambda name: RemoteController(name, ip='127.0.0.1'))

    info('** Starting the network\n')
    net.start()

    info('**Adding Network Interfaces for SDX Setup\n')
    addInterfacesForSDXNetwork(net)

    info('** Running CLI\n')
    CLI(net)
예제 #10
0
def run():
    # Creates the virtual environment, by starting the network and configuring debug information
    info('** Creating an instance of Lab6 network topology\n')
    topo = Lab6Topo()

    info('** Starting the network\n')

    global net
    global hosts
    # We specify the OVSSwitch for better IPv6 performance
    # We use mininext constructor with the instance of the network, the default controller and the customized openvswitch
    net = MiniNExT(topo, controller=Controller, switch=OVSSwitch)
    net.start()
    info('** Executing custom commands\n')
    # Space to add any customize command before prompting command line
    # We assign IPv6 addresses to hosts h1, h2, and h5 as they are not configured through Quagga
    
    # We gather only the hosts created in the topology (no switches nor controller)
    hosts = [ net.getNodeByName( h ) for h in topo.hosts() ]

    for host in hosts:
    	# Only to hosts: We assign IPv6 address
        if host.name == 'h1':
            host.cmd('ip -6 addr add 2001:1:0:1010::10/64 dev h1-eth1')
            host.cmd('ip -6 route add default via 2001:1:0:1010::1')
        elif host.name == 'h2':            
            host.cmd('ip -6 addr add 2001:1:0:2020::20/64 dev h2-eth1')
            host.cmd('ip -6 route add default via 2001:1:0:2020::2')
        elif host.name == 'h5':            
            host.cmd('ip -6 addr add 2001:1:0:5050::50/64 dev h5-eth1')
            host.cmd('ip -6 route add default via 2001:1:0:5050::5')
	
	# Enable Xterm window for every host
    info('** Enabling xterm for hosts only\n')
    # We check if the display is available
    if 'DISPLAY' not in os.environ:
        error( "Error starting terms: Cannot connect to display\n" )
        return
    # Remove previous (and possible non-used) socat X11 tunnels
    cleanUpScreens()
    # Mininet's function to create Xterms in hosts
    makeTerms( hosts, 'host' )

	# Enable the mininext> prompt 
    info('** Running CLI\n')
    CLI(net)
예제 #11
0
def startNetwork():
    "instantiates a topo, then starts the network and prints debug information"

    info('** Creating Quagga network topology\n')
    topo = QuaggaTopo()

    info('** Starting the network\n')
    global net
    net = MiniNExT(topo, controller=OVSController)
    net.start()

    info('** Dumping host connections\n')
    dumpNodeConnections(net.hosts)

    for host in net.hosts:
        host.cmdPrint("echo 1 > /proc/sys/net/ipv4/ip_forward")

    router2 = [
        'ip addr add 183.0.0.2/20 dev R1-eth1',
        'ip addr add 184.0.0.2/20 dev R1-eth2'
    ]
    router3 = ['ip addr add 185.0.0.2/20 dev R2-eth1']
    router4 = ['ip addr add 186.0.0.2/20 dev R3-eth1']
    router5 = [
        'ip addr add 185.0.0.1/20 dev R4-eth1',
        'ip addr add 186.0.0.1/20 dev R4-eth2'
    ]
    ip_addr = {2: router2, 3: router3, 4: router4, 5: router5}
    info('** Setting up ip address\n')
    for k, v in ip_addr.items():
        for e in v:
            net.hosts[k].cmdPrint(e)

    info('** Dumping host processes\n')
    for host in net.hosts:
        host.cmdPrint("ps aux")

    H1 = net.hosts[0]
    H2 = net.hosts[1]

    info('Pinging for Convergence\n')
    pingForConv(H1, H2, 5)
    getTraceroutes(H1, H2)

    info('** Testing network connectivity\n')
    net.ping(net.hosts)

    net.configLinkStatus('R1', 'R2', 'down')
    info('\nPinging for Convergence after R1-R2 link is down')
    pingForConv(H1, H2, 35)
    getTraceroutes(H1, H2)

    info('** Running CLI\n')
    CLI(net)
예제 #12
0
def startNetwork():
    info('** Creating Quagga network topology\n')
    topo = QuaggaTopo()
    net = Mininext(topo=topo,
                   controller=lambda name: RemoteController(name, ip='127.0.0.1'),
                   listenPort=6633)

    info('** Starting the network\n')
    net.start()

    info('** ps aux dumps on all hosts\n')
    for host in net.hosts:
        host.cmdPrint('ps aux')

    info('** Adding Network Interfaces for MTD setup\n')
    add_interfaces_for_mtd(net)

    info('Running CLI\n')
    CLI(net)
    return net
예제 #13
0
def startNetwork():
    info("** Creating Quagga network topology\n")
    topo = QuaggaTopo()

    info("** Starting the network\n")
    global net
    net = MiniNExT(topo, controller=None, autoStaticArp=True, autoSetMacs=True, switch=OVSSwitch, link=TCLink)

    # Manual configuration and startup
    config_components()
    net.start()
    setup_services()
    
    #info('** Dumping host process(es)\n')
    #for host in net.hosts:
        #host.cmdPrint("ps aux")
    #net.get("100_r1").cmdPrint("ps aux")

    info("** Running CLI\n")
    CLI(net)
예제 #14
0
파일: mtd_mininet.py 프로젝트: ltanguay/NDS
def startNetwork():
    info('** Creating Quagga network topology\n')
    topo = QuaggaTopo()
    net = Mininext(topo=topo,
            controller=lambda name: RemoteController(name, ip='127.0.0.1'),
            listenPort=6633)
    
    info('** Starting the network\n')
    net.start()

    info('** ps aux dumps on all hosts\n')
    for host in net.hosts:
        host.cmdPrint('ps aux')

    info('** Adding Network Interfaces for MTD setup\n')
    add_interfaces_for_mtd(net)

    info('Running CLI\n')
    CLI(net)
    return net
예제 #15
0
def startNetwork():
    "instantiates a topo, then starts the network and prints debug information"

    info('** Creating Quagga network topology\n')
    topo = QuaggaTopo()

    info('** Starting the network\n')
    global net
    net = MiniNExT(topo, controller=OVSController)
    net.start()

    # h1, h2, r1, r2, r3, r4 = net.get('host1', 'host2', 'router1', 'router2', 'router3', 'router4')

    #h1intf = h1.defaultIntf()
    #h1intf.setIP('192.168.1.1/24')

    #h2intf = h2.defaultIntf()
    #h2intf.setIP('192.168.2.1/24')

    info('** Dumping host connections\n')
    dumpNodeConnections(net.hosts)

    info('** Testing network connectivity\n')
    net.ping(net.hosts)

    info('** Dumping host processes\n')
    for host in net.hosts:
        host.cmdPrint("ps aux")

    info('** Running CLI\n')
    CLI(net)
예제 #16
0
파일: start.py 프로젝트: hsheth2/tarpan
def startNetwork():
    "instantiates a topo, then starts the network and prints debug information"

    info('** Creating Quagga network topology\n')
    topo = QuaggaTopo()

    info('** Starting the network\n')
    global net
    net = MiniNExT(topo, controller=OVSController)
    net.start()

    info("** Running topology startup commands\n")
    topo.startup_commands(net.hosts)

    info('** Dumping host connections\n')
    dumpNodeConnections(net.hosts)

    info('** Testing network connectivity\n')
    net.ping(net.hosts)

    info('** Dumping host processes\n')
    for host in net.hosts:
        host.cmdPrint("ps aux")

    info('** Running CLI\n')
   # net.startTerms()
    CLI(net)
예제 #17
0
파일: start.py 프로젝트: USC-NSL/miniNExT
def startNetwork():
    "instantiates a topo, then starts the network and prints debug information"

    info('** Creating Quagga network topology\n')
    topo = QuaggaTopo()

    info('** Starting the network\n')
    global net
    net = MiniNExT(topo, controller=OVSController)
    net.start()

    info('** Dumping host connections\n')
    dumpNodeConnections(net.hosts)

    info('** Testing network connectivity\n')
    net.ping(net.hosts)

    info('** Dumping host processes\n')
    for host in net.hosts:
        host.cmdPrint("ps aux")

    info('** Running CLI\n')
    CLI(net)
예제 #18
0
def run():
    " Creates the virtual environment, by starting the network and configuring debug information "
    info('** Creating an instance of Lab4 network topology\n')
    topo = Lab4Topo()

    info('** Starting the network\n')
    global net
    global hosts
    # We use mininext constructor with the instance of the network, the default controller and the openvswitch
    net = MiniNExT(topo, controller=Controller, switch=OVSSwitch)
    net.start()

    info('** Executing custom commands\n')
    ##############################################
    # Space to add any customize command before prompting command line
    # We provide an example on how to assign IPv6 addresses to hosts h1 and h2 as they
    # are not configured through Quagga
    # If required, you can add any extra logic to it

    # We gather only the hosts created in the topology (no switches nor controller)
    hosts = [net.getNodeByName(h) for h in topo.hosts()]
    info('** Adding IPv6 address to hosts\n')
    for host in hosts:
        if host.name is 'h1':
            host.cmd('ip -6 addr add 2001:1:0:11::10/64 dev h1-eth1')
            host.cmd('ip -6 route add default via 2001:1:0:11::1')
        elif host.name is 'h2':
            host.cmd('ip -6 addr add 2001:1:0:12::20/64 dev h2-eth1')
            host.cmd('ip -6 route add default via 2001:1:0:12::2')

    info('** Enabling xterm for all hosts\n')
    makeTerms(hosts, 'node')

    ##############################################
    # Enable the mininext> prompt
    info('** Running CLI\n')
    CLI(net)
예제 #19
0
파일: start.py 프로젝트: rubiruchi/DHT
def startNetwork():
    "instantiates a topo, then starts the network and prints debug information"

    total_nodes = int(sys.argv[1]) if len(sys.argv) > 1 else 6

    info('** Creating Quagga network topology\n')
    topo = QuaggaTopo(total_nodes)

    info('** Starting the network\n')
    global net
    net = MiniNExT(topo, controller=OVSController)
    net.start()

    info('** Dumping host connections\n')
    dumpNodeConnections(net.hosts)

    info('** Testing network connectivity\n')
    net.ping(net.hosts)

    info('** Dumping host processes\n')
    for host in net.hosts:
        host.cmdPrint("ps aux")

    info('** Running CLI\n')
    # pdb.set_trace()

    # import pdb; pdb.set_trace()

    start_chord(net)
    CLI(net)

    while True:
        disp_cur_nodes(net)
        print "1. Add Node"
        print "2. Remove Node"
        print "3. Details of Node"
        print "4. Exit"

        choice = int(input("Please enter your choice : "))

        if choice == 1:
            add_host(net, topo)
            print 'in add node'
        elif choice == 2:
            remove_node(net, 'a1')
            print 'in remove node'
        elif choice == 3:
            get_details(net)
            print 'in details'
        elif choice == 4:
            end_chord(net)
            print 'exiting'
            time.sleep(1)
            break
        else:
            print 'Invalid choice, please try again'
예제 #20
0
def startNetwork():
    info( '** Creating Quagga network topology\n' )
    topo = QuaggaTopo()
    global net
    net = Mininext(topo=topo, switch=SDXSwitch, build=False)

    "Controller"
    net.addController(k0)
    net.addController(k1)

    net.build()
    
    info( '** Starting the network\n' )
    net.start()
        
    info( '**Adding Network Interfaces for SDX Setup\n' )    
    addInterfacesForSDXNetwork(net)
    
    info( '** Running CLI\n' )
    CLI( net )
예제 #21
0
def startNetwork(full=False):
    "instantiates a topo, then starts the network and prints debug information"

    info('** Creating Quagga network topology\n')
    topo = I2()

    if (full):
        info("** Adding WEST and EAST\n")
        add_west(topo)
        add_east(topo)

    global net
    if (not full):
        net = MiniNExT(topo, controller=OVSController)
    else:
        net = MiniNExT(topo, controller=RemoteController)

    info('** Starting the network\n')
    net.start()

    config_i2(net)
    if (full):
        info("** Configuring WEST and EAST\n")
        config_west(net)
        config_east(net)

        info("** Starting HTTP servers on EAST\n")
        starthttp(net.getNodeByName('server1'))
        starthttp(net.getNodeByName('server2'))

    # info('** Dumping host connections\n')
    # dumpNodeConnections(net.hosts)
    #
    # info('** Dumping host processes\n')
    # for host in net.hosts:
    #     host.cmdPrint("ps aux")

    return net
예제 #22
0
def startNetwork():
    "instantiates a topo, then starts the network and prints debug information"

    info('** Creating Quagga network topology\n')
    topo = QuaggaTopo()

    info('** Starting the network\n')
    global net
    net = MiniNExT(topo, controller=OVSController)
    net.start()

    # assign IPs to interfaces.
    topo.setIP(net)

    # change IP forwarding variable to 1
    for host in net.hosts:
        host.cmd("echo '1' > /proc/sys/net/ipv4/ip_forward")
	
	pingh1h2Convergence()
	#linkDown()
    # info('** Dumping host connections\n')
    # dumpNodeConnections(net.hosts)

    #info('** Dumping host processes\n')
    #for host in net.hosts:
     #   host.cmdPrint("ps aux")

  #  net.get('h1').cmdPrint("python /home/riplite.py h1 &")
  #  net.get('h2').cmdPrint("python /home/riplite.py h2 &")
  #  net.get('r1').cmdPrint("python /home/riplite.py r1 &")
  #  net.get('r2').cmdPrint("python /home/riplite.py r2 &")
  #  net.get('r3').cmdPrint("python /home/riplite.py r3 &")
  #  net.get('r4').cmdPrint("python /home/riplite.py r4 &")

    info('** Testing network connectivity\n')
    net.ping(net.hosts)

    info('** Running CLI\n')
    CLI(net)
예제 #23
0
def startNetwork():
    "instantiates a topo, then starts the network and prints debug information"

    info('** Creating Quagga network topology\n')
    topo = QuaggaTopo()

    info('** Starting the network\n')
    global net
    net = MiniNExT(topo, controller=OVSController)
    start = timeit.default_timer()
    net.start()

    info('** Dumping host connections\n')
    dumpNodeConnections(net.hosts)

    for host in net.hosts:
        if host.name == 'R1':
            host.setIP('192.168.102.2/24', intf='R1-eth1')
            host.setIP('192.168.103.2/24', intf='R1-eth2')
        if host.name == 'R2':
            host.setIP('192.168.104.1/24', intf='R2-eth1')
        if host.name == 'R3':
            host.setIP('192.168.105.1/24', intf='R3-eth1')
        if host.name == 'R4':
            host.setIP('192.168.104.2/24', intf='R4-eth1')
            host.setIP('192.168.105.2/24', intf='R4-eth2')
        host.cmd("sysctl -w net.ipv4.ip_forward=1")

    info('** Testing network connectivity\n')
    for host in net.hosts:
        if host.name == 'H1':
            host.cmdPrint('ping -c4 192.168.106.128')
    end = timeit.default_timer()
    elapsed = end - start
    info('** Setup Time - ', elapsed, 's\n')
    net.ping(net.hosts)

    info('** Running CLI\n')
    CLI(net)
예제 #24
0
def startNetwork():
    "instantiates a topo, then starts the network and prints debug information"

    info('** Creating Quagga network topology\n')
    topo = QuaggaTopo()

    info('** Starting the network\n')
    global net, node_dict
    net = MiniNExT(topo, controller=OVSController)

    net.start()

    info('** Dumping host connections\n')
    dumpNodeConnections(net.hosts)

    node_dict['H1'] = net.hosts[0]
    node_dict['R1'] = net.hosts[1]
    node_dict['R2'] = net.hosts[2]
    node_dict['R3'] = net.hosts[3]
    node_dict['R4'] = net.hosts[4]
    node_dict['R5'] = net.hosts[5]
    node_dict['R6'] = net.hosts[6]
    node_dict['R7'] = net.hosts[7]
    node_dict['R8'] = net.hosts[8]

    info('** Enabling ip forwarding on all hosts')
    for host in net.hosts:
        host.cmdPrint("echo 1 > /proc/sys/net/ipv4/ip_forward")

    setup_ip()
    add_static_routes()
    setup_relaying()

    info('** Testing network connectivity\n')
    net.ping(net.hosts)

    info('** Running CLI\n')
    CLI(net)
예제 #25
0
def config_dumbbell(topo):
    global net
    net = MiniNExT(topo, controller=OVSController, link=TCLink)
    info("*** Creating links between nodes in dumbbell topology\n")
    net.addLink(net.getNodeByName("client1"),
                net.getNodeByName("router1"),
                intfName1="meth1",
                intfName2="client1")
    net.addLink(net.getNodeByName("client2"),
                net.getNodeByName("router1"),
                intfName1="meth1",
                intfName2="client2")
    net.addLink(net.getNodeByName("router1"),
                net.getNodeByName("router2"),
                intfName1="router2",
                intfName2="router1",
                bw=1)
    net.addLink(net.getNodeByName("server1"),
                net.getNodeByName("router2"),
                intfName1="meth1",
                intfName2="server1")
    net.addLink(net.getNodeByName("server2"),
                net.getNodeByName("router2"),
                intfName1="meth1",
                intfName2="server2")

    info(
        "*** Configuring IP addresses and routing tables in dumbbell topology\n"
    )
    client1 = net.getNodeByName("client1")
    client1.cmd("ifconfig meth1 %s/24 up" % ("10.0.1.1"))
    client1.cmd("route add default gw %s meth1" % ("10.0.1.2"))
    client1.cmd("iptables -A OUTPUT -p tcp --tcp-flags RST RST -j DROP")

    client2 = net.getNodeByName("client2")
    client2.cmd("ifconfig meth1 %s/24 up" % ("10.0.2.1"))
    client2.cmd("route add default gw %s meth1" % ("10.0.2.2"))
    client2.cmd("iptables -A OUTPUT -p tcp --tcp-flags RST RST -j DROP")

    server1 = net.getNodeByName("server1")
    server1.cmd("ifconfig meth1 %s/24 up" % ("12.0.1.1"))
    server1.cmd("route add default gw %s meth1" % ("12.0.1.2"))
    server1.cmd("iptables -A OUTPUT -p tcp --tcp-flags RST RST -j DROP")

    server2 = net.getNodeByName("server2")
    server2.cmd("ifconfig meth1 %s/24 up" % ("12.0.2.1"))
    server2.cmd("route add default gw %s meth1" % ("12.0.2.2"))
    server2.cmd("iptables -A OUTPUT -p tcp --tcp-flags RST RST -j DROP")

    router1 = net.getNodeByName("router1")
    router1.cmd("ifconfig client1 %s/24 up" % ("10.0.1.2"))
    router1.cmd("ifconfig client2 %s/24 up" % ("10.0.2.2"))
    router1.cmd("ifconfig router2 %s/24 up" % ("11.0.1.1"))
    router1.cmd("route add -net %s/8 gw %s dev router2" %
                ("12.0.0.0", "11.0.1.2"))
    router1.cmd("route add -net %s/24 gw %s dev client1" %
                ("10.0.1.0", "10.0.1.1"))
    router1.cmd("route add -net %s/24 gw %s dev client2" %
                ("10.0.2.0", "10.0.2.1"))

    router2 = net.getNodeByName("router2")
    router2.cmd("ifconfig server1 %s/24 up" % ("12.0.1.2"))
    router2.cmd("ifconfig server2 %s/24 up" % ("12.0.2.2"))
    router2.cmd("ifconfig router1 %s/24 up" % ("11.0.1.2"))
    router2.cmd("route add -net %s/8 gw %s dev router1" %
                ("10.0.0.0", "11.0.1.1"))
    router2.cmd("route add -net %s/24 gw %s dev server1" %
                ("12.0.1.0", "12.0.1.1"))
    router2.cmd("route add -net %s/24 gw %s dev server2" %
                ("12.0.2.0", "12.0.2.1"))

    return net
예제 #26
0
def startNetwork():
	"instantiates a topo, then starts the network and prints debug information"

	info('** Creating Quagga network topology\n')
	topo = QuaggaTopo()

	info('** Starting the network\n')
	global net
	net = MiniNExT(topo, controller=OVSController)
	net.start()

	info('** Dumping host connections\n')
	dumpNodeConnections(net.hosts)

	

	info('** Dumping host processes\n')
	#    for host in net.hosts:
	#        host.cmdPrint("ps aux")
	#    for host in net.hosts:
	#        host.cmdPrint('ifconfig')

	# Enabling IP forwarding
	net.get("R1").cmd("sysctl -w net.ipv4.ip_forward=1")
	net.get("R2").cmd("sysctl -w net.ipv4.ip_forward=1")
	net.get("R3").cmd("sysctl -w net.ipv4.ip_forward=1")
	net.get("R4").cmd("sysctl -w net.ipv4.ip_forward=1")

	# Setting Interface IPs
	net.get("R1").cmd("ifconfig R1-eth1 172.0.2.1/24")
	net.get("R1").cmd("ifconfig R1-eth2 172.0.6.2/24")
	net.get("R2").cmd("ifconfig R2-eth1 172.0.3.1/24")
	net.get("R4").cmd("ifconfig R4-eth1 172.0.3.2/24")
	net.get("R4").cmd("ifconfig R4-eth2 172.0.5.1/24")
	net.get("R3").cmd("ifconfig R3-eth1 172.0.5.2/24")
	
	# Static Routes from R1 to R2
	net.get("H1").cmd("route add default gw 172.0.1.2")
	net.get("R1").cmd("ip route add 172.0.3.0/24 via 172.0.2.2 dev R1-eth1")
	net.get("R1").cmd("ip route add 172.0.4.0/24 via 172.0.2.2 dev R1-eth1")
	net.get("R2").cmd("ip route add 172.0.4.0/24 via 172.0.3.2 dev R2-eth1")
	
	# Allowing Nating ar each router in the path from H1 to H2	
	net.get("R1").cmd("iptables -t nat -A POSTROUTING -o R1-eth1 -j MASQUERADE")
	net.get("R1").cmd("iptables -A FORWARD -i R1-eth1 -o R1-eth0 -m state --state RELATED,ESTABLISHED -j ACCEPT")
	net.get("R1").cmd("iptables -A FORWARD -i R1-eth0 -o R1-eth1 -j ACCEPT") 
	net.get("R2").cmd("iptables -t nat -A POSTROUTING -o R2-eth1 -j MASQUERADE")
	net.get("R2").cmd("iptables -A FORWARD -i R2-eth1 -o R2-eth0 -m state --state RELATED,ESTABLISHED -j ACCEPT")
	net.get("R2").cmd("iptables -A FORWARD -i R2-eth0 -o R2-eth1 -j ACCEPT") 
	net.get("R4").cmd("iptables -t nat -A POSTROUTING -o R4-eth0 -j MASQUERADE")
	net.get("R4").cmd("iptables -A FORWARD -i R4-eth0 -o R4-eth1 -m state --state RELATED,ESTABLISHED -j ACCEPT")
	net.get("R4").cmd("iptables -A FORWARD -i R4-eth1 -o R4-eth0 -j ACCEPT")


	info('** Testing network connectivity\n')
	net.ping(net.hosts)

	
	info('** Running CLI\n')
	CLI(net)
예제 #27
0
def startNetwork():
    "instantiates a topo, then starts the network and prints debug information"

    info('** Creating Quagga network topology\n')
    topo = QuaggaTopo()

    info('** Starting the network\n')
    global net
    net = MiniNExT(topo, controller=OVSController)
    net.start()

    info('** Dumping host connections\n')
    dumpNodeConnections(net.hosts)
    net.get("r1").cmd("sysctl net.ipv4.ip_forward=1")
    net.get("r2").cmd("sysctl net.ipv4.ip_forward=1")
    net.get("r3").cmd("sysctl net.ipv4.ip_forward=1")
    net.get("r4").cmd("sysctl net.ipv4.ip_forward=1")

    net.get("r1").cmd("ifconfig r1-eth1 192.0.2.2/24")

    #net.get("r1").cmd("ip route add 192.0.1.0/24 via 192.0.2.2")
    net.get("r2").cmd("ip route add 192.0.1.0/24 via 192.0.2.2")
    net.get("r2").cmd("ifconfig r2-eth1 192.0.5.1/24")
    net.get("r2").cmd("ip route add 192.0.4.0/24 via 192.0.5.2")

    net.get("r4").cmd("ifconfig r4-eth2 192.0.5.2/24")
    net.get("r4").cmd("ip route add 192.0.2.0/24 via 192.0.5.1")
    net.get("r4").cmd("ip route add 192.0.1.0/24 via 192.0.5.1")

    net.get("r1").cmd("ip route add 192.0.5.0/24 via 192.0.2.1")
    net.get("r1").cmd("ip route add 192.0.4.0/24 via 192.0.2.1")

    net.get("h1").cmd("route add default gw 192.0.1.1")
    net.get("h2").cmd("route add default gw 192.0.4.1")

    net.get("r1").cmd("ifconfig r1-eth2 192.0.3.2/24")
    net.get("r3").cmd("ip route add 192.0.1.0/24 via 192.0.3.2")
    net.get("r1").cmd("ip route add 192.0.6.0/24 via 192.0.3.1")
    net.get("r3").cmd("ifconfig r3-eth1 192.0.6.1/24")
    net.get("r4").cmd("ifconfig r4-eth1 192.0.6.2/24")
    net.get("r3").cmd("ip route add 192.0.4.0/24 via 192.0.6.2")
    net.get("r1").cmd("ip route add 192.0.3.0/24 via 192.0.6.1")

    net.get("r2").cmd("ip route add 192.0.3.0/24 via 192.0.2.2")

    net.get("r2").cmd("ip route add 192.0.6.0/24 via 192.0.5.2")

    net.get("r3").cmd("ip route add 192.0.2.0/24 via 192.0.3.2")
    net.get("r3").cmd("ip route add 192.0.5.0/24 via 192.0.6.2")
    net.get("r4").cmd("ip route add 192.0.3.0/24 via 192.0.6.1")
    net.get("r1").cmd("python /home/mininet/myfolder/server_class.py R1 &")
    net.get("r2").cmd("python /home/mininet/myfolder/server_class.py R2 &")
    net.get("r3").cmd("python /home/mininet/myfolder/server_class.py R3 &")
    net.get("r4").cmd("python /home/mininet/myfolder/server_class.py R4 &")
    net.get("h1").cmd("python /home/mininet/myfolder/server_class.py H1 &")
    net.get("h2").cmd("python /home/mininet/myfolder/server_class.py H2 &")

    info('** Testing network connectivity\n')
    net.ping(net.hosts)

    info('** Dumping host processes\n')
    for host in net.hosts:
        host.cmdPrint("ps aux")

    info('** Running CLI\n')

    CLI(net)
예제 #28
0
def startNetwork():
    "instantiates a topo, then starts the network and prints debug information"

    info('** Creating Quagga network topology\n')
    topo = QuaggaTopo()

    info('** Starting the network\n')
    global net
    net = MiniNExT(topo, controller=OVSController)
    net.start()

    info('** Dumping host connections\n')
    dumpNodeConnections(net.hosts)

    info('** Testing network connectivity\n')
    net.ping(net.hosts)

    info('** Dumping host processes\n')

    h2IPAddress = "192.0.0.213"

    for i in range(2, 6):
        if i == 2:
            net.hosts[i].cmdPrint("ip addr add 192.0.0.201/30 dev R1-eth2")
            net.hosts[i].cmdPrint("ip addr add 192.0.0.197/30 dev R1-eth1")
        elif i == 3:
            net.hosts[i].cmdPrint("ip addr add 192.0.0.209/30 dev R2-eth1")
        elif i == 4:
            net.hosts[i].cmdPrint("ip addr add 192.0.0.205/30 dev R3-eth1")
        elif i == 5:
            net.hosts[i].cmdPrint("ip addr add 192.0.0.206/30 dev R4-eth1")
            net.hosts[i].cmdPrint("ip addr add 192.0.0.214/30 dev R4-eth2")

    for host in net.hosts:
        host.cmdPrint("ps aux")
        host.cmdPrint("echo 1 > /proc/sys/net/ipv4/ip_forward")

    for i in range(len(net.hosts)):
        if i == 0:
            net.hosts[i].cmdPrint("route add default gw 192.0.0.194")
        elif i == 1:
            net.hosts[i].cmdPrint("route add default gw 192.0.0.214")

    if argument == "1":
        startTime = time.time()
        check = 'random'
        print("Checking Time taken by H1 to ping H2...Wait")

        while ' 0% packet loss' not in check:
            check = net.hosts[0].cmdPrint('ping -c10 ' + h2IPAddress)
            if ' 0% packet loss' not in check:
                print("Not able to ping in this ping..Trying again")

        print(check)
        endTime = time.time()
        print('H1 to H2 pinging time= ', (endTime - startTime), 'sec')

    if argument == "2":
        startTime = time.time()

        check = 1
        print("Checking Convergence Time....Wait")
        while check != 0:
            check = net.pingAll()
            if check != 0:
                print("Not converged in this ping...Trying again")

        endTime = time.time()
        print('Convergence time= ', (endTime - startTime), 'sec')

        print('Do R1-R2 Link down')
        startTime = time.time()
        net.configLinkStatus('R1', 'R2', 'down')
        print("Link Down...Checking convergence Time")
        check = 'random'
        while ' 0% packet loss' not in check:
            check = net.hosts[0].cmdPrint('ping -c10 ' + h2IPAddress)
            if ' 0% packet loss' not in check:
                print("Not able to ping in this ping..Trying again")

        print(check)
        endTime = time.time()
        print('H1 to H2 pinging time= ', (endTime - startTime), 'sec')

    info('** Running CLI\n')
    CLI(net)
예제 #29
0
def startNetwork():
    "instantiates a topo, then starts the network and prints debug information"

    info('** Creating Quagga network topology\n')
    topo = QuaggaTopo()

    info('** Starting the network\n')
    global net
    net = MiniNExT(topo, controller=OVSController)
    net.start()

    print("Arun testing Start")
    h1 = net.getNodeByName('H1')
    h2 = net.getNodeByName('H2')

    r1 = net.getNodeByName('R1')
    r1.cmdPrint('ip address add 192.0.2.1/24 dev R1-eth1')
    r1.cmdPrint('ip address add 192.0.3.1/24 dev R1-eth2')
    r2 = net.getNodeByName('R2')
    r2.cmdPrint('ip address add 192.0.4.1/24 dev R2-eth1')
    r4 = net.getNodeByName('R4')
    r4.cmdPrint('ip address add 192.0.5.2/24 dev R4-eth2')
    r4.cmdPrint('ip address add 192.0.4.2/24 dev R4-eth1')
    r3 = net.getNodeByName('R3')
    r3.cmdPrint('ip address add 192.0.5.1/24 dev R3-eth1')

    info('** Enabling Ip forwarding\n')
    for host in net.hosts:
        host.cmdPrint("echo 1 > /proc/sys/net/ipv4/ip_forward")

    info('**** Setting static routes*******')
    h1.cmdPrint('ip route add 192.0.6.0/24 via 192.0.1.2 dev H1-eth0')
    h1.cmdPrint('ip route add 192.0.2.0/24 via 192.0.1.2 dev H1-eth0')
    h1.cmdPrint('ip route add 192.0.4.0/24 via 192.0.1.2 dev H1-eth0')
    h1.cmdPrint('ip route add 192.0.3.0/24 via 192.0.1.2 dev H1-eth0')
    h1.cmdPrint('ip route add 192.0.5.0/24 via 192.0.1.2 dev H1-eth0')

    r1.cmdPrint('ip route add 192.0.6.0/24 via 192.0.2.2 dev R1-eth1')
    r1.cmdPrint('ip route add 192.0.4.0/24 via 192.0.2.2 dev R1-eth1')
    r1.cmdPrint('ip route add 192.0.5.0/24 via 192.0.3.2 dev R1-eth2')

    r2.cmdPrint('ip route add 192.0.6.0/24 via 192.0.4.2 dev R2-eth1')
    r2.cmdPrint('ip route add 192.0.4.0/24 via 192.0.4.2 dev R2-eth1')
    r2.cmdPrint('ip route add 192.0.1.0/24 via 192.0.2.1 dev R2-eth0')
    r2.cmdPrint('ip route add 192.0.3.0/24 via 192.0.2.1 dev R2-eth0')

    h2.cmdPrint('ip route add 192.0.1.0/24 via 192.0.6.1 dev H2-eth0')
    h2.cmdPrint('ip route add 192.0.2.0/24 via 192.0.6.1 dev H2-eth0')
    h2.cmdPrint('ip route add 192.0.3.0/24 via 192.0.6.1 dev H2-eth0')
    h2.cmdPrint('ip route add 192.0.4.0/24 via 192.0.6.1 dev H2-eth0')
    h2.cmdPrint('ip route add 192.0.5.0/24 via 192.0.6.1 dev H2-eth0')

    r4.cmdPrint('ip route add 192.0.2.0/24 via 192.0.4.1 dev R4-eth1')
    r4.cmdPrint('ip route add 192.0.1.0/24 via 192.0.4.1 dev R4-eth1')
    r4.cmdPrint('ip route add 192.0.3.0/24 via 192.0.5.1 dev R4-eth2')

    r3.cmdPrint('ip route add 192.0.1.0/24 via 192.0.3.1 dev R3-eth0')
    r3.cmdPrint('ip route add 192.0.6.0/24 via 192.0.5.2 dev R3-eth1')
    r3.cmdPrint('ip route add 192.0.2.0/24 via 192.0.3.1 dev R3-eth0')

    info('** Dumping host connections\n')
    dumpNodeConnections(net.hosts)

    info('** Testing network connectivity\n')
    net.ping(net.hosts)

    info('** Dumping host processes\n')
    for host in net.hosts:
        host.cmdPrint("ps aux")

    info('** Running CLI\n')
    CLI(net)
예제 #30
0
def startNetwork():
    "instantiates a topo, then starts the network and prints debug information"

    info('** Creating Quagga network topology\n')
    topo = QuaggaTopo()

    info('** Starting the network\n')
    global net
    net = MiniNExT(topo, controller=None)

    info('** Adding the controller\n')
    # Adding the remote controller
    #controller = net.addController('c1', controller=RemoteController, ip='2.0.0.4', port=6633)

    net.start()

    info('** Adding the links\n')
    # Create the full topology, including the SWIFTED router
    Link(net.getNodeByName('r1'),
         net.getNodeByName('r2'),
         intfName1='r2',
         intfName2='r1')
    Link(net.getNodeByName('r3'),
         net.getNodeByName('r5'),
         intfName1='r5',
         intfName2='r3')
    Link(net.getNodeByName('r4'),
         net.getNodeByName('r5'),
         intfName1='r5',
         intfName2='r4')
    Link(net.getNodeByName('r5'),
         net.getNodeByName('r6'),
         intfName1='r6',
         intfName2='r5')

    # Configuring host r1
    node = net.getNodeByName('r1')
    node.cmd('ifconfig r2 1.0.0.2/24')
    node.cmd('route add default gw 1.0.0.1')

    # Configuring r5 and r6
    node = net.getNodeByName('r5')
    node.cmd('/root/.disable_rp_filtering.sh')

    node = net.getNodeByName('r6')
    node.cmd('/root/.disable_rp_filtering.sh')
    node.cmd('ifconfig r5 6.0.0.2/24')
    node.cmd('ifconfig lo 109.207.108.1/24'
             )  ## CHange based on the bview R6 is advertising
    node.cmd('route add default gw 6.0.0.1')

    # Setting the right MAC addresses
    node = net.getNodeByName('r2')
    node.cmd('ip link set dev s1 address 20:00:00:00:00:01')
    node.cmd('/root/.disable_rp_filtering.sh')
    node.cmd('arp -s 2.0.0.2 20:00:00:00:00:02')
    node.cmd('arp -s 2.0.0.3 20:00:00:00:00:03')
    node.cmd('arp -s 2.0.0.4 20:00:00:00:00:04')

    node = net.getNodeByName('r3')
    node.cmd('ip link set dev s1 address 20:00:00:00:00:02')
    node.cmd('/root/.disable_rp_filtering.sh')
    node.cmd('arp -s 2.0.0.1 20:00:00:00:00:01')
    node.cmd('arp -s 2.0.0.3 20:00:00:00:00:03')
    node.cmd('arp -s 2.0.0.4 20:00:00:00:00:04')

    node = net.getNodeByName('r4')
    node.cmd('ip link set dev s1 address 20:00:00:00:00:03')
    node.cmd('/root/.disable_rp_filtering.sh')
    node.cmd('arp -s 2.0.0.1 20:00:00:00:00:01')
    node.cmd('arp -s 2.0.0.2 20:00:00:00:00:02')
    node.cmd('arp -s 2.0.0.4 20:00:00:00:00:04')

    info('** Dumping host connections\n')
    dumpNodeConnections(net.hosts)

    #info('** Testing network connectivity\n')
    #net.ping(net.hosts)

    info('** Dumping host processes\n')
    for host in net.hosts:
        host.cmdPrint("ps aux")

    info('** Running CLI\n')
    CLI(net)
예제 #31
0
def startNetwork():
    "instantiates a topo, then starts the network and prints debug information"

    info('** Creating Quagga network topology\n')
    topo = QuaggaTopo()

    info('** Starting the network\n')
    global net
    net = MiniNExT(topo, controller=OVSController)
    net.start()

    info('** Dumping host connections\n')
    dumpNodeConnections(net.hosts)

    info('** Dumping host processes\n')
    #    for host in net.hosts:
    #        host.cmdPrint("ps aux")
    #    for host in net.hosts:
    #        host.cmdPrint('ifconfig')

    # Enabling IP forwarding
    net.get("R1").cmd("sysctl -w net.ipv4.ip_forward=1")
    net.get("R2").cmd("sysctl -w net.ipv4.ip_forward=1")
    net.get("R3").cmd("sysctl -w net.ipv4.ip_forward=1")
    net.get("R4").cmd("sysctl -w net.ipv4.ip_forward=1")

    # Setting Interface IPs
    net.get("R1").cmd("ifconfig R1-eth1 172.0.2.1/24")
    net.get("R1").cmd("ifconfig R1-eth2 172.0.6.2/24")
    net.get("R2").cmd("ifconfig R2-eth1 172.0.3.1/24")
    net.get("R4").cmd("ifconfig R4-eth1 172.0.3.2/24")
    net.get("R4").cmd("ifconfig R4-eth2 172.0.5.1/24")
    net.get("R3").cmd("ifconfig R3-eth1 172.0.5.2/24")

    # Static Routes from R1 to R2
    net.get("H1").cmd("route add default gw 172.0.1.2")
    net.get("R1").cmd("ip route add 172.0.3.0/24 via 172.0.2.2 dev R1-eth1")
    net.get("R1").cmd("ip route add 172.0.4.0/24 via 172.0.2.2 dev R1-eth1")
    net.get("R2").cmd("ip route add 172.0.4.0/24 via 172.0.3.2 dev R2-eth1")

    # Allowing Nating ar each router in the path from H1 to H2
    net.get("R1").cmd(
        "iptables -t nat -A POSTROUTING -o R1-eth1 -j MASQUERADE")
    net.get("R1").cmd(
        "iptables -A FORWARD -i R1-eth1 -o R1-eth0 -m state --state RELATED,ESTABLISHED -j ACCEPT"
    )
    net.get("R1").cmd("iptables -A FORWARD -i R1-eth0 -o R1-eth1 -j ACCEPT")
    net.get("R2").cmd(
        "iptables -t nat -A POSTROUTING -o R2-eth1 -j MASQUERADE")
    net.get("R2").cmd(
        "iptables -A FORWARD -i R2-eth1 -o R2-eth0 -m state --state RELATED,ESTABLISHED -j ACCEPT"
    )
    net.get("R2").cmd("iptables -A FORWARD -i R2-eth0 -o R2-eth1 -j ACCEPT")
    net.get("R4").cmd(
        "iptables -t nat -A POSTROUTING -o R4-eth0 -j MASQUERADE")
    net.get("R4").cmd(
        "iptables -A FORWARD -i R4-eth0 -o R4-eth1 -m state --state RELATED,ESTABLISHED -j ACCEPT"
    )
    net.get("R4").cmd("iptables -A FORWARD -i R4-eth1 -o R4-eth0 -j ACCEPT")

    info('** Testing network connectivity\n')
    net.ping(net.hosts)

    info('** Running CLI\n')
    CLI(net)
예제 #32
0
def startNetwork():
    "instantiates a topo, then starts the network and prints debug information"

    info('** Creating Quagga network topology\n')
    topo = QuaggaTopo()
    info('** Starting the network\n')
    global net
    net = MiniNExT(topo, controller=OVSController)
    net.start()

    info('** Dumping host connections\n')
    dumpNodeConnections(net.hosts)
    """net.get("r1").cmd('service quagga restart')
    net.get("r1").cmd('chown quagga:quaggavty /etc/quagga/*.conf')
    net.get("r1").cmd('chmod 640 /etc/quagga/*.conf')

    net.get("r2").cmd('service quagga restart')
    net.get("r2").cmd('chown quagga:quaggavty /etc/quagga/*.conf')
    net.get("r2").cmd('chmod 640 /etc/quagga/*.conf')

    net.get("r3").cmd('service quagga restart')
    net.get("r3").cmd('chown quagga:quaggavty /etc/quagga/*.conf')
    net.get("r3").cmd('chmod 640 /etc/quagga/*.conf')

    net.get("r4").cmd('service quagga restart')
    net.get("r4").cmd('chown quagga:quaggavty /etc/quagga/*.conf')
    net.get("r4").cmd('chmod 640 /etc/quagga/*.conf')"""

    net.get("r1").cmd('sysctl net.ipv4.ip_forward=1')
    net.get("r2").cmd('sysctl net.ipv4.ip_forward=1')
    net.get("r3").cmd('sysctl net.ipv4.ip_forward=1')
    net.get("r4").cmd('sysctl net.ipv4.ip_forward=1')

    net.get("h1").cmd('sysctl net.ipv4.ip_forward=1')
    net.get("h2").cmd('sysctl net.ipv4.ip_forward=1')

    #    net.get("h1").cmd("route add default gw 192.0.1.1")
    #    net.get("h2").cmd("route add default gw 192.0.4.1")
    ts = time.time()
    j = 0
    while (j < 20):

        loss = net.ping(net.hosts)
        if (loss == 0):
            #print "my loss:", loss
            te = time.time()
            break
        j += 1
    print "td:", te - ts
    #    info('** Testing network connectivity\n')
    #net.ping(net.hosts)

    info('** Dumping host processes\n')
    for host in net.hosts:
        host.cmdPrint("ps aux")

    info('** Running CLI\n')

    CLI(net)
예제 #33
0
def startNetwork():
	"instantiates a topo, then starts the network and prints debug information"

	info('** Creating Quagga network topology\n')
	topo = QuaggaTopo()

	info('** Starting the network\n')
	global net
	net = MiniNExT(topo, controller=OVSController)
	net.start()

	info('** Dumping host connections\n')
	dumpNodeConnections(net.hosts)

	

	info('** Dumping host processes\n')

	# enabing the rout forwarding for each router
	net.get("R1").cmd("sysctl -w net.ipv4.ip_forward=1")
	net.get("R2").cmd("sysctl -w net.ipv4.ip_forward=1")
	net.get("R3").cmd("sysctl -w net.ipv4.ip_forward=1")
	net.get("R4").cmd("sysctl -w net.ipv4.ip_forward=1")

	# assigning interface IPs for each 	
	net.get("R1").cmd("ifconfig R1-eth1 172.0.2.1/24")
	net.get("R1").cmd("ifconfig R1-eth2 172.0.6.2/24")
	net.get("R2").cmd("ifconfig R2-eth1 172.0.3.1/24")
	net.get("R3").cmd("ifconfig R3-eth1 172.0.5.2/24")	
	net.get("R4").cmd("ifconfig R4-eth1 172.0.3.2/24")
	net.get("R4").cmd("ifconfig R4-eth2 172.0.5.1/24")
	
	# Network test
	info('** Testing network connectivity\n')
	net.ping(net.hosts)
	
	
	info('** Running CLI\n')
	CLI(net)
예제 #34
0
def startNetwork():
    "instantiates a topo, then starts the network and prints debug information"

    info('** Creating Quagga network topology\n')
    topo = QuaggaTopo()

    info('** Starting the network\n')
    global net
    net = MiniNExT(topo, controller=OVSController)
    net.start()

    info('** Dumping host connections\n')
    dumpNodeConnections(net.hosts)

    # Need to assign IPs to all the interfaces in the topology created
    info('** Assigning IPs to interfaces\n')
    net.get('r1').cmd('ip address add 173.0.3.3/16 dev r1-eth1')
    net.get('r1').cmd('ip address add 174.0.3.4/16 dev r1-eth2')
    net.get('r2').cmd('ip address add 175.0.3.5/16 dev r2-eth1')
    net.get('r3').cmd('ip address add 176.0.3.6/16 dev r3-eth1')
    net.get('r4').cmd('ip address add 176.0.4.2/16 dev r4-eth1')
    net.get('r4').cmd('ip address add 177.0.4.3/16 dev r4-eth2')

    # Setting IP Forwarding to 1
    net.get('h1').cmd('echo 1  > /proc/sys/net/ipv4/ip_forward')
    net.get('h2').cmd('echo 1  > /proc/sys/net/ipv4/ip_forward')
    net.get('r1').cmd('echo 1  > /proc/sys/net/ipv4/ip_forward')
    net.get('r2').cmd('echo 1  > /proc/sys/net/ipv4/ip_forward')
    net.get('r3').cmd('echo 1  > /proc/sys/net/ipv4/ip_forward')
    net.get('r4').cmd('echo 1  > /proc/sys/net/ipv4/ip_forward')

    # Creating new static routes
    net.get('h1').cmd('ip route add 0.0.0.0/0 via 172.0.2.1')
    net.get('r1').cmd('ip route add 175.0.0.0/16 via 173.0.3.2')
    net.get('r1').cmd('ip route add 177.0.0.0/16 via 173.0.3.2')
    net.get('r1').cmd('ip route add 176.0.0.0/16 via 174.0.3.1')
    net.get('r2').cmd('ip route add 177.0.0.0/16 via 175.0.4.1')
    net.get('r2').cmd('ip route add 174.0.0.0/16 via 173.0.3.3')
    net.get('r2').cmd('ip route add 176.0.0.0/16 via 175.0.4.1')
    net.get('r2').cmd('ip route add 172.0.0.0/16 via 173.0.3.3')
    net.get('r3').cmd('ip route add 177.0.0.0/16 via 176.0.4.2')
    net.get('r3').cmd('ip route add 173.0.0.0/16 via 174.0.3.4')
    net.get('r3').cmd('ip route add 175.0.0.0/16 via 176.0.3.6')
    net.get('r3').cmd('ip route add 172.0.0.0/16 via 174.0.3.4')
    net.get('r4').cmd('ip route add 173.0.0.0/16 via 175.0.3.5')
    net.get('r4').cmd('ip route add 174.0.0.0/16 via 176.0.3.6')
    net.get('r4').cmd('ip route add 172.0.0.0/16 via 176.0.3.6')
    net.get('h2').cmd('ip route add 0.0.0.0/0 via 177.0.4.3')

    net.get('r1').cmd(
        'iptables -A FORWARD -i r1-eth0 -o r1-eth1 -m state --state RELATED,ESTABLISHED -j ACCEPT'
    )
    net.get('r1').cmd('iptables -A FORWARD -i r1-eth0 -o r1-eth1 -j ACCEPT')
    net.get('r2').cmd(
        'iptables -t nat -A POSTROUTING -o r2-eth1 -j MASQUERADE')
    net.get('r2').cmd(
        'iptables -A FORWARD -i r2-eth0 -o r2-eth1 -m state --state RELATED,ESTABLISHED -j ACCEPT'
    )
    net.get('r2').cmd('iptables -A FORWARD -i r2-eth0 -o r2-eth1 -j ACCEPT')
    net.get('r4').cmd(
        'iptables -t nat -A POSTROUTING -o r4-eth1 -j MASQUERADE')
    net.get('r4').cmd(
        'iptables -A FORWARD -i r4-eth1 -o r4-eth0 -m state --state RELATED,ESTABLISHED -j ACCEPT'
    )
    net.get('r4').cmd('iptables -A FORWARD -i r4-eth1 -o r4-eth0 -j ACCEPT')
    net.get('r4').cmd('iptables -A FORWARD -i r4-eth0 -o r4-eth2 -j ACCEPT')
    net.get('r4').cmd(
        'iptables -A FORWARD -i r4-eth0 -o r4-eth2 -m state --state RELATED,ESTABLISHED -j ACCEPT'
    )
    net.get('r4').cmd(
        'iptables -t nat -A POSTROUTING -o r4-eth2 -j MASQUERADE')
    net.get('r3').cmd('iptables -A FORWARD -i r3-eth1 -o r3-eth0 -j ACCEPT')
    net.get('r3').cmd(
        'iptables -A FORWARD -i r3-eth1 -o r3-eth0 -m state --state RELATED,ESTABLISHED -j ACCEPT'
    )
    net.get('r3').cmd(
        'iptables -t nat -A POSTROUTING -o r3-eth0 -j MASQUERADE')

    info('** Testing network connectivity\n')
    net.ping(net.hosts)

    info('** Dumping host processes\n')
    for host in net.hosts:
        host.cmdPrint("ps aux")

    info('** Running CLI\n')
    CLI(net)
예제 #35
0
                    host.cmd(cmdList)
                # Otherwise run all the commands in the list
                else: 
                    for c in cmdList:
                        host.cmd(c)

if __name__ == "__main__":
    if len(argv) < 2:
        print "usage: sudo python emulator.py config"
        exit()
    script, filename = argv
    data = open(filename)
    config = load(data)
    setLogLevel("info")
    try:
        net = MiniNExT(JAMTopo(config), controller=OVSController, link=TCLink,
                       host=CPULimitedHost, switch=OVSKernelSwitch)
        setupIntfs(net, config)
        net.start()
        # Configure and start NAT connectivity
        # rootnode = connectToInternet(net, config["switch"][0]["name"])
        # print "*** Hosts are running and should have internet connectivity"
        runCmds(net, config)
        print "*** Type 'exit' or control-D to shut down network"
        CLI(net)
        # Shut down NAT
        # stopNAT(rootnode)
        net.stop()
    except:
        cleanup()
        raise
예제 #36
0
def startNetwork():
    "instantiates a topo, then starts the network and prints debug information"

    info('** Creating Quagga network topology\n')
    topo = QuaggaTopo()

    info('** Starting the network\n')
    global net
    net = MiniNExT(topo, controller=OVSController)
    net.start()

    info('** Dumping host connections\n')
    dumpNodeConnections(net.hosts)

    for host in net.hosts:
        if host.name == 'H1':
            host.cmd(
                'ip route add 192.168.102.0/24 via 192.168.101.1 dev H1-eth0')
            host.cmd(
                'ip route add 192.168.103.0/24 via 192.168.101.1 dev H1-eth0')
            host.cmd(
                'ip route add 192.168.104.0/24 via 192.168.101.1 dev H1-eth0')
            host.cmd(
                'ip route add 192.168.105.0/24 via 192.168.101.1 dev H1-eth0')
            host.cmd(
                'ip route add 192.168.106.0/24 via 192.168.101.1 dev H1-eth0')
        if host.name == 'R1':
            host.setIP('192.168.102.2/24', intf='R1-eth1')
            host.setIP('192.168.103.2/24', intf='R1-eth2')
            host.cmd(
                'ip route add 192.168.104.0/24 via 192.168.102.1 dev R1-eth1')
            host.cmd(
                'ip route add 192.168.105.0/24 via 192.168.103.1 dev R1-eth2')
            host.cmd(
                'ip route add 192.168.106.0/24 via 192.168.102.1 dev R1-eth1')
        if host.name == 'R2':
            host.setIP('192.168.104.1/24', intf='R2-eth1')
            host.cmd(
                'ip route add 192.168.101.0/24 via 192.168.102.2 dev R2-eth0')
            host.cmd(
                'ip route add 192.168.103.0/24 via 192.168.102.2 dev R2-eth0')
            host.cmd(
                'ip route add 192.168.105.0/24 via 192.168.104.2 dev R2-eth1')
            host.cmd(
                'ip route add 192.168.106.0/24 via 192.168.104.2 dev R2-eth1')
        if host.name == 'R3':
            host.setIP('192.168.105.1/24', intf='R3-eth1')
            host.cmd(
                'ip route add 192.168.101.0/24 via 192.168.103.2 dev R3-eth0')
            host.cmd(
                'ip route add 192.168.102.0/24 via 192.168.103.2 dev R3-eth0')
            host.cmd(
                'ip route add 192.168.104.0/24 via 192.168.105.2 dev R3-eth1')
            host.cmd(
                'ip route add 192.168.106.0/24 via 192.168.105.2 dev R3-eth1')
        if host.name == 'R4':
            host.setIP('192.168.104.2/24', intf='R4-eth1')
            host.setIP('192.168.105.2/24', intf='R4-eth2')
            host.cmd(
                'ip route add 192.168.101.0/24 via 192.168.104.1 dev R4-eth1')
            host.cmd(
                'ip route add 192.168.102.0/24 via 192.168.104.1 dev R4-eth1')
            host.cmd(
                'ip route add 192.168.103.0/24 via 192.168.105.1 dev R4-eth2')
        if host.name == 'H2':
            host.cmd(
                'ip route add 192.168.101.0/24 via 192.168.106.1 dev H2-eth0')
            host.cmd(
                'ip route add 192.168.102.0/24 via 192.168.106.1 dev H2-eth0')
            host.cmd(
                'ip route add 192.168.103.0/24 via 192.168.106.1 dev H2-eth0')
            host.cmd(
                'ip route add 192.168.104.0/24 via 192.168.106.1 dev H2-eth0')
            host.cmd(
                'ip route add 192.168.105.0/24 via 192.168.106.1 dev H2-eth0')
        host.cmd("sysctl -w net.ipv4.ip_forward=1")

    info('** Testing network connectivity\n')
    net.ping(net.hosts)

    info('** Dumping host processes\n')
    for host in net.hosts:
        host.cmd("ps aux")

    info('** Running CLI\n')
    CLI(net)
예제 #37
0
def startNetwork(topo_info, router_lo, init_quagga_configs, group_number):
    "instantiates a topo, then starts the network and prints debug information"

    info('** Creating Quagga network topology\n')
    topo = QuaggaInternet2Topo(topo_info, router_lo)

    global net
    #net = MiniNExT(topo, controller=OVSController)
    net = MiniNExT(topo, controller=RemoteController)

    info('** Adding Static networks\n')
    addStaticNet(net)

    info('** Starting the network\n')
    net.start()

    info('** Setting Static network\n')
    setStaticNet(net, group_number)

    info('** Adding links and loopback interfaces')
    links_set = Set()
    for router_name, ngh_list in topo_info.items():
        for ngh in ngh_list:

            # Make sure to only create one link between two routers
            if ngh + router_name not in links_set:
                print 'Link added between ' + str(router_name) + ' and ' + str(
                    ngh)
                Link(net.getNodeByName(router_name),
                     net.getNodeByName(ngh),
                     intfName1=ngh.lower(),
                     intfName2=router_name.lower())
                links_set.add(router_name + ngh)

        # Add link to the host
        Link(net.getNodeByName(router_name),
             net.getNodeByName(router_name + '-host'),
             intfName1='host',
             intfName2=router_name.lower())

    info('** Configuring the IP addresses **\n')
    for router_name in topo_info:
        node = net.getNodeByName(router_name)
        node.cmd('ifconfig ebgp_peer 0 up')
        #node.cmd('ifconfig lo '+router_lo[router_name]+'/24 up')
        for ngh, ip in topo_info[router_name].items():
            intf_name = ngh.lower()
            if init_quagga_configs:
                node.cmd('ifconfig ' + intf_name + ' 0.0.0.0/0 up')
            #else:
            #    node.cmd('ifconfig '+intf_name+' '+ip+' up')

    node = net.getNodeByName('HOUS')
    node.cmd('ifconfig mgt 0.0.0.0/0 up')

    info('** Dumping host connections\n')
    dumpNodeConnections(net.hosts)

    info('** Testing network connectivity\n')
    info('** Disabled **\n')
    #net.ping(net.hosts)

    info('** Dumping host processes\n')
    for host in net.hosts:
        if host.name in ['server1', 'server2']:
            continue
        host.cmdPrint("ps aux")

    info('** Running CLI\n')
    CLI(net)

    stopStaticNet(net)
예제 #38
0
def startNetwork():
    "instantiates a topo, then starts the network and prints debug information"

    info('** Creating Quagga network topology\n')
    topo = QuaggaTopo()

    info('** Starting the network\n')
    global net
    net = MiniNExT(topo, controller=OVSController)
    net.start()

    info('** Dumping host connections\n')
    dumpNodeConnections(net.hosts)

    info('** Testing network connectivity\n')
    net.ping(net.hosts)

    # part A1
    net.get('H1').cmd('ifconfig H1-eth0 170.1.1.1/24')
    net.get('H2').cmd('ifconfig H2-eth0 175.7.7.2/24')
    net.get('R1').cmd('ifconfig R1-eth0 170.1.1.2/24')
    net.get('R1').cmd('ifconfig R1-eth1 171.1.1.1/24')
    net.get('R1').cmd('ifconfig R1-eth2 172.1.1.1/24')
    net.get('R2').cmd('ifconfig R2-eth0 171.1.1.2/24')
    net.get('R2').cmd('ifconfig R2-eth1 173.1.1.2/24')
    net.get('R3').cmd('ifconfig R3-eth0 172.1.1.2/24')
    net.get('R3').cmd('ifconfig R3-eth1 174.1.1.2/24')
    net.get('R4').cmd('ifconfig R4-eth0 175.7.7.1/24')
    net.get('R4').cmd('ifconfig R4-eth1 173.1.1.1/24')
    net.get('R4').cmd('ifconfig R4-eth2 174.1.1.1/24')

    #change the IP forwarding variable to 1
    net.get('H1').cmd('sysctl -w net.ipv4.ip_forward=1')
    net.get('H2').cmd('sysctl -w net.ipv4.ip_forward=1')
    net.get('R1').cmd('sysctl -w net.ipv4.ip_forward=1')
    net.get('R2').cmd('sysctl -w net.ipv4.ip_forward=1')
    net.get('R3').cmd('sysctl -w net.ipv4.ip_forward=1')
    net.get('R4').cmd('sysctl -w net.ipv4.ip_forward=1')

    # time.sleep(3000)
    info('** Dumping host processes\n')
    for host in net.hosts:
        host.cmdPrint("ps aux")

    info('** Running CLI\n')
    CLI(net)
예제 #39
0
def startNetwork():
    "instantiates a topo, then starts the network and prints debug information"

    info('** Creating Quagga network topology\n')
    topo = QuaggaTopo()

    info('** Starting the network\n')
    global net
    net = MiniNExT(topo, controller=OVSController)
    net.start()

    info('** Dumping host connections\n')
    dumpNodeConnections(net.hosts)

    info('** Dumping host processes\n')

    # enabing the rout forwarding for each router
    net.get("R1").cmd("sysctl -w net.ipv4.ip_forward=1")
    net.get("R2").cmd("sysctl -w net.ipv4.ip_forward=1")
    net.get("R3").cmd("sysctl -w net.ipv4.ip_forward=1")
    net.get("R4").cmd("sysctl -w net.ipv4.ip_forward=1")

    # assigning interface IPs for each
    net.get("R1").cmd("ifconfig R1-eth1 172.0.2.1/24")
    net.get("R1").cmd("ifconfig R1-eth2 172.0.6.2/24")
    net.get("R2").cmd("ifconfig R2-eth1 172.0.3.1/24")
    net.get("R3").cmd("ifconfig R3-eth1 172.0.5.2/24")
    net.get("R4").cmd("ifconfig R4-eth1 172.0.3.2/24")
    net.get("R4").cmd("ifconfig R4-eth2 172.0.5.1/24")

    # Network test
    info('** Testing network connectivity\n')
    net.ping(net.hosts)

    info('** Running CLI\n')
    CLI(net)
예제 #40
0
def startNetwork():
    "instantiates a topo, then starts the network and prints debug information"

    info('** Creating Quagga network topology\n')
    topo = QuaggaTopo()

    info('** Starting the network\n')
    global net
    net = MiniNExT(topo, controller=OVSController)
    net.start()

    info('** Dumping host connections\n')
    dumpNodeConnections(net.hosts)

    info('** Testing network connectivity\n')
    net.ping(net.hosts) 

#Insert Queries
    net['r1'].cmd('sysctl -w net.ipv4.ip_forward=1')
    net['r2'].cmd('sysctl -w net.ipv4.ip_forward=1')
    net['r3'].cmd('sysctl -w net.ipv4.ip_forward=1')
    net['r4'].cmd('sysctl -w net.ipv4.ip_forward=1')
 
    net['h1'].cmd('ip route add 172.0.2.0/24 via 172.0.1.2')
    net['h1'].cmd('ip route add 172.0.3.0/24 via 172.0.1.2')
    net['h1'].cmd('ip route add 172.0.4.0/24 via 172.0.1.2')
    net['h1'].cmd('ip route add 172.0.5.0/24 via 172.0.1.2')
    net['h1'].cmd('ip route add 172.0.6.0/24 via 172.0.1.2')

    net['r1'].cmd('ip route add 172.0.4.0/24 via 172.0.2.2')
    net['r1'].cmd('ip route add 172.0.5.0/24 via 172.0.3.2')
    net['r1'].cmd('ip route add 172.0.6.0/24 via 172.0.2.2')

    net['r2'].cmd('ip route add 172.0.1.0/24 via 172.0.2.1')
    net['r2'].cmd('ip route add 172.0.3.0/24 via 172.0.2.1')
    net['r2'].cmd('ip route add 172.0.5.0/24 via 172.0.4.2')
    net['r2'].cmd('ip route add 172.0.6.0/24 via 172.0.4.2')

    net['r3'].cmd('ip route add 172.0.1.0/24 via 172.0.3.1')
    net['r3'].cmd('ip route add 172.0.2.0/24 via 172.0.3.1')
    net['r3'].cmd('ip route add 172.0.4.0/24 via 172.0.5.2')
    net['r3'].cmd('ip route add 172.0.6.0/24 via 172.0.5.2')	

    net['r4'].cmd('ip route add 172.0.2.0/24 via 172.0.4.1')
    net['r4'].cmd('ip route add 172.0.3.0/24 via 172.0.5.1')
    net['r4'].cmd('ip route add 172.0.1.0/24 via 172.0.4.1')

    net['h2'].cmd('ip route add 172.0.2.0/24 via 172.0.6.1')
    net['h2'].cmd('ip route add 172.0.3.0/24 via 172.0.6.1')
    net['h2'].cmd('ip route add 172.0.4.0/24 via 172.0.6.1')
    net['h2'].cmd('ip route add 172.0.5.0/24 via 172.0.6.1')
    net['h2'].cmd('ip route add 172.0.1.0/24 via 172.0.6.1')

#r1 sysctl -w net.ipv4.ip_forward=1

    info('** Dumping host processes\n')
    for host in net.hosts:
        host.cmdPrint("ps aux")

    info('** Running CLI\n')
    CLI(net)
예제 #41
0
def simpleTest():
    """Create and test a simple network"""
    net = Mininext(topo=None, build=False)

    "Initialize a service helper for Quagga with default options"
    quaggaSvc = QuaggaService(autoStop=False)

    # Add controllers
    print("Adding controllers...")
    c0 = net.addController(name='c0', controller=Floodlight, ip='127.0.0.1', port=6653,
                           cargs='-cf src/main/resources/floodlightmininet_1.properties')
    c1 = net.addController(name='c1', controller=Floodlight, ip='127.0.0.1', port=7653,
                           cargs='-cf src/main/resources/floodlightmininet_2.properties')

    print("Adding switches...")
    switch1 = net.addSwitch('switch1')
    switch2 = net.addSwitch('switch2')

    print("Adding hosts...")
    host1 = net.addHost('host1', ip='10.0.0.1/24')
    host2 = net.addHost('host2', ip='20.0.0.1/24')

    print("Adding links...")
    net.addLink(host1, switch1)
    net.addLink(host2, switch2)
    net.addLink(switch1, switch2)

    print("Building network...")
    print(net.hosts)
    net.build()

    print("Starting controllers...")
    for controller in net.controllers:
        controller.start()

    print("Starting switches...")
    net.get('switch1').start([c0])
    net.get('switch2').start([c1])

    CLI(net)
    net.stop()

    if __name__ == '__main__':
        # Tell mininet to print useful information
        setLogLevel('info')