Esempio n. 1
0
def topology():
    """Create a network. sta1 <--> sta2 <--> sta3"""

    print "*** Connect wmediumd manager"
    WmediumdManager.connect()

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

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

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

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

    intfrefs = [sta1wlan0, sta2wlan0, sta3wlan0]
    links = [
        WmediumdERRPROBLink(sta1wlan0, sta2wlan0, 0.2),
        WmediumdERRPROBLink(sta2wlan0, sta1wlan0, 0.2),
        WmediumdERRPROBLink(sta2wlan0, sta3wlan0, 0.1),
        WmediumdERRPROBLink(sta3wlan0, sta2wlan0, 0.1)
    ]

    for intfref in intfrefs:
        WmediumdManager.register_interface(intfref.get_intf_mac())

    for link in links:
        WmediumdManager.update_link_errprob(link)

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

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

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

    print "*** Disconnecting wmediumd manager"
    WmediumdManager.disconnect()

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

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

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

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

    intfrefs = [sta1wlan0, sta2wlan0, sta3wlan0]
    links = [
        WmediumdERRPROBLink(sta1wlan0, sta2wlan0, 0.2),
        WmediumdERRPROBLink(sta2wlan0, sta1wlan0, 0.2),
        WmediumdERRPROBLink(sta2wlan0, sta3wlan0, 0.1),
        WmediumdERRPROBLink(sta3wlan0, sta2wlan0, 0.1)
    ]
    WmediumdStarter.initialize(intfrefs, links, use_errprob=True)

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

    print "*** Start wmediumd"
    WmediumdStarter.start()

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

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

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

    print "*** Stopping wmediumd"
    WmediumdStarter.stop()

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

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

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

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

    intfrefs = [sta1wlan0, sta2wlan0, sta3wlan0]
    links = [
        WmediumdLink(sta1wlan0, sta2wlan0, 15),
        WmediumdLink(sta2wlan0, sta1wlan0, 15),
        WmediumdLink(sta2wlan0, sta3wlan0, 15),
        WmediumdLink(sta3wlan0, sta2wlan0, 15)]
    WmediumdConn.set_wmediumd_data(intfrefs, links)

    WmediumdConn.connect_wmediumd_on_startup()

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

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

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

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

    print "*** Stopping wmediumd"
    WmediumdConn.disconnect_wmediumd()

    print "*** Stopping network"
    net.stop()
Esempio n. 4
0
    def configureWmediumd(self, stations, accessPoints):
        """ 
        Updates values for frequency and channel
        
        :param stations: list of stations
        :param accessPoints: list of access points
        """
        intfrefs = []
        links = []
        positions = []
        txpowers = []
        cars = []

        for node in stations:
            if 'carsta' in node.params:
                cars.append(node.params['carsta'])

        nodes = stations + accessPoints + cars

        for node in nodes:
            node.wmediumdIface = DynamicWmediumdIntfRef(node)
            intfrefs.append(node.wmediumdIface)

        if self.enable_interference:
            mode = WmediumdConstants.WMEDIUMD_MODE_INTERFERENCE
            for node in nodes:
                if 'position' not in node.params:
                    posX = 0
                    posY = 0
                    posZ = 0
                else:
                    posX = node.params['position'][0]
                    posY = node.params['position'][1]
                    posZ = node.params['position'][2]
                node.lastpos = [0, 0, 0]
                positions.append(
                    WmediumdPosition(node.wmediumdIface, [posX, posY, posZ]))
                txpowers.append(
                    WmediumdTXPower(node.wmediumdIface,
                                    float(node.params['txpower'][0])))
        else:
            mode = WmediumdConstants.WMEDIUMD_MODE_SNR
            for node in self.wlinks:
                links.append(
                    WmediumdSNRLink(node[0].wmediumdIface,
                                    node[1].wmediumdIface,
                                    node[0].params['snr'][0]))
                links.append(
                    WmediumdSNRLink(node[1].wmediumdIface,
                                    node[0].wmediumdIface,
                                    node[0].params['snr'][0]))

        WmediumdStarter.initialize(intfrefs, links, mode=mode, positions=positions, enable_interference=self.enable_interference, \
                                   auto_add_links=False, txpowers=txpowers, with_server=True)
        WmediumdStarter.start()
def topology():
    """Create a network. sta1 <--> sta2 <--> sta3"""

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

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

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

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

    print "*** Configure wmediumd"
    sta1wlan0 = DynamicWmediumdIntfRef(sta1, sta1.defaultIntf())
    sta2wlan0 = DynamicWmediumdIntfRef(sta2, sta2.defaultIntf())
    sta3wlan0 = DynamicWmediumdIntfRef(sta3, sta3.defaultIntf())

    intfrefs = [sta1wlan0, sta2wlan0, sta3wlan0]
    links = [
        WmediumdLink(sta1wlan0, sta2wlan0, 15),
        WmediumdLink(sta2wlan0, sta1wlan0, 15),
        WmediumdLink(sta2wlan0, sta3wlan0, 15),
        WmediumdLink(sta3wlan0, sta2wlan0, 15)]
    WmediumdConn.set_wmediumd_data(intfrefs, links)

    WmediumdConn.connect_wmediumd_after_startup()

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

    print "*** Stopping wmediumd"
    WmediumdConn.disconnect_wmediumd()

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

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

    print "*** Creating nodes"
    sta1 = net.addStation('sta1', range=50, position='10,10,0')
    sta2 = net.addStation('sta2', range=50, position='20,10,0')
    sta3 = net.addStation('sta3', range=50, position='30,10,0')

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

    intfrefs = [sta1.wmediumdIface, sta2.wmediumdIface, sta3.wmediumdIface]
    links = [
        WmediumdSNRLink(sta1.wmediumdIface, sta2.wmediumdIface, 15),
        WmediumdSNRLink(sta2.wmediumdIface, sta1.wmediumdIface, 15),
        WmediumdSNRLink(sta2.wmediumdIface, sta3.wmediumdIface, 15),
        WmediumdSNRLink(sta3.wmediumdIface, sta2.wmediumdIface, 15)
    ]
    WmediumdStarter.initialize(intfrefs, links, with_server=True)

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

    print "*** Start wmediumd"
    WmediumdStarter.start()

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

    print "*** Enabling Mesh Routing ***"
    net.meshRouting('custom')

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

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

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

    # Required when the position of the nodes are previously defined. Useful to set channel params.
    net.autoAssociation()

    CLI(net)

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

    print "*** Stopping wmediumd"
    WmediumdServerConn.disconnect()
    WmediumdStarter.stop()
Esempio n. 7
0
def topology():

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

    print "*** Creating nodes"
    car = []
    stas = []
    for x in range(0, 4):
        car.append(x)
        stas.append(x)
    for x in range(0, 4):
        car[x] = net.addCar('car%s' % (x), wlans=2, ip='10.0.0.%s/8' % (x + 1), \
        mac='00:00:00:00:00:0%s' % x, mode='b', position='%d,%d,0' % ((150-(x*20)),(100-(x*20))) )

    rs1 = net.addAccessPoint('rs1',
                             ssid='ssid1',
                             mode='g',
                             channel='1',
                             position='60,50,0')
    rs2 = net.addAccessPoint('rs2',
                             ssid='ssid2',
                             mode='g',
                             channel='6',
                             position='160,100,0')
    bs3 = net.addAccessPoint('bs3',
                             ssid='ssid3',
                             mode='g',
                             channel='6',
                             position='150,120,0',
                             range=70)
    c1 = net.addController('c1', controller=Controller)
    h1 = net.addHost('h1')
    s10 = net.addSwitch('s10')

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

    print "*** Creating links"
    net.addLink(rs1, s10)
    net.addLink(rs2, s10)
    net.addLink(bs3, s10)
    net.addLink(s10, h1)
    net.addLink(bs3, car[0])
    net.addLink(rs2, car[0])
    net.addLink(rs1, car[3])

    print "*** Starting network"
    net.build()
    c1.start()
    rs1.start([c1])
    rs2.start([c1])
    bs3.start([c1])
    s10.start([c1])

    i = 201
    for sw in net.vehicles:
        sw.start([c1])

    i = 1
    j = 2
    for c in car:
        c.cmd('ifconfig %s-wlan0 192.168.0.%s/24 up' % (c, i))
        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

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

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

    h1.cmd('ifconfig h1-eth0 200.0.10.2')
    net.vehiclesSTA[3].cmd('ifconfig car3STA-eth1 200.0.10.1')
    net.vehiclesSTA[0].cmd('ip route add 200.0.10.0/24 via 10.0.0.4')

    car[0].cmd('modprobe bonding mode=3')
    car[0].cmd('ip link add bond0 type bond')
    car[0].cmd('ip link set bond0 address 02:01:02:03:04:08')
    car[0].cmd('ip link set car0-eth0 down')
    car[0].cmd('ip link set car0-eth0 address 00:00:00:00:00:11')
    car[0].cmd('ip link set car0-eth0 master bond0')
    car[0].cmd('ip link set car0-wlan0 down')
    car[0].cmd('ip link set car0-wlan0 address 00:00:00:00:00:15')
    car[0].cmd('ip link set car0-wlan0 master bond0')
    car[0].cmd('ip link set car0-wlan1 down')
    car[0].cmd('ip link set car0-wlan1 address 00:00:00:00:00:13')
    car[0].cmd('ip link set car0-wlan1 master bond0')
    car[0].cmd('ip addr add 200.0.10.100/24 dev bond0')
    car[0].cmd('ip link set bond0 up')
    """uncomment to plot graph"""
    net.plotGraph(max_x=250, max_y=250)

    mp1 = net.vehiclesSTA[0]
    mp2 = net.vehiclesSTA[1]
    mp3 = net.vehiclesSTA[2]
    mp4 = net.vehiclesSTA[3]

    print "*** Configure wmediumd"
    sta1wlan0 = DynamicWmediumdIntfRef(mp1)
    sta2wlan0 = DynamicWmediumdIntfRef(mp2)
    sta3wlan0 = DynamicWmediumdIntfRef(mp3)
    sta4wlan0 = DynamicWmediumdIntfRef(mp4)

    intfrefs = [sta1wlan0, sta2wlan0, sta3wlan0, sta4wlan0]
    links = [
        WmediumdLink(sta1wlan0, sta2wlan0, 15),
        WmediumdLink(sta2wlan0, sta1wlan0, 15),
        WmediumdLink(sta2wlan0, sta3wlan0, 15),
        WmediumdLink(sta3wlan0, sta2wlan0, 15),
        WmediumdLink(sta3wlan0, sta4wlan0, 15),
        WmediumdLink(sta4wlan0, sta3wlan0, 15)
    ]
    WmediumdConn.set_wmediumd_data(intfrefs, links)

    WmediumdConn.connect_wmediumd_after_startup()

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

    print "*** Stopping wmediumd"
    WmediumdConn.disconnect_wmediumd()

    print "*** Stopping network"
    net.stop()
Esempio n. 8
0
    def configureWmediumd(cls, mininet):
        """ 
        Updates values for frequency and channel
        """
        from mininet.node import Car

        intfrefs = []
        links = []
        positions = []
        txpowers = []
        cars = []

        cls.configureWiFiDirect = mininet.configureWiFiDirect
        cls.configure4addr = mininet.configure4addr
        cls.enable_error_prob = mininet.enable_error_prob
        cls.enable_interference = mininet.enable_interference
        cls.enable_spec_prob_link = mininet.enable_spec_prob_link

        for node in mininet.stations:
            if 'carsta' in node.params:
                cars.append(node.params['carsta'])

        nodes = mininet.stations + mininet.aps + cars
        for node in nodes:
            node.wmIface = []
            if isinstance(node, Car):
                wlans = 1
            elif '_4addr' in node.params and node.params['_4addr'] == 'ap':
                wlans = 1
            else:
                wlans = len(node.params['wlan'])
            for wlan in range(0, wlans):
                node.wmIface.append(wlan)
                node.wmIface[wlan] = DynamicWmediumdIntfRef(node, intf=wlan)
                intfrefs.append(node.wmIface[wlan])

        if cls.enable_interference:
            mode = WmediumdConstants.WMEDIUMD_MODE_INTERFERENCE
            for node in nodes:
                if 'position' not in node.params:
                    posX = 0
                    posY = 0
                    posZ = 0
                else:
                    posX = node.params['position'][0]
                    posY = node.params['position'][1]
                    posZ = node.params['position'][2]
                node.lastpos = [posX, posY, posZ]

                if isinstance(node, Car):
                    wlans = 1
                elif '_4addr' in node.params and node.params['_4addr'] == 'ap':
                    wlans = 1
                else:
                    wlans = len(node.params['wlan'])
                for wlan in range(0, wlans):
                    positions.append(
                        WmediumdPosition(node.wmIface[wlan],
                                         [posX, posY, posZ]))
                    txpowers.append(
                        WmediumdTXPower(node.wmIface[wlan],
                                        float(node.params['txpower'][wlan])))
        elif cls.enable_spec_prob_link:
            mode = WmediumdConstants.WMEDIUMD_MODE_SPECPROB
        elif cls.enable_error_prob:
            mode = WmediumdConstants.WMEDIUMD_MODE_ERRPROB
            for node in cls.wlinks:
                links.append(
                    WmediumdERRPROBLink(node[0].wmIface[0], node[1].wmIface[0],
                                        node[2]))
                links.append(
                    WmediumdERRPROBLink(node[1].wmIface[0], node[0].wmIface[0],
                                        node[2]))
        else:
            mode = WmediumdConstants.WMEDIUMD_MODE_SNR
            for node in cls.wlinks:
                links.append(
                    WmediumdSNRLink(node[0].wmIface[0], node[1].wmIface[0],
                                    node[0].params['rssi'][0] - (-91)))
                links.append(
                    WmediumdSNRLink(node[1].wmIface[0], node[0].wmIface[0],
                                    node[0].params['rssi'][0] - (-91)))

        WmediumdStarter.initialize(intfrefs,
                                   links,
                                   mode=mode,
                                   positions=positions,
                                   enable_interference=cls.enable_interference,
                                   auto_add_links=False,
                                   txpowers=txpowers,
                                   with_server=True)
        WmediumdStarter.start(mininet, propagationModel)
Esempio n. 9
0
    def configureWmediumd(self, stations, accessPoints):
        """ 
        Updates values for frequency and channel
        
        :param stations: list of stations
        :param accessPoints: list of access points
        """
        intfrefs = []
        links = []
        positions = []
        txpowers = []
        cars = []

        for node in stations:
            if 'carsta' in node.params:
                cars.append(node.params['carsta'])

        nodes = stations + accessPoints + cars

        for node in nodes:
            node.wmIface = []
            if node.type == 'vehicle':
                wlans = 1
            else:
                wlans = len(node.params['wlan'])
            for wlan in range(0, wlans):
                node.wmIface.append(wlan)
                node.wmIface[wlan] = DynamicWmediumdIntfRef(node, intf=wlan)
                intfrefs.append(node.wmIface[wlan])

        if self.enable_interference:
            mode = WmediumdConstants.WMEDIUMD_MODE_INTERFERENCE
            for node in nodes:
                if 'position' not in node.params:
                    posX = 0
                    posY = 0
                    posZ = 0
                else:
                    posX = node.params['position'][0]
                    posY = node.params['position'][1]
                    posZ = node.params['position'][2]
                node.lastpos = [0, 0, 0]

                if hasattr(node, 'type') and node.type == 'vehicle':
                    wlans = 1
                else:
                    wlans = len(node.params['wlan'])
                for wlan in range(0, wlans):
                    positions.append(
                        WmediumdPosition(node.wmIface[wlan],
                                         [posX, posY, posZ]))
                    txpowers.append(
                        WmediumdTXPower(node.wmIface[wlan],
                                        float(node.params['txpower'][wlan])))
        elif self.enable_spec_prob_link:
            mode = WmediumdConstants.WMEDIUMD_MODE_SPECPROB
        elif self.enable_error_prob:
            mode = WmediumdConstants.WMEDIUMD_MODE_ERRPROB
        else:
            mode = WmediumdConstants.WMEDIUMD_MODE_SNR

        WmediumdStarter.initialize(intfrefs, links, mode=mode, positions=positions, enable_interference=self.enable_interference, \
                                   auto_add_links=False, txpowers=txpowers, with_server=True)
        WmediumdStarter.start()
def topology():
    """Create a network. sta1 <--> sta2 <--> sta3"""

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

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

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

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

    WmediumdConn.connect_wmediumd_on_startup()

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

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

    net.meshRouting('custom')

    net.seed(20)

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

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

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

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

    CLI(net)

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

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