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', 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='10,10,0' )
    c1 = net.addController( 'c1', controller=Controller )

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

    print "*** Associating and Creating links"
    net.addLink(ap1, h1, 1, 0)
    net.addLink(ap1, sta1)
    net.addLink(ap1, sta2)
    
    print "*** Starting network"
    net.build()
    c1.start()
    ap1.start( [c1] )
    
    
    "*** Available models: RandomWalk, TruncatedLevyWalk, RandomDirection, RandomWaypoint, GaussMarkov ***"
    net.startMobility(0, model='GaussMarkov', max_x=20, max_y=20, min_v=0.1, max_v=0.3)
   
    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()
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-ssid1', mode= 'g', channel= '1', position='15,50,0' )
    ap2 = net.addBaseStation( 'ap2', ssid= 'new-ssid2', mode= 'g', channel= '6', position='25,30,0' )
    c1 = net.addController( 'c1', controller=Controller )

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

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

    ap1.cmd('ifconfig ap1-eth1 20.0.0.2/8')
    ap2.cmd('ifconfig ap2-eth1 20.0.0.3/8')

    print "*** Starting Wishful framework"
    folder = './'

    print "*** ... agents ..."
    agent1 = WishfulAgent(ap1, folder + 'agent', folder + 'agent_config_1.yaml')
    agent2 = WishfulAgent(ap2, folder + 'agent', folder + 'agent_config_2.yaml')
    agent1.start()
    agent2.start()

    print "*** ... controller ..."
    wf_ctrl = WishfulController(ap1, folder + 'global_controller', folder + 'controller_config.yaml')
    wf_ctrl.start()

    print "*** Starting network"

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

    net.startMobility(startTime=0)
    net.mobility('sta1', 'start', time=0, position='10,45,0')
    net.mobility('sta1', 'stop', time=60, position='50,20,0')
    net.mobility('sta2', 'start', time=0, position='0,60,0')
    net.mobility('sta2', 'stop', time=60, position='30,10,0')
    net.stopMobility(stopTime=60)

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

    print "*** Stopping network"
    wf_ctrl.stop()    
    agent1.stop()
    agent2.stop()
    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()
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()
Example #6
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 #8
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 #9
0
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=100, max_y=100)
    """Seed"""
    net.seed(1)

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

    "*** Available mobility models: RandomWalk, TruncatedLevyWalk, RandomDirection, RandomWayPoint, GaussMarkov ***"
    net.startMobility(startTime=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()
Example #10
0
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-ssid1',
                             mode='g',
                             channel='1',
                             position='15,30,0')
    ap2 = net.addBaseStation('ap2',
                             ssid='new-ssid2',
                             mode='g',
                             channel='6',
                             position='55,30,0')
    c1 = net.addController('c1', controller=Controller)

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

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

    net.startMobility(startTime=0)
    net.mobility('sta1', 'start', time=1, position='10,30,0')
    net.mobility('sta2', 'start', time=2, position='10,40,0')
    net.mobility('sta1', 'stop', time=40, position='60,30,0')
    net.mobility('sta2', 'stop', time=40, position='25,40,0')
    net.stopMobility(stopTime=40)

    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', 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=Controller)

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

    print "*** Stopping network"
    net.stop()
Example #12
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("logDistancePropagationLossModel", exp=4)

    print "*** Configuring wifi nodes"
    net.configureWifiNodes()
    """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 "*** 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,
                  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(model="logDistance", 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()
Example #14
0
def topology():

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

    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', 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='45,40,0')
    c1 = net.addController('c1', controller=Controller)

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

    print "*** Associating and Creating links"
    net.addLink(ap1, h1)
    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)

    net.startMobility(startTime=0)
    net.mobility(sta1, 'start', time=1, position='40.0,30.0,0.0')
    net.mobility(sta2, 'start', time=2, position='40.0,40.0,0.0')
    net.mobility(sta1, 'stop', time=12, position='31.0,10.0,0.0')
    net.mobility(sta2, 'stop', time=22, position='55.0,31.0,0.0')
    net.stopMobility(stopTime=23)

    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 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("logDistancePropagationLossModel", 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', 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 ***"
    net.startMobility(startTime=0,
                      model='RandomDirection',
                      max_x=60,
                      max_y=60,
                      min_v=0.1,
                      max_v=0.2)

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

    print "*** Stopping network"
    net.stop()
Example #18
0
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' )
    ap1 = net.addBaseStation( 'ap1', ssid= 'new-ssid1', mode= 'g', channel= '1', position='15,30,0' )
    ap2 = net.addBaseStation( 'ap2', ssid= 'new-ssid1', mode= 'g', channel= '6', position='55,30,0' )
    s3 = net.addSwitch( 's3' )
    h4 = net.addHost( 'h4', ip='10.0.0.4/8' )
    c1 = net.addController( 'c1', controller=Controller, port=6653 )

    net.plotHost(h4, position='35,90,0')
    net.plotHost(s3, position='35,80,0')

    print "*** Creating links"
    net.addLink(ap1, s3)
    net.addLink(ap2, s3)
    net.addLink(h4, s3)

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

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

    net.startMobility(startTime=0)
    net.mobility('sta1', 'start', time=1, position='10,30,0')
    net.mobility('sta1', 'stop', time=40, position='60,30,0')
    net.stopMobility(stopTime=40)

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

    print "*** Stopping network"
    net.stop()
Example #19
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, 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='ssid-ap1', mode='g', channel='1', position='15,30,0')
    ap2 = net.addAccessPoint('ap2', ssid='ssid-ap2', mode='g', channel='6', position='55,30,0')
    c1 = net.addController('c1', controller=Controller)

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

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

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

    """plotting graph"""
    net.plotGraph(max_x=100, max_y=100)

    net.startMobility(time=0)
    net.mobility(sta1, 'start', time=1, position='10,30,0')
    net.mobility(sta2, 'start', time=2, position='10,40,0')
    net.mobility(sta1, 'stop', time=10, position='60,30,0')
    net.mobility(sta2, 'stop', time=10, position='25,40,0')
    net.stopMobility(time=40)

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

    print "*** Stopping network"
    net.stop()
Example #21
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', 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='15,30,0')
    c1 = net.addController('c1', controller=Controller)

    print "*** Associating and Creating links"
    net.addLink(ap1, h1)
    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=60, max_y=60)

    net.startMobility(startTime=0)
    net.mobility('sta1', 'start', time=1, position='10.0,20.0,0.0')
    net.mobility('sta2', 'start', time=2, position='10.0,30.0,0.0')
    net.mobility('sta1', 'stop', time=12, position='1.0,0.0,0.0')
    net.mobility('sta2', 'stop', time=22, position='25.0,21.0,0.0')
    net.stopMobility(stopTime=23)

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

    print "*** Stopping network"
    net.stop()
Example #22
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')
    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()
Example #23
0
def topology():

    net = Mininet( controller=Controller, link=TCLink, accessPoint=OVSKernelAP )

    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', range='20' )
    ap1 = net.addAccessPoint( 'ap1', ssid= 'ap1-ssid', mode= 'g', channel= '1', position='30,50,0', range='30' )
    ap2 = net.addAccessPoint( 'ap2', ssid= 'ap2-ssid', mode= 'g', channel= '1', position='90,50,0', range='30' )
    ap3 = net.addAccessPoint( 'ap3', ssid= 'ap3-ssid', mode= 'g', channel= '1', position='130,50,0', range='30' )
    c1 = net.addController( 'c1', controller=Controller )

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

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

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

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

    net.startMobility(startTime=0, AC='ssf')
    net.mobility(sta1, 'start', time=20, position='1,50,0')
    net.mobility(sta1, 'stop', time=79, position='159,50,0')
    net.stopMobility(stopTime=80)

    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()
Example #25
0
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-ssid1', mode= 'g', channel= '1', position='15,50,0' )
    ap2 = net.addBaseStation( 'ap2', ssid= 'new-ssid2', mode= 'g', channel= '6', position='25,30,0' )
    c1 = net.addController( 'c1', controller=Controller )

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

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

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

    net.startMobility(0)
    net.mobility('sta1', 'start', time=1, position='10.0,45.0,0.0')
    net.mobility('sta2', 'start', time=2, position='10.0,40.0,0.0')
    net.mobility('sta1', 'stop', time=12, position='15.0,10,0.0')
    net.mobility('sta2', 'stop', time=22, position='25.0,25,0.0')
    net.stopMobility(23)

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

    print "*** Stopping network"
    net.stop()
Example #26
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", 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="15,30,0")
    c1 = net.addController("c1", controller=Controller)

    print "*** Associating and Creating links"
    net.addLink(ap1, h1)
    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=60, max_y=60)

    net.startMobility(startTime=0)
    net.mobility("sta1", "start", time=1, position="10.0,20.0,0.0")
    net.mobility("sta2", "start", time=2, position="10.0,30.0,0.0")
    net.mobility("sta1", "stop", time=12, position="1.0,0.0,0.0")
    net.mobility("sta2", "stop", time=22, position="25.0,21.0,0.0")
    net.stopMobility(stopTime=23)

    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', 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='45,40,0' )
    c1 = net.addController( 'c1', controller=Controller )

    print "*** Associating and Creating links"
    net.addLink(ap1, h1)
    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)

    net.startMobility(startTime=0)
    net.mobility('sta1', 'start', time=1, position='40.0,30.0,0.0')
    net.mobility('sta2', 'start', time=2, position='40.0,40.0,0.0')
    net.mobility('sta1', 'stop', time=12, position='31.0,10.0,0.0')
    net.mobility('sta2', 'stop', time=22, position='55.0,31.0,0.0')
    net.stopMobility(stopTime=23)

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

    print "*** Stopping network"
    net.stop()
Example #28
0
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')
    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 Propagation Model"
    net.propagationModel("logDistancePropagationLossModel", exp=3)

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

    """plotting graph"""
    net.plotGraph(max_x=300, max_y=300)

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

    "*** Available models: RandomWalk, TruncatedLevyWalk, RandomDirection, RandomWayPoint, GaussMarkov, ReferencePoint, TimeVariantCommunity ***"
    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()
Example #29
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()
Example #30
0
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-ssid1', mode= 'g', channel= '1', position='15,50,0' )
    ap2 = net.addBaseStation( 'ap2', ssid= 'new-ssid2', mode= 'g', channel= '6', position='25,30,0' )
    c1 = net.addController( 'c1', controller=Controller )

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

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

    "Configure IP addresses on APs for binding Wishful agent"
    ap1.cmd('ifconfig ap1-eth1 20.0.0.2/8')
    ap2.cmd('ifconfig ap2-eth1 20.0.0.3/8')

    print("*** Starting Wishful framework")
    folder = './'

    print("*** ... agents ...")
    agent1 = WishfulAgent(ap1, folder + 'agent', folder + 'agent1_cfg.yaml')
    agent2 = WishfulAgent(ap2, folder + 'agent', folder + 'agent2_cfg.yaml')
    agent1.start()
    agent2.start()

    print("*** ... controller ...")
    wf_ctrl = WishfulController(ap1, folder + 'global_controller', folder + 'controller_cfg.yaml')
    wf_ctrl.start()

    print("*** Starting network")

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

    if MOBILITY:
        net.startMobility(startTime=0)
        net.mobility('sta1', 'start', time=0, position='10,45,0')
        net.mobility('sta1', 'stop', time=60, position='50,20,0')
        net.mobility('sta2', 'start', time=0, position='0,60,0')
        net.mobility('sta2', 'stop', time=60, position='30,10,0')
        net.stopMobility(stopTime=60)

    print("*** Starting network")

    print("*** wait for node discovery")
    time.sleep(3)

    print("*** perform ping")
    sta1.cmd('ping -c20 %s' % sta2.IP())

    print("*** Check that Wishful agents/controllers are still running ...")
    if not wf_ctrl.check_is_running() or not agent1.check_is_running() or not agent2.check_is_running():
        raise Exception("Error; wishful controller or agents not running; check logfiles ... ")
    else:
        print("*** Wishful agents/controllers: OK")

    if MN_CLI:
        print("*** Running CLI")
        CLI( net )

    # Show controller log file
    print('WiSHFUL agent #1 logfile content:')
    print(agent1.read_log_file())
    print('')

    print('WiSHFUL agent #2 logfile content:')
    print(agent2.read_log_file())
    print('')

    print('WiSHFUL controller logfile content:')
    print(wf_ctrl.read_log_file())
    print('')

    print("*** Stopping network")
    wf_ctrl.stop()    
    agent1.stop()
    agent2.stop()
    net.stop()
Example #31
0
def topology():
    call(["sudo", "sysctl", "-w", "net.mptcp.mptcp_enabled=1"])
    call(["sudo", "modprobe", "mptcp_coupled"])
    call(["sudo", "sysctl", "-w", "net.ipv4.tcp_congestion_control=lia"])
    net = Mininet(controller=None, link=TCLink, accessPoint=OVSKernelAP)
    nodes = []
    print "***Creating nodes"
    h1 = net.addHost('h1', mac='00:00:00:00:00:01', ip='10.0.0.1/8')

    s1 = net.addSwitch('s1', mac='00:00:00:00:00:02')
    s3 = net.addSwitch('s3')
    s4 = net.addSwitch('s4')
    s5 = net.addSwitch('s5')
    s6 = net.addSwitch('s6')
    lte = net.addSwitch('s2', mac='00:00:00:00:00:04')
    sta1 = net.addStation('sta1',
                          mac='00:00:00:00:00:03',
                          wlans=1,
                          position='60,40,0')
    nodes.append(sta1)
    #sta3 = net.addStation('sta3',wlans=2, ip='10.0.3.0/8',position='60,60,0')
    #nodes.append(sta3)
    #sta2 = net.addStation('sta2', mac='00:00:00:00:00:04', ip='10.0.2.0/8',
    #                     position='20,50,0')
    #nodes.append(sta2)
    nodes.append(h1)
    ap1 = net.addAccessPoint('ap1',
                             ssid='ap1-ssid',
                             mode='g',
                             channel='1',
                             position='30,50,0',
                             range='40')
    ap2 = net.addAccessPoint('ap2',
                             ssid='ap2-ssid',
                             mode='g',
                             channel='1',
                             position='90,50,0',
                             range='40')
    ap3 = net.addAccessPoint('ap3',
                             ssid='ap3-ssid',
                             mode='g',
                             channel='1',
                             position='130,50,0',
                             range='40')
    c1 = net.addController('c1', controller=Controller)

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

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

    print "***Associating and Creating links"
    net.addLink(s1, h1)
    '''link for AP1'''
    net.addLink(s3, s1, bw=10, delay='5ms', loss=2, use_htb=True)
    net.addLink(s4, s1, bw=10, delay='10ms', loss=1, use_htb=True)
    net.addLink(s5, s1, bw=10, delay='10ms', loss=1, use_htb=True)
    '''link for LTE'''
    #net.addLink(s6,s1 , bw=20, delay='50ms', loss=0, use_htb=True)
    net.addLink(lte, sta1)
    # net.addLink(ap1,sta3)
    # net.addLink(ap2,sta1)
    # net.addLink(ap2,sta3)
    #net.addLink(lte,sta1)
    net.addLink(ap1, s3)
    net.addLink(ap2, s4)
    net.addLink(ap3, s5)

    net.addLink(lte, s1, bw=10, delay='50ms', loss=1, use_htb=True)
    #net.addLink(lte,s6)
    #net.addLink(lte,sta3)

    # net.addLink(ap3, s1, bw=1000)

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

    # net.startMobility(time=0, AC='ssf')
    # net.mobility(sta1, 'start', time=30, position='1,50,0')
    # net.mobility(sta1, 'stop', time=60, position='29,50,0')
    # net.mobility(sta2, 'start', time=30, position='30,40,0')
    # net.mobility(sta2, 'stop', time=60, position='30,60,0')
    # net.stopMobility(time=10000)

    # iperf -c 10.0.0.1 -t 80 -i 2
    net.startMobility(time=0, AC='ssf')
    net.mobility(sta1, 'start', time=0, position='1,50,0')
    net.mobility(sta1, 'stop', time=100, position='160,50,0')
    net.stopMobility(time=110)

    print "***Starting network"
    net.start()
    # s1.start([c1])
    # s3.start([c1])
    # s4.start([c1])
    # s5.start([c1])
    # lte.start([c1])
    # ap1.start([c1])
    # ap2.start([c1])
    # ap3.start([c1])

    sta1.cmd('ifconfig sta1-wlan0 10.0.1.0/32')
    sta1.cmd('ifconfig sta1-eth1 10.0.1.1/32')

    sta1.cmd('ip route add default 10.0.0.254/8 via sta1-wlan0')
    sta1.cmd('ip route add default 192.168.0.254/24 via sta1-eth1')

    sta1.cmd('ip rule add from 10.0.1.0 table 1')
    sta1.cmd('ip rule add from 10.0.1.1 table 2')

    sta1.cmd('ip route add 10.0.1.0/32 dev sta1-wlan0 scope link table 1')
    sta1.cmd('ip route add default via 10.0.1.0 dev sta1-wlan0 table 1')

    sta1.cmd('ip route add 10.0.1.1/32 dev sta1-eth1 scope link table 2')
    sta1.cmd('ip route add default via 10.0.1.1 dev sta1-eth1 table 2')

    sta1.cmd(
        'ip route add default scope global nexthop via 10.0.1.1 dev sta1-eth1')

    # sta3.cmd('ifconfig sta3-wlan0 10.0.3.0/32')
    # sta3.cmd('ifconfig sta3-wlan1 10.0.3.1/32')
    #
    #
    # sta3.cmd('ip rule add from 10.0.3.0 table 1')
    # sta3.cmd('ip rule add from 10.0.3.1 table 2')
    #
    # sta3.cmd('ip route add 10.0.3.0/32 dev sta3-wlan0 scope link table 1')
    # sta3.cmd('ip route add default via 10.0.3.0 dev sta3-wlan0 table 1')
    #
    # sta3.cmd('ip route add 10.0.3.1/32 dev sta3-wlan1 scope link table 2')
    # sta3.cmd('ip route add default via 10.0.3.1 dev sta3-wlan1 table 2')
    #
    # sta3.cmd('ip route add default scope global nexthop via 10.0.3.0 dev sta3-wlan0')

    print('*** set flow tables ***\n')
    call(["sudo", "bash", "3ap_ft.sh"])
    users = ["sta1"]
    nets = ["ap1", "ap2", "ap3", "s2"]
    FDM(net, users, nets, {}, {}, {})
    #FDM(net,users,nets,{"sta1":1,"sta2":1,"sta3":1},{},{},0,100,5)

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

    time.sleep(1)
    print("starting D-ITG servers...\n")
    h1.cmdPrint("/home/osboxes/DITG/bin/ITGRecv &")
    h1.cmd('popd')
    folderName = 'pcap'
    if not os.path.exists(folderName):
        os.mkdir(folderName)
        user = os.getenv('SUDO_USER')
        os.system('sudo chown -R osboxes:osboxes ' + folderName)
    h1.cmd('tcpdump -i h1-eth0 -w ' + folderName + '/h1.pcap &')

    time.sleep(2)
    sta1.cmdPrint("/home/osboxes/DITG/bin/ITGSend -T TCP  -a 10.0.0.1" +
                  " -c 1000 -C 2000 -t 60000 -l send.log -x recv.log &")
    sta1.cmd('popd')
    sta1.cmd('tcpdump -i sta1-eth1 -w ' + folderName + '/sta1-eth1.pcap &')
    sta1.cmd('tcpdump -i sta1-wlan0 -w ' + folderName + '/sta1-wlan0.pcap &')
    time.sleep(115)
    #CLI(net)
    #
    # CLI(net)
    # for i in range(0,0):
    # # start D-ITG Servers
    #
    #     srv = h1
    #     print("starting D-ITG servers...\n")
    #     srv.cmdPrint("cd ~/D-ITG-2.8.1-r1023/bin")
    #     srv.cmdPrint("./ITGRecv &")
    #     srv.cmdPrint("PID=$!")
    #
    #     time.sleep(1)
    #
    #     # start D-ITG application
    #     # set simulation time
    #     sTime = 30000  # default 120,000ms
    #     #bwReq = [12,12,12,12,12]
    #     # bwReq = [10,10,8,6,6]
    #     # bwReq = [24,4,4,4,22]
    #     bwReq=[6,6, 4]
    #     num_host=4
    #     for i in range(0, num_host - 1):
    #         sender = i
    #         receiver = num_host - 1
    #         ITGTest(sender, receiver, nodes, bwReq[i]*125, sTime)
    #         time.sleep(0.2)
    #     print("running simulaiton...\n")
    #     print("please wait...\n")
    #
    #     time.sleep(sTime/2000)
    #     ap1.dpctl("del-flows")
    #     ap2.dpctl("del-flows")
    #     call(["sudo", "bash","3ap_ft2.sh"])
    #     time.sleep(sTime/2000+10)
    #     for i in [num_host-1]:
    #         srv=nodes[i]
    #         print("killing D-ITG servers...\n")
    #         srv.cmdPrint("kill $PID")
    #     # You need to change the path here
    #     call(["sudo", "python","analysis.py"])

    print "***Stopping network"
    #time.sleep(50)
    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()
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 #34
0
def topology():
    "Create a network."
    net = Mininet(controller=Controller, link=TCLink, accessPoint=OVSKernelAP)

    print "*** Creating nodes"
    sta1 = net.addStation('sta1', wlans=2)
    sta2 = net.addStation('sta2', wlans=2)
    sta3 = net.addStation('sta3', wlans=2)
    ap1 = net.addAccessPoint('ap1',
                             ssid='ssid-ap1',
                             mode='g',
                             channel='11',
                             position='115,62,0')
    ap2 = net.addAccessPoint('ap2',
                             ssid='ssid-ap2',
                             mode='g',
                             channel='1',
                             position='57,142,0')
    c1 = net.addController('c1', controller=Controller)

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

    sta1.setIP('10.0.0.2/8', intf="sta1-wlan0")
    sta2.setIP('10.0.0.3/8', intf="sta2-wlan0")
    sta3.setIP('10.0.0.4/8', intf="sta3-wlan0")
    sta1.setIP('192.168.10.1/24', intf="sta1-wlan1")
    sta2.setIP('192.168.10.2/24', intf="sta2-wlan1")
    sta3.setIP('192.168.10.3/24', intf="sta3-wlan1")

    net.addHoc(sta1, ssid='adhocNet', mode='g')
    net.addHoc(sta2, ssid='adhocNet', mode='g')
    net.addHoc(sta3, ssid='adhocNet', mode='g')

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

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

    net.associationControl('ssf')

    net.startMobility(time=0)
    net.mobility(sta1, 'start', time=1, position='86,188,0')
    net.mobility(sta2, 'start', time=1, position='78,195,0')
    net.mobility(sta3, 'start', time=1, position='93,195,0')
    net.mobility(sta1, 'stop', time=250, position='86,0,0')
    net.mobility(sta2, 'stop', time=250, position='78,7,0')
    net.mobility(sta3, 'stop', time=250, position='93,7,0')
    net.stopMobility(time=250)

    sleep(10)

    s1 = net.get('sta1')
    s2 = net.get('sta2')
    s3 = net.get('sta3')
    popens = {}  # Python subprocess.Popen objects keyed by Mininet hosts
    startTime = int(time()) + SYNC_START
    endTime = startTime + EXPERIMENT_DURATION

    print "*** Starting %d second experiment in %d second(s) - at Unix epoch: %d..." % (
        EXPERIMENT_DURATION, (startTime - int(time())), startTime)

    popens[s1] = s1.popen(EXECUTABLE_PATH, '-addr=%s' % s1.IP(),
                          '-dsts=%s,%s' % (s2.IP(), s3.IP()),
                          '-start=%d' % startTime)
    popens[s2] = s2.popen(EXECUTABLE_PATH, '-role=F', '-addr=%s' % s2.IP())
    popens[s3] = s3.popen(EXECUTABLE_PATH, '-role=F', '-addr=%s' % s3.IP())

    with open(OUTPUT_FILE, 'w') as f:
        for h, line in pmonitor(popens, timeoutms=500):
            if h:
                f.write('<%s>: %s' % (h.name, line))
            if time() >= endTime:
                break

    popens[s1].send_signal(SIGINT)
    popens[s2].send_signal(SIGINT)
    popens[s3].send_signal(SIGINT)

    f.close()

    print "*** Ending experiment..."

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

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

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

    print "*** Creating nodes"
    cars = []
    nodes = []
    print "***Creating nodes"
    h1 = net.addHost('h1', mac='00:00:00:11:00:01', ip='10.0.0.1/8')
    nodes.append(h1)
    s1 = net.addSwitch('s1', mac='00:00:00:11:00:02')
    nodes.append(s1)

    for x in range(0, 5):
        cars.append(x)
    for x in range(0, 5):
        min_ = random.randint(1, 4)
        max_ = random.randint(11, 30)
        cars[x] = net.addCar('car%s' % (x + 1),
                             wlans=1,
                             ip='10.0.0.%s/8' % (x + 1),
                             min_speed=min_,
                             max_speed=max_,
                             range=100)
        #nodes.append(car[x])

    rsu11 = net.addAccessPoint('RSU11', ssid='RSU11', mode='g', channel='1')
    rsu12 = net.addAccessPoint('RSU12', ssid='RSU12', mode='g', channel='6')
    rsu13 = net.addAccessPoint('RSU13', ssid='RSU13', mode='g', channel='11')

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

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

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

    print "*** Associating and Creating links"
    net.addLink(s1, h1)

    net.addLink(rsu11, s1)
    net.addLink(rsu12, s1)
    net.addLink(rsu13, s1)

    for x in range(0, 5):
        net.addLink('car%s' % (x + 1), rsu11)

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

    net.roads(10)

    net.startMobility(time=20)

    print "*** Starting network"
    net.build()
    c1.start()
    rsu11.start([c1])
    rsu12.start([c1])
    rsu13.start([c1])
    #rsu14.start([c1])

    print('*** set flow tables ***\n')
    #call(["sudo", "bash","fa_ft.sh"])

    i = 201
    for sw in net.carsSW:
        sw.start([c1])
        os.system('ip addr add 10.0.0.%s dev %s' % (i, sw))
        i += 1

    i = 1
    j = 2
    k = 1
    for car in cars:
        car.setIP('192.168.0.%s/24' % k, intf='%s-wlan0' % car)
        car.setIP('192.168.1.%s/24' % i, intf='%s-eth1' % car)
        car.cmd('ip route add 10.0.0.0/8 via 192.168.1.%s' % j)
        i += 2
        j += 2
        k += 1

    i = 1
    j = 2
    for carsta in net.carsSTA:
        carsta.setIP('10.0.0.%s/24' % i, intf='%s-mp0' % carsta)
        carsta.setIP('192.168.1.%s/24' % j, intf='%s-eth2' % carsta)
        #May be confuse, but it allows ping to the name instead of ip addr
        carsta.setIP('10.0.0.%s/24' % i, intf='%s-wlan0' % carsta)
        carsta.cmd('echo 1 > /proc/sys/net/ipv4/ip_forward')
        i += 1
        j += 2

    for carsta1 in net.carsSTA:
        i = 1
        j = 1
        for carsta2 in net.carsSTA:
            if carsta1 != carsta2:
                carsta1.cmd('route add -host 192.168.1.%s gw 10.0.0.%s' %
                            (j, i))
            i += 1
            j += 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()
Example #37
0
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',
                          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')

    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')

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

    print "*** Stopping network"
    net.stop()
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()
Example #39
0
def topology():
    "Create a network."
    net = Mininet(controller=Controller, link=TCLink, accessPoint=OVSKernelAP)

    print "*** Creating nodes"
    #sta1 = net.addStation( 'sta1', mac='00:00:00:00:00:02', ip='10.0.0.2/8',position='50,60,0',range=15)
    #sta2 = net.addStation( 'sta2', mac='00:00:00:00:00:03', ip='10.0.0.3/8',position='65,70,0',range=15)
    #sta3 = net.addStation( 'sta3', mac='00:00:00:00:00:04', ip='10.0.0.4/8',position='50,55,0',range=15)
    #sta4 = net.addStation( 'sta4', mac='00:00:00:00:00:05', ip='10.0.0.5/8',position='110,65,0',range=15)
    #sta5 = net.addStation( 'sta5', mac='00:00:00:00:00:06', ip='10.0.0.6/8',position='15,90,0',range=15)
    #sta6 = net.addStation( 'sta6', mac='00:00:00:00:00:07', ip='10.0.0.7/8',position='10,100,0',range=15)
    #sta7 = net.addStation( 'sta7', mac='00:00:00:00:00:08', ip='10.0.0.8/8',position='68,20,0',range=15)
    #sta8 = net.addStation( 'sta8', mac='00:00:00:00:00:09', ip='10.0.0.9/8',position='55,100,0',range=15)
    #sta9 = net.addStation( 'sta9', mac='00:00:00:00:00:10', ip='10.0.0.10/8',position='95,25,0',range=15)
    #sta10 = net.addStation( 'sta10', mac='00:00:00:00:00:11', ip='10.0.0.11/8',position='110,20,0',range=15)
    #sta11 = net.addStation( 'sta11', mac='00:00:00:00:00:12', ip='10.0.0.12/8',position='110,10,0',range=15)
    #sta12 = net.addStation( 'sta12', mac='00:00:00:00:00:13', ip='10.0.0.13/8',position='20,110,0',range=15)
    #sta13 = net.addStation( 'sta13', mac='00:00:00:00:00:14', ip='10.0.0.14/8',position='110,60,0',range=15)
    #sta15 = net.addStation( 'sta15', mac='00:00:00:00:00:16', ip='10.0.0.16/8',position='110,100,0',range=15)
    #sta16 = net.addStation( 'sta16', mac='00:00:00:00:00:17', ip='10.0.0.17/8',position='100,110,0',range=15)
    #sta17 = net.addStation( 'sta17', mac='00:00:00:00:00:18', ip='10.0.0.18/8',position='95,105,0',range=15)
    #sta18 = net.addStation( 'sta18', mac='00:00:00:00:00:19', ip='10.0.0.19/8',position='105,105,0',range=15)
    #sta19 = net.addStation( 'sta19', mac='00:00:00:00:00:20', ip='10.0.0.20/8',position='68,105,0',range=15)
    #sta20 = net.addStation( 'sta20', mac='00:00:00:00:00:21', ip='10.0.0.21/8',range=15)
    sta14 = net.addStation('sta14',
                           mac='00:00:00:00:00:15',
                           ip='10.0.0.15/8',
                           range=15)
    ap1 = net.addAccessPoint('ap1',
                             ssid='ssid-ap1',
                             mode='g',
                             channel='1',
                             position='25,25,0',
                             range=30)
    ap2 = net.addAccessPoint('ap2',
                             ssid='ssid-ap2',
                             mode='g',
                             channel='6',
                             position='25,60,0',
                             range=30)
    ap3 = net.addAccessPoint('ap3',
                             ssid='ssid-ap3',
                             mode='g',
                             channel='1',
                             position='25,100,0',
                             range=30)
    ap4 = net.addAccessPoint('ap4',
                             ssid='ssid-ap4',
                             mode='g',
                             channel='11',
                             position='60,25,0',
                             range=30)
    ap5 = net.addAccessPoint('ap5',
                             ssid='ssid-ap5',
                             mode='g',
                             channel='1',
                             position='60,60,0',
                             range=30)
    ap6 = net.addAccessPoint('ap6',
                             ssid='ssid-ap6',
                             mode='g',
                             channel='11',
                             position='60,100,0',
                             range=30)
    ap7 = net.addAccessPoint('ap7',
                             ssid='ssid-ap7',
                             mode='g',
                             channel='1',
                             position='100,25,0',
                             range=30)
    ap8 = net.addAccessPoint('ap8',
                             ssid='ssid-ap8',
                             mode='g',
                             channel='6',
                             position='95,60,0',
                             range=30)
    ap9 = net.addAccessPoint('ap9',
                             ssid='ssid-ap9',
                             mode='g',
                             channel='1',
                             position='95,95,0',
                             range=30)
    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:06', ip='10.0.0.6/8')
    c1 = net.addController('c1', controller=Controller)

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

    print "*** Associating and Creating links"
    net.addLink(h1, ap1)
    net.addLink(ap1, ap2)
    net.addLink(ap2, ap3)
    net.addLink(ap3, ap6)
    net.addLink(ap6, ap5)
    net.addLink(ap5, ap4)
    net.addLink(ap4, ap7)
    net.addLink(ap7, ap8)
    net.addLink(ap8, ap9)
    #net.addLink(sta1,ap5)
    #net.addLink(sta2,ap5)
    #net.addLink(sta3,ap5)
    #net.addLink(sta4,ap8)
    #net.addLink(h2,ap2)
    print "*** Starting network"
    net.build()
    c1.start()
    ap1.start([c1])
    ap2.start([c1])
    ap3.start([c1])
    ap4.start([c1])
    ap5.start([c1])
    ap6.start([c1])
    ap7.start([c1])
    ap8.start([c1])
    ap9.start([c1])
    """uncomment to plot graph"""
    net.plotGraph(max_x=120, max_y=120)

    net.startMobility(startTime=0)
    net.mobility(sta14, 'start', time=1, position='43,102,0')
    net.mobility(sta14, 'stop', time=101, position='60,102,0')

    net.stopMobility(stopTime=502)
    """association control"""
    #    a=Sta(sta14,"sf",ap1,ap2,ap3,ap4,ap5,ap6,ap7,ap8,ap9)
    #    a.associationcontrol(sta14,"sf",ap1,ap2,ap3,ap4,ap5,ap6,ap7,ap8,ap9)
    """Seed"""
    #net.seed(19)
    """random walking"""
    #net.startMobility(startTime=0, model='RandomDirection',max_x=120,max_y=120, min_v=1,max_v=1)

    print "*** Running CLI"
    CLI(net)
    A = []
    second = sleeptime(0, 0, 0)
    while 1 == 1:
        time.sleep(second)
        associationcontrol(sta14, ap1, ap2, ap3, ap4, ap5, ap6, ap7, ap8, ap9)
        new_rssi = [
            chanFunt(ap1, sta14),
            chanFunt(ap2, sta14),
            chanFunt(ap3, sta14),
            chanFunt(ap4, sta14),
            chanFunt(ap5, sta14),
            chanFunt(ap6, sta14),
            chanFunt(ap7, sta14),
            chanFunt(ap8, sta14),
            chanFunt(ap9, sta14)
        ]
        #print new_rssi
        #the_tag = rssi_tag(sta14)
        #print the_tag
        #t1 = threading.Thread(target=iperf,args=([sta14,h1],'TCP',0.001,))
        #t2 = threading.Thread(target=tcpexamine,args = ([h1]))
        #t1.start()
        #t2.start()
        print(iperf([sta14, h1], l4Type='TCP', seconds=0.0000001,
                    port=5001), datetime.datetime.now())
        #A.append(iperf([sta14,h1],l4Type='TCP',seconds=0.00001,port=5001))
        #if sta14.params['position'] == ('101.00','26.00','0.00'):
        #    print "*************reach destination"
        #if len(A)%1 == 0:
        #B = [float(i) for i in A]
        #    level = average([float(i)for i in A[-1:]])
        #    print "average:{0},{1}".format(level,datetime.datetime.now())
        #with open ("snake7.py","a+") as the_file:
        #    the_file.write(str(level))
        #    the_file.write(' ')
        #    the_file.write('\n')
        #    if len(A)%500==0:
        #        A=[]
        #        print "********************completed epoch{0}***************************".format(len(A)/500)

        #if new_rssi.count(0)==5 or new_rssi.count(0)==6:
        #    the_tag = rssi_tag(sta14)
        #    print new_rssi,the_tag

    #     with open ("tt.py","a+") as the_file:
    #        for item in new_rssi:
    #             the_file.write(str(item))
    #             the_file.write(" ")

    #the_file.write(":")
    #         the_file.write(str(the_tag))
    #         the_file.write('\n')
    #print new_rssi
    #the_tag = rssi_tag(sta14)
    #print the_tag
    #A.append(iperf([h1,sta14],l4Type='TCP',seconds=0.01,port=5001))
    #::if len(A)%20 == 0:
    #    B = [float(i) for i in A]
    #print "average:{}".format(average(B[-20:]))

    #    with open ('throughput.py','a+') as the_file:
    #        for i in A[-10:]
    #            the_file.write(A)
    #            the_file.write('\n')

    #with open ("tt.py","a+") as the_file:
    #    for item in new_rssi:
    #        the_file.write(str(item))
    #        the_file.write(" ")

    #the_file.write(":")
    #    the_file.write(str(the_tag))
    #    the_file.write('\n')

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

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

    print "*** Creating nodes"
    sta1 = net.addStation('sta1',
                          mac='00:00:00:00:00:02',
                          position='70.0,50.0,0.0',
                          ip='10.0.0.1/8',
                          range=10)
    ap1 = net.addAccessPoint('ap1',
                             ssid='ssid_ap1',
                             mode='g',
                             channel='1',
                             position='50,50,0',
                             range='50')
    ap2 = net.addAccessPoint('ap2',
                             ssid='ssid_ap2',
                             mode='g',
                             channel='1',
                             position='125,50,0',
                             range='50',
                             ip='10.8.8.8/8')
    ap3 = net.addAccessPoint('ap3',
                             ssid='ssid_ap3',
                             mode='g',
                             channel='1',
                             position='175,50,0',
                             range='50')
    c1 = net.addController('c1', controller=Controller)
    h1 = net.addHost('h1', ip='10.0.0.3/8')

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

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

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

    # Comment out the following two lines to disable AP
    print "*** Enabling association control (AP)"
    net.associationControl('ssf')

    net.startMobility(startTime=0)
    net.mobility(sta1, 'start', time=60, position='70.0,50.0,0.0')
    net.mobility(sta1, 'stop', time=150, position='200.0,50,0.0')
    net.stopMobility(time=151)

    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()
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 emulate():
    # Setting the position of nodes and providing mobility

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

    print("*** Creating nodes")
    # Add the host
    h1 = net.addHost('h1', mac='00:00:00:00:00:01', ip='10.0.0.1/8')

    # Add 3 mobile stations, sta1, sta2, sta3.
    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')

    # Add an access point
    ap1 = net.addAccessPoint('ap1',
                             ssid='new-ssid',
                             mode='g',
                             channel='1',
                             position='45,40,30')

    # Add a controller
    c1 = net.addController('c1', controller=Controller)

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

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

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

    # Plot a 3-dimensional graph.
    net.plotGraph(max_x=100, max_y=100, max_z=200)

    # Start the mobility at the start of the emulation.
    net.startMobility(time=0)

    # Start the mobile stations from their initial positions.
    net.mobility(sta1, 'start', time=1, position='40.0,30.0,20.0')
    net.mobility(sta2, 'start', time=2, position='40.0,40.0,90.0')
    net.mobility(sta3, 'start', time=3, position='50.0,50.0,160.0')

    # Indicate the final destination of the mobile stations during the emulation.
    net.mobility(sta1, 'stop', time=12, position='31.0,10.0,50.0')
    net.mobility(sta2, 'stop', time=22, position='55.0,31.0,30.0')
    net.mobility(sta3, 'stop', time=32, position='75.0,99.0,120.0')

    # Stop the mobility at certain time.
    net.stopMobility(time=33)

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

    print("*** Stopping network")
    net.stop()
Example #43
0
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-ssid1',
                             mode='g',
                             channel='1',
                             position='15,50,0')
    ap2 = net.addBaseStation('ap2',
                             ssid='new-ssid2',
                             mode='g',
                             channel='6',
                             position='25,30,0')
    c1 = net.addController('c1', controller=Controller)

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

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

    "Configure IP addresses on APs for binding Wishful agent"
    ap1.cmd('ifconfig ap1-eth1 20.0.0.2/8')
    ap2.cmd('ifconfig ap2-eth1 20.0.0.3/8')

    print("*** Starting Wishful framework")
    folder = './'

    print("*** ... agents ...")
    agent1 = WishfulAgent(ap1, folder + 'agent',
                          folder + 'agent_config_1.yaml')
    agent2 = WishfulAgent(ap2, folder + 'agent',
                          folder + 'agent_config_2.yaml')
    agent1.start()
    agent2.start()

    print("*** ... controller ...")
    wf_ctrl = WishfulController(ap1, folder + 'global_controller',
                                folder + 'controller_config.yaml')
    wf_ctrl.start()

    print("*** Starting network")
    """uncomment to plot graph"""
    if GUI:
        net.plotGraph(max_x=100, max_y=100)

    if MOBILITY:
        net.startMobility(startTime=0)
        net.mobility('sta1', 'start', time=0, position='10,45,0')
        net.mobility('sta1', 'stop', time=60, position='50,20,0')
        net.mobility('sta2', 'start', time=0, position='0,60,0')
        net.mobility('sta2', 'stop', time=60, position='30,10,0')
        net.stopMobility(stopTime=60)

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

    print("*** Stopping network")
    wf_ctrl.stop()
    agent1.stop()
    agent2.stop()
    net.stop()
Example #44
0
def topology():
    global car1_new
    global car2_new
    global car3_new
    global car4_new
    car1_new = ''
    car2_new = ''
    car3_new = ''
    car4_new = ''
    "Create a network."
    net = Mininet(controller=RemoteController,
                  link=TCLink,
                  switch=OVSKernelSwitch)

    print "*** Creating nodes"
    car = []
    stas = []
    for x in range(0, 4):
        car.append(x)
        stas.append(x)
    for x in range(0, 4):
        min = random.randint(20, 40)
        max = random.randint(40, 60)
        car[x] = net.addCar('car%s' % (x + 1),
                            wlans=1,
                            ip='10.0.0.%s/8' % (x + 1),
                            min_speed=min,
                            max_speed=max,
                            range=100)

    rsu11 = net.addAccessPoint('RSU11',
                               ssid='RSU11',
                               mode='g',
                               channel='1',
                               range=200,
                               ip='192.168.0.11')
    rsu12 = net.addAccessPoint('RSU12',
                               ssid='RSU12',
                               mode='g',
                               channel='6',
                               range=200,
                               ip='192.168.0.12')
    rsu13 = net.addAccessPoint('RSU13',
                               ssid='RSU13',
                               mode='g',
                               channel='11',
                               range=200,
                               ip='192.168.0.13')
    rsu14 = net.addAccessPoint('RSU14',
                               ssid='RSU14',
                               mode='g',
                               channel='1',
                               range=200,
                               ip='192.168.0.14')
    rsu15 = net.addAccessPoint('RSU15',
                               ssid='RSU15',
                               mode='g',
                               channel='6',
                               range=200,
                               ip='192.168.0.15')
    c1 = net.addController('c1',
                           controller=RemoteController,
                           ip='192.168.56.107')
    print "*** Configuring wifi nodes"
    net.configureWifiNodes()

    net.meshRouting('custom')

    print "*** Associating and Creating links"
    net.addLink(rsu11, rsu12, bw=0.7, loss=2, delay='25ms')
    net.addLink(rsu12, rsu15, bw=1, loss=3, delay='10ms')
    net.addLink(rsu13, rsu15, bw=1, loss=2, delay='10ms')
    net.addLink(rsu13, rsu14, bw=5, loss=2, delay='5ms')
    net.addLink(rsu11, rsu14, bw=0.7, loss=8, delay='25ms')
    net.addLink(rsu11, rsu13, bw=0.7, loss=2, delay='25ms')
    net.addLink(rsu12, rsu14, bw=0.7, loss=8, delay='25ms')
    net.addLink(rsu11, rsu15, bw=0.7, loss=5, delay='25ms')
    net.addLink(rsu14, rsu15, bw=0.7, loss=6, delay='25ms')
    net.addLink(rsu12, rsu13, bw=5, loss=3, delay='5ms')
    print "*** Starting network"
    net.build()
    c1.start()
    rsu11.start([c1])
    rsu12.start([c1])
    rsu13.start([c1])
    rsu14.start([c1])
    rsu15.start([c1])
    i = 201
    for sw in net.vehicles:
        sw.start([c1])
        os.system('ifconfig %s 10.0.0.%s' % (sw, i))
        i += 1
    """uncomment to plot graph"""
    net.plotGraph(max_x=1000, max_y=1000)
    """Number of Roads"""
    net.roads(6)
    """Start Mobility"""
    net.startMobility(startTime=0)

    i = 1
    j = 2
    k = 1
    for c in car:
        c.cmd('ifconfig %s-wlan0 192.168.0.%s/24 up' % (c, k))
        c.cmd('ifconfig %s-eth0 192.168.1.%s/24 up' % (c, i))
        c.cmd('ip route add 10.0.0.0/8 via 192.168.1.%s' % j)
        i += 2
        j += 2
        k += 1

    i = 1
    j = 2
    for v in net.vehiclesSTA:
        v.cmd('ifconfig %s-eth0 192.168.1.%s/24 up' % (v, j))
        v.cmd('ifconfig %s-mp0 10.0.0.%s/24 up' % (v, i))
        v.cmd('echo 1 > /proc/sys/net/ipv4/ip_forward')
        i += 1
        j += 2

    for v1 in net.vehiclesSTA:
        i = 1
        j = 1
        for v2 in net.vehiclesSTA:
            if v1 != v2:
                v1.cmd('route add -host 192.168.1.%s gw 10.0.0.%s' % (j, i))
            i += 1
            j += 2

    car1 = car[0]
    car2 = car[1]
    car3 = car[2]
    car4 = car[3]
    output(car1, car2, car3, car4)
    print "*** Running CLI"
    cmdcli = CLI(net)
    #cmdcli.do_px("print car1.cmd('iwconfig > 1234_py_test.txt')")
    #CLI( net )

    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 #46
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.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)
    """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()