Closed memran2 closed 4 years ago
You said that it works with SDN. Could you please tell me how? AFAIK this scenario works with traditional switches/aps (standalone mode). Is the handover being managed by the OF controller?
This code works if I enables the controller in SDN scenario. Code for SDn scenario is attached below: but the problem is same in both the codes (none SDN and SDN scenarios that when I change the association of sta1 back to ap1 ping stops working) and flow entries are not shown in the flow tables
#!/usr/bin/python
'Example for Handover'
import sys
from time import sleep
from mininet.log import setLogLevel, info
from mn_wifi.cli import CLI
from mn_wifi.net import Mininet_wifi
from mn_wifi.link import wmediumd
from mn_wifi.wmediumdConnector import interference
def topology(args):
global net, sta1, sta2, ap1, ap2 # Globally declared variables number of multiple values in this list ex 10
global sta1_loc_x, sta1_loc_y, sta2_loc_x, sta2_loc_y
global list_dist_s1_ap1, list_dist_s1_ap2, list_dist_s2_ap1, list_dist_s2_ap2
global rssi_s1_ap1, rssi_s1_ap2, rssi_s2_ap1, rssi_s2_ap2
global sta1_associated, sta2_associated
sta1_loc_x = [] # all variables are initialized as empty list to contain nu$
sta1_loc_y = []
sta2_loc_x = []
sta2_loc_y = []
list_dist_s1_ap1 = []
list_dist_s1_ap2 = []
list_dist_s2_ap1 = []
list_dist_s2_ap2 = []
rssi_s1_ap1 = []
rssi_s1_ap2 = []
rssi_s2_ap1 = []
rssi_s2_ap2 = []
sta1_associated = []
sta2_associated = []
"Create a network."
net = Mininet_wifi(link=wmediumd, wmediumd_mode=interference)
info("*** Creating nodes\n")
sta1_args, sta2_args = dict(), dict()
if '-s' in args:
sta1_args['position'], sta2_args['position'] = '0,30,0', '60,30,0'
sta1 = net.addStation('sta1', mac='00:00:00:00:00:01', **sta1_args)
sta2 = net.addStation('sta2', mac='00:00:00:00:00:02', **sta2_args)
ap1 = net.addAccessPoint('ap1', ssid='ssid-ap1', channel='1', position='15,30,0')
ap2 = net.addAccessPoint('ap2', ssid='ssid-ap2', channel='6', position='80,30,0')
c1 = net.addController('c1')
net.setPropagationModel(model="logDistance", exp=4.5)
info("*** Configuring wifi nodes\n")
net.configureWifiNodes()
info("*** Creating links\n")
net.addLink(ap1, ap2)
if '-p' not in args:
net.plotGraph(max_x=110, max_y=110)
if '-s' not in args: # this mobility code is not used , used our own written code below, by passed with -s
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='30,40,0')
net.stopMobility(time=11)
info("*** Starting network\n")
net.build()
c1.start()
ap1.start([c1])
ap2.start([c1])
if '-s' in args:
for x in range(20):
collect_info()
print_info()
move_station(5,0,0)
sleep(0.5)
output_csv()
info("*** Running CLI\n")
CLI(net)
info("*** Stopping network\n")
net.stop()
# This function is collecting information on Sta1 positio,Sta1 (X,y) position, Sta1 Distance from AP, RSSI and association
def collect_info():
global pos_sta1
global pos_sta2
global dist_s1_ap1, dist_s1_ap2, dist_s2_ap1, dist_s2_ap2
#create empty lists
pos_sta1 = sta1.position # finding position of station 1 and storing in variable sta1_pos
pos_sta2 = sta2.position
sta1_loc_x.append(pos_sta1[0])
sta1_loc_y.append(pos_sta1[1])
sta2_loc_x.append(pos_sta2[0])
sta2_loc_y.append(pos_sta2[1])
dist_s1_ap1 = sta1.get_distance_to(ap1)
dist_s1_ap2 = sta1.get_distance_to(ap2)
dist_s2_ap1 = sta2.get_distance_to(ap1)
dist_s2_ap2 = sta2.get_distance_to(ap2)
list_dist_s1_ap1.append(dist_s1_ap1)
list_dist_s1_ap2.append(dist_s1_ap2)
list_dist_s2_ap1.append(dist_s2_ap1)
list_dist_s2_ap2.append(dist_s2_ap2)
rssi_s1_ap1.append(sta1.wintfs[0].get_rssi(ap1.wintfs[0], dist_s1_ap1))
rssi_s1_ap2.append(sta1.wintfs[0].get_rssi(ap2.wintfs[0], dist_s1_ap2))
rssi_s2_ap1.append(sta2.wintfs[0].get_rssi(ap1.wintfs[0], dist_s2_ap1))
rssi_s2_ap2.append(sta2.wintfs[0].get_rssi(ap2.wintfs[0], dist_s2_ap2))
sta1_associated.append(sta1.wintfs[0].associatedTo)
sta2_associated.append(sta2.wintfs[0].associatedTo)
# Mobility function
def move_station(x,y,z):
new_x = pos_sta1[0] + x # in x Position of Sta1, X is added and new_x is calculated
new_y = pos_sta1[1] + y
new_z = pos_sta1[2] + z
new_loc = str(new_x) + "," + str(new_y) + "," + str(new_z) # str function cconverts numeric value to string in Python
sta1.setPosition(new_loc) # Sta1 new position is setup or Sta1 is moved to new position
# This function prints the Stations and AP positions values and their associations
def print_info():
info("sta1 position is: " + str(pos_sta1) + "\n")
info("sta2 position is: " + str(pos_sta2) + "\n")
info("sta1 to ap1 distance = " + str(dist_s1_ap1) + "\n")
info("sta1 to ap2 distance = " + str(dist_s1_ap2) + "\n")
info("sta2 to ap1 distance = " + str(dist_s2_ap1) + "\n")
info("sta2 to ap2 distance = " + str(dist_s2_ap2) + "\n")
info("sta1 to ap1 rssi = " + str(rssi_s1_ap1) + "\n")
info("sta1 to ap2 rssi = " + str(rssi_s1_ap2) + "\n")
info("sta2 to ap1 rssi = " + str(rssi_s2_ap1) + "\n")
info("sta2 to ap2 rssi = " + str(rssi_s2_ap2) + "\n")
info("sta1 associatedTo = " + str(sta1_associated) + "\n")
info("sta2 associatedTo = " + str(sta2_associated) + "\n")
def output_csv():
fhandle = open("dataSDN.csv", "w")
header = "sta1_x,sta1_y,sta2_x,sta2_y,dist_s1_ap1,dist_s1_ap2,dist_s2_ap1,dist_s2_ap2,rssi_s1_ap1,rssi_s1_ap2,rssi_s2_ap1,rssi_s2_ap2,sta1_associateion,sta2_association\n"
fhandle.write(header)
for i in range(len(sta1_loc_x)):
row = str(sta1_loc_x[i])+","+str(sta1_loc_y[i])+","
row = row + str(sta2_loc_x[i])+","+str(sta2_loc_y[i])+","
row = row + str(list_dist_s1_ap1[i])+","+str(list_dist_s1_ap2[i])+","
row = row + str(list_dist_s2_ap1[i])+","+str(list_dist_s2_ap2[i])+","
row = row + str(rssi_s1_ap1[i])+","+str(rssi_s1_ap2[i])+","
row = row + str(rssi_s2_ap1[i])+","+str(rssi_s2_ap2[i])+","
row = row + str(sta1_associated[i])+","+str(sta2_associated[i])+"\n"
print(row)
fhandle.write(row)
fhandle.close()
if __name__ == '__main__':
setLogLevel('info')
topology(sys.argv)
Can you please answer my question? Is the handover being managed by the controller? Did you check the associations? Which troubleshoot steps did you try?
Yes association updates when I set the position but ping does not work rather ping works before I set the position. Once mobility completes the handover has occurred successfully. I have attached the excel file containing the data taken during the simulation, I am not sure about the handover is being managed by SDN controller in SDN scenario or not here I am confused as it does not shows the flow entries if I use my mobility code but if I use built in mobility code then it show the flow entries. I used the following commands to trouble shout: to check association I used: py sta1.wintfs[0].associatedTo to set the position I used: py sta1.setPosition('20,30,0') To check the status of the aps connected to controller i used: sudo ovs-vsctl show To check flow entries in the ap1 and ap2 flow tables I used: sduo ovs-ofctl -O OpenFlow13 dump-flows ap1 and then I change for ap2 to ap2 if I am missing or wrong at some place please guide as I am stuck and can not proceed in the experiment further. I want to simply compare that SDN based WIFI device handover is better than the non SDN based WIFI device handover the is the purpose of my experiment. Below I have attached excel file containing the experiment simulation data and graph having RSSI, Distance of sta1 and sta2 from ap1 and ap2 and the association of the sta1 and sta2 from ap1 and ap2. I only moved sta1 and sta2 is static. For this mobility I have written my own code as I want the mentioned data for my experimentation. Regards, simpletopo_10steps.xlsx
Please double check it with wireless tools such as iw
and iwconfig
. I'd appreciate If you present your code correctly. Can you imagine if someone tries to copy and run your code? Can you do this without wasting any time organizing the formatting?
Sorry Sir. I have attached the two .txt files for your information please. I will also check the code on my end again with iw and iwconfig and update you. Regards, SDNhandover2.txt Simplehandover2.txt
I just updated your comments with the correct formatting. :(
Extremely sorry for being bit late. Actually comments were became bold when I pasted the code here.
Please keep in mind that UserAP
does not support the standalone failMode
. Moreover, you need to make sure that your OF controller manages handover. I'm closing this issue because in fact this isn't an issue.
I have created the python code for mininet-wifi in which I have simple two aps, two stations sta1 and sta2 and I have added the code in it for mobility to take step by step the position of the sta1 during its mobility as i have to note down sta1 positions, its distance from ap1 and ap2 and its received RSSI from both the ap1 and ap2. Every thing works perfect mobility, handover and ping between sta1 and sta2. But when I change the association of sta1 back to ap1 the ping stops. To change the association manually I used the command: py sta1.setPosition('20,40,0') But when I enable the controller then in SDN case it works fine. Actually I want to compare the none SDN scenario with SDN scenario that is why I disabled the controller in this code.
The code is attached please guide I will be thankful to you. Regards,