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()
Example #2
0
def MyNetwork():
    print("Starting")
    net = Mininet(controller=Controller, switch=OVSKernelSwitch)
    c1 = RemoteController("c1", ip='127.0.0.1', port=6653)
    #hosts
    h1 = net.addHost('h1',
                     ip='10.0.1.1/24',
                     defaultRoute='via 10.0.1.4',
                     mac='00:00:00:00:01:01')
    h2 = net.addHost('h2',
                     ip='10.0.1.2/24',
                     defaultRoute='via 10.0.1.4',
                     mac='00:00:00:00:01:02')

    #core switches
    s1 = net.addSwitch('s1')
    s2 = net.addSwitch('s2')

    #host links
    net.addLink(s1, h1)
    net.addLink(s1, s2)
    net.addLink(s2, h2)

    #build network
    info("Starting network \n")
    net.build()
    c1.start()
    s1.start([c1])
    s2.start([c1])
    CLI(net)
    net.stop()
Example #3
0
def topology():
    "Create a network."
    net = Mininet( controller=RemoteController, link=TCLink, switch=OVSKernelSwitch )
	
    _bw=10
    _latency='5ms'
    _max_queue_size=100
    _use_htb=True
    _ip_remote_control='127.0.0.1'
    _port_remote_control=6653

    print "*** Creating nodes"
    h1 = net.addHost( 'h1', mac="00:00:00:00:00:01", ip='10.0.0.1' )
    h2 = net.addHost( 'h2', mac="00:00:00:00:00:02", ip='10.0.0.2' )
    h3 = net.addHost( 'h3', mac="00:00:00:00:00:03", ip='10.0.0.3' )
    h4 = net.addHost( 'h4', mac="00:00:00:00:00:04", ip='10.0.0.4' )
    h5 = net.addHost( 'h5', mac="00:00:00:00:00:05", ip='10.0.0.5' )
    h6 = net.addHost( 'h6', mac="00:00:00:00:00:06", ip='10.0.0.6' )
    h7 = net.addHost( 'h7', mac="00:00:00:00:00:07", ip='10.0.0.7' )
    h8 = net.addHost( 'h8', mac="00:00:00:00:00:08", ip='10.0.0.8' )
    h9 = net.addHost( 'h9', mac="00:00:00:00:00:09", ip='10.0.0.9' )
    h10 = net.addHost( 'h10', mac="00:00:00:00:00:10", ip='10.0.0.10' )
    h11 = net.addHost( 'h11', mac="00:00:00:00:00:11", ip='10.0.0.11' )
    h12 = net.addHost( 'h12', mac="00:00:00:00:00:12", ip='10.0.0.12' )
    s1 = net.addSwitch( 's1' )
    s2 = net.addSwitch( 's2' )
    s3 = net.addSwitch( 's3' )
    #c0 = net.addController('c0', controller=OVSController)
    c0 = RemoteController( 'c0', ip=_ip_remote_control, port=_port_remote_control )

    

    print "*** Associating Stations"
    net.addLink(h1, s2, bw=_bw,latency=_latency,max_queue_size=_max_queue_size,use_htb=_use_htb)
    net.addLink(h2, s2, bw=_bw,latency=_latency,max_queue_size=_max_queue_size,use_htb=_use_htb)
    net.addLink(h3, s3, bw=_bw,latency=_latency,max_queue_size=_max_queue_size,use_htb=_use_htb)
    net.addLink(h4, s3, bw=_bw,latency=_latency,max_queue_size=_max_queue_size,use_htb=_use_htb)
    net.addLink(h5, s3, bw=_bw,latency=_latency,max_queue_size=_max_queue_size,use_htb=_use_htb)
    net.addLink(h6, s3, bw=_bw,latency=_latency,max_queue_size=_max_queue_size,use_htb=_use_htb)
    net.addLink(h7, s3, bw=_bw,latency=_latency,max_queue_size=_max_queue_size,use_htb=_use_htb)
    net.addLink(h8, s3, bw=_bw,latency=_latency,max_queue_size=_max_queue_size,use_htb=_use_htb)
    net.addLink(h9, s3, bw=_bw,latency=_latency,max_queue_size=_max_queue_size,use_htb=_use_htb)
    net.addLink(h10, s3, bw=_bw,latency=_latency,max_queue_size=_max_queue_size,use_htb=_use_htb)
    net.addLink(h11, s3, bw=_bw,latency=_latency,max_queue_size=_max_queue_size,use_htb=_use_htb)
    net.addLink(h12, s3, bw=_bw,latency=_latency,max_queue_size=_max_queue_size,use_htb=_use_htb)
    net.addLink(s1, s2, bw=_bw,latency=_latency,max_queue_size=_max_queue_size,use_htb=_use_htb)
    net.addLink(s1, s3, bw=_bw,latency=_latency,max_queue_size=_max_queue_size,use_htb=_use_htb)
    
    print "*** Starting network"
    net.build()
    c0.start()
    s1.start( [c0] )
    s2.start( [c0] )
    s3.start( [c0] )

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

    print "*** Stopping network"
    net.stop()
Example #4
0
def add_controller(name, host, port):
    logger.debug("adding controller name={}, host={}, port={}"
                 .format(name, host, port))
    ip = socket.gethostbyname(host)
    controller = RemoteController(name, ip=ip, port=port)
    controller.start()
    controllers.append(controller)
    return controller
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()
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()
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"
Example #8
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()
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()
Example #10
0
def topology(is_enable_cli=False):
    """
    create a network.

    mode (str): miminet or containernet
    is_enable_cli (bool): running CLI
    """
    c1 = RemoteController('c1', ip='172.17.20.12', port=6633)
    net = Mininet_wifi(accessPoint=OVSKernelAP)
    info("*** Starting network\n")
    net.build()
    c1.start()
    if is_enable_cli:
        info("*** Running CLI\n")
        CLI_wifi(net)
    info("*** Stopping network\n")
    net.stop()
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"
Example #12
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()
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()
Example #14
0
def simpleTest():

    topo = FatTree()
    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.Servers

    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()
Example #15
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()
def multiControllerNet(con_num=3, sw_num=3, host_num=6):
    "Create a network from semi-scratch with multiple controllers."
    controller_list = []
    switch_list = []
    host_list = []

    net = Mininet(controller=None, switch=OVSSwitch, link=TCLink)

    for i in range(0, con_num):
        name = 'c%s' % str(i + 1)
        c = RemoteController(name, ip='127.0.0.1', port=6653 + i)
        net.addController(c)
        controller_list.append(c)
        print("*** Creating %s" % name)

    print("*** Creating switches")
    switch_list = [net.addSwitch('s%d' % n) for n in range(1, sw_num + 1)]

    print("*** Creating hosts")
    host_list = [net.addHost('h%d' % n) for n in range(1, host_num + 1)]

    print("*** Creating links of host2switch.")
    for i in range(0, sw_num):
        net.addLink(switch_list[i], host_list[i * 2])
        net.addLink(switch_list[i], host_list[i * 2 + 1])

    print("*** Starting network")
    net.build()
    for c in controller_list:
        c.start()

    _No = 0
    SpC = int(sw_num / con_num)
    for i in range(0, sw_num, SpC):
        for j in range(0, SpC):
            switch_list[i + j].start([controller_list[_No]])
            _No += 1

    CLI(net)
    print("*** Stopping network")
    net.stop()
Example #17
0
File: test.py Project: Hungmap/test
def multiControllerNet():
    "Create a network from semi-scratch with multiple controllers."

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

    print("*** Creating (reference) controllers")
    c1 = RemoteController('c1', ip='10.102.10.210', port=6653)
    #c2 = RemoteController( 'c2', ip='10.102.10.210', port=6653 )

    print("*** Creating switches")
    s1 = net.addSwitch('s1')
    s2 = net.addSwitch('s2')

    print("*** Creating hosts")
    hosts1 = [net.addHost('h%d' % n) for n in (3, 4)]
    hosts2 = [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)
    net.addLink(s1, s2)

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

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

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

    print("*** Stopping network")
    net.stop()
Example #18
0
def start_mininet():
    controller = RemoteController('c0', ip='127.0.0.1', port=6633)

    topo = DotTopo()
    topo.import_dot('../res/topology.dot')

    net = Mininet(topo=topo, controller=controller, link=TCLink)

    controller.start()
    net.start()

    # while True:
    random_host1 = net.get('h%d' % randint(1, 160))
    random_host2 = net.get('h%d' % randint(1, 160))

    makeTerm(random_host1, title='Iperf Server', cmd='iperf -s')
    makeTerm(random_host2,
             title='Iperf Client',
             cmd='iperf -c ' + random_host1.IP())

    file = open(config.TC_COMMANDS_PATH)

    start_time = time.time()
    rules_tc = json.loads(file.read())
    for rule_ip in rules_tc:
        print(rule_ip)
        for i in range(1, 160):
            host = net.get('h{}'.format(i))
            if host.IP() == rule_ip:
                print(rule_ip)
                break
        for rule in rules_tc:
            makeTerm(host, title='Commands', cmd=rule)

    end_time = time.time()
    elapsed_time = end_time - start_time
    return elapsed_time
Example #19
0
def myNetwork():

    net = Mininet(topo=None, build=False, ipBase='10.0.0.0/24')

    info("""
Creating the folow topology:
                         
                +----+   
                | c1 |   
                +--:-+                      +----+
                   :     /------------------| h3 |
+----+         +---:---+/                   +----+      
| h1 |---------| swof1 |---
+----+         +-------+   \      
                |   | |     \              +----+
                |   | |      \-------------| h4 |
+----+          |   | |                    +----+
| h2 |-----------   | |     +----+    
+----+              | |-----| h5 |
                    |       +----+
            +----+  |        
            | h6 |--|
            +----+
------------------------------------------------------------------------
DEVICE          NAME            IP:PORT         	DESCRIPTION
------------------------------------------------------------------------
switch_OpenFlow swof1           10.10.0.254/24
                                10.20.0.254/24
                                10.30.0.254/24
controller      c1              127.0.0.1:6633
h1          	h1          	10.10.0.1/24
h2          	h2          	10.10.0.2/24
h3          	h3          	10.20.0.3/24
h4          	h4          	10.20.0.4/24
h5          	h5          	10.30.0.5/24
h6          	h6          	10.30.0.6/24
------------------------------------------------------------------------
""")

    info('*** Adding controller\n')
    controller = RemoteController('controller',
                                  ip='127.0.0.1',
                                  protocol='tcp',
                                  port=6633)
    net.addController(controller)

    info('*** Add switches\n')
    swof1 = net.addSwitch('swof1', cls=OVSKernelSwitch)

    info('*** Add hosts\n')
    h1 = net.addHost('h1',
                     cls=Host,
                     ip='10.10.0.1/24',
                     mac='00:00:00:00:00:01')
    h2 = net.addHost('h2',
                     cls=Host,
                     ip='10.10.0.2/24',
                     mac='00:00:00:00:00:02')
    h3 = net.addHost('h3',
                     cls=Host,
                     ip='10.20.0.3/24',
                     mac='00:00:00:00:00:03')
    h4 = net.addHost('h4',
                     cls=Host,
                     ip='10.20.0.4/24',
                     mac='00:00:00:00:00:04')
    h5 = net.addHost('h5',
                     cls=Host,
                     ip='10.30.0.5/24',
                     mac='00:00:00:00:00:05')
    h6 = net.addHost('h6',
                     cls=Host,
                     ip='10.30.0.6/24',
                     mac='00:00:00:00:00:06')

    info('*** Add links\n')
    net.addLink(swof1, h1)
    net.addLink(swof1, h2)
    net.addLink(swof1, h3)
    net.addLink(swof1, h4)
    net.addLink(swof1, h5)
    net.addLink(swof1, h6)

    info('*** Starting network\n')
    net.build()
    info('*** Starting controllers\n')
    for controller in net.controllers:
        controller.start()

    info('*** Starting switches\n')
    net.get('swof1').start([controller])

    info('*** Post configure hosts\n')
    h1.cmd('route add default gw 10.10.0.254')
    h2.cmd('route add default gw 10.10.0.254')
    h3.cmd('route add default gw 10.20.0.254')
    h4.cmd('route add default gw 10.20.0.254')
    h5.cmd('route add default gw 10.30.0.254')
    h6.cmd('route add default gw 10.30.0.254')

    CLI(net)

    info('########## Stopping CLI ##########\n')
    net.stop()
Example #20
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()
Example #21
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()
Example #22
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()
Example #23
0
def topology():

    # "Create a network."
    net = Mininet(controller=RemoteController,
                  link=TCLink,
                  switch=OVSKernelSwitch)

    _bw = 10
    _latency = '5ms'
    _max_queue_size = 100
    _use_htb = True
    _ip_remote_control = '127.0.0.1'
    _port_remote_control = 6653

    adp_USB100MB_MAC = "00:13:3B:85:05:05"

    print "*** Creating Hosts"
    h1 = net.addHost('h1', mac="00:00:00:00:00:01", ip='192.168.2.1')

    h2 = net.addHost('h2', mac="00:00:00:00:00:02", ip='192.168.2.2')
    h3 = net.addHost('h3', mac="00:00:00:00:00:03", ip='192.168.2.3')
    h4 = net.addHost('h4', mac="00:00:00:00:00:04", ip='192.168.2.4')

    h5 = net.addHost('h5', mac="00:00:00:00:00:05", ip='192.168.2.5')
    h6 = net.addHost('h6', mac="00:00:00:00:00:06", ip='192.168.2.6')
    h7 = net.addHost('h7', mac="00:00:00:00:00:07", ip='192.168.2.7')

    h8 = net.addHost('h8', mac="00:00:00:00:00:08", ip='192.168.2.8')
    h9 = net.addHost('h9', mac="00:00:00:00:00:09", ip='192.168.2.9')
    h10 = net.addHost('h10', mac="00:00:00:00:00:10", ip='192.168.2.10')

    h11 = net.addHost('h11', mac="00:00:00:00:00:11", ip='192.168.2.11')
    # h12 = net.addHost( 'h12', mac="00:00:00:00:00:12", ip='192.168.2.12' )
    # h13 = net.addHost( 'h13', mac="00:00:00:00:00:13", ip='192.168.2.13' )

    hc = net.addHost('hc', mac="00:00:00:00:00:50", ip='192.168.2.50')
    hs1 = net.addHost('hs1', mac="00:00:00:00:00:51", ip='192.168.2.51')
    hs2 = net.addHost('hs2', mac="00:00:00:00:00:52", ip='192.168.2.52')

    print "*** Creating Switchs"
    s35 = net.addSwitch('s35', dpid='00:00:00:00:aa:bb:cc:35')
    s32 = net.addSwitch('s32', dpid='00:00:00:00:aa:bb:cc:32')
    s15 = net.addSwitch('s15', dpid='00:00:00:00:aa:bb:cc:15')
    s14 = net.addSwitch('s14', dpid='00:00:00:00:aa:bb:cc:14')
    s02 = net.addSwitch('s02', dpid='00:00:00:00:aa:bb:cc:02')
    s17 = net.addSwitch('s17', dpid='00:00:00:00:aa:bb:cc:17')
    s38 = net.addSwitch('s38', dpid='00:00:00:00:aa:bb:cc:38')

    print "*** Creating Controller Openflow"
    c0 = RemoteController('c0',
                          ip=_ip_remote_control,
                          port=_port_remote_control)

    print "*** Connecting hosts"
    net.addLink(h1, s32, bw=_bw, use_htb=_use_htb)

    net.addLink(h2, s38, bw=_bw, use_htb=_use_htb)
    net.addLink(h3, s38, bw=_bw, use_htb=_use_htb)
    net.addLink(h4, s38, bw=_bw, use_htb=_use_htb)

    net.addLink(h5, s02, bw=_bw, use_htb=_use_htb)
    net.addLink(h6, s02, bw=_bw, use_htb=_use_htb)
    net.addLink(h7, s02, bw=_bw, use_htb=_use_htb)

    net.addLink(h8, s17, bw=_bw, use_htb=_use_htb)
    net.addLink(h9, s17, bw=_bw, use_htb=_use_htb)
    net.addLink(h10, s17, bw=_bw, use_htb=_use_htb)

    net.addLink(h11, s35, bw=_bw, use_htb=_use_htb)
    # net.addLink(h12, s35, bw=_bw, use_htb=_use_htb)
    # net.addLink(h13, s35, bw=_bw, use_htb=_use_htb)

    net.addLink(hc, s32, bw=_bw, use_htb=_use_htb)
    net.addLink(hs1, s14, bw=_bw, use_htb=_use_htb)
    net.addLink(hs2, s15, bw=_bw, use_htb=_use_htb)

    print "*** Creating connection between switches"
    net.addLink(s35,
                s15,
                bw=_bw,
                latency=_latency,
                max_queue_size=_max_queue_size,
                use_htb=_use_htb)
    net.addLink(s35,
                s14,
                bw=_bw,
                latency=_latency,
                max_queue_size=_max_queue_size,
                use_htb=_use_htb)
    net.addLink(s32,
                s15,
                bw=_bw,
                latency=_latency,
                max_queue_size=_max_queue_size,
                use_htb=_use_htb)
    net.addLink(s32,
                s14,
                bw=_bw,
                latency=_latency,
                max_queue_size=_max_queue_size,
                use_htb=_use_htb)
    net.addLink(s15,
                s17,
                bw=_bw,
                latency=_latency,
                max_queue_size=_max_queue_size,
                use_htb=_use_htb)
    net.addLink(s15,
                s02,
                bw=_bw,
                latency=_latency,
                max_queue_size=_max_queue_size,
                use_htb=_use_htb)
    net.addLink(s14,
                s17,
                bw=_bw,
                latency=_latency,
                max_queue_size=_max_queue_size,
                use_htb=_use_htb)
    net.addLink(s14,
                s02,
                bw=_bw,
                latency=_latency,
                max_queue_size=_max_queue_size,
                use_htb=_use_htb)
    net.addLink(s02,
                s38,
                bw=_bw,
                latency=_latency,
                max_queue_size=_max_queue_size,
                use_htb=_use_htb)
    net.addLink(s17,
                s38,
                bw=_bw,
                latency=_latency,
                max_queue_size=_max_queue_size,
                use_htb=_use_htb)

    print "*** Starting network"
    net.build()
    c0.start()
    s35.start([c0])
    s15.start([c0])
    s17.start([c0])
    s14.start([c0])
    s32.start([c0])
    s02.start([c0])
    s38.start([c0])

    try:

        #Run Floodlight in another terminal
        exec_floodlight = "cd ../floodlight && java -jar target/floodlight.jar > mcast_log.txt && exit"
        # exec_floodlight="cd ../floodlight && ant && java -jar target/floodlight.jar > mcast_log.txt && exit"
        os.system("gnome-terminal -x sh -c '" + exec_floodlight + " ; bash'")

        #wait time for compile and run Floodlight
        time.sleep(15)

        # net.pingAll()

        #Arquivo de log dos hosts
        os.system("rm -f scripts/mcast_v1/log.txt")
        # os.system("cd scripts/mcast_v1 && echo '' > log.txt")
        print "\n"

        #List of hots
        hosts = [h2, h3, h4, h5, h6, h7, h8, h9, h10, h11]  #, h12, h13]

        #Start Server
        h1.cmd('cd scripts/mcast_v1 && python mc_server.py h1 >> log.txt &')
        print "H1 START "
        time.sleep(2)

        thread.start_new_thread(link_down, (net, ))
        thread.start_new_thread(link_iperf, (net, hc, hs1, hs2))

        #Starts a host every 5 seconds
        for i in range(2, (len(hosts) + 2)):

            hosts[i - 2].cmd('cd scripts/mcast_v1 && python mc_client.py h' +
                             str(i) + ' >> log.txt &')
            if (i == 2):
                os.system(
                    "sudo tcpdump -i any -n -tt -v tcp port 6653 > evalvid/files/open_flow_mcast.txt &"
                )
                # os.system("sudo tcpdump -i any -n -tt -v igmp > evalvid/files/igmp_mcast.txt &")
            print("H" + str(i) + " START")
            time.sleep(5)

    except Exception as e:
        print("Failed " + str(e))

    try:
        time.sleep(15)
        os.system(
            "sudo kill -1 $(ps -C 'java -jar target/floodlight.jar' -o pid=)")
        time.sleep(1)
        os.system(
            "mv scripts/mcast_v1/log.txt evalvid/files && mv ../floodlight/mcast_log.txt evalvid/files"
        )
        time.sleep(1)
        os.system("cd evalvid/files && sort -n -k1 log.txt -o log.txt")
        time.sleep(1)
        os.system(
            "sudo kill -1 $(ps -C 'sh -c cd ../floodlight && ant && java -jar target/floodlight.jar > mcast_log.txt' -o pid=)"
        )

        # raw_input("\nPress Enter to continue...\n")
        # os.system("cd evalvid && ./evaluation_complete.sh h2 mcast_10h_5s_linkdown")
    finally:
        print "*** Stopping network"
        net.stop()
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"
Example #25
0
def topology():
    "Create a network."

    c1 = RemoteController('c1', ip='172.17.20.11', port=6633)
    net = Mininet_wifi(accessPoint=OVSKernelAP)
    net.propagationModel(model="logDistance", exp=3)

    info("*** Creating nodes\n")
    #mode = 'mininet'
    mode = 'containernet'
    if mode == 'mininet':
        h1 = net.addHost('h1',
                         cls=Node,
                         mac='00:00:00:00:00:01',
                         ip='10.0.0.11/8')
        sta1 = net.addStation('sta1',
                              cls=Station,
                              mac='00:00:00:00:00:02',
                              ip='10.0.0.12/8')
        sta2 = net.addStation('sta2',
                              cls=Station,
                              mac='00:00:00:00:00:03',
                              ip='10.0.0.13/8')
    else:
        dimage_name = 'kumokay/ubuntu14_wifi:latest'
        h1 = net.addHost('h1',
                         cls=Docker,
                         dimage=dimage_name,
                         mac='00:00:00:00:00:01',
                         ip='10.0.0.11/8')
        sta1 = net.addStation('sta1',
                              cls=DockerStation,
                              dimage=dimage_name,
                              mac='00:00:00:00:00:02',
                              ip='10.0.0.12/8')
        sta2 = net.addStation('sta2',
                              cls=DockerStation,
                              dimage=dimage_name,
                              mac='00:00:00:00:00:03',
                              ip='10.0.0.13/8')
    ap1 = net.addAccessPoint('ap1',
                             ssid='new-ssid',
                             mode='g',
                             channel='1',
                             position='0,0,0')
    net.addController(c1)

    info("*** Configuring wifi nodes\n")
    net.configureWifiNodes()

    info("*** Associating and Creating links\n")
    net.addLink(ap1, h1)

    # net.plotGraph(max_x=200, max_y=200)

    net.startMobility(time=0, repetitions=1)
    net.mobility(sta1, 'start', time=1, position='0.0,0.0,0.0')
    net.mobility(sta2, 'start', time=1, position='0.0,0.0,0.0')
    net.mobility(sta1, 'stop', time=22, position='40.0,40.0,0.0')
    net.mobility(sta2, 'stop', time=22, position='20.0,20.0,0.0')
    net.stopMobility(time=23)

    info("*** Starting network\n")
    net.build()
    c1.start()
    ap1.start([c1])

    info("*** Running CLI\n")
    CLI_wifi(net)

    info("*** Stopping network\n")
    net.stop()
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()
Example #27
0
def topology():

    "Create a network."
    net = Mininet(controller=RemoteController,
                  link=TCLink,
                  switch=OVSKernelSwitch)

    _bw = 10
    _latency = '100ms'
    _max_queue_size = 100
    _use_htb = True
    _ip_remote_control = '127.0.0.1'
    _port_remote_control = 6653

    adp_USB100MB_MAC = "00:13:3B:85:05:05"

    print "*** Creating Hosts"
    h1 = net.addHost('h1', mac="00:00:00:00:00:01", ip='192.168.2.1')

    h2 = net.addHost('h2', mac="00:00:00:00:00:02", ip='192.168.2.2')
    h3 = net.addHost('h3', mac="00:00:00:00:00:03", ip='192.168.2.3')

    h4 = net.addHost('h4', mac="00:00:00:00:00:04", ip='192.168.2.4')
    h5 = net.addHost('h5', mac="00:00:00:00:00:05", ip='192.168.2.5')

    print "*** Creating Switchs"
    s1 = net.addSwitch('s1', dpid='00:00:00:00:aa:bb:cc:01')
    s2 = net.addSwitch('s2', dpid='00:00:00:00:aa:bb:cc:02')
    s3 = net.addSwitch('s3', dpid='00:00:00:00:aa:bb:cc:03')
    s4 = net.addSwitch('s4', dpid='00:00:00:00:aa:bb:cc:04')

    print "*** Creating Controller Openflow"
    c0 = RemoteController('c0',
                          ip=_ip_remote_control,
                          port=_port_remote_control)

    print "*** Connecting hosts"
    net.addLink(h1, s1, bw=_bw, use_htb=_use_htb)

    net.addLink(h2, s2, bw=_bw, use_htb=_use_htb)
    net.addLink(h3, s3, bw=_bw, use_htb=_use_htb)

    net.addLink(h4, s4, bw=_bw, use_htb=_use_htb)
    net.addLink(h5, s4, bw=_bw, use_htb=_use_htb)

    print "*** Creating connection between switches"
    net.addLink(s1,
                s2,
                bw=_bw,
                latency=_latency,
                max_queue_size=_max_queue_size,
                use_htb=_use_htb)
    net.addLink(s1,
                s3,
                bw=_bw,
                latency=_latency,
                max_queue_size=_max_queue_size,
                use_htb=_use_htb)
    net.addLink(s2,
                s4,
                bw=_bw,
                latency=_latency,
                max_queue_size=_max_queue_size,
                use_htb=_use_htb)
    net.addLink(s3,
                s4,
                bw=_bw,
                latency=_latency,
                max_queue_size=_max_queue_size,
                use_htb=_use_htb)

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

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

    print "*** Stopping network"
    net.stop()
Example #28
0
def topology():

    # "Create a network."
    net = Mininet( controller=RemoteController, link=TCLink, switch=OVSKernelSwitch )
	
    _bw=10
    _latency='5ms'
    _max_queue_size=100
    _use_htb=True
    _ip_remote_control='127.0.0.1'
    _port_remote_control=6653

    adp_USB100MB_MAC = "00:13:3B:85:05:05"

    print "*** Creating Hosts"
    h1 = net.addHost( 'h1', mac="00:00:00:00:00:01", ip='192.168.2.1' )

    h2 = net.addHost( 'h2', mac="00:00:00:00:00:02", ip='192.168.2.2' )
    h3 = net.addHost( 'h3', mac="00:00:00:00:00:03", ip='192.168.2.3' )
    h4 = net.addHost( 'h4', mac="00:00:00:00:00:04", ip='192.168.2.4' )

    h5 = net.addHost( 'h5', mac="00:00:00:00:00:05", ip='192.168.2.5' )
    h6 = net.addHost( 'h6', mac="00:00:00:00:00:06", ip='192.168.2.6' )
    h7 = net.addHost( 'h7', mac="00:00:00:00:00:07", ip='192.168.2.7' )

    h8 = net.addHost( 'h8', mac="00:00:00:00:00:08", ip='192.168.2.8' )
    h9 = net.addHost( 'h9', mac="00:00:00:00:00:09", ip='192.168.2.9' )
    h10 = net.addHost( 'h10', mac="00:00:00:00:00:10", ip='192.168.2.10' )

    h11 = net.addHost( 'h11', mac="00:00:00:00:00:11", ip='192.168.2.11' )
    # h12 = net.addHost( 'h12', mac="00:00:00:00:00:12", ip='192.168.2.12' )
    # h13 = net.addHost( 'h13', mac="00:00:00:00:00:13", ip='192.168.2.13' )

    # hc = net.addHost( 'hc', mac="00:00:00:00:00:50", ip='192.168.2.50' )
    # hs1 = net.addHost( 'hs1', mac="00:00:00:00:00:51", ip='192.168.2.51' )
    # hs2 = net.addHost( 'hs2', mac="00:00:00:00:00:52", ip='192.168.2.52' )
    
    print "*** Creating Switchs"
    s35 = net.addSwitch( 's35', dpid='00:00:00:00:aa:bb:cc:35' )
    s32 = net.addSwitch( 's32', dpid='00:00:00:00:aa:bb:cc:32' )
    s15 = net.addSwitch( 's15', dpid='00:00:00:00:aa:bb:cc:15' )
    s14 = net.addSwitch( 's14', dpid='00:00:00:00:aa:bb:cc:14' )
    s02 = net.addSwitch( 's02', dpid='00:00:00:00:aa:bb:cc:02' )
    s17 = net.addSwitch( 's17', dpid='00:00:00:00:aa:bb:cc:17' )
    s38 = net.addSwitch( 's38', dpid='00:00:00:00:aa:bb:cc:38' )
    
    print "*** Creating Controller Openflow"
    c0 = RemoteController( 'c0', ip=_ip_remote_control, port=_port_remote_control )

    print "*** Connecting hosts"
    net.addLink(h1, s32, bw=_bw, use_htb=_use_htb)

    net.addLink(h2, s38, bw=_bw, use_htb=_use_htb)
    net.addLink(h3, s38, bw=_bw, use_htb=_use_htb)
    net.addLink(h4, s38, bw=_bw, use_htb=_use_htb)
    
    net.addLink(h5, s02, bw=_bw, use_htb=_use_htb)
    net.addLink(h6, s02, bw=_bw, use_htb=_use_htb)
    net.addLink(h7, s02, bw=_bw, use_htb=_use_htb)

    net.addLink(h8, s17, bw=_bw, use_htb=_use_htb)
    net.addLink(h9, s17, bw=_bw, use_htb=_use_htb)
    net.addLink(h10, s17, bw=_bw, use_htb=_use_htb)

    net.addLink(h11, s35, bw=_bw, use_htb=_use_htb)
    # net.addLink(h12, s35, bw=_bw, use_htb=_use_htb)
    # net.addLink(h13, s35, bw=_bw, use_htb=_use_htb)

    # net.addLink(hc, s32, bw=_bw, use_htb=_use_htb)
    # net.addLink(hs1, s14, bw=_bw, use_htb=_use_htb)
    # net.addLink(hs2, s15, bw=_bw, use_htb=_use_htb)

    print "*** Creating connection between switches"
    net.addLink(s35, s15, bw=_bw,latency=_latency,max_queue_size=_max_queue_size,use_htb=_use_htb)
    net.addLink(s35, s14, bw=_bw,latency=_latency,max_queue_size=_max_queue_size,use_htb=_use_htb)
    net.addLink(s32, s15, bw=_bw,latency=_latency,max_queue_size=_max_queue_size,use_htb=_use_htb)
    net.addLink(s32, s14, bw=_bw,latency=_latency,max_queue_size=_max_queue_size,use_htb=_use_htb)
    net.addLink(s15, s17, bw=_bw,latency=_latency,max_queue_size=_max_queue_size,use_htb=_use_htb)
    net.addLink(s15, s02, bw=_bw,latency=_latency,max_queue_size=_max_queue_size,use_htb=_use_htb)
    net.addLink(s14, s17, bw=_bw,latency=_latency,max_queue_size=_max_queue_size,use_htb=_use_htb)
    net.addLink(s14, s02, bw=_bw,latency=_latency,max_queue_size=_max_queue_size,use_htb=_use_htb)
    net.addLink(s02, s38, bw=_bw,latency=_latency,max_queue_size=_max_queue_size,use_htb=_use_htb)
    net.addLink(s17, s38, bw=_bw,latency=_latency,max_queue_size=_max_queue_size,use_htb=_use_htb)

    print "*** Starting network"
    net.build()
    c0.start()
    s35.start( [c0] )
    s15.start( [c0] )
    s17.start( [c0] )
    s14.start( [c0] )
    s32.start( [c0] )
    s02.start( [c0] )
    s38.start( [c0] )


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

    print "*** Stopping network"
    net.stop()
Example #29
0
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')
h3.setIP('10.3.0.1/16')

print h0.cmd('ifconfig')
c0.start()
c1.start()
c2.start()
c3.start()

s0.start([c0])
s1.start([c1])
s2.start([c2])
s3.start([c3])

dumpNodeConnections([s0, s1, s2, s3, h0, h1, h2, h3])
temp = l1.intf1
l1.delete()

h0.intfs = {}
h0.ports = {}
Example #30
0
def multiControllerNet():

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

    info("*** Creating switches\n")
    s1 = net.addSwitch('s1')  #switches for the data network
    s2 = net.addSwitch('s2')

    s5 = net.addSwitch('s5')
    s4 = net.addSwitch('s4')

    s3 = net.addSwitch('s3')  #switch for the control network

    info("*** Creating hosts\n")
    agent1 = net.addHost('agent1', ip='10.0.0.11')
    agent2 = net.addHost('agent2', ip='10.0.0.21')
    agent3 = net.addHost('agent3', ip='10.0.0.31')

    agent4 = net.addHost('agent4', ip='10.0.0.41')
    agent5 = net.addHost('agent5', ip='10.0.0.51')
    agent6 = net.addHost('agent6', ip='10.0.0.61')

    client1 = net.addHost('client1', ip='10.0.0.111')
    client2 = net.addHost('client2', ip='10.0.0.112')
    client3 = net.addHost('client3', ip='10.0.0.113')

    server1 = net.addHost('server1', ip='10.0.0.211')
    server2 = net.addHost('server2', ip='10.0.0.212')
    server3 = net.addHost('server3', ip='10.0.0.213')

    info("*** Creating data links\n")
    net.addLink(
        s1,
        client1,
    )
    net.addLink(s1, client2)
    net.addLink(s1, client3)

    net.addLink(s1, s4)

    net.addLink(s4, agent1)
    net.addLink(s4, agent3)
    net.addLink(s4, agent5)

    net.addLink(s1, s2, delay='50ms')

    net.addLink(s2, server1)
    net.addLink(s2, server2)
    net.addLink(s2, server3)

    net.addLink(s2, s5)

    net.addLink(s5, agent2)
    net.addLink(s5, agent4)
    net.addLink(s5, agent6)

    info("*** Creating control links\n")
    Link(agent1, s3, intfName1='eth1')
    Link(agent2, s3, intfName1='eth1')
    Link(agent3, s3, intfName1='eth1')
    Link(agent4, s3, intfName1='eth1')
    Link(agent5, s3, intfName1='eth1')
    Link(agent6, s3, intfName1='eth1')

    agent1.cmd('ifconfig eth1 192.168.100.1 netmask 255.255.255.0')
    agent2.cmd('ifconfig eth1 192.168.100.2 netmask 255.255.255.0')
    agent3.cmd('ifconfig eth1 192.168.100.3 netmask 255.255.255.0')
    agent4.cmd('ifconfig eth1 192.168.100.4 netmask 255.255.255.0')
    agent5.cmd('ifconfig eth1 192.168.100.5 netmask 255.255.255.0')
    agent6.cmd('ifconfig eth1 192.168.100.6 netmask 255.255.255.0')

    info("*** Starting network\n")
    net.build()

    makeTerms([
        agent1, agent2, agent3, agent4, agent5, agent6, server1, server2,
        server3, client1, client2, client3
    ])

    info("*** Creating controllers\n")
    local = net.addController('localctl',
                              port=6633)  #controller for control network
    local.start()
    s3.start([local])

    info("*** Assigning IP to host interface\n")
    subprocess.Popen('sudo ifconfig s3 192.168.100.10/24 up', shell=True)

    remote = RemoteController(
        'remotectl', ip='192.168.100.10',
        port=6663)  #controller for data network (floodlight IP)
    remote.start()
    s1.start([remote])
    s2.start([remote])
    s4.start([remote])
    s5.start([remote])

    CLI(net)

    #info( "*** Stopping network\n" )
    cleanUpScreens()
    local.stop()
    net.stop()
Example #31
0
def myNetwork():

    net = Mininet(topo=None, build=False, ipBase='10.0.0.0/24')

    info("""
Creating the folow topology:

               +------------+
+----+         | controller |                      +----+
| h1 |         +-----:------+                  /---| h3 |
+----+           +---:---+     +----+    +----+    +----+
      \----------| swof1 |-----| r2 |----| s1 |
                 +-------+     +----+    +----+    +----+
+----+              |                       |------| h4 |
| h2 |--------------|                              +----+
+----+
------------------------------------------------------------------------
DEVICE          NAME            IP:PORT         	DESCRIPTION
------------------------------------------------------------------------
switch_OpenFlow swof1           10.0.0.250/24      
controller      controller      127.0.0.1:6633
r2          	r2            	10.0.0.254/24
            	            	192.168.111.254/24
h1          	h1          	10.0.0.1/24
h2          	h2          	10.0.0.2/24
h3          	h3          	192.168.111.1/24
h4          	h4          	192.168.111.2/24
------------------------------------------------------------------------
""")

    info('*** Adding controller\n')
    controller = RemoteController('controller',
                                  ip='127.0.0.1',
                                  protocol='tcp',
                                  port=6633)
    net.addController(controller)

    info('*** Add switches\n')
    swof1 = net.addSwitch('swof1', cls=OVSKernelSwitch)
    s1 = net.addSwitch('s1', cls=OVSKernelSwitch, failMode='standalone')

    info('*** Add router\n')
    r2 = net.addHost('r2', cls=Node, ip='10.0.0.254/24')

    info('*** Add hosts\n')
    h1 = net.addHost('h1',
                     cls=Host,
                     ip='10.0.0.1/24',
                     defaultRoute='via 10.0.0.254')
    h2 = net.addHost('h2',
                     cls=Host,
                     ip='10.0.0.2/24',
                     defaultRoute='via 10.0.0.254')
    h3 = net.addHost('h3',
                     cls=Host,
                     ip='192.168.111.1/24',
                     defaultRoute='via 192.168.111.254')
    h4 = net.addHost('h4',
                     cls=Host,
                     ip='192.168.111.2/24',
                     defaultRoute='via 192.168.111.254')

    info('*** Add links\n')
    net.addLink(swof1, r2)
    net.addLink(s1, r2)

    net.addLink(swof1, h1)
    net.addLink(swof1, h2)

    net.addLink(s1, h3)
    net.addLink(s1, h4)

    info('*** Starting network\n')
    net.build()
    info('*** Starting controllers\n')

    info('*** Starting controllers\n')
    for controller in net.controllers:
        controller.start()

    info('*** Starting switches\n')
    net.get('swof1').start([controller])
    net.get('s1').start([])

    info('*** Post configure switches and hosts\n')
    swof1.cmd('ifconfig swof1 10.0.0.250/24 up')

    info('*** Config router\n')
    r2.cmd('sysctl -w net.ipv4.ip_forward=1')
    r2.cmd('ifconfig r2-eth0 down && ifconfig r2-eth0 10.0.0.254/24 up')
    r2.cmd('ifconfig r2-eth1 down && ifconfig r2-eth1 192.168.111.254/24 up')

    CLI(net)

    info('########## Stopping CLI ##########\n')
    net.stop()
Example #32
0
if '__main__' == __name__:
    net = Mininet(switch=OVSSwitch)

    c0 = RemoteController('c0', '127.0.0.1', 6633)
    c1 = RemoteController('c1', '127.0.0.1', 6632)
    net.addController(c0)
    net.addController(c1)

    s1 = net.addSwitch('s1')

    h1 = net.addHost('h1')
    h2 = net.addHost('h2')
    h3 = net.addHost('h3')

    Link(s1, h1)
    Link(s1, h2)
    Link(s1, h3)

    net.build()

    c0.start()
    c1.start()
    s1.start([c0, c1])

    ofp_version(s1, ['OpenFlow13'])

    CLI(net)

    net.stop()
Example #33
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)
Example #34
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()
Example #35
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()
Example #36
0
def multiControllerNet():
    "Create a network from semi-scratch with multiple controllers."

    net = Containernet(controller=Controller, switch=OVSSwitch, link=TCLink)

    info("*** Creating (reference) controllers\n")
    c = RemoteController('c', ip='172.17.0.1', port=6653)

    info("*** Creating switches\n")
    s1 = net.addSwitch('s1')
    s2 = net.addSwitch('s2')

    info("*** Creating hosts\n")
    #agent1 = net.addHost('agent1', ip='10.0.0.11')
    #agent2 = net.addHost('agent2', ip='10.0.0.21')
    home_path = os.path.expanduser('~')
    agent1 = net.addDocker('agent1',
                           ip='10.0.0.11',
                           dimage="khayamgondal/sosagent:v4",
                           volumes=["" + home_path + "/SOSAgent:/sos-agent"])
    agent2 = net.addDocker('agent2',
                           ip='10.0.0.21',
                           dimage="khayamgondal/sosagent:v4",
                           volumes=["" + home_path + "/SOSAgent:/sos-agent"])
    client1 = net.addDocker('client1',
                            ip='10.0.0.111',
                            dimage="khayamgondal/sosagent:v4")
    server1 = net.addDocker('server1',
                            ip='10.0.0.211',
                            dimage="khayamgondal/sosagent:v4")

    #controller = net.addDocker('controller', ip='10.0.0.69', dimage="khayamgondal/sosagent:v4", volumes=["/home/ubuntu/sos-for-floodlight:/sos-for-floodlight"])
    #client1 = net.addHost('client1', ip='10.0.0.111')
    #server1 = net.addHost('server1', ip='10.0.0.211')

    info("*** Creating links\n")
    net.addLink(s1, client1, port1=1, port2=1)
    net.addLink(s1, agent1, port1=2, port2=1)

    net.addLink(s1, s2, delay='100ms', port1=3, port2=3)

    net.addLink(s2, server1, port1=1, port2=1)
    net.addLink(s2, agent2, port1=2, port2=1)

    #net.addLink(controller, s1, port1=0, port2=5)
    #net.addLink(controller, s2, port1=1, port2=5)

    info("*** Starting network\n")
    net.build()
    c.start()
    s1.start([c])
    s2.start([c])

    #info( "*** Testing network\n" )
    #net.pingAll()

    #info( "*** Running CLI\n" )
    CLI(net)

    #info( "*** Stopping network\n" )
    net.stop()
Example #37
0
def multiControllerNet():

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

    info( "*** Creating switches\n" )
    s1 = net.addSwitch( 's1' ) #switches for the data network
    s2 = net.addSwitch( 's2' )

    s3 = net.addSwitch( 's3' ) #switch for the control network

    info( "*** Creating hosts\n" )
    agent1 = net.addHost('agent1', ip='10.0.0.11')
    agent2 = net.addHost('agent2', ip='10.0.0.21')

    client1 = net.addHost('client1', ip='10.0.0.111')
    server1 = net.addHost('server1', ip='10.0.0.211')

    #controller = net.addHost('controller', ip='10.0.2.150')


    #controller.cmd("cd  /home/vagrant/sos-for-floodlight && java -jar target/floodlight.jar")

    info( "*** Creating data links\n" )

    net.addLink( s1, client1)
    net.addLink(s1, agent1)
    net.addLink( s1, s2 , delay='100ms')
    net.addLink(s2,server1)
    net.addLink(s2,agent2)

    info( "*** Creating control links\n" )
    Link(agent1, s3, intfName1='agent1-eth1')
    agent1.cmd('ifconfig agent1-eth1 192.168.100.1 netmask 255.255.255.0')
    Link(agent2, s3, intfName1='agent2-eth1')
    agent2.cmd('ifconfig agent2-eth1 192.168.100.2 netmask 255.255.255.0')


    info( "*** Starting network\n" )
    net.build()

    makeTerms([agent1, agent2, server1, client1])

    info( "*** Creating controllers\n" )
    local = net.addController( 'localctl', port=6633 ) #controller for control network
    local.start()
    s3.start([local])

    info("*** Assigning IP to host interface\n")
    #call ('sudo', '/sbin/ifconfig', 's3', '192.168.100.10/24', 'up', shell=True)
    subprocess.Popen('sudo ifconfig s3 192.168.100.10/24 up', shell=True)

    remote = RemoteController( 'remotectl', ip='192.168.100.10',
                               port=6653 ) #controller for data network (floodlight IP)
    remote.start()
    s1.start( [ remote ] )
    s2.start( [ remote] )

    #info( "*** Testing network\n" )
    #net.pingAll()

    #info( "*** Running CLI\n" )
    CLI( net )

    #info( "*** Stopping network\n" )
    cleanUpScreens()
    net.stop()
    local.stop()
Example #38
0
def myNetwork():

    net = Mininet(topo=None, build=False, ipBase='10.0.0.0/8')

    info("""
Creating the folow topology:

                   +------------+
                   | controller |            +--------+
                   +-----:------+   /--------| client |
+-------+            +---:---+-----/         +--------+
| server |-----------| swof1 |
+--------+           +-------+----\          +---------+
                                   \---------|  guest  |
                                             +---------+

------------------------------------------------------------------------
DEVICE          NAME            IP:PORT         	DESCRIPTION
------------------------------------------------------------------------
switch_OpenFlow swof1           10.0.0.254/8      
controller      controller      127.0.0.1:6633

server          server          10.0.0.1/8
client          client          10.0.0.2/8
guest           guest           10.0.0.3/8
------------------------------------------------------------------------
""")

    info('*** Adding controller\n')
    controller = RemoteController('controller',
                                  ip='127.0.0.1',
                                  protocol='tcp',
                                  port=6633)
    net.addController(controller)

    info('*** Add switches\n')
    swof1 = net.addSwitch('swof1', cls=OVSKernelSwitch)

    info('*** Add hosts\n')
    server = net.addHost('server',
                         cls=Host,
                         ip='10.0.0.1',
                         defaultRoute=None,
                         mac='00:00:00:00:00:01')
    client = net.addHost('client',
                         cls=Host,
                         ip='10.0.0.2',
                         defaultRoute=None,
                         mac='00:00:00:00:00:02')
    guest = net.addHost('guest',
                        cls=Host,
                        ip='10.0.0.3',
                        defaultRoute=None,
                        mac='00:00:00:00:00:03')

    info('*** Add links\n')
    net.addLink(swof1, server)
    net.addLink(swof1, client)
    net.addLink(swof1, guest)

    info('*** Starting network\n')
    net.build()
    info('*** Starting controllers\n')
    for controller in net.controllers:
        controller.start()

    info('*** Starting switches\n')
    net.get('swof1').start([controller])

    info('*** Post configure switches and hosts\n')
    swof1.cmd('ifconfig swof1 10.0.0.254')

    CLI(net)

    info('########## Stopping CLI ##########\n')
    net.stop()
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' )
h3.setIP( '10.3.0.1/16' )

print h0.cmd('ifconfig')
c0.start()
c1.start()
c2.start()
c3.start()

s0.start( [ c0 ] )
s1.start( [ c1 ] )
s2.start( [ c2 ] )
s3.start( [ c3 ] )

dumpNodeConnections([s0,s1,s2,s3,h0,h1,h2,h3])
temp = l1.intf1
l1.delete()

h0.intfs = {}
h0.ports = {}
Example #40
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()
Example #41
0
from mininet.net import Mininet
from mininet.node import RemoteController, OVSSwitch
import netconstants as netconst
from mininet.cli import CLI

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)
    c_any = RemoteController('c_any', netconst.CTLR_AC_IP, netconst.PORT_CTLR)
    #c_any = RemoteController('c_any', netconst.CTLR_AC_IP, netconst.PORT_CTLR)
    net.addController(c_any)
    # add switches
    s1 = net.addSwitch('s1')
    # add host
    h1 = net.addHost('h1')
    net.addLink(s1, h1)

    # build net
    net.build()
    net.start()
    # start: Overridden to do nothing.
    c_any.start()
    ofp_version(s1, ['OpenFlow13'])
    # add command line interface
    CLI(net)
Example #42
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()
Example #43
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()