intrig-unicamp / mininet-wifi

Emulator for Software-Defined Wireless Networks
https://mn-wifi.readthedocs.io/
Other
459 stars 245 forks source link

Station cannot change its AP #240

Closed FT-199 closed 5 years ago

FT-199 commented 5 years ago

I ran a simple scenario in mininet-wifi: Two RSUs with a host connected to RSU1 and a car(station) moving on a path connecting RSU1 and RSU2. RSU positions: RSU1: position='100.0,110.0,0', range=100 RSU2: position='400.0,110.0,0',range=100 road: {'x1':0,'y1':100,'x2':500,'y2':100}

image

At the beginning of the simulation works well. However, after two or three times of mobility repetition, car1 sticks to one RSU and cannot switch to another one.

mininet-wifi> py car1.params {'finPos': ['480', '100', '0'], 'txpower': [14, 14], 'position': (352, 100.0, 0), 'wlan': ['car1-wlan0', 'car1-mp1'], 'ssid': ['', 'mesh-ssid'], 'ip': ['192.168.1.1/24', '10.0.0.1/24'], 'range': [9, 46], 'antennaGain': [5, 5], 'apsInRange': [<OVSAP rsu2: lo:127.0.0.1,rsu2-wlan1:None,rsu2-eth2:None pid=16174> ], 'mac': ['00:00:00:00:00:01', '02:00:00:00:01:00'], 'mode': ['g', 'g'], 'antennaHeight': [1.0, 1.0], 'associatedTo': [<OVSAP rsu2: lo:127.0.0.1,rsu2-wlan1:None,rsu2-eth2:None pid=16174> , ''], 'freq': [2.412, 2.432], 'speed': 16.0, 'channel': ['1', '5'], 'initPos': [4.0, '100', '0']}

mininet-wifi> py car1.params {'finPos': ['480', '100', '0'], 'txpower': [14, 14], 'position': (48, 100.0, 0), 'wlan': ['car1-wlan0', 'car1-mp1'], 'ssid': ['', 'mesh-ssid'], 'ip': ['192.168.1.1/24', '10.0.0.1/24'], 'range': [9, 46], 'antennaGain': [5, 5], 'apsInRange': [<OVSAP rsu2: lo:127.0.0.1,rsu2-wlan1:None,rsu2-eth2:None pid=16174> ], 'mac': ['00:00:00:00:00:01', '02:00:00:00:01:00'], 'mode': ['g', 'g'], 'antennaHeight': [1.0, 1.0], 'associatedTo': [<OVSAP rsu2: lo:127.0.0.1,rsu2-wlan1:None,rsu2-eth2:None pid=16174> , ''], 'freq': [2.412, 2.432], 'speed': 16.0, 'channel': ['1', '5'], 'initPos': [4.0, '100', '0']}

ramonfontes commented 5 years ago

We fixed an issue with the 'repetition' last week. Could you try the latest commit?

FT-199 commented 5 years ago

Thanks. The problem seems to be solved. However, there is another problem with mobility:

mininet-wifi> Exception in thread Thread-1: Traceback (most recent call last): File "/usr/lib/python2.7/threading.py", line 801, in __bootstrap_inner self.run() File "/usr/lib/python2.7/threading.py", line 754, in run self.target(*self.args, self.__kwargs) File "/usr/local/lib/python2.7/dist-packages/mininet_wifi-2.4-py2.7.egg/mn_wifi/mobility.py", line 431, in configure self.run(plot, kwargs) File "/usr/local/lib/python2.7/dist-packages/mininet_wifi-2.4-py2.7.egg/mn_wifi/mobility.py", line 466, in run node.points[node.time * node.moveFac]) IndexError: list index out of range

ramonfontes commented 5 years ago

This is strange. Can you share your script?

FT-199 commented 5 years ago

!/usr/bin/python

'Setting the position of nodes and providing mobility'

import sys

from mininet.node import Controller,OVSKernelSwitch from mininet.log import setLogLevel, info from mn_wifi.cli import CLI_wifi from mn_wifi.net import Mininet_wifi,Host from mn_wifi.link import wmediumd, mesh from mn_wifi.wmediumdConnector import interference from setting2 import *

def topology(): "Create a network." net = Mininet_wifi(topo=None, controller=Controller, link=wmediumd, wmediumd_mode=interference) ###################################################################### add controller/host/switch

# c1 = net.addController('c1')
h1 = net.addHost('h1', cls=Host, ip='192.168.1.10', defaultRoute=None)

###################################################################### add rsus
rsus=[]
cars=[]
for r in myRSU.keys():
    rsus.append(net.addAccessPoint('rsu%s' %r, ssid='vanet', mode='g', channel='1',
                          position=myRSU[r]['pos'], range=myRSU[r]['cov']))
###################################################################### add cars
for c in car_mobility.keys():
    mac_temp=str('0%s'%c) if c<10 else str(c)
    car_mac='00:00:00:00:00:%s'%mac_temp
    cars.append(net.addStation('car%s' %c ,wlans=2, mac=car_mac))

###################################################################### setPropagationModel
net.setPropagationModel(model="logDistance", exp=4.5)
net.configureWifiNodes()

###################################################################### add links
net.addLink(rsus[0],rsus[1])
net.addLink(rsus[0], h1)

for car in cars:
    net.addLink(car, intf=car.params['wlan'][1],
                cls=mesh, ssid='mesh-ssid', channel=5)

###################################################################### mobility
net.plotGraph(max_x=myNetwork[0], max_y=myNetwork[1])
for car in cars:
    c=int(cars.index(car))+1
    index=0
    points=[0]*(len(car_mobility[c]['r_id'])+1)
    for path in car_mobility[c]['r_id']:

        start_point=str(road[path]['x1']) +','+ str(road[path]['y1'])+',0'
        end_point = str(road[path]['x2']-20) + ',' + str(road[path]['y2']) + ',0'
        points[index] = start_point if car_mobility[c]['move_to']=='right' else end_point
        index+=1
        points[index] = end_point if car_mobility[c]['move_to']=='right' else start_point

    print(points)
    car.coord=points
    net.mobility(car,'start',time=car_mobility[c]['time'][0])
    net.mobility(car, 'stop', time=car_mobility[c]['time'][1])

net.startMobility(time=0, repetitions=Iteration)
net.stopMobility(time=max_sim_time)
###################################################################### mobility

info("*** Starting network\n")

net.build()

for rsu in rsus:
    rsu.start([])

for car in cars:
    car.setIP('192.168.1.%s/24' % (int(cars.index(car)) + 1),
              intf='car%s-wlan0' % (int(cars.index(car)) + 1))
    car.setIP('10.0.0.%s/24' % (int(cars.index(car)) + 1),
              intf='car%s-mp1' % (int(cars.index(car)) + 1))

info("*** Running CLI\n")
CLI_wifi(net)

info("*** Stopping network\n")
net.stop()

if name == 'main': setLogLevel('info') coord = True if '-c' in sys.argv else False topology()

FT-199 commented 5 years ago

setting2.py

Iteration=4 max_sim_time=10 myNetwork=[500,500]

road={1:{'x1':0,'y1':100,'x2':500,'y2':100}}

rsu={id:{road_id,position, coverage}

myRSU={1:{'r_id':1,'pos':'100.0,110.0,0','cov':100}, 2:{'r_id':2,'pos':'400.0,110.0,0','cov':100}} ###############################################################################33

car_mobility={carid:{road,timing},movement direction}

car_mobility={1:{'r_id':[1],'time':[1,10],'move_to':'right'}}

ramonfontes commented 5 years ago

I successfully run your script. Please try the testmob branch.

FT-199 commented 5 years ago

What do you mean by testmob?

ramonfontes commented 5 years ago

Branch...

FT-199 commented 5 years ago

Ok. Thanks.