Ejemplo n.º 1
0
def simpleTest():
    """Create and test a simple network"""
    net = Mininext(topo=None, build=False)

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

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

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

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

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

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

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

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

    CLI(net)
    net.stop()

    if __name__ == '__main__':
        # Tell mininet to print useful information
        setLogLevel('info')
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)
    """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.º 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()

	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.º 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)

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

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

    # 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/betrfs/CSE534-Homework/homework-3/riplite.py h1 &")
    net.get('h2').cmdPrint("python /home/betrfs/CSE534-Homework/homework-3/riplite.py h2 &")
    net.get('r1').cmdPrint("python /home/betrfs/CSE534-Homework/homework-3/riplite.py r1 &")
    net.get('r2').cmdPrint("python /home/betrfs/CSE534-Homework/homework-3/riplite.py r2 &")
    net.get('r3').cmdPrint("python /home/betrfs/CSE534-Homework/homework-3/riplite.py r3 &")
    net.get('r4').cmdPrint("python /home/betrfs/CSE534-Homework/homework-3/riplite.py r4 &")

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    info('** Running CLI\n')

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

    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.º 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)

    # 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.º 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)

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

    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/24")
    net.get("r1").cmd("ifconfig r1-eth2 194.0.1.1/24")
    net.get("r2").cmd("ifconfig r2-eth1 193.0.1.2/24")
    net.get("r3").cmd("ifconfig r3-eth1 194.0.1.2/24")
    net.get("r4").cmd("ifconfig r4-eth1 195.0.1.2/24")
    net.get("r4").cmd("ifconfig r4-eth2 196.0.1.2/24")

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