Пример #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()

    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)
Пример #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
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():
    "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)
Пример #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)
Пример #6
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)
Пример #7
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'
Пример #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)

    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)
Пример #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()

    # 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)
Пример #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()

    # 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)
Пример #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)

    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)
Пример #12
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)
Пример #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)
    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)
Пример #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
    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)
Пример #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, 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)
Пример #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)
Пример #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=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)
Пример #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)
Пример #19
0
#!/usr/bin/python
"""Example network of Quagga routers(QuaggaTopo + QuaggaService)"""
import sysimport atexit
# patch isShellBuiltinimport mininet.utilimport mininext.utilmininet.util.isShellBuiltin = mininext.util.isShellBuiltinsys.modules['mininet.util'] = mininet.util
from mininet.util import dumpNodeConnectionsfrom mininet.node import OVSControllerfrom mininet.log import setLogLevel, info
from mininext.cli import CLIfrom mininext.net import MiniNExT
from topo import QuaggaTopo
net = None

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)

def stopNetwork(): "stops a network (only called on a forced cleanup)"
 if net is not None:        info('** Tearing down Quagga network\n')        net.stop()
if __name__ == '__main__': # Force cleanup on exit by registering a cleanup function    atexit.register(stopNetwork)
 # Tell mininet to print useful information    setLogLevel('info')    startNetwork()
Пример #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)

    # 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)
Пример #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)
Пример #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)

    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)
Пример #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)

    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)
Пример #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')
    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)
Пример #25
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)
Пример #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)

    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)
Пример #27
0
def startNetwork(static_routes):
    "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()
    t_start = datetime.now()
    info('** Dumping host connections\n')
    dumpNodeConnections(net.hosts)

    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")

    net.get("R1").cmd("ifconfig R1-eth1 172.0.2.2/24")
    net.get("R1").cmd("ifconfig R1-eth2 172.0.3.2/24")
    net.get("R2").cmd("ifconfig R2-eth0 172.0.2.1/24")
    net.get("R2").cmd("ifconfig R2-eth1 172.0.5.1/24")
    net.get("R3").cmd("ifconfig R3-eth0 172.0.3.1/24")
    net.get("R3").cmd("ifconfig R3-eth1 172.0.6.1/24")
    net.get("R4").cmd("ifconfig R4-eth0 172.0.4.1/24")
    net.get("R4").cmd("ifconfig R4-eth1 172.0.5.2/24")
    net.get("R4").cmd("ifconfig R4-eth2 172.0.6.2/24")
    net.get("H2").cmd("ifconfig H2-eth0 172.0.4.2/24")

    if static_routes:
        net.get("R1").cmd("ip route add 172.0.5.0/24 via 172.0.2.1 dev R1-eth1")
        net.get("R1").cmd("ip route add 172.0.4.0/24 via 172.0.2.1 dev R1-eth1")
        net.get("R1").cmd("ip route add 172.0.4.0/24 via 172.0.3.1 dev R1-eth2")
        net.get("R1").cmd("ip route add 172.0.6.0/24 via 172.0.3.1 dev R1-eth2")
        net.get("R2").cmd("ip route add 172.0.1.0/24 via 172.0.2.2 dev R2-eth0")
        net.get("R2").cmd("ip route add 172.0.4.0/24 via 172.0.5.2 dev R2-eth1")
        net.get("R2").cmd("ip route add 172.0.3.0/24 via 172.0.2.2 dev R2-eth0")
        net.get("R3").cmd("ip route add 172.0.1.0/24 via 172.0.3.2 dev R3-eth0")
        net.get("R3").cmd("ip route add 172.0.2.0/24 via 172.0.3.2 dev R3-eth0")
        net.get("R3").cmd("ip route add 172.0.4.0/24 via 172.0.6.2 dev R3-eth1")
        net.get("R4").cmd("ip route add 172.0.2.0/24 via 172.0.5.1 dev R4-eth1")
        net.get("R4").cmd("ip route add 172.0.3.0/24 via 172.0.6.1 dev R4-eth2")
        net.get("R4").cmd("ip route add 172.0.1.0/24 via 172.0.5.1 dev R4-eth1")
        net.get("R4").cmd("ip route add 172.0.1.0/24 via 172.0.6.1 dev R4-eth2")
    
    net.get("R1").cmd("iptables -t nat -A POSTROUTING -o R1-eth0 -j MASQUERADE")
    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-eth1 -o R1-eth0 -j ACCEPT")
    
    net.get("R2").cmd("iptables -t nat -A POSTROUTING -o R2-eth0 -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-eth1 -o R2-eth0 -j ACCEPT")
    
    net.get("R3").cmd("iptables -t nat -A POSTROUTING -o R3-eth1 -j MASQUERADE")
    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 -A FORWARD -i R3-eth0 -o R3-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")
    net.get("R4").cmd("iptables -A FORWARD -i R4-eth2 -o R4-eth0 -m state --state RELATED,ESTABLISHED -j ACCEPT")
    net.get("R4").cmd("iptables -A FORWARD -i R4-eth0 -o R4-eth2 -j ACCEPT")
    
    info('** Testing network connectivity\n')

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

    info('** Running CLI\n')
    loss = 100
    while (loss > 0):
        loss = net.pingAll()
    t_end = datetime.now() - t_start
    print "Percentage Loss: " + str(loss)
    print "Route Convergence Time: " + str(t_end.total_seconds()) + "seconds"
    
    if static_routes:
        print ("[MESSAGE:] Enabling Static Routes...")
    else:
        print ("[MESSAGE:] Disabling Static Routes...")
    
    CLI(net)