Ejemplo n.º 1
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)
Ejemplo n.º 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()

	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)
Ejemplo n.º 3
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)
Ejemplo n.º 4
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("** 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)
Ejemplo n.º 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)
    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("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("r1").cmd("ifconfig r1-eth1 193.0.1.1")
    net.get("r1").cmd("ifconfig r1-eth2 194.0.1.1")
    net.get("r2").cmd("ifconfig r2-eth1 193.0.1.2")
    net.get("r3").cmd("ifconfig r3-eth1 194.0.1.2")
    net.get("r4").cmd("ifconfig r4-eth1 195.0.1.2")
    net.get("r4").cmd("ifconfig r4-eth2 196.0.1.2")

    net.get("h1").cmd("route add default gw 192.0.1.2")
    net.get("h2").cmd("route add default gw 197.1.1.2")
    net.get("r1").cmd("ip route add 197.1.1.0/24 via 193.0.1.2")
    net.get("r1").cmd("ip route add 195.0.1.0/24 via 193.0.1.2")
    net.get("r2").cmd("ip route add 197.1.1.0/24 via 195.0.1.2")
    net.get("r4").cmd("ip route add 193.0.1.0/24 via 195.0.1.1")
    net.get("r4").cmd("ip route add 192.0.1.0/24 via 195.0.1.1")
    net.get("r2").cmd("ip route add 192.0.1.0/24 via 193.0.1.1")

    net.get("r1").cmd("ip route add 196.0.1.0/24 via 194.0.1.2")
    net.get("r3").cmd("ip route add 197.1.1.0/24 via 196.0.1.2")
    net.get("r4").cmd("ip route add 194.0.1.0/24 via 196.0.1.1")
    net.get("r3").cmd("ip route add 192.0.1.0/24 via 194.0.1.1")

    net.get("r3").cmd("ip route add 195.0.1.0/24 via 196.0.1.2")
    net.get("r2").cmd("ip route add 194.0.1.0/24 via 193.0.1.1")
    net.get("r3").cmd("ip route add 193.0.1.0/24 via 194.0.1.1")
    net.get("r2").cmd("ip route add 196.0.1.0/24 via 195.0.1.2")

    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)
Ejemplo n.º 6
0
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'
Ejemplo n.º 7
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)
Ejemplo n.º 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()

    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)
Ejemplo n.º 9
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)
Ejemplo n.º 10
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')

    # Set 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')

    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)
Ejemplo n.º 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()

    # 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)
Ejemplo n.º 12
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)
Ejemplo n.º 13
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)
Ejemplo n.º 14
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)
Ejemplo n.º 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()

    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)
Ejemplo n.º 16
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)
Ejemplo n.º 17
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)
Ejemplo n.º 18
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)
Ejemplo n.º 19
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)
Ejemplo n.º 20
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')
    
    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")
        elif i == 2:
            net.hosts[i].cmdPrint("ip route add 192.0.0.204/30 via 192.0.0.202")
            net.hosts[i].cmdPrint("ip route add 192.0.0.208/30 via 192.0.0.198")
            net.hosts[i].cmdPrint("ip route add 192.0.0.212/30 via 192.0.0.198")
        elif i == 3:
            net.hosts[i].cmdPrint("ip route add 192.0.0.192/30 via 192.0.0.197")
            net.hosts[i].cmdPrint("ip route add 192.0.0.200/30 via 192.0.0.197")
            net.hosts[i].cmdPrint("ip route add 192.0.0.204/30 via 192.0.0.210")
            net.hosts[i].cmdPrint("ip route add 192.0.0.212/30 via 192.0.0.210")
        elif i == 4:
            net.hosts[i].cmdPrint("ip route add 192.0.0.192/30 via 192.0.0.201")
            net.hosts[i].cmdPrint("ip route add 192.0.0.196/30 via 192.0.0.201")
            net.hosts[i].cmdPrint("ip route add 192.0.0.208/30 via 192.0.0.201")
            net.hosts[i].cmdPrint("ip route add 192.0.0.212/30 via 192.0.0.206")
        elif i == 5:
            net.hosts[i].cmdPrint("ip route add 192.0.0.192/30 via 192.0.0.205")
            net.hosts[i].cmdPrint("ip route add 192.0.0.196/30 via 192.0.0.209")
            net.hosts[i].cmdPrint("ip route add 192.0.0.200/30 via 192.0.0.205")


    info('** Running CLI\n')
    CLI(net)
Ejemplo n.º 21
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)
Ejemplo n.º 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()

    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')
    startTime = time.time()
    while net.ping([net.get('H1'), net.get('H2')]) != 0:
        endTime = time.time()
        elapsedTime = endTime - startTime
        print 'Elapsed Time - ', elapsedTime
        continue
    endTime = time.time()
    elapsedTime = endTime - startTime
    print 'Convergence Time - ' + str(elapsedTime) + 's'

    selfPath = os.path.dirname(
        os.path.abspath(inspect.getfile(inspect.currentframe())))
    info('** Dumping host processes\n')
    for host in net.hosts:
        host.cmdPrint(selfPath + "/server.py " + host.name + " > " +
                      host.name + ".log &")

    info('** Running CLI\n')
    CLI(net)
Ejemplo n.º 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)
    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)
Ejemplo n.º 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
    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)