def topology():

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

    print "*** Creating nodes"
    sta1 = net.addStation('sta1',
                          mac='00:00:00:00:00:01',
                          ip='10.0.0.1/8',
                          range=10)
    ap1 = net.addAccessPoint('ap1',
                             ssid='new-ssid1',
                             mode='g',
                             channel='1',
                             position='15,30,0',
                             range=33)
    ap2 = net.addAccessPoint('ap2',
                             ssid='new-ssid1',
                             mode='g',
                             channel='6',
                             position='55,30,0',
                             range=33)
    s3 = net.addSwitch('s3')
    h1 = net.addHost('h1', mac='00:00:00:00:00:02', ip='10.0.0.2/8')
    c1 = net.addController('c1', controller=Controller, port=6653)

    print "*** Configuring WiFi Nodes"
    net.configureWifiNodes()

    net.plotNode(h1, position='35,90,0')
    net.plotNode(s3, position='35,80,0')

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

    '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(sta1, 'stop', time=80, position='60,30,0')
    net.stopMobility(time=80)

    print "*** Starting network"
    net.build()
    c1.start()
    ap1.start([c1])
    ap2.start([c1])
    s3.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-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()
Example #3
0
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 #4
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',
                          range=20)
    sta2 = net.addStation('sta2',
                          mac='00:00:00:00:00:03',
                          ip='10.0.0.3/8',
                          range=20)
    ap1 = net.addAccessPoint('ap1',
                             ssid='ssid-ap1',
                             mode='g',
                             channel='1',
                             position='15,30,0',
                             range=30)
    ap2 = net.addAccessPoint('ap2',
                             ssid='ssid-ap2',
                             mode='g',
                             channel='6',
                             position='55,30,0',
                             range=30)
    c1 = net.addController('c1', controller=Controller)

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

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

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

    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 "*** Starting network"
    net.build()
    c1.start()
    ap1.start([c1])
    ap2.start([c1])

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

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

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

    print "*** Creating nodes"
    sta1 = net.addStation('sta1',
                          mac='00:00:00:00:00:02',
                          ip='10.0.0.2/8',
                          range=20)
    sta2 = net.addStation('sta2',
                          mac='00:00:00:00:00:03',
                          ip='10.0.0.3/8',
                          range=20)
    ap1 = net.addAccessPoint('ap1',
                             ssid='ssid-ap1',
                             mode='g',
                             channel='1',
                             failMode='standalone',
                             position='15,30,0',
                             range=30)
    ap2 = net.addAccessPoint('ap2',
                             ssid='ssid-ap2',
                             mode='g',
                             channel='6',
                             failMode='standalone',
                             position='55,30,0',
                             range=30)

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

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

    '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=30, position='60,30,0')
    net.mobility(sta2, 'stop', time=10, position='25,40,0')
    net.stopMobility(time=40)

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

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

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

    "Create a network."
    net = Mininet(controller=Controller, 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.plotGraph(max_x=200, max_y=200)

    if coord:
        sta1.coord = ['40.0,30.0,0.0', '31.0,10.0,0.0', '31.0,30.0,0.0']
        sta2.coord = ['40.0,40.0,0.0', '55.0,31.0,0.0', '55.0,81.0,0.0']

    net.startMobility(time=0, repetitions=1)
    if coord:
        net.mobility(sta1, 'start', time=1)
        net.mobility(sta2, 'start', time=2)
        net.mobility(sta1, 'stop', time=12)
        net.mobility(sta2, 'stop', time=22)
    else:
        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(time=23)

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

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

    print "*** Stopping network"
    net.stop()
Example #7
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 #8
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.addAccessPoint('ap1',
                             ssid='new-ssid1',
                             mode='g',
                             channel='1',
                             position='15,30,0')
    ap2 = net.addAccessPoint('ap2',
                             ssid='new-ssid2',
                             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])
    """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 #9
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 #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' )
    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 #11
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 #12
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()
Example #13
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 #14
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 #16
0
class Functions:
    mini = 0

    def __init__(self):
        self.mini = Mininet(controller=Controller,
                            link=TCLink,
                            accessPoint=OVSKernelAP)

    def stop(self):
        self.mini.stopMobility()
        self.mini.stop()

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

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

        c1 = self.mini.addController('c1', controller=Controller)

        self.mini.configureWifiNodes()
        '''self.mini.plotGraph(max_x=300, max_y=300)

        self.mini.seed(20)'''

        "*** Available models: RandomWalk, TruncatedLevyWalk, RandomDirection, RandomWayPoint, GaussMarkov, ReferencePoint, TimeVariantCommunity ***"
        self.mini.startMobility(time=0,
                                model='GaussMarkov',
                                max_x=200,
                                max_y=200,
                                min_x=-200,
                                min_y=-200,
                                min_v=0.3,
                                max_v=1.2)

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

    def ping_nodes(self, src, dst):
        hosts = []
        for x in self.mini.stations:
            if x.name == src:
                hosts.append(x)
        for x in self.mini.accessPoints:
            if x.name == src:
                hosts.append(x)

        for x in self.mini.stations:
            if x.name == dst:
                hosts.append(x)
        for x in self.mini.accessPoints:
            if x.name == dst:
                hosts.append(x)
        return hosts

    def ping(self, src=None, dst=None, timeout=None):
        if src is None and dst is None:
            hosts = None
        else:
            hosts = self.ping_nodes(src, dst)
            if not hosts:
                return "Entered wrong set of nodes for pinging!"

        packets = 0
        lost = 0
        ploss = None
        out_string = ""
        if not hosts:
            hosts = self.mini.hosts + self.mini.stations
            out_string += '*** Ping: testing ping reachability\n'
        for node in hosts:
            out_string += '%s -> ' % node.name
            for dest in hosts:
                if node != dest:
                    opts = ''
                    if timeout:
                        opts = '-W %s' % timeout
                    if dest.intfs:
                        result = node.cmdPrint('ping -c1 %s %s' %
                                               (opts, dest.IP()))
                        sent, received = self.mini._parsePing(result)
                    else:
                        sent, received = 0, 0
                    packets += sent
                    if received > sent:
                        out_string += '*** Error: received too many packets\n'
                        out_string += '%s' % result
                        node.cmdPrint('route')
                        exit(1)
                    lost += sent - received
                    out_string += ('%s ' % dest.name) if received else 'X '
            out_string += '\n'
        if packets > 0:
            ploss = 100.0 * lost / packets
            received = packets - lost
            out_string += "*** Results: %i%% dropped (%d/%d received)\n" % (
                ploss, received, packets)
        else:
            ploss = 0
            out_string += "*** Warning: No packets sent\n"
        print out_string
        return out_string

    def ret_info(self):
        array = []

        for x in range(0, len(self.mini.accessPoints)):
            string_pos = str(
                self.mini.accessPoints[x].params['position'][0]) + " " + str(
                    self.mini.accessPoints[x].params['position'][1])
            string_name = self.mini.accessPoints[x].name
            node = make_node(string_name, string_pos, 'ap')
            array.append(node)

        for y in range(0, len(self.mini.stations)):
            string_pos = str(
                self.mini.stations[y].params['position'][0]) + " " + str(
                    self.mini.stations[y].params['position'][1])
            string_name = self.mini.stations[y].name
            node = make_node(string_name, string_pos, 'st')
            array.append(node)

        return array
Example #17
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 #18
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()
Example #19
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')
    sta3 = net.addStation('sta3', mac='00:00:00:00:00:04', ip='10.0.0.4/8')
    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()

    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)

    print "*** Waiting until stations are in range of ap2..."
    sleep(55)

    print "*** Starting test..."
    s1 = net.get('sta1')
    s2 = net.get('sta2')
    outfile = '/tmp/%s.out' % s2.name
    s2.cmd('./rcv.py 2>&1 > %s &' % outfile)
    sleep(1)
    s1.cmd('./send.py')
    sleep(1)
    s1.cmd('kill %send.py')
    s2.cmd('kill %rcv.py')
    print "*** Ending test..."

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

    print "*** Stopping network"
    net.stop()
Example #20
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 #21
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()
Example #22
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 #23
0
def topology():
    call(["sudo", "sysctl","-w","net.mptcp.mptcp_enabled=0"])
    call(["sudo", "modprobe","mptcp_coupled"])
    call(["sudo", "sysctl","-w", "net.ipv4.tcp_congestion_control=cubic"])
    net = Mininet(controller=Controller, 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')
    nodes.append(h1)

    s1 = net.addSwitch('s1', mac='00:00:00:00:00:02')
    nodes.append(s1)
    sta1 = net.addStation('sta1', mac='00:00:00:00:00:03')
    nodes.append(sta1)
    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(ap1,s1)
    net.addLink(ap2,s1)
    net.addLink(ap3,s1)

    net.plotGraph(max_x=200, max_y=200)
    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=10000)
    print"***Starting network"
    net.start()

    c1.start()
    s1.start([c1])
    ap1.start([c1])
    ap2.start([c1])
    ap3.start([c1])
    
    print('*** set flow tables ***\n')
    #call(["sudo", "bash","fa_ft.sh"])
    users=["sta1"]
    nets=["ap1","ap2","ap3"]
    #FDM(net,users,nets,{},{},{},0,100,5)
    print"***Running CLI"
    CLI(net)

    time.sleep(1)
    print("starting D-ITG servers...\n")
    h1.cmdPrint("/home/osboxes/DITG/bin/ITGRecv &")
    time.sleep(2)
    sta1.cmdPrint("/home/osboxes/DITG/bin/ITGSend -T UDP  -a 10.0.0.1"+" -c 100 -C 200 -t 10000 -l send.log -x recv.log")
    time.sleep(5)

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

    print"***Stopping network"
    time.sleep(1)
    net.stop()
Example #24
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 #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)

    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 #26
0
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,60,0',
                             range='30')
    ap2 = net.addAccessPoint('ap2',
                             ssid='AP2',
                             mode='g',
                             channel='6',
                             position='60,60,0',
                             range='30')
    ap3 = net.addAccessPoint('ap3',
                             ssid='AP3',
                             mode='g',
                             channel='11',
                             position='40,40,0',
                             range='30')
    ap4 = net.addAccessPoint('ap4',
                             ssid='AP4',
                             mode='g',
                             channel='1',
                             position='60,40,0',
                             range='30')
    ap5 = net.addAccessPoint('ap5',
                             ssid='AP5',
                             mode='g',
                             channel='6',
                             position='80,50,0',
                             range='30')

    sta1 = net.addStation('sta1',
                          mac='00:00:00:00:00:10',
                          ip='10.0.0.10/24',
                          position='0,0,0')
    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(sw10, sw40)
    net.addLink(sw10, h1)
    net.addLink(sw20, h2)
    net.addLink(sw10, ap1)
    net.addLink(sw20, ap2)
    net.addLink(sw30, ap3)
    net.addLink(sw40, ap4)
    net.addLink(sw30, ap5)

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

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

    start = 2
    net.startMobility(startTime=start)
    net.mobility(sta1, 'start', time=start, position='0.0,0.0,0.0')
    net.mobility(sta1, 'stop', time=start + 30, position='60.0,50.0,0.0')
    net.stopMobility(stopTime=start + 31)

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

    print "Running CLI"
    CLI(net)

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

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

    #Adding Physical Interface
    info( 'Defining physical interface\n')
    intfName = 'eth1'

    print "*** Creating nodes"
    h1 = net.addHost("h1", mac='00:00:00:00:00:04', ip='10.0.0.5/8', position='260,200,0')
    r1 = net.addHost("r1", mac='00:00:00:00:01:00', ip='192.168.59.4/24', position='500,20,0')
    sta1 = net.addStation('sta1', mac='00:00:00:00:00:02', ip='192.168.59.2/24')
    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', range='170', position='0,1,0')
    ap2 = net.addAccessPoint('ap2', ssid='ssid-ap2', mode='g', channel='9', range='170', position='300,1,0')
#    ap3 = net.addAccessPoint('ap3', ssid='ssid-ap3', mode='g', channel='11', range='170', position='520,1,0')
    s1 = net.addSwitch('s1',ip = '10.0.0.1/8' ,position='260,0,0')
    s2 = net.addSwitch('s2',ip = '172.26.117.1/24', position='260,170,0')
    s3 = net.addSwitch('s3',ip = '192.168.59.1/24', position='260,340,0')
    c1 = net.addController('c1', controller=Controller)

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

    print "*** Creating links"
    net.addLink(ap1, s1)
    net.addLink(ap2 ,s3)
#    net.addLink(ap3, s1)
    net.addLink(h1, s1)
    net.addLink(s1, s2)
    net.addLink(s2, s3)
    net.addLink(s3, r1)

    info( 'Adding hardware interface', intfName, 'to switch', s2.name, '\n')
    _intf = Intf( intfName, node=s2 )

    """plotting graph"""
    net.plotGraph(min_x=-200, max_x=700, min_y=-200, max_y=200)

    net.startMobility(time=50)
    net.mobility(sta1, 'start', time=50, position='400,0,0') #-100,-50 test1
    net.mobility(sta2, 'start', time=50, position='-100,0,0')
#    net.mobility(h1 , 'start',time = 50 ,position ='0.110.0')
    net.mobility(sta1, 'stop', time=650, position='500,1,0')
    net.mobility(sta2, 'stop', time=650, position='500,-1,0')
    net.stopMobility(time=650)

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

   # ap3.start([c1])
    print s1.cmd('ovs-vsctl set bridge s1 protocols=OpenFlow13')
    print s1.cmd('ovs-ofctl -O OpenFlow13 add-flow s1 action=flood')
    print s2.cmd('ovs-vsctl set bridge s2 protocols=OpenFlow13')
    print s2.cmd('ovs-ofctl -O OpenFlow13 add-flow s2 action=flood')
    print r1.cmd('ifconfig r1-eth0 inet6 add 2001:aaaa::1/64')
    print r1.cmd('ifconfig r1-eth1 inet6 add 2001:bbbb::1/64')
    print r1.cmd('radvd -C radvd1.conf')
    print r1.cmd('sysctl -w net.ipv6.conf.all.forwarding=1')
    print h1.cmd('ifconfig h1-eth0 inet6 add 2001:bbbb::2/64')
    print h1.cmd('ip -6 route add ::/0 via 2001:bbbb::1')

    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)

    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)

    """
    print "*** Starting test..."
    s1 = net.get('sta1')
    s2 = net.get('sta2')
    s2.sendCmd('./rcv.py')
    sleep(1)
    s1.sendCmd('./send.py')
    sleep(1)
    s2.waitOutput()
    s1.waitOutput()
    s1.cmd('kill %send.py')
    s2.cmd('kill %rcv.py')
    print "*** Ending test..."
    """
    print "*** Starting test..."
    s1 = net.get('sta1')
    s2 = net.get('sta2')
    s3 = net.get('sta3')
    po2 = s2.popen('./rcv.py', s2.IP(), '%s.out' % s2.name)
    po3 = s3.popen('./rcv.py', s3.IP(), '%s.out' % s3.name)
    sleep(1)
    po1 = s1.popen('./send.py')
    sleep(5)
    po1.send_signal( SIGINT )
    po2.send_signal( SIGINT )
    po3.send_signal( SIGINT )
    print "*** Ending test..."

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

    print "*** Stopping network"
    net.stop()
Example #29
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=Controller, 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')
    nodes.append(h1)
    s1 = net.addSwitch('s1', mac='00:00:00:00:00:02')

    #lte = net.addSwitch('s2')
    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='1,50,0')
    nodes.append(sta1)
    s3=net.addSwitch('s3')
    s4=net.addSwitch('s4')
    s5=net.addSwitch('s5')
    s6=net.addSwitch('s6')

    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(h1, s1)

    #net.addLink(ap1,s1)
    #net.addLink(ap2,s1)
    #net.addLink(ap3,s1)

    net.addLink(ap1, s3)
    net.addLink(ap2, s4)
    net.addLink(ap3, s5)

    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)
    #net.addLink(s6,s1 , bw=20, delay='50ms', loss=0, use_htb=True)

    net.addLink(lte,s1 , bw=20, delay='50ms', loss=0, use_htb=True)

    #net.addLink(lte,sta1)
    #net.addLink(ap1,sta1)

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

    net.startMobility(time=0, AC='ssf')
    net.mobility(sta1, 'start', time=0, position='1,50,0')
    net.mobility(sta1, 'stop', time=100, position='13,50,0')
    net.stopMobility(time=1000)

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

    c1.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])

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

    time.sleep(1)
    print("starting D-ITG servers...\n")
    h1.cmdPrint("/home/osboxes/DITG/bin/ITGRecv &")
    time.sleep(2)
    sta1.cmdPrint("/home/osboxes/DITG/bin/ITGSend -T TCP  -a 10.0.0.1"+" -c 1000 -C 2000 -t 10000 -l send.log -x recv.log")


    print("running simulaiton...\n")
    time.sleep(10)
    #time.sleep(sTime/2000)


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

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

    print "*** Creating nodes"
    h0 = net.addHost('h0', ip='10.0.0.33/8')
    s0 = net.addSwitch('s0')
    ap1 = net.addAccessPoint('ap1',
                             ssid='ssid',
                             mode='g',
                             channel='1',
                             position='15,30,0',
                             range='20')
    ap2 = net.addAccessPoint('ap2',
                             ssid='ssid',
                             mode='g',
                             channel='6',
                             position='65,30,0',
                             range='20')
    ap3 = net.addAccessPoint('ap3',
                             ssid='ssid',
                             mode='g',
                             channel='6',
                             position='230,130,0',
                             range='20')
    sate10 = net.addAccessPoint('sate10',
                                ssid='satellite',
                                mode='g',
                                channel='6',
                                position='37,50,0',
                                range='100')
    lte20 = net.addAccessPoint('lte20',
                               ssid='lte',
                               mode='g',
                               channel='6',
                               position='105,5,0',
                               range='100')

    stas = []
    for n in range(0, 9):
        stas.append(n)
    for n in range(0, 9):
        stas[n] = net.addStation('sta%s' % (n + 1),
                                 mac='00:00:00:00:00:0%s' % (n + 1),
                                 ip='10.0.0.%s/8' % (n + 1))
    sta11 = net.addStation('sta11', position='69,25,0')

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

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

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

    print "*** Creating links and associations"
    net.addLink(h0, s0)
    net.addLink(s0, ap3, bw=20, loss=0.1)
    net.addLink(ap1, ap2)
    net.addLink(ap2, ap3, bw=20, loss=0.1)
    net.addLink(s0, sate10, bw=20, loss=0.1)
    net.addLink(s0, lte20, bw=20, loss=0.1)
    """plot graph"""
    net.plotGraph(max_x=300, max_y=300)

    net.startMobility(time=0)
    net.mobility(stas[0], 'start', time=3, position='190, 190, 0.0')
    net.mobility(stas[0], 'stop', time=5, position='63, 39, 0.0')
    net.mobility(stas[1], 'start', time=1, position='190, 130, 0.0')
    net.mobility(stas[1], 'stop', time=5, position='90, 100, 0.0')
    net.mobility(stas[2], 'start', time=0, position='20, 130, 0.0')
    net.mobility(stas[2], 'stop', time=5, position='50, 70, 0.0')
    net.mobility(stas[3], 'start', time=1, position='170, 90, 0.0')
    net.mobility(stas[3], 'stop', time=3, position='120, 70, 0.0')
    net.mobility(stas[4], 'start', time=1, position='170, 90, 0.0')
    net.mobility(stas[4], 'stop', time=3, position='100, 75, 0.0')
    for sta in stas[5:]:
        x_start = random.randint(0, 300)
        y_start = random.randint(0, 300)
        x_stop = random.randint(5, 30)
        y_stop = random.randint(3, 50)
        t_start = random.randint(1, 5)
        t_stop = random.randint(8, 10)
        net.mobility(sta,
                     'start',
                     time=t_start,
                     position='%s, %s, 0.0' % (x_start, y_start))
        net.mobility(sta,
                     'stop',
                     time=t_stop,
                     position='%s, %s, 0.0' % (x_stop, y_stop))

    net.stopMobility(time=10)

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

    sleep(5)
    cnt = 1
    for sta in stas:
        cmd = 'iwconfig sta%d-wlan0 disconnect' % (cnt)
        sta.cmd(str(cmd))
        sta.cmd('iwconfig sta%d-wlan0 essid %s ap %s' %
                (cnt, lte20.params['ssid'][0], lte20.params['mac'][0]))
        cnt += 1
    sta11.cmd('iwconfig sta11-wlan0 essid %s ap %s' %
              (lte20.params['ssid'][0], lte20.params['mac'][0]))

    #h0.cmd('iperf -s -i 1 > result')
    #cnt = 1
    #for sta in stas:
    #    print('iperf -c -i 1 -t 10 > result%d' % cnt)
    #    sta.cmd('iperf -c -i 1 -t 10 > result%d' % cnt)
    #sta11.cmd('iperf -c -i 1 -t 10 > result11')

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

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