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)
def run(): # Creates the virtual environment, by starting the network and configuring debug information info('** Creating an instance of Lab6 network topology\n') topo = Lab6Topo() info('** Starting the network\n') global net global hosts # We specify the OVSSwitch for better IPv6 performance # We use mininext constructor with the instance of the network, the default controller and the customized openvswitch net = MiniNExT(topo, controller=Controller, switch=OVSSwitch) net.start() info('** Executing custom commands\n') # Space to add any customize command before prompting command line # We assign IPv6 addresses to hosts h1, h2, and h5 as they are not configured through Quagga # We gather only the hosts created in the topology (no switches nor controller) hosts = [ net.getNodeByName( h ) for h in topo.hosts() ] for host in hosts: # Only to hosts: We assign IPv6 address if host.name == 'h1': host.cmd('ip -6 addr add 2001:1:0:1010::10/64 dev h1-eth1') host.cmd('ip -6 route add default via 2001:1:0:1010::1') elif host.name == 'h2': host.cmd('ip -6 addr add 2001:1:0:2020::20/64 dev h2-eth1') host.cmd('ip -6 route add default via 2001:1:0:2020::2') elif host.name == 'h5': host.cmd('ip -6 addr add 2001:1:0:5050::50/64 dev h5-eth1') host.cmd('ip -6 route add default via 2001:1:0:5050::5') # Enable Xterm window for every host info('** Enabling xterm for hosts only\n') # We check if the display is available if 'DISPLAY' not in os.environ: error( "Error starting terms: Cannot connect to display\n" ) return # Remove previous (and possible non-used) socat X11 tunnels cleanUpScreens() # Mininet's function to create Xterms in hosts makeTerms( hosts, 'host' ) # Enable the mininext> prompt info('** Running CLI\n') CLI(net)
def startNetwork(full=False): "instantiates a topo, then starts the network and prints debug information" info('** Creating Quagga network topology\n') topo = I2() if (full): info("** Adding WEST and EAST\n") add_west(topo) add_east(topo) global net if (not full): net = MiniNExT(topo, controller=OVSController) else: net = MiniNExT(topo, controller=RemoteController) info('** Starting the network\n') net.start() config_i2(net) if (full): info("** Configuring WEST and EAST\n") config_west(net) config_east(net) info("** Starting HTTP servers on EAST\n") starthttp(net.getNodeByName('server1')) starthttp(net.getNodeByName('server2')) # info('** Dumping host connections\n') # dumpNodeConnections(net.hosts) # # info('** Dumping host processes\n') # for host in net.hosts: # host.cmdPrint("ps aux") return net
def run(): " Creates the virtual environment, by starting the network and configuring debug information " info('** Creating an instance of Lab4 network topology\n') topo = Lab4Topo() info('** Starting the network\n') global net global hosts # We use mininext constructor with the instance of the network, the default controller and the openvswitch net = MiniNExT(topo, controller=Controller, switch=OVSSwitch) net.start() info('** Executing custom commands\n') ############################################## # Space to add any customize command before prompting command line # We provide an example on how to assign IPv6 addresses to hosts h1 and h2 as they # are not configured through Quagga # If required, you can add any extra logic to it # We gather only the hosts created in the topology (no switches nor controller) hosts = [net.getNodeByName(h) for h in topo.hosts()] info('** Adding IPv6 address to hosts\n') for host in hosts: if host.name is 'h1': host.cmd('ip -6 addr add 2001:1:0:11::10/64 dev h1-eth1') host.cmd('ip -6 route add default via 2001:1:0:11::1') elif host.name is 'h2': host.cmd('ip -6 addr add 2001:1:0:12::20/64 dev h2-eth1') host.cmd('ip -6 route add default via 2001:1:0:12::2') info('** Enabling xterm for all hosts\n') makeTerms(hosts, 'node') ############################################## # Enable the mininext> prompt info('** Running CLI\n') CLI(net)
def config_dumbbell(topo): global net net = MiniNExT(topo, controller=OVSController, link=TCLink) info("*** Creating links between nodes in dumbbell topology\n") net.addLink(net.getNodeByName("client1"), net.getNodeByName("router1"), intfName1="meth1", intfName2="client1") net.addLink(net.getNodeByName("client2"), net.getNodeByName("router1"), intfName1="meth1", intfName2="client2") net.addLink(net.getNodeByName("router1"), net.getNodeByName("router2"), intfName1="router2", intfName2="router1", bw=1) net.addLink(net.getNodeByName("server1"), net.getNodeByName("router2"), intfName1="meth1", intfName2="server1") net.addLink(net.getNodeByName("server2"), net.getNodeByName("router2"), intfName1="meth1", intfName2="server2") info( "*** Configuring IP addresses and routing tables in dumbbell topology\n" ) client1 = net.getNodeByName("client1") client1.cmd("ifconfig meth1 %s/24 up" % ("10.0.1.1")) client1.cmd("route add default gw %s meth1" % ("10.0.1.2")) client1.cmd("iptables -A OUTPUT -p tcp --tcp-flags RST RST -j DROP") client2 = net.getNodeByName("client2") client2.cmd("ifconfig meth1 %s/24 up" % ("10.0.2.1")) client2.cmd("route add default gw %s meth1" % ("10.0.2.2")) client2.cmd("iptables -A OUTPUT -p tcp --tcp-flags RST RST -j DROP") server1 = net.getNodeByName("server1") server1.cmd("ifconfig meth1 %s/24 up" % ("12.0.1.1")) server1.cmd("route add default gw %s meth1" % ("12.0.1.2")) server1.cmd("iptables -A OUTPUT -p tcp --tcp-flags RST RST -j DROP") server2 = net.getNodeByName("server2") server2.cmd("ifconfig meth1 %s/24 up" % ("12.0.2.1")) server2.cmd("route add default gw %s meth1" % ("12.0.2.2")) server2.cmd("iptables -A OUTPUT -p tcp --tcp-flags RST RST -j DROP") router1 = net.getNodeByName("router1") router1.cmd("ifconfig client1 %s/24 up" % ("10.0.1.2")) router1.cmd("ifconfig client2 %s/24 up" % ("10.0.2.2")) router1.cmd("ifconfig router2 %s/24 up" % ("11.0.1.1")) router1.cmd("route add -net %s/8 gw %s dev router2" % ("12.0.0.0", "11.0.1.2")) router1.cmd("route add -net %s/24 gw %s dev client1" % ("10.0.1.0", "10.0.1.1")) router1.cmd("route add -net %s/24 gw %s dev client2" % ("10.0.2.0", "10.0.2.1")) router2 = net.getNodeByName("router2") router2.cmd("ifconfig server1 %s/24 up" % ("12.0.1.2")) router2.cmd("ifconfig server2 %s/24 up" % ("12.0.2.2")) router2.cmd("ifconfig router1 %s/24 up" % ("11.0.1.2")) router2.cmd("route add -net %s/8 gw %s dev router1" % ("10.0.0.0", "11.0.1.1")) router2.cmd("route add -net %s/24 gw %s dev server1" % ("12.0.1.0", "12.0.1.1")) router2.cmd("route add -net %s/24 gw %s dev server2" % ("12.0.2.0", "12.0.2.1")) return net
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)
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)
def startNetwork(topo_info, router_lo, init_quagga_configs, group_number): "instantiates a topo, then starts the network and prints debug information" info('** Creating Quagga network topology\n') topo = QuaggaInternet2Topo(topo_info, router_lo) global net #net = MiniNExT(topo, controller=OVSController) net = MiniNExT(topo, controller=RemoteController) info('** Adding Static networks\n') addStaticNet(net) info('** Starting the network\n') net.start() info('** Setting Static network\n') setStaticNet(net, group_number) info('** Adding links and loopback interfaces') links_set = Set() for router_name, ngh_list in topo_info.items(): for ngh in ngh_list: # Make sure to only create one link between two routers if ngh + router_name not in links_set: print 'Link added between ' + str(router_name) + ' and ' + str( ngh) Link(net.getNodeByName(router_name), net.getNodeByName(ngh), intfName1=ngh.lower(), intfName2=router_name.lower()) links_set.add(router_name + ngh) # Add link to the host Link(net.getNodeByName(router_name), net.getNodeByName(router_name + '-host'), intfName1='host', intfName2=router_name.lower()) info('** Configuring the IP addresses **\n') for router_name in topo_info: node = net.getNodeByName(router_name) node.cmd('ifconfig ebgp_peer 0 up') #node.cmd('ifconfig lo '+router_lo[router_name]+'/24 up') for ngh, ip in topo_info[router_name].items(): intf_name = ngh.lower() if init_quagga_configs: node.cmd('ifconfig ' + intf_name + ' 0.0.0.0/0 up') #else: # node.cmd('ifconfig '+intf_name+' '+ip+' up') node = net.getNodeByName('HOUS') node.cmd('ifconfig mgt 0.0.0.0/0 up') info('** Dumping host connections\n') dumpNodeConnections(net.hosts) info('** Testing network connectivity\n') info('** Disabled **\n') #net.ping(net.hosts) info('** Dumping host processes\n') for host in net.hosts: if host.name in ['server1', 'server2']: continue host.cmdPrint("ps aux") info('** Running CLI\n') CLI(net) stopStaticNet(net)