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

    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.º 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('** 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)