Skip to content

Commit

Permalink
Merge branch 'Development'
Browse files Browse the repository at this point in the history
  • Loading branch information
rubenmunilla committed Feb 8, 2018
2 parents c07df4a + f491f59 commit 78f03ec
Show file tree
Hide file tree
Showing 3 changed files with 62 additions and 4 deletions.
8 changes: 6 additions & 2 deletions poolfile
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,9 @@ NETWORKS wi5-demo
####### ShowStatistics
# APPLICATION net.floodlightcontroller.odin.applications.ShowStatistics

####### SimpleLoadBalancer
# APPLICATION net.floodlightcontroller.odin.applications.SimpleLoadBalancer

####### MobilityManager params
####### MOBILITY TimeToStart(sec) IdleClient(sec) Hysteresis(sec) SignalThreshold(dBm) ScanningTime(sec) NumberOfTriggers TimerResetTriggers(sec)
# APPLICATION net.floodlightcontroller.odin.applications.MobilityManager
Expand Down Expand Up @@ -50,9 +53,10 @@ NETWORKS wi5-demo
# APPLICATION net.floodlightcontroller.odin.applications.ChannelLoop

####### Smart Ap Selection params
####### SMARTAPSELECTION TimeToStart(sec) ScanningInterval(msec) AddedTime(msec) SignalThreshold(dBm) Hysteresis(sec) Alpha(0-1) Pause(sec)
####### SMARTAPSELECTION TimeToStart(sec) ScanningInterval(msec) AddedTime(msec) SignalThreshold(dBm) Hysteresis(sec) Alpha(0-1) Pause(sec) Mode Filename
####### Mode = RSSI; It will allow change between RSSI and FitnessFactor algorithm
# APPLICATION net.floodlightcontroller.odin.applications.SmartApSelection
# SMARTAPSELECTION 30 200 0 -56 4 0.2 0
# SMARTAPSELECTION 50 200 0 -56 4 0.2 0 RSSI SmartApSelectionLog.txt

# Pool-2
#NAME pool-2
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@
import java.util.Map.Entry;
import java.util.Set;
import java.util.Arrays;
import java.io.File;
import java.io.PrintStream;

import net.floodlightcontroller.odin.master.OdinApplication;
import net.floodlightcontroller.odin.master.OdinClient;
Expand Down Expand Up @@ -66,10 +68,34 @@ public void run() {
e.printStackTrace();
}

// Write on file integration
PrintStream ps = null;

if(SMARTAP_PARAMS.filename.length()>0){
File f = new File(SMARTAP_PARAMS.filename);
try {
ps = new PrintStream(f);
} catch (Exception e) {
e.printStackTrace();
}
}

num_agents = getAgents().size(); // Number of agents
channels = new int[num_agents]; // Array to store the channels in use
int[] channelsAux = new int[num_agents];

ps.println("[SmartAPSelection] Log file " + SMARTAP_PARAMS.filename); // Log in file
ps.println("[SmartAPSelection] Parameters:");
ps.println("\tTime_to_start: " + SMARTAP_PARAMS.time_to_start);
ps.println("\tScanning_interval: " + SMARTAP_PARAMS.scanning_interval);
ps.println("\tAdded_time: " + SMARTAP_PARAMS.added_time);
ps.println("\tSignal_threshold: " + SMARTAP_PARAMS.signal_threshold);
ps.println("\tHysteresis_threshold: " + SMARTAP_PARAMS.hysteresis_threshold);
ps.println("\tPrevius_data_weight (alpha): " + SMARTAP_PARAMS.weight);
ps.println("\tPause between scans: " + SMARTAP_PARAMS.pause);
ps.println("\tMode: " + SMARTAP_PARAMS.mode);
ps.println("\tFilename: " + SMARTAP_PARAMS.filename);

// Get channels from APs, assuming there is no change in all operation, if already in array->0
for (InetAddress agentAddr: getAgents()) {
int chann = getChannelFromAgent(agentAddr);
Expand All @@ -83,8 +109,11 @@ public void run() {
//System.out.println("[SmartAPSelection] Chann added "+chann);
}
System.out.println("[SmartAPSelection] AP " + agentAddr + " in channel: " + chann);
ps.println("[SmartAPSelection] AP " + agentAddr + " in channel: " + chann); // Log in file
num_channels++;
}
ps.println("[SmartAPSelection]");
ps.flush();

vals_rx = new String[num_channels][num_agents]; // Matrix to store the results from agents
Map<MACAddress, Double[]> rssiData = new HashMap<MACAddress, Double[]> (); // Map to store RSSI for each STA in all APs
Expand Down Expand Up @@ -240,6 +269,8 @@ public void run() {
// Now comparation and handoff if it's needed
time = System.currentTimeMillis();

ps.println(time + " ms"); // Log in file

for (OdinClient oc: clients) {

client_index = 0;
Expand All @@ -263,6 +294,7 @@ public void run() {
continue;

System.out.println("\033[K\r[SmartAPSelection] Client " + clientAddr + " in agent " + agentAddr);
ps.println("\tClient " + clientAddr + " in agent " + agentAddr); // Log in file

client_dBm = rssiData.get(eth);

Expand Down Expand Up @@ -291,14 +323,17 @@ public void run() {

currentRssi = client_dBm[ind_aux];
System.out.print("[\033[48;5;29m" + client_dBm[ind_aux] + "\033[00m]"); // Dark Green
ps.println("\t\t[Associated] Rssi in agent " + agents[ind_aux] + ": " + client_dBm[ind_aux] + " dBm"); // Log in file

}else{
if(ind_aux==client_index){ // Max

System.out.print("[\033[48;5;88m" + client_dBm[ind_aux] + "\033[00m]"); // Dark red
ps.println("\t\t[BetterAP] Rssi in agent " + agents[ind_aux] + ": " + client_dBm[ind_aux] + " dBm"); // Log in file

}else{
System.out.print("["+ client_dBm[ind_aux] +"]"); //
ps.println("\t\t[WorseAP] Rssi in agent " + agents[ind_aux] + ": " + client_dBm[ind_aux] + " dBm"); // Log in file
}
}

Expand All @@ -320,21 +355,26 @@ public void run() {
handoffDate.put(eth,Long.valueOf(System.currentTimeMillis()));
System.out.println(" - Handoff >--->--->---> "+agents[client_index]);

ps.println("\t\t[Action] Handoff to agent: " + agents[client_index]); // Log in file

}else{
System.out.println(" - No Handoff: Hysteresis time not reached");
ps.println("\t\t[No Action] No Handoff: Hysteresis time not reached"); // Log in file
}
}else{
System.out.println(" - No Handoff: Rssi Threshold not reached");
ps.println("\t\t[No Action] No Handoff: Rssi Threshold not reached"); // Log in file
}
}else{
System.out.println(""); // Best AP already
ps.println("\t\t[No Action] There is no better Rssi heard"); // Log in file
}

}else{
System.out.println("\033[K\r[SmartAPSelection] No data received");
}
}
ps.flush();
System.out.println("\033[K\r[SmartAPSelection] Assignation done in: " + (System.currentTimeMillis()-time) + " ms");
System.out.println("\033[K\r[SmartAPSelection] ====================");
System.out.println("\033[K\r");
Expand Down
18 changes: 16 additions & 2 deletions src/main/java/net/floodlightcontroller/odin/master/OdinMaster.java
Original file line number Diff line number Diff line change
Expand Up @@ -1262,7 +1262,11 @@ public void startUp(FloodlightModuleContext context) {
}

if (fields[0].equals("SMARTAPSELECTION")){ // SMART AP SELECTION
smartap_params = new SmartApSelectionParams(Integer.parseInt(fields[1]),Integer.parseInt(fields[2]),Integer.parseInt(fields[3]),Double.parseDouble(fields[4]),Long.parseLong(fields[5]), Double.parseDouble(fields[6]),Integer.parseInt(fields[7]));
if(fields.length==10){// Filename added in poolfile
smartap_params = new SmartApSelectionParams(Integer.parseInt(fields[1]),Integer.parseInt(fields[2]),Integer.parseInt(fields[3]),Double.parseDouble(fields[4]),Long.parseLong(fields[5]), Double.parseDouble(fields[6]),Integer.parseInt(fields[7]), fields[8], fields[9]);
}else{
smartap_params = new SmartApSelectionParams(Integer.parseInt(fields[1]),Integer.parseInt(fields[2]),Integer.parseInt(fields[3]),Double.parseDouble(fields[4]),Long.parseLong(fields[5]), Double.parseDouble(fields[6]),Integer.parseInt(fields[7]), fields[8], "");
}
log.info("SmartApSelection configured:");
log.info("\t\tTime_to_start: " + smartap_params.time_to_start);
log.info("\t\tScanning_interval: " + smartap_params.scanning_interval);
Expand All @@ -1271,6 +1275,12 @@ public void startUp(FloodlightModuleContext context) {
log.info("\t\tHysteresis_threshold: " + smartap_params.hysteresis_threshold);
log.info("\t\tPrevius_data_weight (alpha): " + smartap_params.weight);
log.info("\t\tPause between scans: " + smartap_params.pause);
log.info("\t\tMode: " + smartap_params.mode);
if(smartap_params.filename.length()>0){
log.info("\t\tFilename: " + smartap_params.filename);
}else{
log.info("\t\tFilename not assigned");
}
br.mark(1000);
continue;
}
Expand Down Expand Up @@ -1676,15 +1686,19 @@ public class SmartApSelectionParams {
public long hysteresis_threshold;
public Double weight;
public int pause;
public String mode;
public String filename;

public SmartApSelectionParams (int time_to_start, int scanning_interval, int added_time, Double signal_threshold, long hysteresis_threshold, Double weight, int pause) {
public SmartApSelectionParams (int time_to_start, int scanning_interval, int added_time, Double signal_threshold, long hysteresis_threshold, Double weight, int pause, String mode, String filename) {
this.time_to_start = time_to_start*1000;
this.scanning_interval = scanning_interval;
this.added_time = added_time;
this.signal_threshold = signal_threshold;
this.hysteresis_threshold = hysteresis_threshold;
this.weight = weight;
this.pause = pause*1000;
this.mode = mode;
this.filename = filename;
}
}

Expand Down

0 comments on commit 78f03ec

Please sign in to comment.