From f491f5965993c41757e15060d81483dfb2d7a353 Mon Sep 17 00:00:00 2001 From: rubenmunilla Date: Thu, 8 Feb 2018 09:31:11 +0100 Subject: [PATCH] SmartApSelection Log Added log option to SmartApSelection app --- poolfile | 8 +++- .../odin/applications/SmartApSelection.java | 40 +++++++++++++++++++ .../odin/master/OdinMaster.java | 18 ++++++++- 3 files changed, 62 insertions(+), 4 deletions(-) diff --git a/poolfile b/poolfile index 79fe7e4d..9ce95459 100644 --- a/poolfile +++ b/poolfile @@ -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 @@ -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 diff --git a/src/main/java/net/floodlightcontroller/odin/applications/SmartApSelection.java b/src/main/java/net/floodlightcontroller/odin/applications/SmartApSelection.java index c578cd36..1613a4fb 100644 --- a/src/main/java/net/floodlightcontroller/odin/applications/SmartApSelection.java +++ b/src/main/java/net/floodlightcontroller/odin/applications/SmartApSelection.java @@ -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; @@ -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); @@ -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 rssiData = new HashMap (); // Map to store RSSI for each STA in all APs @@ -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; @@ -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); @@ -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 } } @@ -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"); diff --git a/src/main/java/net/floodlightcontroller/odin/master/OdinMaster.java b/src/main/java/net/floodlightcontroller/odin/master/OdinMaster.java index aa2f8012..519fd701 100644 --- a/src/main/java/net/floodlightcontroller/odin/master/OdinMaster.java +++ b/src/main/java/net/floodlightcontroller/odin/master/OdinMaster.java @@ -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); @@ -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; } @@ -1676,8 +1686,10 @@ 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; @@ -1685,6 +1697,8 @@ public SmartApSelectionParams (int time_to_start, int scanning_interval, int add this.hysteresis_threshold = hysteresis_threshold; this.weight = weight; this.pause = pause*1000; + this.mode = mode; + this.filename = filename; } }