Exemplo n.º 1
0
def topology():
    net = Mininet(controller=Controller, link=TCLink, switch=OVSKernelSwitch)

    print "*** Creating nodes"
    h1 = net.addHost('red1', mac='00:00:00:00:10:01', ip='10.0.10.1/24')
    h2 = net.addHost('blue1', mac='00:00:00:00:20:01', ip='10.0.20.1/24')

    s1 = net.addSwitch('s1', protocols='OpenFlow13')
    ctrl = RemoteController('ryu', ip='192.168.10.1')

    print "*** Creating links"
    net.addLink(s1, h1, bw=10)
    net.addLink(s1, h2, bw=10)

    print "*** Starting network"
    net.build()
    ctrl.start()
    s1.start([ctrl])
    s1.cmd(
        'ovs-vsctl add-port s1 vtep2 -- set interface vtep2 type=vxlan option:remote_ip=192.168.20.2 option:key=flow ofport_request=12 &')
    s1.cmd(
        'ovs-vsctl add-port s1 vtep3 -- set interface vtep3 type=vxlan option:remote_ip=192.168.30.2 option:key=flow ofport_request=13 &')
    print "*** Running Ping"
    time.sleep(5)
    h1.cmd('ping -c 1 10.0.10.10 &')
    h1.cmd('ifconfig red1-eth0 mtu 1450')
    # h1.cmd('python -m SimpleHTTPServer 80 &')
    h2.cmd('ping -c 1 10.0.20.10 &')
    h2.cmd('ifconfig blue1-eth0 mtu 1450')

    print "*** Running CLI"
    CLI(net)
    print "*** Stopping network"
    net.stop()
def simpleTest():
    "Create and test a simple network"
    topo = SingleSwitchTopo()
    hst=[]
    controllerPort = topo.options.coPort
    net = Mininet( topo=topo,switch=OVSSwitch, link=TCLink, controller=lambda name: RemoteController( name, ip='127.0.0.1', port=controllerPort ) )
    c0 = RemoteController( 'c0', ip='127.0.0.1', port=controllerPort )
    net.start()
    c0.start()
    net.pingAll()
    hosts=topo.Host

    print "total links is: %s" %(topo.TotalLink) 
    
    for i in range(0,len(hosts)):
        hst.append(net.get('H'+str(i)))

    #start for run server

    #need to clear file macs
    os.system("echo '' > /root/serverScript/macs.txt")

    H1 = net.get('H1')
    H1.cmd( 'python -m SimpleHTTPServer 80 &' )
    H1.cmd( "ifconfig -a | awk '/^[a-zA-Z]/ { iface=$1; mac=$NF; next } /inet addr:/ { if(iface !~ /lo/) { print mac} }' >> /root/serverScript/macs.txt" )


    H5 = net.get('H5')
    H5.cmd( 'python -m SimpleHTTPServer 80 &' )
    H5.cmd( "ifconfig -a | awk '/^[a-zA-Z]/ { iface=$1; mac=$NF; next } /inet addr:/ { if(iface !~ /lo/) { print mac} }' >> /root/serverScript/macs.txt" )

    H10 = net.get('H10')
    H10.cmd( 'python -m SimpleHTTPServer 80 &' )
    H10.cmd( "ifconfig -a | awk '/^[a-zA-Z]/ { iface=$1; mac=$NF; next } /inet addr:/ { if(iface !~ /lo/) { print mac} }' >> /root/serverScript/macs.txt" )


    H14 = net.get('H14')
    H14.cmd( 'python -m SimpleHTTPServer 80 &' )
    H14.cmd( "ifconfig -a | awk '/^[a-zA-Z]/ { iface=$1; mac=$NF; next } /inet addr:/ { if(iface !~ /lo/) { print mac} }' >> /root/serverScript/macs.txt" )

    #set mac in scheduledScript.sh
    os.system("/root/serverScript/setupFatTree.sh")   
    os.system("/root/serverScript/createVIP.sh")
    #end for run server

    CLI(net)
    net.stop()
Exemplo n.º 3
0
def topology():
    "Create a network."
    net = Mininet( link=TCLink, switch=OVSSwitch )
    c0 = Controller( 'c0', port=6634 )
    c1 = RemoteController( 'c1', ip='127.0.0.1', port=6633 )
    net.addController(c0)
    net.addController(c1) 

    
    print "*** Creating nodes"
    s0 = net.addSwitch('s0')
    ap1 = net.addBaseStation( 'ap1', ssid="ssid_ap1", mode="g", channel="5" )
    ap2 = net.addBaseStation( 'ap2', ssid="ssid_ap2", mode="g", channel="1" )
   
    
    sta1 = net.addStation( 'sta1', ip='192.168.0.1/24' )
    sta2 = net.addStation( 'sta2', ip='192.168.0.2/24' )
    sta3 = net.addStation( 'sta3', ip='192.168.0.3/24' )
    sta4 = net.addStation( 'sta4', ip='192.168.0.4/24' )
    h1 = net.addHost('h0', ip='192.168.0.5')
    h2 = net.addHost('h1', ip='192.168.0.6')
       
    print "*** Adding Link"
    net.addLink(sta1, ap1, bw=10, loss=0)
    net.addLink(sta2, ap1, bw=10, loss=0)
    net.addLink(sta3, ap2, bw=10, loss=0)
    net.addLink(sta4, ap2, bw=10, loss=0)
    net.addLink(ap1, s0)
    net.addLink(ap2, s0)
    net.addLink(h1, s0)
    net.addLink(h2, s0)

    net.build()
    c0.start()
    c1.start()
                                 
                                 
    ap1.start( [c0] )
    ap2.start( [c0] )
    #nat0.start( [c0] )
    s0.start([c1])

    print "*** Running CLI"
    CLI( net )

    print "*** Stopping network"
    net.stop()
Exemplo n.º 4
0
def simpleTest():
    "Create and test a simple network"
    topo = SingleSwitchTopo()
    hst=[]
    net = Mininet( topo=topo,switch=OVSSwitch, controller=lambda name: RemoteController( name, ip='127.0.0.1' ) )
    c0 = RemoteController( 'c0', ip='127.0.0.1' )
    net.start()
    c0.start()
    hosts=topo.Host
    
    print "total links is: %s" %(topo.TotalLink) 
    
    for i in range(0,len(hosts)):
        hst.append(net.get('H'+str(i)))

    CLI(net)
    net.stop()
Exemplo n.º 5
0
def topology():
    net = Mininet(controller=Controller, link=TCLink, switch=OVSKernelSwitch)

    print "*** Creating nodes"
    h1 = net.addHost('red3', mac='00:00:00:00:10:03', ip='10.0.10.3/24')
    h2 = net.addHost('blue2', mac='00:00:00:00:20:02', ip='10.0.20.2/24')
    h3 = net.addHost('red1', mac='00:00:00:00:10:01', ip='10.0.10.1/24')
    h4 = net.addHost('blue1', mac='00:00:00:00:20:01', ip='10.0.20.1/24')
    s2 = net.addSwitch('s2', protocols='OpenFlow13')
    ctrl = RemoteController('ryu', ip='192.168.20.1')

    print "*** Creating links"
    net.addLink(s2, h1, bw=10)
    net.addLink(s2, h2, bw=10)
    net.addLink(s2, h3, bw=10)
    net.addLink(s2, h4, bw=10)

    print "*** Starting network"
    net.build()
    ctrl.start()
    s2.start([ctrl])
    print "**Create VXLAN Tunnel: vtep1 vtep3"
    s2.cmd(
        'ovs-vsctl add-port s2 vtep1 -- set interface vtep1 type=vxlan option:remote_ip=192.168.10.2 option:key=flow ofport_request=11 &')
    s2.cmd(
        'ovs-vsctl add-port s2 vtep3 -- set interface vtep3 type=vxlan option:remote_ip=192.168.30.2 option:key=flow ofport_request=13 &')
    print "***Turn down shadow ports"
    s2.cmd('ifconfig s2-eth3 down &')
    s2.cmd('ifconfig s2-eth4 down &')
    print "*** Running PingAll"
    time.sleep(4)
    h1.cmd('ping -c 1 10.0.10.10 &')
    h1.cmd('ifconfig red3-eth0 mtu 1450')
    h2.cmd('ping -c 1 10.0.20.10 &')
    h2.cmd('ifconfig blue2-eth0 mtu 1450')
    h3.cmd('ifconfig red1-eth0 mtu 1450')
    # h3.cmd('python -m SimpleHTTPServer 80 &')
    h4.cmd('ifconfig blue1-eth0 mtu 1450')
    print "*** Running CLI"
    CLI(net)
    print "*** Stopping network"
    net.stop()
Exemplo n.º 6
0
def genericTest(topo):
    c0 = RemoteController('c0', ip='127.0.0.1', port=6633)
    net = Mininet(topo=topo, switch=OVSSwitch, controller=c0)
    net.start()
    setHosts(net)
    dumpNodeConnections(net.hosts)
    x = input("Enter port1: ")
    y = input("Enter port2: ")
    rest(x, y)
    CLI(net)

    net.stop()
Exemplo n.º 7
0
def dtvLCSTest():
    "Create and test the simple LCS topology"

    topos = {}
    ## net = Mininet(topo)
    net = Mininet(controller=lambda a: RemoteController(a, ip='10.0.2.2'),
                  topo=None)
    net.addController('c0')

    # Receiver
    rcv = net.addHost('rcv', ip='10.1.3.3')

    # The core
    core = net.addSwitch('core', dpid=int2dpid(5))

    # Connect the receiver to the coreh
    net.addLink(rcv, core)

    cp = net.addSwitch('cp', dpid=int2dpid(1))
    cb = net.addSwitch('cb', dpid=int2dpid(2))
    net.addLink(cp, core)
    net.addLink(cb, core)
    net.addLink(cp, cb)

    # Primary and backup routers
    lp = net.addSwitch('lp', dpid=int2dpid(3))
    lb = net.addSwitch('lb', dpid=int2dpid(4))

    net.addLink(lp, cp)
    net.addLink(lb, cb)

    # Now create all the hosts
    n = 4
    for e in range(n):
        ipaddr = '10.1.1.' + str(e + 1)
        print "IP: " + ipaddr

        enc = net.addHost('e' + str(e + 1), ip=ipaddr)

        # Add the primary and backup links
        net.addLink(enc, lp)
        net.addLink(enc, lb)

    net.configHosts()
    net.start()

    print "Dumping host connections"
    dumpNodeConnections(net.hosts)

    print "Testing network connectivity"
    CLI(net)

    net.stop()
Exemplo n.º 8
0
def run():
	c = RemoteController(name='c0',ip='127.0.0.1',protocol = 'tcp',port=6633)
        net = Mininet(topo=Topology(),controller=None,link=TCLink)
        net.addController(c)
        net.start()

        CLI(net)
	try:
        	net.stop()
	except OSError as exc:
		if exc.errno == 36:
			print ""
Exemplo n.º 9
0
def run():
    #c=net.addController(name='c',
    #                 controller=RemoteController,
    #                 ip='172.17.0.2',
    #                 protocol='tcp')
    c = RemoteController('c', '10.5.0.2')
    net = Mininet(topo=SimplePktSwitch(), host=CPULimitedHost, controller=None)
    net.addController(c)
    net.start()

    CLI(net)
    net.stop()
Exemplo n.º 10
0
def IotTest():
        controllerInstance = RemoteController('Iot-Controller',ip='10.108.101.212',port=6633)
	#controllerInstance = RemoteController('Iot-Controller',ip='127.0.0.1',port=6633)
	topo = IotTopo(n=4)
	net = Mininet(topo,build=False,controller = RemoteController, host = CPULimitedHost, link = TCLink,ipBase='192.168.3.0/24')
	net.addController(controllerInstance)
	net.build()
	net.start()
	CLI(net)
	dumpNodeConnections(net.hosts)       
	#net.ping(net.hosts)    
	net.stop()       
Exemplo n.º 11
0
def main():
    "Create network and run simple performance test"
    topo = MyTopo(n=4)
    net = Mininet(topo=topo, build=False, link=TCLink)
    c0 = RemoteController('c0',
                          controller=RemoteController,
                          ip='0.0.0.0',
                          port=6633)
    net.addController(c0)
    net.start()
    CLI(net)
    net.stop()
Exemplo n.º 12
0
def task2():

    c0 = RemoteController('c0', ip='127.0.0.1', port=6633)
    net = Mininet(topo=Task2Topo(), controller=c0)

    net.start()

    net_test(net)

    CLI(net)

    net.stop()
Exemplo n.º 13
0
def main(args):
    if not args.onos_ip:
        controller = ONOSCluster('c0', 3)
        onosIp = controller.nodes()[0].IP()
    else:
        controller = RemoteController('c0', ip=args.onos_ip)
        onosIp = args.onos_ip

    topo = ClosTopo(args)

    net = Mininet(topo=topo, build=False, controller=[controller])

    net.build()
    net.start()

    print "Network started"

    # Always generate background pings.
    sleep(3)
    for (h1, h2) in combinations(net.hosts, 2):
        h1.startPingBg(h2)
        h2.startPingBg(h1)

    print "Background ping started"

    for h in net.hosts:
        h.startIperfServer()

    print "Iperf servers started"

    if args.bg_traffic:
        sleep(4)
        print "Starting iperf clients..."
        net.hosts[0].startIperfClient(net.hosts[-1], flowBw="400k",
                                      numFlows=50, duration=10)

    generateNetcfg(onosIp, net, args)

    if args.netcfg_sleep > 0:
        print "Waiting %d seconds before pushing config to ONOS..." \
              % args.netcfg_sleep
        sleep(args.netcfg_sleep)

    print "Pushing config to ONOS..."
    call(("%s/onos-netcfg" % RUN_PACK_PATH, onosIp, TEMP_NETCFG_FILE))

    if not args.onos_ip:
        ONOSCLI(net)
    else:
        CLI(net)

    net.stop()
    call(("rm", "-f", TEMP_NETCFG_FILE))
Exemplo n.º 14
0
def run():
    c = RemoteController('c', '0.0.0.0', 6633)
    # Change the args of GenericTree() to your desired values. You could even get them from command line.
    net = Mininet(topo=GenericTree(depth=2, fanout=3),
                  host=CPULimitedHost,
                  controller=None)
    net.addController(c)
    net.start()

    # installStaticFlows( net )
    CLI(net)
    net.stop()
Exemplo n.º 15
0
def main(argz):
    topo = TutorialTopo()
    controller = RemoteController('c0', ip=argz.onos_ip)
    #controller = RemoteController('c0', ip='127.0.0.1')

    net = Mininet(topo=topo, controller=None)
    #net = Mininet(topo=topo, controller=lambda name: controller, listenPort=6633)
    net.addController(controller)

    net.start()
    CLI(net)
    net.stop()
Exemplo n.º 16
0
def run():
    c = RemoteController('c', '134.117.57.114')
    #switch = partial( OVSSwitch, protocols='OpenFlow13' )
    #c = RemoteController('c', '127.0.0.1')
    net = Mininet(topo=MeshTopo(), host=CPULimitedHost, controller=None)
    net.addController(c)
    net.start()
    #net.pingAll()
    link_failure(net)
    CLI(net)
    link_failure(net)
    net.stop()
Exemplo n.º 17
0
def setup(ctls):
    net = Mininet(topo=OpticalTopo(), controller=None)
    i = 1
    for ctl in ctls:
        net.addController(RemoteController('c%d' % i, ip=ctl))
        i += 1

    net.start()
    LINCSwitch.bootOE(net)
    CLI(net)
    net.stop()
    LINCSwitch.shutdownOE()
Exemplo n.º 18
0
    def _connect_controller(self, net):
        controller = RemoteController(self.topo.switch_id + "_c")
        net.addController(controller)
        for i, host in enumerate(self.topo.host_list):
            # Configure host
            net.addLink(controller, host)
            # Configure controller
            ctrl_iface = "%s_c-eth%d" % (self.topo.switch_id, i)

            for index, switch in self.topo.ports[host].items():
                switch_iface = switch[0] + "-eth" + str(switch[1])
                self.host_ctrl_map[switch_iface] = ctrl_iface
Exemplo n.º 19
0
def simpleTest():
	# argument to put in either remote or local controller
	"Create and test a simple network"
	#c0 = RemoteController( 'c0', ip='192.168.90.146' )
	c0 = RemoteController( 'c0', ip='192.168.56.1' )
# the cmap here needs to dynamically take the switch name from the switchLists[] so that it is not static
#cmap = { 'a11': c0, 'a12': c0, 'a21': c0, 'a22': c0, 'a31': c0, 'a32': c0, 'a41': c0, 'a42': c0, 'c11': c0, 'c21': c0, 'c31': c0, 'c41': c0, 't11': c0, 't12': c0, 't21': c0, 't22': c0, 't31': c0, 't32': c0, 't41': c0, 't42': c0}


	class MultiSwitch( OVSSwitch ):
		"Custom Switch() subclass that connects to different controllers"
	def start( self, controllers ):
		return OVSSwitch.start( self, [ cmap[ self.name ] ] )
	#section for handling the differnt argumetns.... simpleTest(arg1, arg2, ...) will take in arguments from user
	topo = dcFatTreeTopo(k=2)
	net = Mininet( topo=topo, switch=MultiSwitch, build=False, link=TCLink )
	cString = "{"
	for i in irange(0, len(allList)-1):
		if i != len(allList)-1:
			tempCString = "'" + allList[i] + "'" + " : c0, "
		else:
			tempCString = "'" + allList[i] + "'" + " : c0 "
		cString += tempCString
	cmapString = cString + "}"
#print "wowzer" + cmapString
	cmap = cmapString
	net.addController(c0)
	net.build()
	net.start()
	print "Dumping host connections"
	dumpNodeConnections(net.hosts)
	print "Testing network connectivity"
#def perfTest():
		# if user test argument is active then pick the correct test
	net.pingAll()
	net.pingAll()
	print "Testing bandwidth between h11 and h12..............."
	#h11, h12 = net.get('h11', 'h12')
	#net.iperf((h11, h12)
	#print "Testing bandwidth between h11 and h14..............."
	h11, h14 = net.get('h11', 'h14')
	net.iperf((h11, h14))
	#print "Testing bandwidth between h11 and h16..............."
	h11, h22 = net.get('h11', 'h22')
	net.iperf((h11, h22))
	#print "Testing bandwidth between h11 and h18..............."
	h11, h24 = net.get('h11', 'h24')
	net.iperf((h11, h24))
	# also argument for generating traffic
	# arugment for stat analysis
	CLI( net )
	net.stop()
Exemplo n.º 20
0
def main():
    parser = argparse.ArgumentParser()
    parser.add_argument('-N', '--N', type=int)
    parser.add_argument('-K', '--K', type=int)
    args = parser.parse_args()
    N=3		# the defaults
    K=1
    if args.N is not None:
        N = args.N
    if args.K is not None:
        K = args.K
    trunktopo = TrunkNKTopo(N=N,K=K)
    #setLogLevel('info')
    net = Mininet(topo = trunktopo, switch = OVSKernelSwitch, controller = RemoteController,
		autoSetMacs = True,
		link = TCLink
                )  
    c = RemoteController( 'c', ip='127.0.0.1', port=6633 )
    net.addController(c)
    net.start()

    r = net['r']
    s = net['s']
    
    # left hosts: hi has IPv4 address 10.0.i.1/24
    for i in range(1,N+1):
       hi = net['h' + str(i)]
       hi.cmd('ifconfig {} {}'.format(iface('h', i, 0), ip(i,1,24)))
       hi.cmd('ip route add to default via {} dev {}'.format(ip(i,2), iface('h',i,0)))

    for i in range(1,N+1):
       r.cmd('ifconfig r-eth{} {}'.format(i, ip(i,2,24)))

    r_eth0_addr = '00:00:00:00:00:04'

    r.cmd('sysctl net.ipv4.ip_forward=1')
    r.cmd('ifconfig r-eth0 10.0.0.2/24')
    r.cmd('arp -s 10.0.0.1 {}'.format(etherfake))
    # r.cmd('ip route add to 10.0.0.0/24 via 10.0.0.1 dev r-eth0')   # shouldn't be necessary
    # s.cmd('ifconfig s-eth1 10.0.0.1/24')
    # s.cmd('ip route add to 10.0.0.0/16 via 10.0.0.2 dev s-eth1')

    # now configure the righthand hosts (the servers)
    for i in range(1,N+1):
        ti = net['t' + str(i)]
        ti.cmd('ifconfig {} 10.0.0.1/24'.format(iface('t',i,0)))
        ti.cmd('ip route add to default via 10.0.0.2 dev {}'.format(iface('t',i,0)))
        ti.cmd('arp -s 10.0.0.2 {}'.format(r_eth0_addr))
        ti.cmd('/usr/sbin/sshd')

    CLI( net)
    net.stop()
Exemplo n.º 21
0
def MakeTestBed_and_Test(kval, timeout, ping_interval, controller_ip):
  print "a. Firing up Mininet"
  net = Mininet(topo=Alfares_FatTree(kval), controller=lambda name: RemoteController( 'c0', controller_ip ), host=CPULimitedHost, link=TCLink)
  net.start() 

  time.sleep(5)
  hosts = net.hosts

  # One ping from each host. Make the controller ready.
  print "b. Get all the paths ready"
  for h1 in hosts:
    for h2 in hosts:
      if h1!=h2:
        h1.cmdPrint('ping', '-c 1', '-W 1', str(h2.IP()))
        time.sleep(1)
        break

#  h1 = hosts[0]
#  for h2 in hosts[1:]:
#    h1.cmdPrint('ping', '-c3', str(h2.IP()))
#    time.sleep(15)

  print 'READY! Waiting 11 seconds before actual measurement starts.'
  time.sleep(11)


  print 'Testing!!! '
  for h1 in hosts:
    for h2 in hosts:
      if h1!=h2:
        h1.cmdPrint('ping', '-c 3', str(h2.IP()))


#  # Start continuous ping
#  print "c. Starting continuous allpair ping"
#  for h1 in hosts:
#    for h2 in hosts:
#      if h1!=h2:
#        h1.cmdPrint('ping', str(h2.IP()), '&')
#        startpings(h1,h2, timeout, ping_interval)
   
  # Wait
  time.sleep(timeout)

  # Stop pings
  print "d. Stopping pings"
  for host in hosts:
    host.cmd( 'pkill ping' )

  # Stop mininit
  print "e. Stopping Mininet"
  net.stop()
Exemplo n.º 22
0
def start(ip="127.0.0.1", port=6633):

    ctrlr = lambda n: RemoteController(
        n, defaultIP=ip, port=port, inNamespace=False)
    net = Mininet(switch=UserSwitch,
                  controller=ctrlr,
                  intf=VLANIntf,
                  autoStaticArp=True)
    c1 = net.addController('c1')

    ####### End of static Mininet prologue ######

    eth1 = '00:00:00:00:00:01'
    eth2 = '00:00:00:00:00:02'
    ip1 = '10.0.0.1'
    ip2 = '10.0.0.2'

    #         -- s2 --
    #        /        \
    # h1 - s1          s3 - h2
    #        \        /
    #         -- s4 --
    # Ports to host are numbered 1, then clockwise

    h1 = net.addHost('h1', mac=eth1, ip=ip1)
    h2 = net.addHost('h2', mac=eth2, ip=ip2)
    s1 = net.addSwitch('s1')
    s2 = net.addSwitch('s2')
    s3 = net.addSwitch('s3')
    s4 = net.addSwitch('s4')
    net.addLink(h1, s1, 0, 1)
    net.addLink(h2, s3, 0, 1)
    net.addLink(s1, s2, 2, 1)
    net.addLink(s2, s3, 2, 3)
    net.addLink(s3, s4, 2, 2)
    net.addLink(s4, s1, 1, 3)

    ###### Start of static Mininet epilogue ######
    # Set up logging etc.
    lg.setLogLevel('info')
    lg.setLogLevel('output')

    # Start the network and prime other ARP caches
    net.start()
    h1.setDefaultRoute('h1-eth0')
    h2.setDefaultRoute('h2-eth0')

    # Enter CLI mode
    output("Network ready\n")
    output("Press Ctrl-d or type exit to quit\n")
    CLI(net)
    net.stop()
Exemplo n.º 23
0
def main(args):
    topo = ClosTopo()

    if not args.onos_ip:
        controller = ONOSCluster('c0', 3)
        onosIp = controller.nodes()[0].IP()
    else:
        controller = RemoteController('c0', ip=args.onos_ip, port=args.onos_port)
        onosIp = args.onos_ip

    net = Mininet(topo=topo, build=False, controller=[controller])
    print net.switches


    net.build()
    switch = net.switches[0]
    Intf( 'eth0', node=switch )
    print net.switches

    net.start()

    print "Network started"

    '''
    # Generate background traffic.
    sleep(3)
    for (h1, h2) in combinations(net.hosts, 2):
        h1.startPingBg(h2)
        h2.startPingBg(h1)
    
    print "Background ping started"
    '''

    for h in net.hosts:
        h.startIperfServer()

    print "Iperf servers started"

    # sleep(4)
    # print "Starting traffic from h1 to h3..."
    # net.hosts[0].startIperfClient(net.hosts[-1], flowBw="200k", numFlows=100, duration=10)

    print "Setting netcfg..."
    call(("onos-netcfg", onosIp,
          "%s/tools/test/topos/simple-cfg.json" % ONOS_ROOT))

    if not args.onos_ip:
        ONOSCLI(net)
    else:
        CLI(net)

    net.stop()
Exemplo n.º 24
0
def runner():
    "Create and run a custom topo with adjustable link parameters"
    topo = CompleteGraphTopo()
    c = RemoteController('c', '127.0.0.1', 6633)
    net = Mininet(topo=topo,
                  controller=None,
                  host=CPULimitedHost,
                  link=TCLink,
                  waitConnected=True,
                  autoSetMacs=True)

    net.addController(c)
    net.start()
    topo.enable_BFD(net)
    CLI(net)

    s1 = net.getNodeByName("s1")
    s2 = net.getNodeByName('s2')
    s3 = net.getNodeByName('s3')
    s6 = net.getNodeByName("s6")
    s7 = net.getNodeByName("s7")
    s8 = net.getNodeByName("s8")
    s9 = net.getNodeByName("s9")
    # h1 ping h9 & h9 ping h1
    net.delLinkBetween(s2, s9)
    #h1 ping h7
    net.delLinkBetween(s1, s3)
    #h3 ping h8
    net.delLinkBetween(s3, s7)
    #h8 ping h6
    net.delLinkBetween(s6, s8)
    # net.stop()

    test_pair = [(1, 9), (1, 7), (3, 8), (8, 6), (9, 1)]
    result = {'hop': [], 'delay': [], 'throughput': []}
    for pair in test_pair:
        host1, host2 = pair
        src = net.getNodeByName('h' + str(host1 + 1))
        dst = net.getNodeByName('h' + str(host2 + 1))
        sent, received, min_, avg = ping(net, [src, dst], 1024, 2)
        print 'Delay ', avg, ' for ', pair
        result['delay'].append(float(avg))
        hop = get_path_length(net, src, dst)
        print 'Hop ', hop, ' for ', pair
        result['hop'].append(float(hop))
        time, datasize_tx, bitrate = doIperf(net, src, dst)
        print 'Throughput ', bitrate, ' for ', pair
        result['throughput'].append(float(bitrate))
    print 'Average Number of Hop:', getavg(result['hop'])
    print 'Average Delay: ', getavg(result['delay'])
    print 'Throughput:', getavg(result['throughput'])
    net.stop()
Exemplo n.º 25
0
def RemoteControllerNet():
    "Cria uma rede configurada manualmente com controlador remoto."

    net = Mininet(controller=RemoteController, switch=OVSSwitch, build=False)

    print "*** Criando switches"
    SW1 = net.addSwitch('SW1')
    SW2 = net.addSwitch('SW2')

    print "*** Criando hosts e enlaces para os switches"
    hosts = {}
    for oct3 in range(10, 31, 10):
        for host in range(1, 2 + 1):
            name = "h%d_%d" % (oct3, host)
            hosts[name] = net.addHost(name,
                                      ip='192.168.%d.%d/24' % (oct3, host),
                                      mac='02:00:00:00:%d:%d' % (oct3, host))
            if oct3 == 10:
                net.addLink(hosts[name], SW2)
            elif oct3 == 20:
                net.addLink(hosts[name], SW1)
            elif oct3 == 30 and host == 1:
                net.addLink(hosts[name], SW2)
            elif oct3 == 30 and host == 2:
                net.addLink(hosts[name], SW1)

    print "*** Criando enlace entre os switches"

    net.addLink(SW1, SW2)

    print "*** Adicionando controlador remoto POX"
    c0 = RemoteController('POX', ip='127.0.0.1', port=6633)

    print "*** Construindo e iniciando os elementos da rede"
    net.build()
    SW1.start([c0])
    SW2.start([c0])

    print "*** Configurando default GWs em cada host"
    for oct3 in range(10, 31, 10):
        for host in range(1, 2 + 1):
            name = "h%d_%d" % (oct3, host)
            hosts[name].cmd('route add default gw 192.168.%d.254' % oct3)

    print "*** Imprimindo tabela de conexoes:"
    dumpNodeConnections(net.switches)

    print "*** Iniciando CLI"
    CLI(net)

    print "*** Parando a rede..."
    net.stop()
Exemplo n.º 26
0
def start():
    "Create network and run simple performance test"

    net = Mininet(controller=None,
                  topo=DcellTopo(),
                  link=TCLink,
                  switch=OVSSwitch)
    c3 = RemoteController('c3', ip='192.168.56.101', port=6633)
    net.addController(c3)

    net.start()
    CLI(net)
    net.stop()
Exemplo n.º 27
0
def IotTest():
    controllerInstance = RemoteController('Iot-Controller',
                                          ip='10.108.102.225',
                                          port=6633)
    topo = IotTopo()
    net = Mininet(topo, build=False, ipBase='192.168.3.0/24')
    net.addController(controllerInstance)
    net.build()
    net.start()
    CLI(net)
    dumpNodeConnections(net.hosts)
    #net.ping(net.hosts)
    net.stop()
Exemplo n.º 28
0
def runCustomMiniTopo():
    topo = MinimalTopo()

    net = Mininet(
        topo=topo,
        controller=lambda name: RemoteController(name, ip='127.0.0.1'),
        switch=OVSSwitch,
        autoSetMacs=True)
    net.start()

    CLI(net)

    net.stop()
Exemplo n.º 29
0
def setup(num_switches, hosts_per_switch, ctrlr_name, ctrlr_ip):
    """Setup the topology and configuration.
    """
    topo = LinearTopo(num_switches, hosts_per_switch)
    net = Mininet(topo,
                  controller=RemoteController,
                  autoSetMacs=True,
                  autoStaticArp=True,
                  build=False)
    remote = RemoteController(ctrlr_name, ip=ctrlr_ip)
    net.addController(remote)
    net.build()
    return net
Exemplo n.º 30
0
def setupNetwork():
    "Create network and run simple performance test"
    topo = GeneratedTopo()
    net = Mininet(topo=topo, controller=lambda a: RemoteController( a, ip='127.0.0.1', port=6633 ), host=CPULimitedHost, link=TCLink)
    # net.build()
    # CLI(net)
    # net.stop()
    # print "Testing network connectivity"
    # net.pingAll()
    # print "Testing bandwidth between h1 and h2"
    # h1, h2 = net.getNodeByName('h1', 'h2')
    # net.iperf((h1, h2))
    return net
Exemplo n.º 31
0
def startMininet(controller_ip):
    "Create and test a simple network"
    topo = MyTopology()
    net = Mininet(topo=topo,
                  controller=lambda c1: RemoteController(c1, ip=controller_ip),
                  link=TCLink)
    net.start()
    net.get("host1").setARP(ip='192.168.0.3', mac='60:57:18:B1:A4:22')
    net.get("edge").cmd(
        "ovs-vsctl -- --id=@ft create Flow_Table flow_limit=1500 overflow_policy=refuse -- set Bridge admin flow_tables=0=@ft"
    )
    CLI(net)
    net.stop()
Exemplo n.º 32
0
    def build_network(self):
        """ Builds a mininet network based on the network matrix that's been 
            given """

        topo = self.MyTopo(hosts_matrix=self.hosts_matrix,
                           switch_matrix=self.link_matrix,
                           switch_dps=self.switch_dps,
                           p4_switches=self.p4_switches,
                           logger=self.logger)
        self.net = Mininet(topo=topo,
                           controller=RemoteController(name="faucet",
                                                       ip="127.0.0.1",
                                                       port=6653))
Exemplo n.º 33
0
def StanfordTopoTest(controller_ip, controller_port, dummy_controller_ip,
                     dummy_controller_port):
    topo = StanfordTopo()

    main_controller = lambda a: RemoteController(
        a, ip=controller_ip, port=controller_port)
    net = StanfordMininet(topo=topo,
                          switch=OVSKernelSwitch,
                          controller=main_controller)

    net.start()

    # These switches should be set to a local controller..
    dummy_switches = topo.dummy_switches
    dummyClass = lambda a: RemoteController(
        a, ip=dummy_controller_ip, port=dummy_controller_port)
    dummy_controller = net.addController(name='dummy_controller',
                                         controller=dummyClass)
    dummy_controller.start()

    for dpid in dummy_switches:
        switch = net.nameToNode["s%s" % dpid]
        switch.pause()
        switch.start([dummy_controller])

    # Turn on STP
    for switchName in topo.switches():
        switch = net.nameToNode[switchName]
        cmd = "ovs-vsctl set Bridge %s stp_enable=true" % switch.name
        switch.cmd(cmd)

    switch.cmd('ovs-vsctl set Bridge s1 other_config:stp-priority=0x10')

    # Install dummy rules
    for rule in topo.dummy_rules:
        switch.cmd(rule)

    CLI(net)
    net.stop()
Exemplo n.º 34
0
def setup(ctrlr_name, ctrlr_ip):
    """Setup the topology and configuration.
    """
    topo = CustomTopo()
    net = Mininet(topo,
                  controller=RemoteController,
                  autoSetMacs=True,
                  autoStaticArp=True,
                  build=False)
    remote = RemoteController(ctrlr_name, ip=ctrlr_ip)
    net.addController(remote)
    net.build()
    return net
Exemplo n.º 35
0
    def __init__(self, controller_ip):
        # Create an instance of our topology
        mininet.clean.cleanup()
        topo = RingTopo()

        # Create a network based on the topology using OVS and controlled by
        # a remote controller.
        patch('mininet.util.fixLimits', side_effect=None)
        self.net = Mininet(topo=topo,
                           controller=lambda name: RemoteController(
                               name, ip=controller_ip, port=6653),
                           switch=OVSSwitch,
                           autoSetMacs=True)
def multiControllerNet():
    "Create a network from semi-scratch with multiple controllers."

    net = Mininet( controller=Controller, switch=OVSSwitch )

    print "*** Creating (reference) controllers"
    
    c1 = RemoteController( 'c1', port=6633 )
    c2 = RemoteController( 'c2', port=6644 )


    #c1 = net.addController('c1')
    #c2 = net.addController('c2')
    
    print "*** Creating switches"
    s1 = net.addSwitch( 's1' )
    s2 = net.addSwitch( 's2' )
    s3 = net.addSwitch( 's3' ) 
    print "*** Creating hosts"
    hosts1 = [ net.addHost( 'h%d' % n ) for n in 1, 2 ]
    hosts2 = [ net.addHost( 'h%d' % n ) for n in 3, 4 ]
    hosts3 = [ net.addHost( 'h%d' % n ) for n in 5, 6 ]
    print "*** Creating links"
    for h in hosts1:
        net.addLink( s1, h )
    for h in hosts2:
        net.addLink( s2, h )
    for h in hosts3:
        net.addLink( s3, h )
    net.addLink( s1, s2 )
    net.addLink( s2, s3 )

    print "*** Starting network"
    net.build()
    c1.start()
    c2.start()
    s1.start( [ c1 ] )
    s2.start( [ c2 ] )
    s3.start( [ c2 ] )  

    print "*** Testing network"
    # net.pingAll()

    print "*** Running CLI"
    CLI( net )

    print "*** Stopping network"
Exemplo n.º 37
0
def BeginSimulation() :

    # We begin mininet initially
    net = Mininet( controller=Controller, switch=OVSSwitch)

    print "*** Creating (reference) controllers On 192.168.2.50/51 Change if necessary"
    c0 = RemoteController( 'c0', ip='192.168.56.21', port=6634 )  #This is parent controller (change tomcat 8081)
    c1 = RemoteController( 'c1', ip='192.168.56.21', port=6633 )
    c2 = RemoteController( 'c2', ip='192.168.56.1', port=6633 )

    print "*** Creating switches"
    s1 = net.addSwitch( 's1' )
    s2 = net.addSwitch( 's2' )
    s3 = net.addSwitch( 's3' )
    s4 = net.addSwitch( 's4' )
    gs1 = net.addSwitch( 'gs1' )
    gs2 = net.addSwitch( 'gs2' )

    print "*** Creating hosts"
    print "*** Creating hosts"
    hosts1 = [ addHost1( net, n) for n in 1, 2, 3, 4 ]
    hosts2 = [ addHost2( net, n) for n in 5, 6, 7, 8 ]
    hosts3 = [ addHost3( net, n) for n in 9, 10, 11, 12 ]
    hosts4 = [ addHost4( net, n) for n in 13, 14, 15, 16 ]

    # These are the hsots that move to other side. We will bring the links up when we want to show the host movement
    s3_temp_host1 = net.addHost( 'h17', ip = '10.0.0.66', mac = '00:00:00:00:00:1') 
    s3_temp_host2 = net.addHost( 'h18', ip = '10.0.0.67', mac = '00:00:00:00:00:2') 

    print "*** Creating links"
    for h in hosts1:
        net.addLink( s1, h )
    for h in hosts2:
        net.addLink( s2, h )
    for h in hosts3:
        net.addLink( s3, h )
    for h in hosts4:
        net.addLink( s4, h )

    net.addLink( s1, s2 )
    net.addLink( s3, s4 )

    net.addLink( s2, s3 )

    net.addLink( gs1, gs2 )

    # Additional links to simlulate host movement (handover). Note that this link will be down initially
    net.addLink( s3, s3_temp_host1)
    net.addLink( s3, s3_temp_host2)

    print "*** Starting network"
    net.build()
    c0.start()
    c1.start()
    c2.start()
    s1.start( [ c1 ] )
    s2.start( [ c1 ] )
    s3.start( [ c2 ] )
    s4.start( [ c2 ] )
    gs1.start( [ c0 ] )
    gs2.start( [ c0 ] )

    # Remember that these two links will be down initially and needs to be manually pulled up whenever we need handover
    net.configLinkStatus('h17', 's3', 'down')
    net.configLinkStatus('h18', 's3', 'down')
    CLI(net)
Exemplo n.º 38
0
 def __init__ (self,name):
     RemoteController.__init__(self,'FLController','127.0.0.1',6633)
Exemplo n.º 39
0
def topology():
    "Create a network."
    net = Mininet( link=TCLink, switch=OVSSwitch )
    #create local controller for APs
    c0 = Controller( 'c0', port=6634 )
    #create controller for s0 (Ryuretic)
    c1 = RemoteController( 'c1', ip='127.0.0.1', port=6633 )
    net.addController(c0)
    net.addController(c1)
    
    print "*** Creating nodes"
    s0 = net.addSwitch('s0')
    ap1 = net.addBaseStation( 'ap1', ssid="ssid_ap1", mode="g", channel="5" )
    ap2 = net.addBaseStation( 'ap2', ssid="ssid_ap2", mode="g", channel="1" )
    ###########
    ap3 = net.addBaseStation( 'ap3', ssid="ssid_ap3", mode="g", channel="10" )   
    sta1 = net.addStation( 'sta1', ip='192.168.0.1/24',
                           defaultRoute='via 192.168.0.224' )
    sta2 = net.addStation( 'sta2', ip='192.168.0.2/24',
                           defaultRoute='via 192.168.0.224' )
    sta3 = net.addStation( 'sta3', ip='192.168.0.3/24',
                           defaultRoute='via 192.168.0.224' )
    sta4 = net.addStation( 'sta4', ip='192.168.0.4/24',
                           defaultRoute='via 192.168.0.224' )
    #############
    sta5 = net.addStation( 'sta5', ip='10.0.0.2/24', defaultRoute='via 10.0.0.22' )
    sta6 = net.addStation( 'sta6', ip='10.0.0.3/24', defaultRoute='via 10.0.0.22')
    #############
    h1 = net.addHost('h1', ip='192.168.0.5', defaultRoute='via 192.168.0.224')
    h2 = net.addHost('h2', ip='192.168.0.6', defaultRoute='via 192.168.0.224')

    print "*** Adding Link"
    net.addLink(sta1, ap1, bw=10, loss=0)
    net.addLink(sta2, ap1, bw=10, loss=0)
    net.addLink(sta3, ap2, bw=10, loss=0)
    net.addLink(sta4, ap2, bw=10, loss=0)
    ###############
    net.addLink(sta5, ap3, bw=10, loss=0)
    net.addLink(sta6, ap3, bw=10, loss=0)     
    net.addLink(ap1, s0)
    net.addLink(ap2, s0)
    net.addLink(h1, s0)
    net.addLink(h2, s0)
    ######

    ##############################################################
    #Add NAT granting access to Internet
    nat = net.addHost( 'nat', cls=NAT, ip='192.168.0.224',
                       subnet='192.168.0.0/24', inNamespace=False)
    net.addLink(nat, s0)
    ##############################################################
    #Create RAP
    nat1=net.addHost('nat1', cls=NAT, ip='192.168.0.22',
                                  subnet='10.0.0.0/24', inNameSpace=False,
                                  inetIntf='nat1-eth0', localIntf='nat1-eth1',
                                  defaultRoute='via 192.168.0.224')

    net.addLink(nat1,s0)
    net.addLink(ap3, nat1)
    ###############################################################
    net.build()
    c0.start()
    c1.start()                            
                                 
    ap1.start( [c0] )
    ap2.start( [c0] )
    ap3.start( [c0] )
    s0.start( [c1] )
    nat1.setIP('10.0.0.22/8', intf='nat1-eth1')

    print "*** Running CLI"
    CLI( net )

    print "*** Stopping network"
    net.stop()
Exemplo n.º 40
0
    def __init__( self):

        RemoteController.__init__(self, )
Exemplo n.º 41
0
	def __init__(self, name, ip = '192.168.56.1', port = 6633, **opt):
		RemoteController.__init__(self, name, ip, port, **opt)
Exemplo n.º 42
0
    for i in range(num_leaf):
        name = 's2%02d' % (i)
        sw = net.addSwitch(name)
        leaf_switches.append(sw)

    for ss in spine_switches:
        for ls in leaf_switches:
            net.addLink(ss, ls)

    hid = 0
    for ls in leaf_switches:
        h1 = net.addHost('h%03d' % (hid, ))
        h2 = net.addHost('h%03d' % (hid + 1, ))
        hid += 2
        net.addLink(ls, h1)
        net.addLink(ls, h2)

    c0 = RemoteController('c0', '127.0.0.1', 6653)
    net.build()
    c0.start()

    for ss in spine_switches:
        ss.start([c0])

    for ls in leaf_switches:
        ls.start([c0])

    CLI(net)

    net.stop()
Exemplo n.º 43
0
def topology():
    "Create a network."
    net = Mininet( link=TCLink, switch=OVSSwitch )
    c0 = Controller( 'c0', port=6634 )
    c1 = RemoteController( 'c1', ip='127.0.0.1', port=6633 )
    net.addController(c0)
    net.addController(c1) 

    
    print "*** Creating nodes"
    s0 = net.addSwitch('s0')
    ap1 = net.addBaseStation( 'ap1', ssid="ssid_ap1", mode="g", channel="5" )
    ap2 = net.addBaseStation( 'ap2', ssid="ssid_ap2", mode="g", channel="1" )
   
    
    sta1 = net.addStation( 'sta1', ip='192.168.0.1/24', defaultRoute='via 192.168.0.224' )
    sta2 = net.addStation( 'sta2', ip='192.168.0.2/24', defaultRoute='via 192.168.0.224' )
    sta3 = net.addStation( 'sta3', ip='192.168.0.3/24', defaultRoute='via 192.168.0.224' )
    sta4 = net.addStation( 'sta4', ip='192.168.0.4/24', defaultRoute='via 192.168.0.224' )
    h1 = net.addHost('h1', ip='192.168.0.5', defaultRoute='via 192.168.0.224')
    h2 = net.addHost('h2', ip='192.168.0.6', defaultRoute='via 192.168.0.224')

    
       
    print "*** Adding Link"
    net.addLink(sta1, ap1, bw=10, loss=0)
    net.addLink(sta2, ap1, bw=10, loss=0)
    net.addLink(sta3, ap2, bw=10, loss=0)
    net.addLink(sta4, ap2, bw=10, loss=0)
    net.addLink(ap1, s0)
    net.addLink(ap2, s0)
    net.addLink(h1, s0)
    net.addLink(h2, s0)

    ##############################################################
    #nat = net.addNAT('nat', ip=natIP, inNamespace=False)
    nat = net.addHost( 'nat', cls=NAT, ip='192.168.0.224', subnet='192.168.0.0/24', inNamespace=False)
    net.addLink(nat, s0)
    ##############################################################

    
##    s2 = net.addSwitch('s2')
##    nat1=net.addHost('nat1', cls=NAT, ip='192.168.0.220',
##                                  subnet='10.0.0.0/24',
##                                  inetIntf='nat1-eth0', localIntf='nat1-eth1',
##                                  **hostConfig)
##    net.addLink(nat1, s0)
##    natParams = {'ip' : '10.0.0.1/24'}
##    net.addLink(s2, nat1, intfName1='nat1-eth1', params1=natParams)
##
##    h3 = net.addHost('h3', ip='10.0.0.2', defaultRoute = 'via 10.0.0.1')
##    h4 = net.addHost('h4', ip='10.0.0.3', defaultRoute = 'via 10.0.0.1')
##    h5 = net.addHost('h5', ip='10.0.0.4', defaultRoute = 'via 10.0.0.1')
##    net.addLink(h3, s2)
##    net.addLink(h4, s2)
##    net.addLink(h5, s2)
    
        
    net.build()
    c0.start()
    c1.start()
                                 
                                 
    ap1.start( [c0] )
    ap2.start( [c0] )
    s0.start([c1])

    print "*** Running CLI"
    CLI( net )

    print "*** Stopping network"
    net.stop()
            error( 'link src status change failed: %s\n' % result )
        result = dstIntf.ifconfig( status )
        if result:
            error( 'link dst status change failed: %s\n' % result )

h0 = Host( 'h0' )
h1 = Host( 'h1' )
h2 = Host( 'h2' )
h3 = Host( 'h3' )

s0 = OVSKernelSwitch( 's0' ,inNamespace=False )
s1 = OVSKernelSwitch( 's1' ,inNamespace=False )
s2 = OVSKernelSwitch( 's2', inNamespace=False  )
s3 = OVSKernelSwitch( 's3' ,inNamespace=False ) 

c0 = RemoteController( 'c0', ip = '10.108.100.195' ) 
c1 = RemoteController( 'c1', ip = '10.108.100.248' ) 
c2 = RemoteController( 'c2', ip = '10.108.102.176' ) 
c3 = RemoteController( 'c3', ip = '10.108.101.48' )

l1 = Link( h0, s1 )
Link( h1, s1 ) 
Link( h2, s2 )
Link( h3, s3 )
Link( s0, s1 )
Link( s0, s2 )
Link( s0, s3 )

h0.setIP( '10.1.0.1/16' )
h1.setIP( '10.1.0.2/16' )
h2.setIP( '10.2.0.1/16' )
def multiControllerNet():
    "Create a network from semi-scratch with multiple controllers."

    net = Mininet( controller=Controller, switch=OVSSwitch )

    print "*** Creating (reference) controllers"
    
    c1 = RemoteController( 'c1', port=6633 )
    c2 = RemoteController( 'c2', port=6644 )


    #c1 = net.addController('c1')
    #c2 = net.addController('c2')
    
    print "*** Creating switches"
    s1 = net.addSwitch( 's1' )
    s2 = net.addSwitch( 's2' )
    s3 = net.addSwitch( 's3' )
    s4 = net.addSwitch( 's4' )
    s5 = net.addSwitch( 's5' )
    s6 = net.addSwitch( 's6' )
    s7 = net.addSwitch( 's7' )
    s8 = net.addSwitch( 's8' )
    s9 = net.addSwitch( 's9' ) 
    print "*** Creating hosts"
    hosts3 = [ net.addHost( 'h%d' % n ) for n in 1, 2 ]
    hosts4 = [ net.addHost( 'h%d' % n ) for n in 3, 4 ]
    hosts5 = [ net.addHost( 'h%d' % n ) for n in 5, 6 ]
    hosts6 = [ net.addHost( 'h%d' % n ) for n in 7, 8 ]
    hosts8 = [ net.addHost( 'h%d' % n ) for n in 9, 10 ]
    hosts9 = [ net.addHost( 'h%d' % n ) for n in 11, 12 ]

    print "*** Creating links"
    for h in hosts3:
        net.addLink( s3, h )
    for h in hosts4:
        net.addLink( s4, h )
    for h in hosts5:
        net.addLink( s5, h )
    for h in hosts6:
        net.addLink( s6, h )
    for h in hosts8:
        net.addLink( s8, h )
    for h in hosts9:
        net.addLink( s9, h )
    net.addLink( s1, s3 )
    net.addLink( s1, s4 )
    net.addLink( s2, s5 )
    net.addLink( s2, s6 )
    net.addLink( s7, s9 )
    net.addLink( s6, s9 )

    print "*** Starting network"
    net.build()
    c1.start()
    c2.start()
    s1.start( [ c1 ] )
    s2.start( [ c1 ] )
    s3.start( [ c1 ] )  
    s4.start( [ c1 ] )
    s5.start( [ c1 ] )
    s6.start( [ c1 ] )
    s7.start( [ c2 ] )
    s8.start( [ c2 ] )
    s9.start( [ c2 ] )
    print "*** Testing network"
    # net.pingAll()

    print "*** Running CLI"
    CLI( net )

    print "*** Stopping network"
Exemplo n.º 46
0
def emptyNet():

    "Create an empty network and add nodes to it."

    net = Mininet( controller=Controller)

    info( '*** Adding controller\n' )
    ctrlRemote = RemoteController( 'c0', ip=ipControladorOF )
    net.addController(ctrlRemote)
    info('--> remote IP controller - c0:' + ctrlRemote.IP() +'\n')
    
    #ctrlLocal = RemoteController('c1', port=6633, ip="127.0.0.1")
    ctrlLocal = Controller('c1', port=6634)
    net.addController(ctrlLocal)
    info('--> local IP controller - c1:' + ctrlLocal.IP() +'\n')
    
    
    
    info( '*** Adding hosts\n' )
    lanH1 = net.addHost('h1', ip='10.0.0.1')
    lanH2 = net.addHost('h2', ip='10.0.0.2')
    lanIDS = net.addHost('h3', ip='10.0.0.3')
    lanRouter = net.addHost('h4')
    wanH1 = net.addHost('h5', ip='192.168.0.5')
    wanH2 = net.addHost('h6', ip='192.168.0.6')

    info( '*** Adding switch\n' )
    lanSw = net.addSwitch('s1')
    wanSw = net.addSwitch('s2')

    info( '*** Creating links\n' )
    net.addLink(lanH1, lanSw)
    net.addLink(lanH2, lanSw)
    net.addLink(lanIDS, lanSw)
    net.addLink(lanRouter, lanSw)
    net.addLink(lanRouter, wanSw)
    net.addLink(wanH1, wanSw)
    net.addLink(wanH2, wanSw)

    info( '*** Starting network\n')
    net.start()
    
    info('*** Starting controllers and switches')
    #link remote controller to s0 internal network swith
    ctrlRemote.start()
    #use remote controller
    lanSw.start([ctrlRemote])
    
    #use local controller
    #info('\n\n\n************ using local controller for swLAN')
    #lanSw.start([ctrlLocal])
    
    #start local controller to switch from s1 external network
    ctrlLocal.start()
    wanSw.start([ctrlLocal])
    
    info( '*** Executing hosts scripts\n')
    execCmds(net)
    
    sleep(5) # wai 5 seconds to start IDS!
    
    #log tests in files, the name of file and directory will be composed by date/time of start execution of test
    hst1 = net.getNodeByName('h1')
    hst1.cmdPrint('mkdir /var/log/tcpdump/'+date)
    arquivo = open('/var/log/tcpdump/'+date+'/teste.txt', 'w')
    textoTeste = """
    Test -
    \n Begin at:\n
    """
    data = datetime.datetime.now()
    textoTeste=textoTeste+"%s/%s/%s as %s:%s:%s:%s\n"%(data.year,data.month,data.day,data.hour,data.minute,data.second,data.microsecond)
    arquivo.write(textoTeste)
    
    ### Tests
    
    #
    # Start the testes here!
    #
    # Select the test to run. For that uncomment the line of the desired test.
	   
    info( '*** Executing Tests\n')
    textoTeste = textoTeste =teste1(net)
    #textoTeste = testeIperf(net)
    #textoTeste = testeIDSWakeupExternoInterno(net)
    #textoTeste = testeDDoSExtInt(net)
    #textoTeste = testeDDoSIntExt(net)
    #textoTeste = testeDDoSIntInt(net)
    
    # record attack test!
    textoTeste = textoTeste+"""
     
    put comment of test here
    
    """
    
    arquivo.write(textoTeste)

    ### end of test!
    
    # register the time that test was finished
    data = datetime.datetime.now()
    textoTeste=' \nFinished at:\n '+"%s/%s/%s as %s:%s:%s:%s\n"%(data.year,data.month,data.day,data.hour,data.minute,data.second,data.microsecond)
    arquivo.write(textoTeste)
    arquivo.close()

    info( '*** Running CLI\n' )
    #Uncomment below line for execute the test with CLI console
    #CLI( net )
    sleep(5)
    info('*** Stoping IDS process\n')
    desligarIDS(net,'h3')
    #thIds.join()

    info( '*** Stopping network\n' )
    lanSw.stop()
    ctrlRemote.stop()

    net.stop() 
    exit()
Exemplo n.º 47
0
def loaderbanlanceNet(control_ip):

    "Create a network from semi-scratch with one controller."
    if not control_ip:
        sys.exit(1)
    ip_controller=control_ip
    ip_switch="10.0.0.5"
    bw_link=100 # 100 M
    delay_link='0ms'
    loss_link=0 # 0%
    total_client_num = 6 # clint ip total number must <=25600
    total_time_per = 1
    inter_time_per = 1
    ip_vip ="10.0.0.100" 

    #net
    net = Mininet( controller=Controller, switch=OVSSwitch, build=False, host=CPULimitedHost, link=TCLink)
    #controller
    print "*** Creating (reference) controller"
    c1 = RemoteController( 'c1', ip=ip_controller )
    #switch
    print "*** Creating and configuring switche"
    s1 = net.addSwitch( 's1' )
    s1.setIP(ip_switch, 8 )
    #hosts
    print "*** Creating and configuring hosts"
    hosts1 = [ net.addHost( 'h%d' % n,cpu=.5 / 4) for n in 1, 2, 3 ] #  4 hosts and Each host gets 50%/n of system CPU
    #links
    print "*** Creating links"
    for h in hosts1:
        net.addLink( s1, h, bw=bw_link, delay=delay_link, loss=loss_link, use_htb=True)#  10 Mbps, 5ms delay, 10% loss

    # start network
    print "*** Starting network"
    net.build()# NOTE build() at this time
    c1.start()
    s1.start( [ c1 ] )

    #set host ip
    print "*** get node and set nodeip after net start"
    h1, h2, h3 = net.getNodeByName('h1', 'h2', 'h3')# NOTE you must get the host name before you use it
    h1.setIP('10.0.0.1', 8 )
    h2.setIP('10.0.0.2', 8 )
    h3.setIP('10.0.0.3', 8 )

    print "*** Testing network connectivity"
    net.pingAll()# you must pingall to add???? the floadbalancer low-entry for ip 10.0.0.100

    print "*** Testing load-balance module "
    curdir = os.path.abspath(os.curdir)
    h3.cmd('rm %s/loaddata/*.data' % curdir)
    h3.cmd('mkdir -p %s/loaddata/' % curdir)
    h3.cmd('touch %s/loaddata/h1.data %s/loaddata/h2.data %s/loaddata/h3.data' %
    (curdir, curdir, curdir))
    h1.cmd('iperf -s >> %s/loaddata/h1.data &' % curdir)
    h2.cmd('iperf -s >> %s/loaddata/h2.data &' % curdir)

    client_num = 0
    #default_ip = '10.0.0.6', controller ip  :10.0.0.100
    i=0
    j=6
    while client_num < total_client_num:
        h3.setIP('10.0.%d.%d' %(i,j),8)
        if j%256 == 0:
            i+=1
            j=1
        client_num +=1
        j+=1
        print 'client: %d ip: %s' % (client_num,h3.IP())
        if h3.IP() == ip_controller: # NOTE:host ip is not able to equal controller ip
            continue 
        h3.cmd("iperf -c 10.0.0.100 -t%d -i%d >> %s/loaddata/h3.data " %
        (total_time_per, inter_time_per, curdir))
        time.sleep(2)
    else:
        print 'The test loop is over,total client num :%d' % client_num

    print "*** Running CLI"
    CLI( net )

    print "*** Stopping network"
    net.stop()
Exemplo n.º 48
0
from mininet.net import Mininet
from mininet.node import RemoteController, OVSSwitch


def ofp_version(switch, protocols):
    protocols_str = ','.join(protocols)
    command = 'ovs-vsctl set Bridge %s protocols=%s' % (switch, protocols_str)
    switch.cmd(command.split(' '))


if '__main__' == __name__:
    net = Mininet(switch=OVSSwitch)


    controllers = []
    c0 = RemoteController('c0', '10.10.10.10', 6633)
    c1 = RemoteController('c1', '10.10.10.10', 6634)
    c2 = RemoteController('c2', '10.10.10.10', 6635)
    controllers.append(c0)
    controllers.append(c1)
    controllers.append(c2)

    net.addController(c0)
    net.addController(c1)
    net.addController(c2)

    switches = []
    for domain in range(0, 3):
        s1 = net.addSwitch('s%d' % (domain*3 + 1, ))
        s2 = net.addSwitch('s%d' % (domain*3 + 2, ))
        s3 = net.addSwitch('s%d' % (domain*3 + 3, ))
Exemplo n.º 49
0
def topology():
    "Create a network."
    net = Mininet( link=TCLink, switch=OVSSwitch )
    #create local controller for APs
    c0 = Controller( 'c0', port=6634 )
    #create controller for s0 (Ryuretic)
    c1 = RemoteController( 'c1', ip='127.0.0.1', port=6633 )
    net.addController(c0)
    net.addController(c1)
    
    print "*** Creating nodes"
    s0 = net.addSwitch('s0')
        ##################    Create Rogue APs    ############################### 
    ap1 = net.addBaseStation( 'ap1', ssid="ssid_ap1", channel="1", mode="g",
                              range='20' )
    ap3 = net.addBaseStation( 'ap3', ssid="ssid_ap3", mode="g", channel="6",
                              range='20')
    
    ################   Create Rogue Stations   #############################
    sta1 = net.addStation( 'sta1', ip='192.168.0.11/24', mac='AA:BB:BB:BB:BB:01',
                           defaultRoute='via 192.168.0.224' )
    sta2 = net.addStation( 'sta2', ip='192.168.0.12/24', mac='AA:BB:BB:BB:BB:02',
                           defaultRoute='via 192.168.0.224' )
    sta3 = net.addStation( 'sta3', ip='192.168.0.13/24', mac='AA:BB:BB:BB:BB:03',
                           defaultRoute='via 192.168.0.224' )
    sta4 = net.addStation( 'sta4', ip='10.0.0.1/24', mac='AA:BB:BB:BB:BB:11',
                           defaultRoute='via 10.0.0.22' )
    sta5 = net.addStation( 'sta5', ip='10.0.0.2/24', mac='AA:BB:BB:BB:BB:12',
                           defaultRoute='via 10.0.0.22' )
    sta6 = net.addStation( 'sta6', ip='10.0.0.3/24', mac='AA:BB:BB:BB:BB:13',
                           defaultRoute='via 10.0.0.22' )
    
    ##################    Create Hosts    ####################################
    h1 = net.addHost('h1', ip='192.168.0.1', mac='AA:AA:AA:AA:AA:01',
                     defaultRoute='via 192.168.0.224')
    h2 = net.addHost('h2', ip='192.168.0.2', mac='AA:AA:AA:AA:AA:02',
                     defaultRoute='via 192.168.0.224')
    h3 = net.addHost('h3', ip='192.168.0.3', mac='AA:AA:AA:AA:AA:03',
                     defaultRoute='via 192.168.0.224')
    h4 = net.addHost('h4', ip='192.168.0.4', mac='AA:AA:AA:AA:AA:04',
                     defaultRoute='via 192.168.0.224')
    h5 = net.addHost('h5', ip='192.168.0.5', mac='AA:AA:AA:AA:AA:05',
                     defaultRoute='via 192.168.0.224')
    h6 = net.addHost('h6', ip='192.168.0.6', mac='AA:AA:AA:AA:AA:06',
                     defaultRoute='via 192.168.0.224')
    ##################   Wireless AP Interface   #############################

    print "*** Adding Link"
    wl_bw = 15
    wl_delay = '5ms'
    wl_loss = 10
    
    net.addLink(ap1, sta1, bw=wl_bw, loss=wl_loss, delay=wl_delay )
    net.addLink(ap1, sta2, bw=wl_bw, loss=wl_loss, delay=wl_delay )
    net.addLink(ap1, sta3, bw=wl_bw, loss=wl_loss, delay=wl_delay )
    #####################    NAT1 Interface    ###############################   
    net.addLink(ap3, sta4, bw=wl_bw, loss=wl_loss, delay=wl_delay )
    net.addLink(ap3, sta5, bw=wl_bw, loss=wl_loss, delay=wl_delay )
    net.addLink(ap3, sta6, bw=wl_bw, loss=wl_loss, delay=wl_delay )
    #####################   Link devices to Switch    ######################## 
    w_delay='3ms'
    
    net.addLink(ap1, s0, bw=15, delay=w_delay)
    net.addLink(h1, s0, bw=15, delay=w_delay)
    net.addLink(h2, s0, bw=15, delay=w_delay)
    net.addLink(h3, s0, bw=15, delay=w_delay)
    net.addLink(h4, s0, bw=15, delay=w_delay)
    net.addLink(h5, s0, bw=15, delay=w_delay)
    net.addLink(h6, s0, bw=15, delay=w_delay)
    ######################   Create NAT for Internet   #######################
    nat = net.addHost( 'nat', cls=NAT, ip='192.168.0.224', mac='AA:AA:AA:AA:02:24',
                       subnet='192.168.0.0/24', inNamespace=False)
    net.addLink(nat, s0, bw=50)
    ###########################     Create RAP        ########################
    nat1=net.addHost('nat1', cls=NAT, ip='192.168.0.22', mac='AA:AA:AA:AA:00:22',
                                  subnet='10.0.0.0/24', inNameSpace=False,
                                  inetIntf='nat1-eth0', localIntf='nat1-eth1',
                                  defaultRoute='via 192.168.0.224')
    net.addLink(nat1,s0, bw=15, delay=w_delay)
    net.addLink(ap3, nat1,bw=15, delay='2ms')
    #########################   Build Topology      ##########################
    net.build()
    #########################   Start Topology      ##########################     
    c0.start()
    c1.start()                                               
    ap1.start( [c0] )
    ap3.start( [c0] )
    s0.start( [c1] )
    ########################   Add RAP Interface    ########################## 
    nat1.setIP('10.0.0.22/8', intf='nat1-eth1')

    print "*** Running CLI"
    CLI( net )

    print "*** Stopping network"
    net.stop()