Example #1
0
def topology():

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

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

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

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

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

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

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

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

    print "*** Creating nodes"
    if autoTxPower:
        sta1 = net.addStation('sta1', position='10,10,0', range=100)
        sta2 = net.addStation('sta2', position='90,10,0', range=100)
        sta3 = net.addStation('sta3', position='170,10,0', range=100)
    else:
        sta1 = net.addStation('sta1', position='10,10,0')
        sta2 = net.addStation('sta2', position='90,10,0')
        sta3 = net.addStation('sta3', position='170,10,0')

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

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

    print "*** Creating links"
    net.addHoc(sta1, ssid='adhocNet', mode='g', channel=5)
    net.addHoc(sta2, ssid='adhocNet', mode='g', channel=5)
    net.addHoc(sta3, ssid='adhocNet', mode='g', channel=5)

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

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

    print "*** Stopping network"
    net.stop()
Example #3
0
def topology():
    "Create a network."
    net = Mininet( controller=Controller, link=TCLink, accessPoint=UserAP, enable_wmediumd=True, enable_interference=True )

    print "*** Creating nodes"
    sta1 = net.addStation( 'sta1', radius_passwd='sdnteam', radius_identity='joe', position='110,120,0' )
    sta2 = net.addStation( 'sta2', radius_passwd='hello', radius_identity='bob', position='200,100,0' )
    ap1 = net.addAccessPoint( 'ap1', ssid="simplewifi", mode="8021x", encrypt='wpa2', enable_radius='yes', position='150,100,0' )
    c0 = net.addController('c0', controller=Controller, ip='127.0.0.1', port=6633 )

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

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

    print "*** Associating Stations"
    net.addLink(sta1, ap1)
    net.addLink(sta2, ap1)

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

    print "*** Building graph"
    net.plotGraph(max_x=300, max_y=300)

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

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

    print "*** Creating nodes"
    net.addStation('sta1', position='10,20,0')
    net.addStation('sta2', position='40,30,0')
    net.addStation('sta3', position='60,20,0')
    net.addAccessPoint('ap1',
                       ssid="my-ssid",
                       mode="a",
                       channel="36",
                       failMode='standalone',
                       position='10,10,0')

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

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

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

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

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

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

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

    print "*** Creating nodes"
    net.addStation('sta1', ip='10.0.0.1/8', position='80,80,0')
    ap1 = net.addAccessPoint('ap1', ip='10.0.0.101/8', mac='02:00:00:00:00:01', ssid="handover", mode="g", channel="1", ieee80211r='yes', mobility_domain='a1b2', passwd='123456789a', encrypt='wpa2', position='10,30,0', inNamespace=True)
    ap2 = net.addAccessPoint('ap2', ip='10.0.0.102/8', mac='02:00:00:00:00:02', ssid="handover", mode="g", channel="6", ieee80211r='yes', mobility_domain='a1b2', passwd='123456789a', encrypt='wpa2', position='60,30,0', inNamespace=True)
    ap3 = net.addAccessPoint('ap3', ip='10.0.0.103/8', mac='02:00:00:00:00:03', ssid="handover", mode="g", channel="1", ieee80211r='yes', mobility_domain='a1b2', passwd='123456789a', encrypt='wpa2', position='120,100,0', inNamespace=True)
    c1 = net.addController('c1', controller=Controller)

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

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

    'plotting graph'
    net.plotGraph(min_x=-100, min_y=-100, max_x=200, max_y=200)

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

    os.system('pkill -f "\wpa_supplicant -B -Dnl80211\"')

    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"
    ap1 = net.addBaseStation( 'ap1', ssid="ssid_ap1", txpower=15, mode="g", channel=1, position="10,10,0" )
    sta1 = net.addStation( 'sta1', ip='192.168.0.1/24', txpower=15, position='10,10,0' )
    sta2 = net.addStation( 'sta2', ip='192.168.0.2/24', txpower=15, position='11.36,10,0' )

    print "*** Adding Link"
    net.addLink(sta1, ap1)
    net.addLink(sta2, ap1)

    "*** Available propagation models: friisPropagationLossModel, twoRayGroundPropagationLossModel, logDistancePropagationLossModel ***"
    net.propagationModel('logDistancePropagationLossModel', exp=3, sL=1)
    #net.propagationModel('ITUPropagationLossModel', pL=50)
    #net.propagationModel('twoRayGroundPropagationLossModel')
    #net.propagationModel('friisPropagationLossModel', sL=2)

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

    for i in range(1,8):
        x = 10+i*1.36
 	y = 10
	z = 0
        pos = '%s,%s,%s' % (x,y,z)
        sta1.moveStationTo(pos)
        print sta1.params['rssi'][0] 

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

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

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

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

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

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

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

    net.seed(1)

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

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

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

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

    "Create a network."
    if wmediumd:
        net = Mininet(controller=Controller,
                      link=TCLink,
                      accessPoint=UserAP,
                      enable_wmediumd=True,
                      enable_interference=True)
    else:
        net = Mininet(controller=Controller, link=TCLink, accessPoint=UserAP)

    print "*** Creating nodes"
    sta1 = net.addStation('sta1',
                          mac='00:00:00:00:00:01',
                          ip='10.0.0.1/8',
                          position='120,140,0',
                          range=10)
    sta2 = net.addStation('sta2',
                          mac='00:00:00:00:00:02',
                          ip='10.0.0.2/8',
                          position='10,30,0',
                          range=10)
    sta3 = net.addStation('sta3',
                          mac='00:00:00:00:00:03',
                          ip='10.0.0.3/8',
                          position='10,50,0',
                          range=10)
    ap1 = net.addAccessPoint('ap1',
                             ssid='new-ssid',
                             mode='g',
                             channel='1',
                             position='15,30,0',
                             ieee80211r='yes',
                             mobility_domain='a1b2',
                             passwd='123456789a',
                             encrypt='wpa2',
                             range=33)
    c1 = net.addController('c1', controller=Controller)

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

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

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

    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,
                  accessPoint=OVSKernelAP)

    print "*** Creating nodes"
    sta1 = net.addStation('sta1', mac='00:00:00:00:00:01', ip='10.0.0.1/8')
    ap1 = net.addAccessPoint('ap1',
                             ssid='new-ssid1',
                             mode='g',
                             channel='1',
                             position='15,30,0')
    ap2 = net.addAccessPoint('ap2',
                             ssid='new-ssid1',
                             mode='g',
                             channel='6',
                             position='55,30,0')
    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)

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

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

    h1.plot(position='35,90,0')
    s3.plot(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()
Example #10
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 #11
0
def topology():

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

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

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

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

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

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

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

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

    print "*** Stopping network"
    net.stop()
Example #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('friisPropagationLossModel', sL=2)

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

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

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

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

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

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

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

    print "*** Creating nodes"
    net.addStation('sta1', position='15,20,0')
    ap1 = net.addAccessPoint('ap1', mac='00:00:00:00:00:01', ssid="handover",
                             mode="g", channel="1", passwd='123456789a',
                             encrypt='wpa2', position='10,30,0')
    ap2 = net.addAccessPoint('ap2', mac='00:00:00:00:00:02', ssid="handover",
                             mode="g", channel="6", passwd='123456789a',
                             encrypt='wpa2', position='60,30,0')
    ap3 = net.addAccessPoint('ap3', mac='00:00:00:00:00:03', ssid="handover",
                             mode="g", channel="1", passwd='123456789a',
                             encrypt='wpa2', position='120,100,0')
    c1 = net.addController('c1', controller=Controller)

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

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

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

    print "*** Setting bgscan"
    net.setBgscan(signal=-45, s_inverval=5, l_interval=10)

    net.plotGraph(min_x=-100, min_y=-100, max_x=200, max_y=200)

    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."
    net = Mininet(controller=Controller,
                  link=TCLink,
                  accessPoint=OVSKernelAP,
                  enable_wmediumd=True)

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

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

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

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

    net.seed(20)

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

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

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

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

    print "*** Creating nodes"
    sta1 = net.addStation('sta1', ip='10.0.0.1/8', position='10,10,0')
    sta2 = net.addStation('sta2', ip='10.0.0.2/8', position='40,40,0')

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

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

    print "*** Starting WiFi Direct"
    net.wifiDirect(sta1)
    net.wifiDirect(sta2)

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

    "Plotting graph"
    net.plotGraph(max_x=200, max_y=200)

    sta1.cmd('wpa_cli -ista1-wlan0 p2p_find')
    sta2.cmd('wpa_cli -ista2-wlan0 p2p_find')
    sta2.cmd('wpa_cli -ista2-wlan0 p2p_peers')
    time.sleep(2)
    sta1.cmd('wpa_cli -ista1-wlan0 p2p_peers')
    time.sleep(2)
    pin = sta1.cmd(
        'wpa_cli -ista1-wlan0 p2p_connect 02:00:00:00:01:00 pin auth')
    time.sleep(3)
    sta2.cmd('wpa_cli -ista2-wlan0 p2p_connect 02:00:00:00:00:00 %s' % pin)

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

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

    "Create a network."
    net = Mininet(controller=Controller,
                  accessPoint=OVSKernelAP,
                  driver='capwap_wtp',
                  enable_wmediumd=True,
                  enable_interference=True)

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

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

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

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

    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)

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

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

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

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

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

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

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

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

    print "*** Creating nodes"
    sta1 = net.addStation('sta1', ip='10.0.0.1/8', position='10,10,0')
    sta2 = net.addStation('sta2', ip='10.0.0.2/8', position='20,20,0')

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

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

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

    print "*** Starting WiFi Direct"
    net.wifiDirect(sta1)
    net.wifiDirect(sta2)

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

    sta1.cmd('wpa_cli -ista1-wlan0 p2p_find')
    sta2.cmd('wpa_cli -ista2-wlan0 p2p_find')
    sta2.cmd('wpa_cli -ista2-wlan0 p2p_peers')
    sleep(3)
    sta1.cmd('wpa_cli -ista1-wlan0 p2p_peers')
    sleep(3)
    pin = sta1.cmd('wpa_cli -ista1-wlan0 p2p_connect %s pin auth'
                   % sta2.params['mac'][1])
    sleep(3)
    sta2.cmd('wpa_cli -ista2-wlan0 p2p_connect %s %s'
             % (sta1.params['mac'][1], pin))

    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 #20
0
def topology():
    "Create a network."
    net = Mininet(enable_wmediumd=True, enable_interference=True)

    print "*** Creating nodes"
    sta1 = net.addStation('sta1', position='10,10,0')
    sta2 = net.addStation('sta2', position='60,10,0')
    sta3 = net.addStation('sta3', position='100,10,0')
    sta4 = net.addStation('sta4', position='10,140,0')
    sta5 = net.addStation('sta5', position='60,140,0')
    sta6 = net.addStation('sta6', position='100,140,0')

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

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

    print "*** Creating links"
    net.addMesh(sta1, ssid='meshNet')
    net.addMesh(sta2, ssid='meshNet')
    net.addMesh(sta3, ssid='meshNet')
    net.addHoc(sta4, ssid='adhocNet')
    net.addHoc(sta5, ssid='adhocNet')
    net.addHoc(sta6, ssid='adhocNet')

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

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

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

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

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

    print "*** Creating nodes"
    sta1 = net.addStation('sta1',
                          mac='00:00:00:00:00:02',
                          ip='10.0.0.1/8',
                          speed=4)
    sta2 = net.addStation('sta2',
                          mac='00:00:00:00:00:03',
                          ip='10.0.0.2/8',
                          speed=6)
    sta3 = net.addStation('sta3',
                          mac='00:00:00:00:00:04',
                          ip='10.0.0.3/8',
                          speed=3)
    sta4 = net.addStation('sta4',
                          mac='00:00:00:00:00:05',
                          ip='10.0.0.4/8',
                          speed=3)
    ap1 = net.addAccessPoint('ap1',
                             ssid='new-ssid',
                             mode='g',
                             channel='1',
                             position='45,45,0')
    c1 = net.addController('c1', controller=Controller)

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

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

    print "*** Creating links"
    net.addHoc(sta3, ssid='adhocNet')
    net.addHoc(sta4, ssid='adhocNet')

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

    getTrace(sta1, 'examples/replaying/replayingMobility/node1.dat')
    getTrace(sta2, 'examples/replaying/replayingMobility/node2.dat')
    getTrace(sta3, 'examples/replaying/replayingMobility/node3.dat')
    getTrace(sta4, 'examples/replaying/replayingMobility/node4.dat')

    replayingMobility(net)

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

    print "*** Stopping network"
    net.stop()
Example #22
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=2,
                          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)
    #net.addLink(ap1, s1, bw=1.5, delay='5ms', loss=5, use_htb=True)
    '''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(ap1, sta1)
    net.addLink(ap1, sta3)
    net.addLink(ap2, sta1)
    net.addLink(ap2, sta3)
    net.addLink(ap1, s3)
    net.addLink(ap2, s4)
    net.addLink(ap3, s5)
    #net.addLink(lte,sta1)

    #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

    print "***Starting network"
    net.start()
    #c1.start()
    #s1.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-wlan1 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-wlan1')

    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-wlan1 scope link table 2')
    sta1.cmd('ip route add default via 10.0.1.1 dev sta1-wlan1 table 2')

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

    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", "sta2", "sta3"]
    nets = ["ap1", "ap2", "ap3", "s2"]
    FDM(net, users, nets, {}, {}, {})
    #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 "***Running CLI"
    CLI(net)

    print "***Stopping network"
    time.sleep(50)
    net.stop()
Example #23
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=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')
    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='ssid-ap1',
                             mode='g',
                             channel='1',
                             position='50,50,0')
    ap2 = net.addAccessPoint('ap2',
                             ssid='ssid-ap2',
                             mode='g',
                             channel='6',
                             position='70,50,0',
                             range=30)  # range: set the AP range
    ap3 = net.addAccessPoint('ap3',
                             ssid='ssid-ap3',
                             mode='g',
                             channel='11',
                             position='90,50,0')
    c1 = net.addController('c1', controller=Controller)

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

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

    print "*** Associating and Creating links"
    net.addLink(ap1, ap2)
    net.addLink(ap2, ap3)
    """plotting 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(time=0,
                      model='RandomWayPoint',
                      max_x=120,
                      max_y=120,
                      min_v=0.3,
                      max_v=0.5)

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

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

    print "*** Stopping network"
    net.stop()
Example #25
0
def topology():
    """
          *ap2--h4.      .s7.
         *         .    .    .
    sta1*           s6--     s9--h10
        *          .    .    .
         *        .      .  .
          *ap3--h5        s8
    """

    call(["sudo", "sysctl", "-w", "net.mptcp.mptcp_enabled=1"])
    call(["sudo", "modprobe", "mptcp_coupled"])
    call(["sudo", "sysctl", "-w", "net.ipv4.tcp_congestion_control=lia"])
    "Create a network."
    net = Mininet(controller=Controller, link=TCLink, switch=OVSKernelSwitch)

    print "*** Creating nodes"
    sta1 = net.addStation('sta1', wlans=1, position='55,15,0')
    '''
    ap2 = net.addAccessPoint(
        'ap2', mac='00:00:00:00:00:02',
         ssid= 'ssid_ap2', mode= 'g',
        channel= '1', position='50,10,0', range=40)
    '''
    ap3 = net.addAccessPoint('ap3',
                             mac='00:00:00:00:00:03',
                             ssid='ssid_ap3',
                             mode='g',
                             channel='6',
                             position='70,50,0',
                             range=40)

    s6 = net.addSwitch('s6', mac='00:00:00:00:00:06')
    #s7 = net.addSwitch( 's7', mac='00:00:00:00:00:07', protocols='OpenFlow10' )
    #s8 = net.addSwitch( 's8', mac='00:00:00:00:00:08', protocols='OpenFlow10' )
    #s9 = net.addSwitch( 's9', mac='00:00:00:00:00:09', protocols='OpenFlow10' )
    h10 = net.addHost('h10', mac='00:00:00:00:00:10')
    c11 = net.addController('c11', controller=Controller)
    #c11 = net.addController( 'c11', controller=RemoteController, ip='127.0.0.1' )
    net.propagationModel(model='logDistance', exp=4)

    print "*** Configuring wifi nodes"
    net.configureWifiNodes()
    net.plotGraph(max_x=120, max_y=120)

    net.addLink(ap3, sta1)
    #net.addLink(sta1, ap3)
    #net.addLink(sta1, s7)
    net.addLink(ap3, s6, bw=1000)
    #net.addLink(ap3, s6, bw=1000)

    net.addLink(s6, h10, bw=1000)
    '''
    net.addLink(ap2, h4, bw=1000)
    net.addLink(ap3, h5, bw=1000)
    net.addLink(s6, h4, bw=1000)
    net.addLink(s6, h5, bw=1000)
    net.addLink(s6, s7, bw=1000)
    net.addLink(s6, s8, bw=1000)
    net.addLink(s7, s9, bw=1000)
    net.addLink(s8, s9, bw=1000)
    net.addLink(s9, h10, bw=1000)
    '''

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

    print "*** Associating and Creating links"
    '''
    sta1.cmd('ifconfig sta1-wlan0 10.0.1.0/32')
    sta1.cmd('ifconfig sta1-wlan1 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-wlan1')

    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-wlan1 scope link table 2')
    sta1.cmd('ip route add default via 10.0.1.1 dev sta1-wlan1 table 2')

    sta1.cmd('ip route add default scope global nexthop via 10.0.1.0 dev sta1-wlan0')
    '''
    '''
    h10.cmd('ip route add 10.0.0.0/8 via 192.168.1.1')
    h10.cmd('ip route add 192.168.0.0/24 via 192.168.1.2')

    h4.cmd('sysctl -w net.ipv4.ip_forward=1')
    h5.cmd('sysctl -w net.ipv4.ip_forward=1')
    '''

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

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

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

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

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

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

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

    'Seed'
    net.seed(20)

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

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

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

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

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

    print("*** Stopping network")
    net.stop()
Example #27
0
def topology():
    "Create a network."
    net = Mininet(controller=Controller, switch=OVSKernelSwitch,
                  enable_wmediumd=True, enable_interference=True)
   
    print "*** Creating nodes"
    cars = []
    stas = []
    for x in range(0, 10):
        cars.append(x)
        stas.append(x)
    for x in range(0, 10):
        cars[x] = net.addCar('car%s' % (x),
                             wlans=1, ip='10.0.0.%s/8' % (x + 1))
    
    e1 = net.addAccessPoint('e1', ssid='vanet-ssid', mac='00:00:00:11:00:01',
                            mode='g', channel='1', passwd='123456789a',
                            encrypt='wpa2', position='1127.02,513.27,0')
    e2 = net.addAccessPoint('e2', ssid='vanet-ssid', mac='00:00:00:11:00:02',
                            mode='g', channel='6', passwd='123456789a',
                            encrypt='wpa2', position='1024.82,469.75,0')
    e3 = net.addAccessPoint('e3', ssid='vanet-ssid', mac='00:00:00:11:00:03',
                            mode='g', channel='11', passwd='123456789a',
                            encrypt='wpa2', position='914.42,299.22,0')
    e4 = net.addAccessPoint('e4', ssid='vanet-ssid', mac='00:00:00:11:00:04',
                            mode='g', channel='1', passwd='123456789a',
                            encrypt='wpa2', position='1165.62,345.92,0')
    e5 = net.addAccessPoint('e5', ssid='vanet-ssid', mac='00:00:00:11:00:05',
                            mode='g', channel='6', passwd='123456789a',
                            encrypt='wpa2', position='1159.62,151.61,0')
    e6 = net.addAccessPoint('e6', ssid='vanet-ssid', mac='00:00:00:11:00:06',
                            mode='g', channel='11', passwd='123456789a',
                            encrypt='wpa2', position='1363.68,337.40,0')


    c1 = net.addController('c1', controller=Controller, ip='127.0.0.1',
                           port=6633)

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

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

    print "*** add links"
    net.addLink(e1, e2)
    net.addLink(e2, e3)
    net.addLink(e3, e4)
    net.addLink(e4, e5)
    net.addLink(e5, e6)

    print "*** Starting SUMO"
    net.useExternalProgram('sumo-gui', config_file='ucla.sumocfg')

    print "*** Starting network"
    net.build()
    c1.start()
    e1.start([c1])
    e2.start([c1])
    e3.start([c1])
    e4.start([c1])
    e5.start([c1])
    e6.start([c1])

    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
    for car in cars:
        car.setIP('192.168.0.%s/24' % i, 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

    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=Controller,
                  link=TCLink,
                  accessPoint=UserAP,
                  enable_wmediumd=True,
                  enable_interference=True)

    print "*** Creating nodes"
    cars = []
    stas = []
    for x in range(0, 10):
        cars.append(x)
        stas.append(x)
    for x in range(0, 10):
        cars[x] = net.addCar('car%s' % (x),
                             wlans=1,
                             ip='10.0.0.%s/8' % (x + 1))

    e1 = net.addAccessPoint('e1',
                            ssid='vanet-ssid',
                            mac='00:00:00:11:00:01',
                            mode='g',
                            channel='1',
                            passwd='123456789a',
                            encrypt='wpa2',
                            position='3279.02,3736.27,0')
    e2 = net.addAccessPoint('e2',
                            ssid='vanet-ssid',
                            mac='00:00:00:11:00:02',
                            mode='g',
                            channel='6',
                            passwd='123456789a',
                            encrypt='wpa2',
                            position='2320.82,3565.75,0')
    e3 = net.addAccessPoint('e3',
                            ssid='vanet-ssid',
                            mac='00:00:00:11:00:03',
                            mode='g',
                            channel='11',
                            passwd='123456789a',
                            encrypt='wpa2',
                            position='2806.42,3395.22,0')
    e4 = net.addAccessPoint('e4',
                            ssid='vanet-ssid',
                            mac='00:00:00:11:00:04',
                            mode='g',
                            channel='1',
                            passwd='123456789a',
                            encrypt='wpa2',
                            position='3332.62,3253.92,0')
    e5 = net.addAccessPoint('e5',
                            ssid='vanet-ssid',
                            mac='00:00:00:11:00:05',
                            mode='g',
                            channel='6',
                            passwd='123456789a',
                            encrypt='wpa2',
                            position='2887.62,2935.61,0')
    e6 = net.addAccessPoint('e6',
                            ssid='vanet-ssid',
                            mac='00:00:00:11:00:06',
                            mode='g',
                            channel='11',
                            passwd='123456789a',
                            encrypt='wpa2',
                            position='2351.68,3083.40,0')
    c1 = net.addController('c1',
                           controller=Controller,
                           ip='127.0.0.1',
                           port=6653)

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

    print "*** Setting bgscan"
    net.setBgscan(signal=-45, s_inverval=5, l_interval=10)

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

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

    net.addLink(e1, e2)
    net.addLink(e2, e3)
    net.addLink(e3, e4)
    net.addLink(e4, e5)
    net.addLink(e5, e6)

    "Available Options: sumo, sumo-gui"
    net.useExternalProgram('sumo-gui', config_file='map.sumocfg')

    print "*** Starting network"
    net.build()
    c1.start()
    e1.start([c1])
    e2.start([c1])
    e3.start([c1])
    e4.start([c1])
    e5.start([c1])
    e6.start([c1])

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

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

    i = 1
    j = 2
    for v in net.carsSTA:
        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.carsSTA:
        i = 1
        j = 1
        for v2 in net.carsSTA:
            if v1 != v2:
                v1.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()
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=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 #30
0
def topology():

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

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

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

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

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

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

    "Seed"
    net.seed(20)

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

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

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

    fixNetworkManager( root, 'root-eth0' )

    startNAT(root, internetIface)

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

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

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

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

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

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

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

    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')
    rsu14 = net.addAccessPoint('RSU14', ssid='RSU14', mode='g', channel='11')
    c1 = net.addController('c1', controller=Controller)

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

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

    print "*** Associating and Creating links"
    net.addLink(rsu11, rsu12)
    net.addLink(rsu11, rsu13)
    net.addLink(rsu11, rsu14)

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

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

    """Start Mobility"""
    net.startMobility(time=0)

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

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

    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.carsSTA:
        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.carsSTA:
        i = 1
        j = 1
        for v2 in net.carsSTA:
            if v1 != v2:
                v1.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()