def topology():
    "Create a network."
    net = Mininet( controller=Controller, link=TCLink, switch=OVSKernelSwitch,
                   accessPoint=OVSKernelAP )

    print "*** Creating nodes"
    sta1 = net.addStation('sta1', wlans=2, ip='10.0.0.2/8', max_x=120, max_y=50,
                           min_v=1.4, max_v=1.6)
    h1 = net.addHost( 'h1', mac='00:00:00:00:00:01', ip='10.0.0.1/8' )
    ap1 = net.addAccessPoint( 'ap1', ssid='ssid_ap1', mode= 'g', channel=6, position='70,25,0' )
    ap2 = net.addAccessPoint( 'ap2', ssid='ssid_ap2', mode= 'g', channel=1, position='30,25,0' )
    ap3 = net.addAccessPoint( 'ap3', ssid='ssid_ap3', mode= 'g', channel=11, position='110,25,0' )
    s4 = net.addSwitch( 's4', mac='00:00:00:00:00:10' )
    c1 = net.addController( 'c1', controller=Controller )

    print "*** Configuring wifi nodes"
    net.configureWifiNodes()

    print "*** Associating and Creating links"
    net.addLink(ap1, s4)
    net.addLink(ap2, s4)
    net.addLink(ap3, s4)
    net.addLink(s4, h1)

    sta1.cmd('modprobe bonding mode=3')
    sta1.cmd('ip link add bond0 type bond')
    sta1.cmd('ip link set bond0 address 02:01:02:03:04:08')
    sta1.cmd('ip link set sta1-wlan0 down')
    sta1.cmd('ip link set sta1-wlan0 address 00:00:00:00:00:11')
    sta1.cmd('ip link set sta1-wlan0 master bond0')
    sta1.cmd('ip link set sta1-wlan1 down')
    sta1.cmd('ip link set sta1-wlan1 address 00:00:00:00:00:12')
    sta1.cmd('ip link set sta1-wlan1 master bond0')
    sta1.cmd('ip addr add 10.0.0.10/8 dev bond0')
    sta1.cmd('ip link set bond0 up')

    'seed'
    net.seed(12)

    'plotting graph'
    net.plotGraph(max_x=140, max_y=140)

    net.startMobility(startTime=0, model='RandomDirection')

    print "*** Starting network"
    net.build()
    c1.start()
    s4.start( [c1] )
    ap1.start( [c1] )
    ap2.start( [c1] )
    ap3.start( [c1] )

    sta1.cmd('ip addr del 10.0.0.2/8 dev sta1-wlan0')
    os.system('ovs-ofctl add-flow s4 actions=normal')

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

    print "*** Stopping network"
    net.stop()
def topology():

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

    print "*** Creating nodes"
    sta1 = net.addStation( 'sta1', mac='00:00:00:00:00:02', ip='10.0.0.2/8' )
    sta2 = net.addStation( 'sta2', mac='00:00:00:00:00:03', ip='10.0.0.3/8' )
    ap1 = net.addBaseStation( 'ap1', ssid= 'new-ssid', mode= 'g', channel= '1', position='50,50,0' )
    c1 = net.addController( 'c1', controller=Controller )

    print "*** Associating and Creating links"
    net.addLink(ap1, sta1)
    net.addLink(ap1, sta2)
    
    print "*** Starting network"
    net.build()
    c1.start()
    ap1.start( [c1] )
    
    """uncomment to plot graph"""
    net.plotGraph(max_x=100, max_y=100)

    """Seed"""
    net.seed(20) 

    "*** Available models: RandomWalk, TruncatedLevyWalk, RandomDirection, RandomWayPoint, GaussMarkov, ReferencePoint, TimeVariantCommunity ***"
    net.startMobility(startTime=0, model='RandomDirection', max_x=60, max_y=60, min_v=0.5, max_v=0.5)
   
    print "*** Running CLI"
    CLI( net )

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

    "Create a network."
    net = Mininet(controller=Controller, link=TCLink, accessPoint=OVSKernelAP)

    print "*** Creating nodes"
    net.addStation('sta1', antennaHeight='1', antennaGain='5')
    net.addStation('sta2', antennaHeight='1', antennaGain='5')
    ap1 = net.addAccessPoint('ap1', ssid='new-ssid', equipmentModel='DI524',
                             mode='g', channel='1', position='50,50,0')
    c1 = net.addController('c1', controller=Controller)

    net.propagationModel(model="logDistance", exp=4)

    print "*** Configuring wifi nodes"
    net.configureWifiNodes()

    net.plotGraph(max_x=100, max_y=100)

    net.seed(1)

    net.startMobility(time=0, model='RandomWayPoint', max_x=100, max_y=100,
                      min_v=0.5, max_v=0.5)

    print "*** Starting network"
    net.build()
    c1.start()
    ap1.start([c1])

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

    print "*** Stopping network"
    net.stop()
def topology():
    "Create a network."
    net = Mininet( controller=Controller, link=TCLink, switch=OVSKernelSwitch )

    print "*** Creating nodes"
    sta1 = net.addStation( 'sta1', wlans=2, ip='10.0.0.2/8' )
    h1 = net.addHost( 'h1', mac='00:00:00:00:00:01', ip='10.0.0.1/8' )
    h2 = net.addHost( 'h2', mac='00:00:00:00:00:11', ip='10.0.0.11/8' )
    ap1 = net.addBaseStation( 'ap1', ssid='ssid_ap1', mode= 'g', channel=6, position='70,25,0' )
    ap2 = net.addBaseStation( 'ap2', ssid='ssid_ap2', mode= 'g', channel=1, position='30,25,0' )
    ap3 = net.addBaseStation( 'ap3', ssid='ssid_ap3', mode= 'g', channel=11, position='110,25,0' )
    s4 = net.addSwitch( 's4', mac='00:00:00:00:00:10' )
    c1 = net.addController( 'c1', controller=Controller )

    print "*** Associating and Creating links"
    net.addLink(ap1, s4)
    net.addLink(ap2, s4)
    net.addLink(ap3, s4)
    net.addLink(s4, h1)
    net.addLink(s4, h2)

    sta1.cmd('modprobe bonding mode=3')
    sta1.cmd('ip link add bond0 type bond')
    sta1.cmd('ip link set bond0 address 02:01:02:03:04:08')
    sta1.cmd('ip link set sta1-wlan0 down')
    sta1.cmd('ip link set sta1-wlan0 address 00:00:00:00:00:11')
    sta1.cmd('ip link set sta1-wlan0 master bond0')
    sta1.cmd('ip link set sta1-wlan1 down')
    sta1.cmd('ip link set sta1-wlan1 address 00:00:00:00:00:12')
    sta1.cmd('ip link set sta1-wlan1 master bond0')
    sta1.cmd('ip addr add 10.0.0.10/8 dev bond0')
    sta1.cmd('ip link set bond0 up')

    print "*** Starting network"
    net.build()
    c1.start()
    s4.start( [c1] )
    ap1.start( [c1] )
    ap2.start( [c1] )
    ap3.start( [c1] )

    sta1.cmd('ip addr del 10.0.0.2/8 dev sta1-wlan0')
    os.system('ovs-ofctl add-flow s4 actions=normal')

    """seed"""
    net.seed(12)

    """uncomment to plot graph"""
    net.plotGraph(max_x=140, max_y=140)
    
    "*** Available models: RandomWalk, TruncatedLevyWalk, RandomDirection, RandomWaypoint, GaussMarkov ***"
    net.startMobility(startTime=0, model='RandomDirection', max_x=120, max_y=50, min_v=0.4, max_v=0.6)

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

    print "*** Stopping network"
    net.stop()
def topology():

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

    print "*** Creating nodes"
    h1 = net.addHost( 'h1', mac='00:00:00:00:00:01', ip='10.0.0.1/8' )
    sta1 = net.addStation( 'sta1', mac='00:00:00:00:00:02', ip='10.0.0.2/8' )
    sta2 = net.addStation( 'sta2', wlans=2, ip='10.0.0.3/8' )
    sta3 = net.addStation( 'sta3', mac='00:00:00:00:00:04', ip='10.0.0.4/8' )
    sta4 = net.addStation( 'sta4', wlans=2, ip='10.0.0.5/8' )
    sta5 = net.addStation( 'sta5', mac='00:00:00:00:00:06', ip='10.0.0.6/8' )
    sta6 = net.addStation( 'sta6', wlans=2,ip='10.0.0.7/8' )

    ap1 = net.addBaseStation( 'ap1', ssid= 'new-ssid1', mode= 'g', channel= '1', position='30,30,0', range= 30)
    ap2 = net.addBaseStation( 'ap2', ssid= 'new-ssid2', mode= 'g', channel= '2', position='60,30,0', range= 40 )
    ap3 = net.addBaseStation( 'ap3', ssid= 'new-ssid3', mode= 'g', channel= '3', position='30,50,0', range= 35 )
    ap4 = net.addBaseStation( 'ap4', ssid= 'new-ssid4', mode= 'g', channel= '4', position='60,50,0', range= 45 )
    c1 = net.addController( 'c1', controller=Controller )


    print "*** Associating and Creating links"
    net.addLink(ap1, ap2)
    net.addLink(ap1, ap3)
    net.addLink(ap1, ap4)
    net.addLink(ap2, ap3)
    net.addLink(ap2, ap4)
    net.addLink(ap3, ap4)

    net.addLink(ap1, h1)
    net.addLink(ap1, sta1)
    net.addLink(ap1, sta2)
    net.addLink(ap2, sta3)
    net.addLink(ap3, sta4)
    net.addLink(ap4, sta5)
    net.addLink(ap4, sta6)
    print "*** Starting network"
    net.build()
    c1.start()
    ap1.start( [c1] )
    ap2.start( [c1] )
    ap3.start( [c1] )
    ap4.start( [c1] )
    
    net.seed(10)

    """uncomment to plot graph"""
    net.plotGraph(max_x=100, max_y=100)

    net.startMobility(startTime=0, model='RandomWayPoint', max_x=60, max_y=60, min_v=0.1, max_v=0.5, AC='ssf')

   

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

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

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

    print "*** Creating nodes"
    for n in range(10):
	staList.append(n)
	staList[n] = net.addStation( 'sta%s' % (n+1), wlans=2, mac='00:00:00:00:00:%s' % (n+1), ip='192.168.0.%s/24' % (n+1) )
    phyap1 = net.addPhysicalBaseStation( 'phyap1', ssid= 'SBRC16-MininetWiFi', mode= 'g', channel= '1', position='50,115,0', phywlan='wlan11' )
    sta11 = net.addStation( 'sta11', ip='10.0.0.111/8', position='120,200,0')
    ap2 = net.addAccessPoint( 'ap2', ssid= 'ap2', mode= 'g', channel= '11', position='100,175,0' )
    ap3 = net.addAccessPoint( 'ap3', ssid= 'ap3', mode= 'g', channel= '6', position='150,50,0' )
    ap4 = net.addAccessPoint( 'ap4', ssid= 'ap4', mode= 'g', channel= '1', position='175,150,0' )
    c1 = net.addController( 'c1', controller=Controller, port=6653 )
    root = Node( 'root', inNamespace=False )

    print "*** Configuring wifi nodes"
    net.configureWifiNodes()

    """uncomment to plot graph"""
    net.plotGraph(max_x=240, max_y=240)

    """Routing"""
    net.meshRouting('custom')

    """Seed"""
    net.seed(20)

    print "*** Associating and Creating links"
    for sta in staList:
        net.addMesh(sta, ssid='meshNet')
    net.addLink(phyap1, ap2)
    net.addLink(ap2, ap3)
    net.addLink(ap3, ap4)

    print "*** Starting network"
    net.build()
    c1.start()
    phyap1.start( [c1] )
    ap2.start( [c1] )
    ap3.start( [c1] )
    ap4.start( [c1] )

    ip = 201
    for sta in staList:
        sta.setIP('10.0.0.%s/8' % ip, intf="%s-wlan1" % sta)
        ip+=1

    "*** Available models: RandomWalk, TruncatedLevyWalk, RandomDirection, RandomWayPoint, GaussMarkov, ReferencePoint, TimeVariantCommunity ***"
    net.startMobility(startTime=0, model='RandomWalk', max_x=200, max_y=220, min_v=0.1, max_v=0.2)

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

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

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

    print "*** Creating nodes"
    for n in range(10):
	sta.append(n)
	sta[n] = net.addStation( 'sta%s' % (n+1), wlans=2, mac='00:00:00:00:00:%s' % (n+1), ip='192.168.0.%s/24' % (n+1) )
    phyap1 = net.addPhysicalBaseStation( 'phyap1', ssid= 'SBRC16-MininetWiFi', mode= 'g', channel= '1', position='50,115,0', wlan='wlan11' )
    sta11 = net.addStation( 'sta11', ip='10.0.0.111/8', position='120,200,0')
    ap2 = net.addBaseStation( 'ap2', ssid= 'ap2', mode= 'g', channel= '11', position='100,175,0' )
    ap3 = net.addBaseStation( 'ap3', ssid= 'ap3', mode= 'g', channel= '6', position='150,50,0' )
    ap4 = net.addBaseStation( 'ap4', ssid= 'ap4', mode= 'g', channel= '1', position='175,150,0' )
    c1 = net.addController( 'c1', controller=Controller, port=6653 )
    root = Node( 'root', inNamespace=False )

    print "*** Creating links"
    for station in sta:
        net.addMesh(station, ssid='meshNet')

    """uncomment to plot graph"""
    net.plotGraph(max_x=240, max_y=240)

    """Routing"""
    net.meshRouting('custom')

    """Seed"""
    net.seed(20)

    print "*** Associating and Creating links"
    net.addLink(phyap1, ap2)
    net.addLink(ap2, ap3)
    net.addLink(ap3, ap4)

    print "*** Starting network"
    net.build()

    c1.start()
    phyap1.start( [c1] )
    ap2.start( [c1] )
    ap3.start( [c1] )
    ap4.start( [c1] )

    ip = 201
    for station in sta:
        station.cmd('ifconfig %s-wlan1 10.0.0.%s/8' % (station, ip))
        ip+=1

    "*** Available models: RandomWalk, TruncatedLevyWalk, RandomDirection, RandomWayPoint, GaussMarkov, ReferencePoint, TimeVariantCommunity ***"
    net.startMobility(startTime=0, model='RandomWalk', max_x=200, max_y=220, min_v=0.1, max_v=0.2)

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

    print "*** Stopping network"
    net.stop()
def topology():
    "Create a network."
    net = Mininet( controller=Controller, link=TCLink, switch=OVSKernelSwitch )

    print "*** Creating nodes"
    sta1 = net.addStation( 'sta1', mac='00:00:00:00:00:02', ip='10.0.0.2/8' )
    sta2 = net.addStation( 'sta2', mac='00:00:00:00:00:03', ip='10.0.0.3/8' )
    sta3 = net.addStation( 'sta3', mac='00:00:00:00:00:04', ip='10.0.0.4/8' )
    sta4 = net.addStation( 'sta4', mac='00:00:00:00:00:05', ip='10.0.0.5/8' )
    sta5 = net.addStation( 'sta5', mac='00:00:00:00:00:06', ip='10.0.0.6/8' )
    sta6 = net.addStation( 'sta6', mac='00:00:00:00:00:07', ip='10.0.0.7/8' )
    sta7 = net.addStation( 'sta7', mac='00:00:00:00:00:08', ip='10.0.0.8/8' )
    sta8 = net.addStation( 'sta8', mac='00:00:00:00:00:09', ip='10.0.0.9/8' )
    sta9 = net.addStation( 'sta9', mac='00:00:00:00:00:10', ip='10.0.0.10/8' )
    sta10 = net.addStation( 'sta10', mac='00:00:00:00:00:11', ip='10.0.0.11/8' )
    ap1 = net.addBaseStation( 'ap1', ssid= 'new-ssid1', mode= 'g', channel= '1', position='50,50,0' )
    ap2 = net.addBaseStation( 'ap2', ssid= 'new-ssid2', mode= 'g', channel= '1', position='70,50,0', range=30 ) #range: set the AP range
    ap3 = net.addBaseStation( 'ap3', ssid= 'new-ssid3', mode= 'g', channel= '1', position='90,50,0' )
    c1 = net.addController( 'c1', controller=Controller )

    print "*** Associating and Creating links"
    net.addLink(ap1, ap2)
    net.addLink(ap2, ap3)
    
    print "*** Starting network"
    net.build()
    c1.start()
    ap1.start( [c1] )
    ap2.start( [c1] )
    ap3.start( [c1] )
    
    """uncomment to plot graph"""
    net.plotGraph(max_x=120, max_y=120)

    """association control"""
    net.associationControl('ssf')

    """Seed"""
    net.seed(1) 

    """ *** Available models: 
                RandomWalk, TruncatedLevyWalk, RandomDirection, RandomWayPoint, GaussMarkov
	*** Association Control (AC) - mechanism that optimizes the use of the APs:
                llf (Least-Loaded-First)
                ssf (Strongest-Signal-First)"""
    net.startMobility(startTime=0, model='RandomWayPoint', max_x=120, max_y=120, min_v=0.3, max_v=0.5)
   
    print "*** Running CLI"
    CLI( net )

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

    "Create a network."
    net = Mininet(controller=Controller,
                  link=TCLink,
                  accessPoint=OVSKernelAP,
                  useWmediumd=True)

    print "*** Creating nodes"
    ap1 = net.addAccessPoint('ap1',
                             ssid='new-ssid',
                             mode='a',
                             channel='36',
                             range=100,
                             position='50,50,0')
    sta1 = net.addStation('sta1', mac='00:00:00:00:00:02', ip='10.0.0.2/8')
    sta2 = net.addStation('sta2', mac='00:00:00:00:00:03', ip='10.0.0.3/8')
    c1 = net.addController('c1', controller=Controller)

    print "*** Configuring wifi nodes"
    net.configureWifiNodes()

    print "*** Configuring Propagation Model"
    net.propagationModel("logDistancePropagationLossModel", exp=3)

    print "*** Associating and Creating links"
    net.addLink(ap1, sta1)
    net.addLink(ap1, sta2)

    print "*** Starting network"
    net.build()
    c1.start()
    ap1.start([c1])
    """uncomment to plot graph"""
    net.plotGraph(max_x=100, max_y=100)
    """Seed"""
    net.seed(20)

    "*** Available models: RandomWalk, TruncatedLevyWalk, RandomDirection, RandomWayPoint, GaussMarkov, ReferencePoint, TimeVariantCommunity ***"
    net.startMobility(startTime=0,
                      model='RandomDirection',
                      max_x=100,
                      max_y=100,
                      min_v=0.5,
                      max_v=0.8)

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

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

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

    print "*** Creating nodes"
    car1 = net.addVehicle( 'car1', wlans=2, mac='00:00:00:00:00:01', ip='10.0.0.1/8', min_speed=1, max_speed=5 )
    car2 = net.addVehicle( 'car2', wlans=2, mac='00:00:00:00:00:02', ip='10.0.0.2/8', min_speed=5, max_speed=10 )
    car3 = net.addVehicle( 'car3', mac='00:00:00:00:00:03', ip='10.0.0.3/8', min_speed=10, max_speed=15 )
    car4 = net.addVehicle( 'car4', mac='00:00:00:00:00:04', ip='10.0.0.4/8', min_speed=15, max_speed=20 )
    car5 = net.addVehicle( 'car5', mac='00:00:00:00:00:05', ip='10.0.0.5/8', min_speed=15, max_speed=20 )
    bs1 = net.addBaseStation( 'BS1', ssid= 'new-ssid1', mode= 'g', channel= '1' )
    bs2 = net.addBaseStation( 'BS2', ssid= 'new-ssid2', mode= 'g', channel= '6' )
    bs3 = net.addBaseStation( 'BS3', ssid= 'new-ssid3', mode= 'g', channel= '11' )
    c1 = net.addController( 'c1', controller=Controller )

    print "*** Associating and Creating links"
    net.addMesh(car1, ssid='mesh')
    net.addMesh(car2, ssid='mesh')
    net.addMesh(car3, ssid='mesh')
    net.addMesh(car4, ssid='mesh')
    net.addMesh(car5, ssid='mesh')
    net.addLink(bs1, bs2)
    net.addLink(bs1, bs3)
       
    print "*** Starting network"
    net.build()
    c1.start()
    bs1.start( [c1] )
    bs2.start( [c1] )
    bs3.start( [c1] )
    
    """uncomment to plot graph"""
    net.plotGraph(max_x=500, max_y=500)

    """Number of Roads"""
    net.roads(4)

    """Seed"""
    net.seed(20) 

    """Start Mobility"""
    net.startMobility(startTime=0)
   
    print "*** Running CLI"
    CLI( net )

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

    "Create a network."
    net = Mininet(controller=Controller, link=TCLink, accessPoint=OVSKernelAP)

    print "*** Creating nodes"
    sta1 = net.addStation('sta1')
    sta2 = net.addStation('sta2')
    ap1 = net.addAccessPoint('ap1',
                             ssid='new-ssid',
                             equipmentModel='DI524',
                             mode='g',
                             channel='1',
                             position='50,50,0')
    c1 = net.addController('c1', controller=Controller)

    "*** Available propagation models: friisPropagationLossModel, twoRayGroundPropagationLossModel, logDistancePropagationLossModel ***"
    net.propagationModel('friisPropagationLossModel', sL=2)

    print "*** Configuring wifi nodes"
    net.configureWifiNodes()

    print "*** Associating and Creating links"
    net.addLink(ap1, sta1)
    net.addLink(ap1, sta2)

    print "*** Starting network"
    net.build()
    c1.start()
    ap1.start([c1])
    """plotting graph"""
    net.plotGraph(max_x=100, max_y=100)
    """Seed"""
    net.seed(1)

    "*** Available mobility models: RandomWalk, TruncatedLevyWalk, RandomDirection, RandomWayPoint, GaussMarkov ***"
    net.startMobility(time=0,
                      model='RandomWayPoint',
                      max_x=100,
                      max_y=100,
                      min_v=0.5,
                      max_v=0.5)

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

    print "*** Stopping network"
    net.stop()
def topology():

    "Create a network."
    net = Mininet(controller=Controller,
                  link=TCLink,
                  accessPoint=OVSKernelAP,
                  enable_wmediumd=True)

    print "*** Creating nodes"
    ap1 = net.addAccessPoint('ap1',
                             ssid='new-ssid',
                             mode='a',
                             channel='36',
                             position='150,150,0')
    net.addStation('sta1', mac='00:00:00:00:00:02', ip='10.0.0.2/8')
    net.addStation('sta2', mac='00:00:00:00:00:03', ip='10.0.0.3/8')
    c1 = net.addController('c1', controller=Controller)

    print "*** Configuring Propagation Model"
    net.propagationModel("logDistancePropagationLossModel", exp=3)

    print "*** Configuring wifi nodes"
    net.configureWifiNodes()

    net.plotGraph(max_x=300, max_y=300)

    net.seed(20)

    net.startMobility(time=0,
                      model='RandomDirection',
                      max_x=300,
                      max_y=300,
                      min_v=0.5,
                      max_v=0.8)

    print "*** Starting network"
    net.build()
    c1.start()
    ap1.start([c1])

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

    print "*** Stopping network"
    net.stop()
def topology():

    "Create a network."
    net = Mininet(controller=RemoteController,
                  link=TCLink,
                  accessPoint=OVSKernelAP)

    print "*** Creating nodes"
    sta1 = net.addStation('sta1', mac='00:00:00:00:00:02', ip='10.0.0.2/8')
    sta2 = net.addStation('sta2', mac='00:00:00:00:00:03', ip='10.0.0.3/8')
    ap1 = net.addAccessPoint('ap1',
                             ssid='new-ssid',
                             mode='g',
                             channel='1',
                             position='50,50,0')
    c1 = net.addController('c1', controller=RemoteController, ip='127.0.0.1')

    print "*** Configuring wifi nodes"
    net.configureWifiNodes()
    """plotting graph"""
    net.plotGraph(max_x=100, max_y=100)
    """Seed"""
    net.seed(20)

    "*** Available models: RandomWalk, TruncatedLevyWalk, RandomDirection, RandomWayPoint, GaussMarkov, ReferencePoint, TimeVariantCommunity ***"
    net.startMobility(time=0,
                      model='RandomDirection',
                      max_x=100,
                      max_y=100,
                      min_v=0.5,
                      max_v=0.8)

    print "*** Starting network"
    net.build()
    c1.start()
    ap1.start([c1])

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

    print "*** Stopping network"
    net.stop()
def topology():

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

    print "*** Creating nodes"
    sta1 = net.addStation('sta1', mac='00:00:00:00:00:02', ip='10.0.0.2/8')
    sta2 = net.addStation('sta2', mac='00:00:00:00:00:03', ip='10.0.0.3/8')
    ap1 = net.addBaseStation('ap1',
                             ssid='new-ssid',
                             mode='g',
                             channel='1',
                             position='50,50,0')
    c1 = net.addController('c1', controller=Controller)

    print "*** Associating and Creating links"
    net.addLink(ap1, sta1)
    net.addLink(ap1, sta2)

    print "*** Starting network"
    net.build()
    c1.start()
    ap1.start([c1])
    """uncomment to plot graph"""
    net.plotGraph(max_x=100, max_y=100)
    """Seed"""
    net.seed(20)

    "*** Available models: RandomWalk, TruncatedLevyWalk, RandomDirection, RandomWayPoint, GaussMarkov, ReferencePoint, TimeVariantCommunity ***"
    #    net.startMobility(startTime=0, model='RandomWalk', max_x=60, max_y=60, min_v=0.1, max_v=0.1)
    net.startMobility(startTime=0,
                      model='RandomDirection',
                      max_x=60,
                      max_y=60,
                      min_v=0.1,
                      max_v=0.1)

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

    print "*** Stopping network"
    net.stop()
Example #15
0
def topology(mobility):
    "Create a network."
    net = Mininet(enable_wmediumd=True, enable_interference=True)

    print "*** Creating nodes"
    if mobility:
        sta1 = net.addStation('sta1')
        sta2 = net.addStation('sta2')
        sta3 = net.addStation('sta3')
    else:
        sta1 = net.addStation('sta1', position='10,10,0')
        sta2 = net.addStation('sta2', position='50,10,0')
        sta3 = net.addStation('sta3', position='90,10,0')

    print "*** Configuring wifi nodes"
    net.configureWifiNodes()

    print "*** Creating links"
    net.addMesh(sta1, ssid='meshNet', channel=5)
    net.addMesh(sta2, ssid='meshNet', channel=5)
    net.addMesh(sta3, ssid='meshNet', channel=5)

    if mobility:
        net.plotGraph(max_x=100, max_y=100)

        net.seed(20)

        net.startMobility(time=0,
                          model='RandomDirection',
                          max_x=100,
                          max_y=100,
                          min_v=0.5,
                          max_v=0.8)

    print "*** Starting network"
    net.build()

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

    print "*** Stopping network"
    net.stop()
Example #16
0
def create(count_st, count_ap):
    mini = Mininet(controller=RemoteController,
                   link=TCLink,
                   accessPoint=OVSKernelAP)

    list_st = []
    for x in range(1, count_st + 1):
        list_st.append(
            mini.addStation("sta" + str(x),
                            mac='00:00:00:00:00:0' + str(x),
                            ip='10.0.0.' + str(x) + '/8'))

    list_ap = []
    for y in range(1, count_ap + 1):
        list_ap.append(
            mini.addAccessPoint('ap' + str(y),
                                ssid='test_ssid' + str(y),
                                mode='g',
                                channel=str(y + 1),
                                position=str(randint(0, 100)) + ',' +
                                str(randint(0, 100)) + ',0'))

    c1 = mini.addController('c1', controller=RemoteController)

    mini.configureWifiNodes()
    mini.plotGraph(max_x=100, max_y=100)
    mini.seed(20)

    "*** Available models: RandomWalk, TruncatedLevyWalk, RandomDirection, RandomWayPoint, GaussMarkov, ReferencePoint, TimeVariantCommunity ***"
    mini.startMobility(time=0,
                       model='RandomDirection',
                       max_x=100,
                       max_y=100,
                       min_v=0.5,
                       max_v=0.8)

    print "*** Starting network"
    mini.build()
    c1.start()
    for x in range(0, count_ap):
        list_ap[x].start([c1])
def topology():

    "Create a network."
    net = Mininet(controller=Controller, accessPoint=OVSKernelAP)

    print "*** Creating nodes"
    net.addStation('sta1', mac='00:00:00:00:00:02', ip='10.0.0.2/8')
    net.addStation('sta2', mac='00:00:00:00:00:03', ip='10.0.0.3/8')
    ap1 = net.addAccessPoint('ap1',
                             ssid='new-ssid',
                             mode='g',
                             channel='1',
                             position='50,50,0')
    c1 = net.addController('c1', controller=Controller)

    print "*** Configuring wifi nodes"
    net.configureWifiNodes()

    net.plotGraph(max_x=100, max_y=100)

    net.seed(20)

    net.startMobility(time=0,
                      model='RandomDirection',
                      max_x=100,
                      max_y=100,
                      min_v=0.5,
                      max_v=0.8)

    print "*** Starting network"
    net.build()
    c1.start()
    ap1.start([c1])

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

    print "*** Stopping network"
    net.stop()
def topology():

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

    print "*** Creating nodes"
    sta1 = net.addStation( 'sta1' )
    sta2 = net.addStation( 'sta2' )
    ap1 = net.addBaseStation( 'ap1', ssid= 'new-ssid', equipmentModel='DI524', mode='g', channel='1', position='50,50,0' )
    c1 = net.addController( 'c1', controller=Controller )

    print "*** Associating and Creating links"
    net.addLink(ap1, sta1)
    net.addLink(ap1, sta2)
    
    print "*** Starting network"
    net.build()
    c1.start()
    ap1.start( [c1] )
    
    """uncomment to plot graph"""
    net.plotGraph(max_x=150, max_y=150)

    """Seed"""
    net.seed(1) 

    "*** Available propagation models: friisPropagationLossModel, twoRayGroundPropagationLossModel, logDistancePropagationLossModel ***"
 #   net.propagationModel('youngModel')
    net.propagationModel('friisPropagationLossModel', sL=2)

    "*** Available mobility models: RandomWalk, TruncatedLevyWalk, RandomDirection, RandomWayPoint, GaussMarkov ***"
    net.startMobility(startTime=0, model='RandomWayPoint', max_x=160, max_y=160, min_v=0.1, max_v=0.2)
   
    print "*** Running CLI"
    CLI( net )

    print "*** Stopping network"
    net.stop()
def topology():

    "Create a network."
    net = Mininet( controller=RemoteController, link=TCLink, switch=UserSwitch )
    sta = []

    print "*** Creating nodes"
    for n in range(10):
	sta.append(n)
	sta[n] = net.addStation( 'sta%s' % (n+1), wlans=2, mac='00:00:00:00:00:%s' % (n+1), ip='192.168.0.%s/24' % (n+1) )
    phyap1 = net.addPhysicalBaseStation( 'phyap1', protocols='OpenFlow13', ssid= 'ap-ssid1', mode= 'g', channel= '1', position='50,115,0', wlan='wlan11' )
    ap2 = net.addBaseStation( 'ap2', protocols='OpenFlow13', ssid= 'ap-ssid2', mode= 'g', channel= '11', position='100,175,0' )
    ap3 = net.addBaseStation( 'ap3', protocols='OpenFlow13', ssid= 'ap-ssid3', mode= 'g', channel= '6', position='150,115,0' )
    ap4 = net.addBaseStation( 'ap4', protocols='OpenFlow13', ssid= 'ap-ssid4', mode= 'g', channel= '6', position='100,55,0' )
    sta11 = net.addStation( 'sta11', ip='10.0.0.111/8', position='120,200,0')
    c1 = net.addController( 'c1', controller=RemoteController, port=6653 )
    root = Node( 'root', inNamespace=False )

    print "*** Creating links"
    for station in sta:
        net.addMesh(station, ssid='meshNet')

    """uncomment to plot graph"""
    net.plotGraph(max_x=240, max_y=240)

    """Routing"""
    net.meshRouting('custom')

    """Seed"""
    net.seed(20)

    print "*** Associating and Creating links"
    net.addLink(phyap1, ap2)
    net.addLink(ap2, ap3)
    net.addLink(sta11, ap2)
    net.addLink(ap3, ap4)
    net.addLink(ap4, phyap1)
    link = net.addLink( root, ap3 )
    link.intf1.setIP( '10.254', 8 )

    """Adding datapath"""
    net.addOfDataPath('ap3', 'wlan0')

    print "*** Starting network"
    net.build()

    c1.start()
    phyap1.start( [c1] )
    ap2.start( [c1] )
    ap3.start( [c1] )
    ap4.start( [c1] )

    time.sleep(2)
    """output=all,flood"""
    ap3.cmd('dpctl unix:/tmp/ap3 meter-mod cmd=add,flags=1,meter=1 drop:rate=100')
    ap3.cmd('dpctl unix:/tmp/ap3 flow-mod table=0,cmd=add in_port=4,eth_type=0x800,ip_dst=10.0.0.100, meter:1 apply:output=flood')

    startNAT( root )
    sta11.cmd('ip route add default via 10.0.0.254')
    sta11.cmd('pushd /homt/alpha; python3 -m http.server 80 &')

    ip = 201
    for station in sta:
        station.cmd('ifconfig %s-wlan1 10.0.0.%s/8' % (station, ip))
        station.cmd('ip route add default via 10.0.0.254')
        ip+=1

    "*** Available models: RandomWalk, TruncatedLevyWalk, RandomDirection, RandomWayPoint, GaussMarkov, ReferencePoint, TimeVariantCommunity ***"
    net.startMobility(startTime=0, model='RandomWalk', max_x=200, max_y=220, min_v=0.1, max_v=0.2)

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

    print "*** Stopping network"
    net.stop()
def topology():
    """Create a network. sta1 <--> sta2 <--> sta3"""

    print "*** Network creation"
    net = Mininet()

    print "*** Creating nodes"
    sta1 = net.addStation('sta1', range=200)
    sta2 = net.addStation('sta2', range=200)
    sta3 = net.addStation('sta3', range=200)

    print "*** Configure wmediumd"
    # This should be done right after the station has been initialized
    sta1.wmediumdIface = DynamicWmediumdIntfRef(sta1)
    sta2.wmediumdIface = DynamicWmediumdIntfRef(sta2)
    sta3.wmediumdIface = DynamicWmediumdIntfRef(sta3)

    intfrefs = [sta1.wmediumdIface, sta2.wmediumdIface, sta3.wmediumdIface]
    links = [
        WmediumdLink(sta1wlan0, sta2wlan0, 15),
        WmediumdLink(sta2wlan0, sta1wlan0, 15),
        WmediumdLink(sta2wlan0, sta3wlan0, 15),
        WmediumdLink(sta3wlan0, sta2wlan0, 15)
    ]
    WmediumdConn.set_wmediumd_data(intfrefs, links, with_server=True)

    WmediumdConn.connect_wmediumd_on_startup()

    print "*** Configuring wifi nodes"
    net.configureWifiNodes()

    net.plotGraph(max_x=240, max_y=240)

    net.meshRouting('custom')

    net.seed(20)

    print "*** Creating links"
    net.addMesh(sta1, ssid='adNet')
    net.addMesh(sta2, ssid='adNet')
    net.addMesh(sta3, ssid='adNet')

    print "*** Starting network"
    net.start()
    print "\n\n\n"
    print "*** Pinging sta2"
    sta1.cmdPrint('ping -c 1 10.0.0.2')

    print "*** Setting up the mobility model"
    net.startMobility(startTime=0,
                      model='RandomDirection',
                      max_x=220,
                      max_y=220,
                      min_v=0.1,
                      max_v=0.2)

    print "*** Update wmediumd"
    WmediumdServerConn.connect()

    CLI(net)

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

    print "*** Stopping wmediumd"
    WmediumdServerConn.disconnect()
    WmediumdConn.disconnect_wmediumd()
def topology():

    "Create a network."
    net = Mininet( controller=RemoteController, link=TCLink, switch=UserSwitch )
    staList = []
    internetIface = 'eth0'
    usbDongleIface = 'wlan0'

    print "*** Creating nodes"
    for n in range(10):
	staList.append(n)
	staList[n] = net.addStation( 'sta%s' % (n+1), wlans=2, mac='00:00:00:00:00:%s' % (n+1), ip='192.168.0.%s/24' % (n+1) )
    phyap1 = net.addPhysicalBaseStation( 'phyap1', protocols='OpenFlow13', ssid='Sigcomm-2016-Mininet-WiFi', mode= 'g', channel= '1', position='50,115,0', phywlan=usbDongleIface )
    ap2 = net.addBaseStation( 'ap2', protocols='OpenFlow13', ssid='ap-ssid2', mode= 'g', channel= '11', position='100,175,0' )
    ap3 = net.addBaseStation( 'ap3', protocols='OpenFlow13', ssid='ap-ssid3', mode= 'g', channel= '6', position='150,115,0' )
    ap4 = net.addBaseStation( 'ap4', protocols='OpenFlow13', ssid='ap-ssid4', mode= 'g', channel= '11', position='100,55,0' )
    c5 = net.addController( 'c5', controller=RemoteController, port=6653 )
    sta11 = net.addStation( 'sta11', ip='10.0.0.111/8', position='60,100,0')
    h12 = net.addHost( 'h12', ip='10.0.0.109/8')
    root = net.addHost( 'root', ip='10.0.0.254/8', inNamespace=False )

    print "*** Creating links"
    for sta in staList:
        net.addMesh(sta, ssid='meshNet')

    """uncomment to plot graph"""
    net.plotGraph(max_x=240, max_y=240)

    """Routing"""
    net.meshRouting('custom')

    """Seed"""
    net.seed(20)

    print "*** Associating and Creating links"
    net.addLink(phyap1, ap2)
    net.addLink(ap2, ap3)
    net.addLink(sta11, ap2)
    net.addLink(ap3, ap4)
    net.addLink(ap4, phyap1)
    net.addLink(root, ap3)
    net.addLink(phyap1, h12)

    print "*** Starting network"
    net.build()
    c5.start()
    phyap1.start( [c5] )
    ap2.start( [c5] )
    ap3.start( [c5] )
    ap4.start( [c5] )

    time.sleep(2)
    """output=all,flood"""
    ap3.cmd('dpctl unix:/tmp/ap3 meter-mod cmd=add,flags=1,meter=1 drop:rate=100')
    ap3.cmd('dpctl unix:/tmp/ap3 flow-mod table=0,cmd=add in_port=4,eth_type=0x800,ip_dst=10.0.0.100,meter:1 apply:output=flood')
    phyap1.cmd('dpctl unix:/tmp/phyap1 flow-mod table=0,cmd=add in_port=2,ip_dst=10.0.0.109,eth_type=0x800,ip_proto=6,tcp_dst=80 apply:set_field=tcp_dst:80,set_field=ip_dst:10.0.0.111,output=5')
    phyap1.cmd('dpctl unix:/tmp/phyap1 flow-mod table=0,cmd=add in_port=1,eth_type=0x800,ip_proto=6,tcp_src=80 apply:set_field=ip_src:10.0.0.109,output=2')

    fixNetworkManager( root, 'root-eth0' )

    startNAT(root, internetIface)

    sta11.cmd('ip route add default via 10.0.0.254')
    sta11.cmd('pushd /home/fontes; python3 -m http.server 80 &')

    ip = 201
    for sta in staList:
        sta.setIP('10.0.0.%s/8' % ip, intf="%s-wlan1" % sta)
        sta.cmd('ip route add default via 10.0.0.254')
        ip+=1

    "*** Available models: RandomWalk, TruncatedLevyWalk, RandomDirection, RandomWayPoint, GaussMarkov, ReferencePoint, TimeVariantCommunity ***"
    net.startMobility(startTime=0, model='RandomWalk', max_x=200, max_y=200, min_v=0.1, max_v=0.2)

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

    print "*** Stopping network"
    net.stop()
def topology():

    "Create a network."
    net = Mininet(controller=Controller,
                  link=TCLink,
                  accessPoint=OVSKernelAP,
                  enable_wmediumd=True,
                  enable_interference=True)

    print "*** Creating nodes"

    ap10 = net.addAccessPoint('Mobile1',
                              ssid='Mobile1',
                              equipmentModel='DI524',
                              mode='g',
                              channel='1',
                              position='0,10,0')

    ap1 = net.addAccessPoint('ap1',
                             ssid='Antenna1',
                             equipmentModel='DI524',
                             mode='g',
                             channel='1',
                             position='0,0,0')

    ap2 = net.addAccessPoint('ap2',
                             ssid='Antenna2',
                             equipmentModel='DI524',
                             mode='g',
                             channel='1',
                             position='100,0,0')

    ap3 = net.addAccessPoint('ap3',
                             ssid='Antenna3',
                             equipmentModel='DI524',
                             mode='g',
                             channel='1',
                             position='0,100,0')

    c1 = net.addController('c1', controller=Controller)

    net.propagationModel(model="logDistancePropagationLossModel", exp=3.5)

    print "*** Configuring wifi nodes"
    net.configureWifiNodes()

    net.plotGraph(max_x=100, max_y=100)

    net.seed(20)

    #net.startMobility(time=0, model='RandomDirection', max_x=90,min_x=10, max_y=90, min_y=90,min_v=0.5, max_v=0.8)

    print "*** Starting network"
    net.build()
    c1.start()
    ap1.start([c1])
    ap2.start([c1])
    ap3.start([c1])
    ap10.start([c1])  #Mobile from ap10 forward

    #AP1 TO MODE MONITOR
    ap1.cmd("ifconfig ap1-wlan1 down")
    ap1.cmd('iwconfig ap1-wlan1 mode monitor')
    ap1.cmd('ifconfig ap1-wlan1 up')

    #AP2 TO MODE MONITOR
    ap2.cmd("ifconfig ap2-wlan1 down")
    ap2.cmd('iwconfig ap2-wlan1 mode monitor')
    ap2.cmd('ifconfig ap2-wlan1 up')

    #AP3 TO MODE MONITOR
    ap3.cmd("ifconfig ap3-wlan1 down")
    ap3.cmd('iwconfig ap3-wlan1 mode monitor')
    ap3.cmd('ifconfig ap3-wlan1 up')

    print "*** Running CLI, le pasa la red a la consola de mininet"
    CLI(net)

    #sdo_py('sta1.params["rssi"]')

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

    "Create a network."
    net = Mininet(controller=RemoteController,
                  accessPoint=OVSKernelAP,
                  enable_wmediumd=True,
                  enable_interference=True)
    staList = []

    print("*** Creating nodes")
    for n in range(10):
        staList.append(n)
        staList[n] = net.addStation('sta%s' % (n + 1),
                                    wlans=2,
                                    mac='00:00:00:00:00:' + '%02x' % (n + 1),
                                    ip='192.168.0.%s/24' % (n + 1))
    phyap1 = net.addPhysicalBaseStation(
        'phyap1',
        ssid='SBRC16-MininetWiFi,SBRC16-MininetWiFi',
        mode='g',
        channel='1',
        wlans=2,
        position='50,115,0',
        phywlan='wlan2')
    net.addStation('sta11', ip='10.0.0.111/8', position='120,200,0')
    ap2 = net.addAccessPoint('ap2',
                             ssid='ap2',
                             mode='g',
                             channel='11',
                             position='100,175,0')
    ap3 = net.addAccessPoint('ap3',
                             ssid='ap3',
                             mode='g',
                             channel='6',
                             position='150,50,0')
    ap4 = net.addAccessPoint('ap4',
                             ssid='ap4',
                             mode='g',
                             channel='1',
                             position='175,150,0')
    c1 = net.addController('c1', controller=Controller, port=6653)
    Node('root', inNamespace=False)

    net.propagationModel(model="logDistance", exp=4)

    print("*** Configuring wifi nodes")
    net.configureWifiNodes()

    'plotting graph'
    net.plotGraph(max_x=220, max_y=220)

    'Seed'
    net.seed(20)

    print("*** Associating and Creating links")
    for sta in staList:
        net.addMesh(sta, ssid='meshNet')
    net.addLink(phyap1, ap2)
    net.addLink(ap2, ap3)
    net.addLink(ap3, ap4)

    net.startMobility(time=0,
                      model='RandomWalk',
                      max_x=220,
                      max_y=220,
                      min_v=0.1,
                      max_v=0.2)

    print("*** Starting network")
    net.build()
    c1.start()
    phyap1.start([c1])
    ap2.start([c1])
    ap3.start([c1])
    ap4.start([c1])

    ip = 201
    for sta in staList:
        sta.setIP('10.0.0.%s/8' % ip, intf="%s-wlan1" % sta)
        ip += 1

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

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

    "Create a network."
    net = Mininet(controller=RemoteController, link=TCLink, switch=UserSwitch)
    staList = []

    print "*** Creating nodes"
    for n in range(10):
        staList.append(n)
        staList[n] = net.addStation('sta%s' % (n + 1),
                                    wlans=2,
                                    mac='00:00:00:00:00:%s' % (n + 1),
                                    ip='192.168.0.%s/24' % (n + 1))
    phyap1 = net.addPhysicalBaseStation('phyap1',
                                        protocols='OpenFlow13',
                                        ssid='ap-ssid1',
                                        mode='g',
                                        channel='1',
                                        position='50,115,0',
                                        phywlan='wlan1')
    ap2 = net.addBaseStation('ap2',
                             protocols='OpenFlow13',
                             ssid='ap-ssid2',
                             mode='g',
                             channel='11',
                             position='100,175,0')
    ap3 = net.addBaseStation('ap3',
                             protocols='OpenFlow13',
                             ssid='ap-ssid3',
                             mode='g',
                             channel='6',
                             position='150,115,0')
    ap4 = net.addBaseStation('ap4',
                             protocols='OpenFlow13',
                             ssid='ap-ssid4',
                             mode='g',
                             channel='6',
                             position='100,55,0')
    sta11 = net.addStation('sta11', ip='10.0.0.111/8', position='120,200,0')
    c1 = net.addController('c1', controller=RemoteController, port=6653)
    root = Node('root', inNamespace=False)

    print "*** Creating links"
    for sta in staList:
        net.addMesh(sta, ssid='meshNet')
    """uncomment to plot graph"""
    net.plotGraph(max_x=240, max_y=240)
    """Routing"""
    net.meshRouting('custom')
    """Seed"""
    net.seed(20)

    print "*** Associating and Creating links"
    net.addLink(phyap1, ap2)
    net.addLink(ap2, ap3)
    net.addLink(sta11, ap2)
    net.addLink(ap3, ap4)
    net.addLink(ap4, phyap1)
    link = net.addLink(root, ap3)
    link.intf1.setIP('10.254', 8)
    """Adding datapath"""
    net.addOfDataPath('ap3', 'wlan0')

    print "*** Starting network"
    net.build()

    c1.start()
    phyap1.start([c1])
    ap2.start([c1])
    ap3.start([c1])
    ap4.start([c1])

    time.sleep(2)
    """output=all,flood"""
    ap3.cmd(
        'dpctl unix:/tmp/ap3 meter-mod cmd=add,flags=1,meter=1 drop:rate=100')
    ap3.cmd(
        'dpctl unix:/tmp/ap3 flow-mod table=0,cmd=add in_port=4,eth_type=0x800,ip_dst=10.0.0.100, meter:1 apply:output=flood'
    )

    startNAT(root)
    sta11.cmd('ip route add default via 10.0.0.254')
    sta11.cmd('pushd /homt/alpha; python3 -m http.server 80 &')

    ip = 201
    for sta in staList:
        sta.setIP('10.0.0.%s/8' % ip, intf="%s-wlan1" % sta)
        sta.cmd('ip route add default via 10.0.0.254')
        ip += 1

    "*** Available models: RandomWalk, TruncatedLevyWalk, RandomDirection, RandomWayPoint, GaussMarkov, ReferencePoint, TimeVariantCommunity ***"
    net.startMobility(startTime=0,
                      model='RandomWalk',
                      max_x=200,
                      max_y=220,
                      min_v=0.1,
                      max_v=0.2)

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

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

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

    print "*** Creating nodes"
    car1 = net.addVehicle('car1',
                          wlans=2,
                          mac='00:00:00:00:00:01',
                          ip='10.0.0.1/8',
                          min_speed=1,
                          max_speed=5)
    car2 = net.addVehicle('car2',
                          wlans=2,
                          mac='00:00:00:00:00:02',
                          ip='10.0.0.2/8',
                          min_speed=5,
                          max_speed=10)
    car3 = net.addVehicle('car3',
                          mac='00:00:00:00:00:03',
                          ip='10.0.0.3/8',
                          min_speed=10,
                          max_speed=15)
    car4 = net.addVehicle('car4',
                          mac='00:00:00:00:00:04',
                          ip='10.0.0.4/8',
                          min_speed=15,
                          max_speed=20)
    car5 = net.addVehicle('car5',
                          mac='00:00:00:00:00:05',
                          ip='10.0.0.5/8',
                          min_speed=15,
                          max_speed=20)
    bs1 = net.addBaseStation('BS1', ssid='new-ssid1', mode='g', channel='1')
    bs2 = net.addBaseStation('BS2', ssid='new-ssid2', mode='g', channel='6')
    bs3 = net.addBaseStation('BS3', ssid='new-ssid3', mode='g', channel='11')
    c1 = net.addController('c1', controller=Controller)

    print "*** Associating and Creating links"
    net.addMesh(car1, ssid='mesh')
    net.addMesh(car2, ssid='mesh')
    net.addMesh(car3, ssid='mesh')
    net.addMesh(car4, ssid='mesh')
    net.addMesh(car5, ssid='mesh')
    net.addLink(bs1, bs2)
    net.addLink(bs1, bs3)

    print "*** Starting network"
    net.build()
    c1.start()
    bs1.start([c1])
    bs2.start([c1])
    bs3.start([c1])
    """uncomment to plot graph"""
    net.plotGraph(max_x=500, max_y=500)
    """Number of Roads"""
    net.roads(4)
    """Seed"""
    net.seed(20)
    """Start Mobility"""
    net.startMobility(startTime=0)

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

    print "*** Stopping network"
    net.stop()
def topology():
    "Create a network."
    net = Mininet(controller=Controller, link=TCLink, switch=OVSKernelSwitch)

    print "*** Creating nodes"
    h1 = net.addHost('h1', mac='00:00:00:00:00:01', ip='10.0.0.1/8')
    h2 = net.addHost('h2', mac='00:00:00:00:00:11', ip='10.0.0.11/8')
    sta1 = net.addStation('sta1', wlans=2, ip='10.0.0.2/8')
    ap1 = net.addBaseStation('ap1',
                             ssid='ssid_ap1',
                             mode='g',
                             channel='6',
                             position='70,25,0')
    ap2 = net.addBaseStation('ap2',
                             ssid='ssid_ap2',
                             mode='g',
                             channel='1',
                             position='30,25,0')
    ap3 = net.addBaseStation('ap3',
                             ssid='ssid_ap3',
                             mode='g',
                             channel='11',
                             position='110,25,0')
    s4 = net.addSwitch('s4', mac='00:00:00:00:00:10')
    c1 = net.addController('c1', controller=Controller)

    print "*** Associating and Creating links"
    net.addLink(ap1, s4)
    net.addLink(ap2, s4)
    net.addLink(ap3, s4)
    net.addLink(s4, h1)
    net.addLink(s4, h2)

    sta1.cmd('modprobe bonding mode=3')
    sta1.cmd('ip link add bond0 type bond')
    sta1.cmd('ip link set bond0 address 02:01:02:03:04:08')
    sta1.cmd('ip link set sta1-wlan0 down')
    sta1.cmd('ip link set sta1-wlan0 address 00:00:00:00:00:11')
    sta1.cmd('ip link set sta1-wlan0 master bond0')
    sta1.cmd('ip link set sta1-wlan1 down')
    sta1.cmd('ip link set sta1-wlan1 address 00:00:00:00:00:12')
    sta1.cmd('ip link set sta1-wlan1 master bond0')
    sta1.cmd('ip addr add 10.0.0.10/8 dev bond0')
    sta1.cmd('ip link set bond0 up')

    print "*** Starting network"
    net.build()
    c1.start()
    s4.start([c1])
    ap1.start([c1])
    ap2.start([c1])
    ap3.start([c1])

    sta1.cmd('ip addr del 10.0.0.2/8 dev sta1-wlan0')
    os.system('ovs-ofctl add-flow s4 actions=normal')
    """seed"""
    net.seed(12)
    """uncomment to plot graph"""
    net.plotGraph(max_x=140, max_y=140)

    "*** Available models: RandomWalk, TruncatedLevyWalk, RandomDirection, RandomWaypoint, GaussMarkov ***"
    net.startMobility(startTime=0,
                      model='RandomDirection',
                      max_x=120,
                      max_y=50,
                      min_v=0.4,
                      max_v=0.6)

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

    print "*** Stopping network"
    net.stop()
def topology():
    "Create a network."
    net = Mininet(controller=Controller, link=TCLink, switch=OVSKernelSwitch)

    print "*** Creating nodes"
    sta1 = net.addStation('sta1', mac='00:00:00:00:00:02', ip='10.0.0.2/8')
    sta2 = net.addStation('sta2', mac='00:00:00:00:00:03', ip='10.0.0.3/8')
    sta3 = net.addStation('sta3', mac='00:00:00:00:00:04', ip='10.0.0.4/8')
    sta4 = net.addStation('sta4', mac='00:00:00:00:00:05', ip='10.0.0.5/8')
    sta5 = net.addStation('sta5', mac='00:00:00:00:00:06', ip='10.0.0.6/8')
    sta6 = net.addStation('sta6', mac='00:00:00:00:00:07', ip='10.0.0.7/8')
    sta7 = net.addStation('sta7', mac='00:00:00:00:00:08', ip='10.0.0.8/8')
    sta8 = net.addStation('sta8', mac='00:00:00:00:00:09', ip='10.0.0.9/8')
    sta9 = net.addStation('sta9', mac='00:00:00:00:00:10', ip='10.0.0.10/8')
    sta10 = net.addStation('sta10', mac='00:00:00:00:00:11', ip='10.0.0.11/8')
    ap1 = net.addAccessPoint('ap1',
                             ssid='new-ssid1',
                             mode='g',
                             channel='1',
                             position='50,50,0')
    ap2 = net.addAccessPoint('ap2',
                             ssid='new-ssid2',
                             mode='g',
                             channel='1',
                             position='70,50,0',
                             range=30)  #range: set the AP range
    ap3 = net.addAccessPoint('ap3',
                             ssid='new-ssid3',
                             mode='g',
                             channel='1',
                             position='90,50,0')
    c1 = net.addController('c1', controller=Controller)

    print "*** Configuring wifi nodes"
    net.configureWifiNodes()

    print "*** Associating and Creating links"
    net.addLink(ap1, ap2)
    net.addLink(ap2, ap3)

    print "*** Starting network"
    net.build()
    c1.start()
    ap1.start([c1])
    ap2.start([c1])
    ap3.start([c1])
    """uncomment to plot graph"""
    net.plotGraph(max_x=120, max_y=120)
    """association control"""
    net.associationControl('ssf')
    """Seed"""
    net.seed(1)
    """ *** Available models: 
                RandomWalk, TruncatedLevyWalk, RandomDirection, RandomWayPoint, GaussMarkov
	*** Association Control (AC) - mechanism that optimizes the use of the APs:
                llf (Least-Loaded-First)
                ssf (Strongest-Signal-First)"""
    net.startMobility(startTime=0,
                      model='RandomWayPoint',
                      max_x=120,
                      max_y=120,
                      min_v=0.3,
                      max_v=0.5)

    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)
    sta = []

    print "*** Creating nodes"
    for n in range(10):
        sta.append(n)
        sta[n] = net.addStation('sta%s' % (n + 1),
                                wlans=2,
                                mac='00:00:00:00:00:%s' % (n + 1),
                                ip='192.168.0.%s/24' % (n + 1))
    phyap1 = net.addPhysicalBaseStation('phyap1',
                                        ssid='ap-ssid1',
                                        mode='g',
                                        channel='1',
                                        position='50,115,0',
                                        wlan='wlan11')
    ap2 = net.addBaseStation('ap2',
                             ssid='ap-ssid2',
                             mode='g',
                             channel='11',
                             position='100,175,0')
    c1 = net.addController('c1', controller=Controller, port=6653)
    root = Node('root', inNamespace=False)

    print "*** Creating links"
    for station in sta:
        net.addMesh(station, ssid='meshNet')
    """uncomment to plot graph"""
    net.plotGraph(max_x=240, max_y=240)
    """Routing"""
    net.meshRouting('custom')
    """Seed"""
    net.seed(20)

    print "*** Associating and Creating links"
    net.addLink(phyap1, ap2)

    print "*** Starting network"
    net.build()

    c1.start()
    phyap1.start([c1])
    ap2.start([c1])

    ip = 201
    for station in sta:
        station.cmd('ifconfig %s-wlan1 10.0.0.%s/8' % (station, ip))
        ip += 1

    "*** Available models: RandomWalk, TruncatedLevyWalk, RandomDirection, RandomWayPoint, GaussMarkov, ReferencePoint, TimeVariantCommunity ***"
    net.startMobility(startTime=0,
                      model='RandomWalk',
                      max_x=200,
                      max_y=220,
                      min_v=0.1,
                      max_v=0.2)

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

    print "*** Stopping network"
    net.stop()
def topology():

    "Create a network."
    net = Mininet(controller=Controller, link=TCLink, accessPoint=OVSKernelAP)

    print "*** Creating nodes"

    ap1 = net.addAccessPoint('ap1',
                             ssid='new-ssid1',
                             mode='g',
                             channel='1',
                             position='30,40,0',
                             range='35')
    ap2 = net.addAccessPoint('ap2',
                             ssid='new-ssid2',
                             mode='g',
                             channel='6',
                             position='80,40,0',
                             range='35')

    sta1 = net.addStation(
        'sta1',
        mac='00:00:00:00:00:02',
        ip='10.0.0.2/8',
        range='3',
    )
    sta2 = net.addStation('sta2',
                          mac='00:00:00:00:00:03',
                          ip='10.0.0.3/8',
                          position='40,58,0',
                          range='3')
    sta3 = net.addStation('sta3',
                          mac='00:00:00:00:00:04',
                          ip='10.0.0.4/8',
                          position='25,60,0',
                          range='3')
    sta4 = net.addStation('sta4',
                          mac='00:00:00:00:00:05',
                          ip='10.0.0.5/8',
                          position='70,40,0',
                          range='3')
    sta5 = net.addStation('sta5',
                          mac='00:00:00:00:00:06',
                          ip='10.0.0.6/8',
                          position='25,20,0',
                          range='3')
    sta6 = net.addStation('sta6',
                          mac='00:00:00:00:00:07',
                          ip='10.0.0.7/8',
                          position='20,40,0',
                          range='3')
    c1 = net.addController('c1', controller=Controller)

    net.propagationModel("logDistancePropagationLossModel", exp=5)

    #print "*** Configuring wifi nodes"
    net.configureWifiNodes()

    print "*** Associating and Creating links"
    net.addLink(ap1, ap2)

    net.plotGraph(max_x=120, max_y=120)

    net.associationControl('llf')

    net.seed(1)

    #net.startMobility(AC='llf', time=0)
    #net.mobility(sta1, 'start', time=1, position='0,50,0')
    #net.mobility(sta1, 'stop', time=49, position='100,50,0')
    #net.stopMobility(time=50)

    net.startMobility(time=0,
                      model='RandomWayPoint',
                      max_x=120,
                      max_y=80,
                      min_v=1,
                      max_v=1.2,
                      AC='llf')
    #net.startMobility(time=0, model='RandomDirection', max_x=140, max_y=140, min_v=0.7, max_v=0.9, AC='llf')
    #net.startMobility(time=0, model='RandomWalk', max_x=140, max_y=140, min_v=0.7, max_v=0.9, AC='llf')

    print "*** Starting network"
    net.build()
    c1.start()
    ap1.start([c1])
    ap2.start([c1])

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

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

    "Create a network."
    net = Mininet( controller=RemoteController, accessPoint=UserAP,
                   enable_wmediumd=True, enable_interference=True )
    staList = []
    internetIface = 'enp2s0'
    usbDongleIface = 'wlan2'

    print "*** Creating nodes"
    for n in range(10):
        staList.append(n)
        staList[n] = net.addStation(
            'sta%s' % (n+1), wlans=2, mac='00:00:00:00:00:' + '%02x' % (n+1),
            ip='192.168.0.%s/24' % (n+1))
    phyap1 = net.addPhysicalBaseStation(
        'phyap1', wlans=2, protocols='OpenFlow13',
        ssid='Sigcomm-2016-Mininet-WiFi,Sigcomm-2016-Mininet-WiFi',
        mode='g', channel='1', position='50,115,0', phywlan=usbDongleIface)
    ap2 = net.addAccessPoint( 'ap2', protocols='OpenFlow13', ssid='ap-ssid2',
                              mode='g', channel='11', position='100,175,0' )
    ap3 = net.addAccessPoint( 'ap3', protocols='OpenFlow13', ssid='ap-ssid3',
                              mode='g', channel='6', position='150,115,0' )
    ap4 = net.addAccessPoint( 'ap4', protocols='OpenFlow13', ssid='ap-ssid4',
                              mode='g', channel='11', position='100,55,0' )
    c5 = net.addController( 'c5', controller=RemoteController, port=6653 )
    sta11 = net.addStation( 'sta11', ip='10.0.0.111/8', position='60,100,0')
    h12 = net.addHost( 'h12', ip='10.0.0.109/8')
    root = net.addHost( 'root', ip='10.0.0.254/8', inNamespace=False )

    print "*** Configuring Propagation Model"
    net.propagationModel(model="logDistance", exp=4)

    print "*** Configuring wifi nodes"
    net.configureWifiNodes()

    print "*** Creating links"
    for sta in staList:
        net.addMesh(sta, ssid='meshNet')

    net.plotGraph(max_x=240, max_y=240)

    "Seed"
    net.seed(20)

    print "*** Associating and Creating links"
    net.addLink(phyap1, ap2)
    net.addLink(ap2, ap3)
    net.addLink(sta11, phyap1, 0, 1)
    net.addLink(ap3, ap4)
    net.addLink(ap4, phyap1)
    net.addLink(root, ap3)
    net.addLink(phyap1, h12)

    print "*** Starting network"
    net.build()
    c5.start()
    phyap1.start( [c5] )
    ap2.start( [c5] )
    ap3.start( [c5] )
    ap4.start( [c5] )

    time.sleep(2)
    'output=all,flood'
    ap3.cmd('dpctl unix:/tmp/ap3 meter-mod cmd=add,flags=1,meter=1 drop:rate=100')
    ap3.cmd('dpctl unix:/tmp/ap3 flow-mod table=0,cmd=add in_port=4,eth_type=0x800,ip_dst=10.0.0.100,meter:1 apply:output=flood')
    phyap1.cmd('dpctl unix:/tmp/phyap1 flow-mod table=0,cmd=add in_port=2,ip_dst=10.0.0.109,eth_type=0x800,ip_proto=6,tcp_dst=80 apply:set_field=tcp_dst:80,set_field=ip_dst:10.0.0.111,output=5')
    phyap1.cmd('dpctl unix:/tmp/phyap1 flow-mod table=0,cmd=add in_port=1,eth_type=0x800,ip_proto=6,tcp_src=80 apply:set_field=ip_src:10.0.0.109,output=2')

    fixNetworkManager( root, 'root-eth0' )

    startNAT(root, internetIface)

    sta11.cmd('ip route add default via 10.0.0.254')
    sta11.cmd('pushd /home/fontes; python3 -m http.server 80 &')

    ip = 201
    for sta in staList:
        sta.setIP('10.0.0.%s/8' % ip, intf="%s-wlan1" % sta)
        sta.cmd('ip route add default via 10.0.0.254')
        ip+=1

    net.startMobility(startTime=0, model='RandomWalk', max_x=200,
                      max_y=200, min_v=0.1, max_v=0.2)

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

    print "*** Stopping network"
    net.stop()
def topology():
    net = Mininet(controller=RemoteController,
                  link=TCLink,
                  accessPoint=OVSKernelAP,
                  switch=OVSKernelSwitch,
                  useWmediumd=True)

    print "Creating nodes"

    h1 = net.addHost('h1', mac='00:00:00:00:00:01', ip='10.0.0.1/24')
    h2 = net.addHost('h2', mac='00:00:00:00:00:02', ip='10.0.0.2/24')

    sw10 = net.addSwitch('sw10')
    sw20 = net.addSwitch('sw20')
    sw30 = net.addSwitch('sw30')
    sw40 = net.addSwitch('sw40')

    ap1 = net.addAccessPoint('ap1',
                             ssid='AP1',
                             mode='g',
                             channel='1',
                             position='40,120,0',
                             range='30')
    ap2 = net.addAccessPoint('ap2',
                             ssid='AP2',
                             mode='g',
                             channel='6',
                             position='80,120,0',
                             range='30')
    ap3 = net.addAccessPoint('ap3',
                             ssid='AP3',
                             mode='g',
                             channel='11',
                             position='120,120,0',
                             range='30')
    ap4 = net.addAccessPoint('ap4',
                             ssid='AP4',
                             mode='g',
                             channel='1',
                             position='160,120,0',
                             range='30')
    ap5 = net.addAccessPoint('ap5',
                             ssid='AP5',
                             mode='g',
                             channel='6',
                             position='60,80,0',
                             range='30')
    ap6 = net.addAccessPoint('ap6',
                             ssid='AP6',
                             mode='g',
                             channel='11',
                             position='100,80,0',
                             range='30')
    ap7 = net.addAccessPoint('ap7',
                             ssid='AP7',
                             mode='g',
                             channel='1',
                             position='140,80,0',
                             range='30')
    ap8 = net.addAccessPoint('ap8',
                             ssid='AP8',
                             mode='g',
                             channel='6',
                             position='180,80,0',
                             range='30')
    ap9 = net.addAccessPoint('ap9',
                             ssid='AP9',
                             mode='g',
                             channel='11',
                             position='40,40,0',
                             range='30')
    ap10 = net.addAccessPoint('ap10',
                              ssid='AP10',
                              mode='g',
                              channel='1',
                              position='80,40,0',
                              range='30')
    ap11 = net.addAccessPoint('ap11',
                              ssid='AP11',
                              mode='g',
                              channel='6',
                              position='120,40,0',
                              range='30')
    ap12 = net.addAccessPoint('ap12',
                              ssid='AP12',
                              mode='g',
                              channel='11',
                              position='160,40,0',
                              range='30')

    sta1 = net.addStation('sta1', mac='00:00:00:00:00:10', ip='10.0.0.10/24')
    c0 = net.addController('c0',
                           controller=RemoteController,
                           ip='127.0.0.1',
                           port=6653)

    net.configureWifiNodes()

    print "Associating and creating links"
    net.addLink(sw10, sw20)
    net.addLink(sw20, sw30)
    net.addLink(sw30, sw40)
    net.addLink(sw10, h1)
    net.addLink(sw20, h2)
    net.addLink(sw10, ap1)
    net.addLink(sw10, ap2)
    net.addLink(sw10, ap6)
    net.addLink(sw20, ap3)
    net.addLink(sw20, ap4)
    net.addLink(sw20, ap8)
    net.addLink(sw30, ap5)
    net.addLink(sw30, ap9)
    net.addLink(sw30, ap10)
    net.addLink(sw40, ap7)
    net.addLink(sw40, ap11)
    net.addLink(sw40, ap12)

    print "Starting network"
    net.build()
    c0.start()
    sw10.start([c0])
    sw20.start([c0])
    sw30.start([c0])
    sw40.start([c0])
    ap1.start([c0])
    ap2.start([c0])
    ap3.start([c0])
    ap4.start([c0])
    ap5.start([c0])
    ap6.start([c0])
    ap7.start([c0])
    ap8.start([c0])
    ap9.start([c0])
    ap10.start([c0])
    ap11.start([c0])
    ap12.start([c0])

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

    net.associationControl('ssf')
    net.seed(1)

    start = 2
    net.startMobility(startTime=0,
                      model='RandomDirection',
                      max_x=200,
                      max_y=150,
                      min_v=3.0,
                      max_v=5.0)
    # net.mobility(sta2, 'start', time=start, position='0.0,0.0,0.0')
    # net.mobility(sta2, 'stop', time=start+10, position='20.0,20.0,0.0')
    # net.stopMobility(stopTime=start+11)

    thread.start_new_thread(MySocket().start, (net, ))

    print "Running CLI"
    CLI(net)

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

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

    print "*** Creating nodes"
    h1 = net.addHost('h1', mac='00:00:00:00:00:01', ip='10.0.0.1/8')
    sta1 = net.addStation('sta1', mac='00:00:00:00:00:02', ip='10.0.0.2/8')
    sta2 = net.addStation('sta2', wlans=2, ip='10.0.0.3/8')
    sta3 = net.addStation('sta3', mac='00:00:00:00:00:04', ip='10.0.0.4/8')
    sta4 = net.addStation('sta4', wlans=2, ip='10.0.0.5/8')
    sta5 = net.addStation('sta5', mac='00:00:00:00:00:06', ip='10.0.0.6/8')
    sta6 = net.addStation('sta6', wlans=2, ip='10.0.0.7/8')

    ap1 = net.addBaseStation('ap1',
                             ssid='new-ssid1',
                             mode='g',
                             channel='1',
                             position='30,30,0',
                             range=30)
    ap2 = net.addBaseStation('ap2',
                             ssid='new-ssid2',
                             mode='g',
                             channel='2',
                             position='60,30,0',
                             range=40)
    ap3 = net.addBaseStation('ap3',
                             ssid='new-ssid3',
                             mode='g',
                             channel='3',
                             position='30,50,0',
                             range=35)
    ap4 = net.addBaseStation('ap4',
                             ssid='new-ssid4',
                             mode='g',
                             channel='4',
                             position='60,50,0',
                             range=45)
    c1 = net.addController('c1', controller=Controller)

    print "*** Associating and Creating links"
    net.addLink(ap1, ap2)
    net.addLink(ap1, ap3)
    net.addLink(ap1, ap4)
    net.addLink(ap2, ap3)
    net.addLink(ap2, ap4)
    net.addLink(ap3, ap4)

    net.addLink(ap1, h1)
    net.addLink(ap1, sta1)
    net.addLink(ap1, sta2)
    net.addLink(ap2, sta3)
    net.addLink(ap3, sta4)
    net.addLink(ap4, sta5)
    net.addLink(ap4, sta6)
    print "*** Starting network"
    net.build()
    c1.start()
    ap1.start([c1])
    ap2.start([c1])
    ap3.start([c1])
    ap4.start([c1])

    net.seed(10)
    """uncomment to plot graph"""
    net.plotGraph(max_x=100, max_y=100)

    net.startMobility(startTime=0,
                      model='RandomWayPoint',
                      max_x=60,
                      max_y=60,
                      min_v=0.1,
                      max_v=0.5,
                      AC='ssf')

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

    print "*** Stopping network"
    net.stop()
Example #33
0
def topology():
    "Create a network."
    net = Mininet(controller=Controller, link=TCLink, accessPoint=OVSKernelAP)

    print "*** Creating nodes"
    net.addStation('sta1', mac='00:00:00:00:00:02', ip='10.0.0.2/8')
    net.addStation('sta2', mac='00:00:00:00:00:03', ip='10.0.0.3/8')
    net.addStation('sta3', mac='00:00:00:00:00:04', ip='10.0.0.4/8')
    net.addStation('sta4', mac='00:00:00:00:00:05', ip='10.0.0.5/8')
    net.addStation('sta5', mac='00:00:00:00:00:06', ip='10.0.0.6/8')
    net.addStation('sta6', mac='00:00:00:00:00:07', ip='10.0.0.7/8')
    net.addStation('sta7', mac='00:00:00:00:00:08', ip='10.0.0.8/8')
    net.addStation('sta8', mac='00:00:00:00:00:09', ip='10.0.0.9/8')
    net.addStation('sta9', mac='00:00:00:00:00:10', ip='10.0.0.10/8')
    net.addStation('sta10', mac='00:00:00:00:00:11', ip='10.0.0.11/8')
    ap1 = net.addAccessPoint('ap1',
                             ssid='ssid-ap1',
                             mode='g',
                             channel='1',
                             position='50,50,0')
    ap2 = net.addAccessPoint('ap2',
                             ssid='ssid-ap2',
                             mode='g',
                             channel='6',
                             position='70,50,0',
                             range=30)
    ap3 = net.addAccessPoint('ap3',
                             ssid='ssid-ap3',
                             mode='g',
                             channel='11',
                             position='90,50,0')
    c1 = net.addController('c1', controller=Controller)

    net.propagationModel(model="logDistance", exp=5)

    print "*** Configuring wifi nodes"
    net.configureWifiNodes()

    print "*** Associating and Creating links"
    net.addLink(ap1, ap2)
    net.addLink(ap2, ap3)

    net.plotGraph(max_x=120, max_y=120)

    net.associationControl('ssf')

    net.seed(1)

    net.startMobility(time=0,
                      model='RandomWayPoint',
                      max_x=120,
                      max_y=120,
                      min_v=0.3,
                      max_v=0.5)

    print "*** Starting network"
    net.build()
    c1.start()
    ap1.start([c1])
    ap2.start([c1])
    ap3.start([c1])

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

    print "*** Stopping network"
    net.stop()
Example #34
0
    def topology(self):
        "Create a network."
        net = Mininet(controller=Controller,
                      link=TCLink,
                      accessPoint=OVSKernelAP)

        print "*** Creating nodes"
        self.sta14 = net.addStation('sta14',
                                    mac='00:00:00:00:00:15',
                                    ip='10.0.0.15/8',
                                    range=10)
        self.h1 = net.addHost('h1', mac='00:00:00:00:00:01', ip='10.0.0.1/8')
        self.ap1 = net.addAccessPoint('ap1',
                                      ssid='ssid-ap1',
                                      mode='g',
                                      channel='1',
                                      position='10,20,0',
                                      range=35)
        self.ap2 = net.addAccessPoint('ap2',
                                      ssid='ssid-ap2',
                                      mode='g',
                                      channel='1',
                                      position='44,20,0',
                                      range=35)
        self.ap3 = net.addAccessPoint('ap3',
                                      ssid='ssid-ap3',
                                      mode='g',
                                      channel='1',
                                      position='27,50,0',
                                      range=35)
        #self.ap4 = net.addAccessPoint('ap4', ssid='ssid-ap4', mode='g', channel='1', position='55,55,0', range=35)
        c1 = net.addController('c1', controller=Controller)

        print "*** Configuring wifi nodes"
        net.configureWifiNodes()

        print "*** Associating and Creating links"
        net.addLink(self.h1, self.ap1)
        net.addLink(self.ap1, self.ap2)
        net.addLink(self.ap2, self.ap3)
        #net.addLink(self.ap3,self.sta14)
        """uncomment to plot graph"""
        net.plotGraph(max_x=55, max_y=55)
        """association control"""
        #net.associationControl("ssf")
        """Seed"""
        net.seed(13)
        """random walking"""
        net.startMobility(time=0,
                          model='RandomDirection',
                          max_x=55,
                          max_y=55,
                          min_v=0.09,
                          max_v=0.09)

        print "*** Starting network"
        net.build()
        c1.start()
        self.ap1.start([c1])
        self.ap2.start([c1])
        self.ap3.start([c1])
        #self.ap4.start([c1])
        #net.startMobility(startTime=0)
        #net.mobility(self.sta14, 'start', time=0, position='20,30,0')
        #net.mobility(self.sta14, 'stop', time=101, position='19.9,29.9,0')
        #net.stopMobility(stopTime=3600)

        print "*** Running CLI"
        CLI(net)
        self._getstatestart()
        while not self.valid:
            time.sleep(self.second)

        n_actions, n_features = self._getspace()
        brain = BrainDQN(n_actions, n_features, 60, param_file=None)
        state = np.array(self.observation)
        print 'initial observation:' + str(state)

        #self.aplist=['ap1','ap2','ap3','ap4']
        #self.id4ap = dict(zip(xrange(0,n_actions),self.aplist))
        #print self.id4ap
        #data = {}
        #fig = Display(self.id4ap)
        #fig.display()
        try:
            while True:

                action, q_value = brain.getAction(state)
                print "action:  " + str(action) + "  Q:  " + str(q_value)
                reward, nextstate = self.step(self.currentID, action)
                print "reward:  " + str(reward) + '  state_:  ' + str(
                    nextstate)

                #data['timestamp'] = time.time()
                #data['rssi'] = nextstate
                #data['q'] = q_value
                #data['reward'] = reward
                #data['action_index'] = action
                #print 'DATA:  ',data
                #fig.append(data)

                brain.setPerception(state, action, reward, nextstate, False)
                state = nextstate

        except KeyboardInterrupt:
            print 'saving replayMemory...'
            brain.saveReplayMemory()
            #fig.stop()
        pass
        # print new_rssi
        # snr_dict = map(setSNR,new_rssi)
        print "*** Stopping network"
        net.stop()
def topology():

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

    print "*** Creating nodes"
    ## The mobile node
    sta1 = net.addStation('sta1',
                          wlans=2,
                          mac='00:00:00:00:00:02',
                          ip='10.0.0.2/24')
    ## The long range, poor quality access point
    ap1 = net.addAccessPoint('ap1',
                             ssid='ap1-ssid',
                             mode='g',
                             channel='1',
                             position='50,50,0',
                             range=51)
    ## The sort range, good quality access points
    ap2 = net.addAccessPoint('ap2',
                             ssid='ap2-ssid',
                             mode='g',
                             channel='4',
                             position='10,10,0',
                             range=30)
    ap3 = net.addAccessPoint('ap3',
                             ssid='ap3-ssid',
                             mode='g',
                             channel='4',
                             position='90,10,0',
                             range=30)
    ap4 = net.addAccessPoint('ap4',
                             ssid='fast-ssid',
                             mode='g',
                             channel='4',
                             position='50,80,0',
                             range=10)
    ## Controller for the APs (don't need to change this)
    c1 = net.addController('c1', controller=Controller)
    ## The host, will run the HTTP server in this example
    h1 = net.addHost('h1', ip='10.0.0.3/24')

    print "*** Configuring wifi nodes"
    net.configureWifiNodes()

    ## (ap2--ap3--ap4)
    print "*** Creating links"
    net.addLink(ap2, ap3)
    net.addLink(ap3, ap4)

    ## Poor quality link ap1---h1
    net.addLink(ap1, h1, bw=2, delay='10ms', max_queue_size=1000)
    ## Good quality link ap2---h1 (note that ap2--ap3--ap4)
    net.addLink(ap2, h1)

    ## Just to make sure the interfaces are correctly set
    net.addLink(ap1, sta1)
    net.addLink(ap2, sta1)

    print "*** Starting network"
    net.build()
    c1.start()
    ap1.start([c1])
    ap2.start([c1])
    ap3.start([c1])
    ap4.start([c1])

    ## Manually set a second IP for h1 and sta1
    sta1.setIP('10.1.0.2/24', intf='sta1-wlan1')
    h1.setIP('10.1.0.3/24', intf='h1-eth1')

    ## Run a simple HTTP server on h1
    print "*** Starting HTTP server on H1"
    h1.cmdPrint('python -m SimpleHTTPServer 80 &')

    h1.cmdPrint("python code/server.py &")
    """association control"""
    net.associationControl('ssf')
    """Plot graph"""
    net.plotGraph(max_x=100, max_y=100)
    """Seed"""
    net.seed(20)

    "*** Available models: RandomWalk, TruncatedLevyWalk, RandomDirection, RandomWayPoint, GaussMarkov, ReferencePoint, TimeVariantCommunity ***"
    net.startMobility(startTime=0,
                      model='RandomWayPoint',
                      max_x=100,
                      max_y=100,
                      min_v=0.5,
                      max_v=0.8)

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

    print "*** Stopping network"
    net.stop()
Example #36
0
    def topology(self):
        "Create a network."
        net = Mininet(controller=Controller,
                      link=TCLink,
                      accessPoint=OVSKernelAP)

        print "*** Creating nodes"
        self.sta14 = net.addStation('sta14',
                                    mac='00:00:00:00:00:15',
                                    ip='10.0.0.15/8',
                                    range=50)
        self.h1 = net.addHost('h1', mac='00:00:00:00:00:01', ip='10.0.0.1/8')
        self.ap1 = net.addAccessPoint('ap1',
                                      ssid='ssid-ap1',
                                      mode='g',
                                      channel='1',
                                      position='200,30,0',
                                      range=180)
        self.ap2 = net.addAccessPoint('ap2',
                                      ssid='ssid-ap2',
                                      mode='g',
                                      channel='1',
                                      position='100,230,0',
                                      range=180)
        self.ap3 = net.addAccessPoint('ap3',
                                      ssid='ssid-ap3',
                                      mode='g',
                                      channel='1',
                                      position='300,230,0',
                                      range=180)

        c1 = net.addController('c1', controller=Controller)

        print "*** Configuring wifi nodes"
        net.configureWifiNodes()

        print "*** Associating and Creating links"
        net.addLink(self.h1, self.ap1)
        net.addLink(self.ap1, self.ap2)
        net.addLink(self.ap2, self.ap3)
        """uncomment to plot graph"""
        net.plotGraph(max_x=400, max_y=400)
        """association control"""
        net.associationControl("ssf")
        """Seed"""
        net.seed(5)
        """random walking"""
        net.startMobility(time=0,
                          model='RandomDirection',
                          max_x=400,
                          max_y=400,
                          min_v=3,
                          max_v=5)

        print "*** Starting network"
        net.build()
        c1.start()
        self.ap1.start([c1])
        self.ap2.start([c1])
        self.ap3.start([c1])

        print "*** Running CLI"
        CLI(net)
        second = self.sleeptime(0, 0, 1)

        # new_rssi = [chanFunt(ap1,sta14),chanFunt(ap2,sta14),chanFunt(ap3,sta14)]
        # n_actions, n_APs = len(new_rssi), len(new_rssi)
        # brain = DeepQNetwork(n_actions,n_APs,param_file = None)

        # state = new_rssi
        # print 'initial observation:' + str(state)
        try:
            while True:
                time.sleep(second)
                new_rssi = [
                    self.chanFunt(self.ap1, self.sta14),
                    self.chanFunt(self.ap2, self.sta14),
                    self.chanFunt(self.ap3, self.sta14)
                ]
                print new_rssi, self.connected_tag(self.sta14)
                # print _getreward(sta14,h1)
                print self.iperf([self.sta14, self.h1], seconds=0.0000001)
                # action,q_value = brain.choose_action(state)
                # reward, nextstate = step(rssi_tag(sta14),action)

                # brain.setPerception(state, action, reward, nextstate)
                # state = nextstate
        except KeyboardInterrupt:
            print 'saving replayMemory...'
            # brain.saveReplayMemory()
        pass
        # print new_rssi
        # snr_dict = map(setSNR,new_rssi)

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