Skip to content

Commit

Permalink
Merge branch 'Development'
Browse files Browse the repository at this point in the history
  • Loading branch information
rubenmunilla committed Jul 26, 2017
2 parents 1defc5d + c87481d commit 0c4c82b
Show file tree
Hide file tree
Showing 3 changed files with 58 additions and 31 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@

import net.floodlightcontroller.odin.master.OdinMaster.ScannParams;

import org.apache.commons.io.output.TeeOutputStream;

public class ShowMatrixOfDistancedBs extends OdinApplication {

// IMPORTANT: this application only works if all the agents in the
Expand All @@ -30,6 +32,10 @@ public class ShowMatrixOfDistancedBs extends OdinApplication {
Map<InetAddress, Integer> scanningAgents = new HashMap<InetAddress, Integer> ();
int result; // Result for scanning

// Matrix
private String matrix = "";
private String avg_dB = "";


@Override
public void run() {
Expand All @@ -44,18 +50,19 @@ public void run() {
while (true) {
try {
Thread.sleep(SCANN_PARAMS.reporting_period);
matrix = "";

System.out.println("[ShowScannedStationsStatistics] Matrix of Distance");
System.out.println("[ShowScannedStationsStatistics] ==================");
System.out.println("[ShowScannedStationsStatistics]");
System.out.println("[ShowMatrixOfDistancedBs] Matrix of Distance");
System.out.println("[ShowMatrixOfDistancedBs] ==================");
System.out.println("[ShowMatrixOfDistancedBs]");

//For channel SCANNING_CHANNEL
System.out.println("[ShowMatrixOfDistancedBs] Scanning channel " + SCANN_PARAMS.channel);
System.out.println("[ShowScannedStationsStatistics]");
System.out.println("[ShowMatrixOfDistancedBs]");

for (InetAddress beaconAgentAddr: getAgents()) {
scanningAgents.clear();
System.out.println("[ShowMatrixOfDistancedBs] Agent to send mesurement beacon: " + beaconAgentAddr);
System.out.println("[ShowMatrixOfDistancedBs] Agent to send measurement beacon: " + beaconAgentAddr);

// For each Agent
System.out.println("[ShowMatrixOfDistancedBs] Request for scanning during the interval of " + SCANN_PARAMS.scanning_interval + " ms in SSID " + SCANNED_SSID);
Expand All @@ -69,9 +76,9 @@ public void run() {
}
}

// Request to send mesurement beacon
// Request to send measurement beacon
if (requestSendMesurementBeaconFromAgent(beaconAgentAddr, SCANN_PARAMS.channel, SCANNED_SSID) == 0) {
System.out.println("[ShowMatrixOfDistancedBs] Agent BUSY during mesurement beacon operation");
System.out.println("[ShowMatrixOfDistancedBs] Agent BUSY during measurement beacon operation");
continue;
}

Expand All @@ -84,6 +91,8 @@ public void run() {

// Stop sending meesurement beacon
stopSendMesurementBeaconFromAgent(beaconAgentAddr);

matrix = matrix + beaconAgentAddr.toString().substring(1);

for (InetAddress agentAddr: getAgents()) {
if (agentAddr != beaconAgentAddr) {
Expand All @@ -93,7 +102,7 @@ public void run() {

// Reception distances
if (scanningAgents.get(agentAddr) == 0) {
System.out.println("[ShowScannedStationsStatistics] Agent BUSY during scanning operation");
System.out.println("[ShowMatrixOfDistancedBs] Agent BUSY during scanning operation");
continue;
}
Map<MACAddress, Map<String, String>> vals_rx = getScannedStationsStatsFromAgent(agentAddr,SCANNED_SSID);
Expand All @@ -102,15 +111,29 @@ public void run() {
for (Entry<MACAddress, Map<String, String>> vals_entry_rx: vals_rx.entrySet()) {
// NOTE: the clients currently scanned MAY NOT be the same as the clients who have been associated
MACAddress APHwAddr = vals_entry_rx.getKey();
avg_dB = vals_entry_rx.getValue().get("avg_signal");
System.out.println("\tAP MAC: " + APHwAddr);
System.out.println("\t\tavg signal: " + vals_entry_rx.getValue().get("avg_signal") + " dBm");
System.out.println("\tavg signal: " + avg_dB + " dBm");
if(avg_dB.length()>6){
matrix = matrix + "\t" + avg_dB.substring(0,6) + " dBm";
}else{
matrix = matrix + "\t" + avg_dB + " dBm ";
}
}
}

}else{
matrix = matrix + "\t----------";
}
}
matrix = matrix + "\n";
}
//Print matrix
System.out.println("[ShowMatrixOfDistancedBs] ==================");
System.out.println(matrix);
System.out.println("[ShowMatrixOfDistancedBs] ==================");
} catch (InterruptedException e) {
e.printStackTrace();
}
}
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -155,9 +155,13 @@ public void run() {
if (isWi5Lvap) {
continue;
}
System.out.println("\t\tAP of client: none");
System.out.println("\t\tChannel of AP: none");
System.out.println("\t\tCode: non-Wi-5 Equipment");
System.out.println("\t\tAP of client: unknown");
System.out.println("\t\tChannel of AP: unknown");
if(vals_entry_rx.getValue().get("equipment").equals("AP")){
System.out.println("\t\tCode: non-Wi-5 AP");
}else{
System.out.println("\t\tCode: non-Wi-5 STA");
}
System.out.println("");
}
}
Expand Down
34 changes: 17 additions & 17 deletions src/main/java/net/floodlightcontroller/odin/master/OdinAgent.java
Original file line number Diff line number Diff line change
Expand Up @@ -73,15 +73,15 @@ class OdinAgent implements IOdinAgent {
private static final String WRITE_HANDLER_CHANNEL_SWITCH_ANNOUNCEMENT = "channel_switch_announcement";
private static final String WRITE_HANDLER_SCAN_CLIENT = "scan_client";
private static final String WRITE_HANDLER_SCAN_APS = "scan_APs";
private static final String WRITE_HANDLER_SEND_MESUREMENT_BEACON = "send_mesurement_beacon";
private static final String WRITE_HANDLER_SEND_MEASUREMENT_BEACON = "send_measurement_beacon";
private static final String WRITE_HANDLER_SCANING_FLAGS = "scanning_flags";
private static final String ODIN_AGENT_ELEMENT = "odinagent";

private final String detectionAgentIP = setDetectorIpAddress();
private static final String DETECTION_AGENT_ELEMENT = "detectionagent";

private final int TX_STAT_NUM_PROPERTIES = 7;
private final int RX_STAT_NUM_PROPERTIES = 7;
private final int TX_STAT_NUM_PROPERTIES = 8;
private final int RX_STAT_NUM_PROPERTIES = 8;
private final int MTX_DISTANCE_RX_STAT_NUM_PROPERTIES = 1;
private final int ODIN_AGENT_PORT = 6777;

Expand Down Expand Up @@ -642,9 +642,9 @@ public int requestScannedStationsStats (int channel, String ssid) {
String row[] = flags.split(" ");
int client_scanning_flag = Integer.parseInt(row[0].trim());
int AP_scanning_flag = Integer.parseInt(row[1].trim());
int mesurement_beacon_flag = Integer.parseInt(row[2].trim());
log.info("READ_HANDLER_SCANING_FLAGS ---- " + " client_scanning_flag:" + client_scanning_flag + " AP_scanning_flag:" + AP_scanning_flag + " mesurement_beacon_flag:" + mesurement_beacon_flag);
if (client_scanning_flag == 1 || AP_scanning_flag == 1 || mesurement_beacon_flag == 1)
int measurement_beacon_flag = Integer.parseInt(row[2].trim());
log.info("READ_HANDLER_SCANING_FLAGS ---- " + " client_scanning_flag:" + client_scanning_flag + " AP_scanning_flag:" + AP_scanning_flag + " measurement_beacon_flag:" + measurement_beacon_flag);
if (client_scanning_flag == 1 || AP_scanning_flag == 1 || measurement_beacon_flag == 1)
return (0);

StringBuilder sb = new StringBuilder();
Expand Down Expand Up @@ -704,8 +704,8 @@ public Map<MACAddress, Map<String, String>> getScannedStationsStats (String ssid
/**
* Request scanned stations statistics from the agent
* @param agentAddr InetAddress of the agent
* @param #channel to send mesurement beacon
* @param time interval to send mesurement beacon
* @param #channel to send measurement beacon
* @param time interval to send measurement beacon
* @param ssid to scan (e.g odin_init)
* @ If request is accepted return 1, otherwise, return 0
*/
Expand All @@ -717,24 +717,24 @@ public int requestSendMesurementBeacon (int channel, String ssid) {
String row[] = flags.split(" ");
int client_scanning_flag = Integer.parseInt(row[0].trim());
int AP_scanning_flag = Integer.parseInt(row[1].trim());
int mesurement_beacon_flag = Integer.parseInt(row[2].trim());
log.info("READ_HANDLER_SCANING_FLAGS ---- " + " client_scanning_flag:" + client_scanning_flag + " AP_scanning_flag:" + AP_scanning_flag + " mesurement_beacon_flag:" + mesurement_beacon_flag);
if (client_scanning_flag == 1 || AP_scanning_flag == 1 || mesurement_beacon_flag == 1)
int measurement_beacon_flag = Integer.parseInt(row[2].trim());
log.info("READ_HANDLER_SCANING_FLAGS ---- " + " client_scanning_flag:" + client_scanning_flag + " AP_scanning_flag:" + AP_scanning_flag + " measurement_beacon_flag:" + measurement_beacon_flag);
if (client_scanning_flag == 1 || AP_scanning_flag == 1 || measurement_beacon_flag == 1)
return (0);

StringBuilder sb = new StringBuilder();
sb.append(ssid);
sb.append(" ");
sb.append(channel);
log.info("Sending WRITE_HANDLER_SEND_MESUREMENT_BEACON " + sb.toString());
invokeWriteHandler(WRITE_HANDLER_SEND_MESUREMENT_BEACON, sb.toString());
log.info("Sending WRITE_HANDLER_SEND_MEASUREMENT_BEACON " + sb.toString());
invokeWriteHandler(WRITE_HANDLER_SEND_MEASUREMENT_BEACON, sb.toString());
return (1);
}



/**
* Stop sending mesurement beacon from the agent
* Stop sending measurement beacon from the agent
*
* @param agentAddr InetAddress of the agent
*
Expand All @@ -743,13 +743,13 @@ public int requestSendMesurementBeacon (int channel, String ssid) {
public int stopSendMesurementBeacon () {
int client_scanning_flag = 0;
int AP_scanning_flag = 0;
int mesurement_beacon_flag = 0;
int measurement_beacon_flag = 0;
StringBuilder sb = new StringBuilder();
sb.append(client_scanning_flag);
sb.append(" ");
sb.append(AP_scanning_flag);
sb.append(" ");
sb.append(mesurement_beacon_flag);
sb.append(measurement_beacon_flag);
log.info("Sending WRITE_HANDLER_SCANING_FLAGS " + sb.toString());
invokeWriteHandler(WRITE_HANDLER_SCANING_FLAGS, sb.toString());
return (1);
Expand All @@ -765,4 +765,4 @@ public String setDetectorIpAddress(){
String detectorIp = OdinMaster.getDetectorIpAddress();
return detectorIp;
}
}
}

0 comments on commit 0c4c82b

Please sign in to comment.