WIFI-1947: OpensyncGateway - ApNode use only ON channel survey data

This commit is contained in:
Mike Hansen
2021-04-06 13:32:01 -04:00
parent eeeec8999f
commit f96b5b4bed

View File

@@ -1087,72 +1087,74 @@ public class MqttStatsPublisher {
// populate it from report.survey // populate it from report.survey
for (Survey survey : report.getSurveyList()) { for (Survey survey : report.getSurveyList()) {
if (survey.getSurveyType().equals(SurveyType.ON_CHANNEL)) { // only interested in ON_CHANNEL for this Metrics Report
int busyRx = 0; /* Rx = Rx_obss + Rx_errr (self and obss errors) */ int busyRx = 0; /* Rx = Rx_obss + Rx_errr (self and obss errors) */
int busyTx = 0; /* Tx */ int busyTx = 0; /* Tx */
int busySelf = 0; /* Rx_self (derived from succesful Rx frames) */ int busySelf = 0; /* Rx_self (derived from succesful Rx frames) */
int busy = 0; /* Busy = Rx + Tx + Interference */ int busy = 0; /* Busy = Rx + Tx + Interference */
int totalDurationMs = 0; int totalDurationMs = 0;
RadioType radioType = RadioType.UNSUPPORTED; RadioType radioType = RadioType.UNSUPPORTED;
List<Integer> noiseList = new ArrayList<>(); List<Integer> noiseList = new ArrayList<>();
for (SurveySample surveySample : survey.getSurveyListList()) { for (SurveySample surveySample : survey.getSurveyListList()) {
if (surveySample.getDurationMs() == 0) { if (surveySample.getDurationMs() == 0) {
continue; continue;
}
// we need to perform a weighted average here because the
// samples are in percentage, and may be of different durations
busyTx += surveySample.getBusyTx() * surveySample.getDurationMs();
busyRx += surveySample.getBusyRx() * surveySample.getDurationMs();
busy += surveySample.getBusy() * surveySample.getDurationMs();
busySelf += surveySample.getBusySelf() * surveySample.getDurationMs();
totalDurationMs += surveySample.getDurationMs();
noiseList.add(getNegativeSignedIntFrom8BitUnsigned(surveySample.getNoise()));
}
if (totalDurationMs > 0) {
RadioUtilization radioUtil = new RadioUtilization();
radioUtil.setTimestampSeconds((int) ((survey.getTimestampMs()) / 1000));
int pctBusyTx = busyTx / totalDurationMs;
checkIfOutOfBound("pctBusyTx", pctBusyTx, survey, totalDurationMs, busyTx, busyRx, busy, busySelf);
radioUtil.setAssocClientTx(pctBusyTx);
int pctBusyRx = busyRx / totalDurationMs;
checkIfOutOfBound("pctBusyRx", pctBusyRx, survey, totalDurationMs, busyTx, busyRx, busy, busySelf);
radioUtil.setAssocClientRx(pctBusyRx);
double pctIBSS = (busyTx + busySelf) / totalDurationMs;
radioUtil.setIbss(pctIBSS);
int nonWifi = (busy - (busyTx + busyRx)) / totalDurationMs;
checkIfOutOfBound("nonWifi", nonWifi, survey, totalDurationMs, busyTx, busyRx, busy, busySelf);
radioUtil.setNonWifi(nonWifi);
radioType = OvsdbToWlanCloudTypeMappingUtility.getRadioTypeFromOpensyncStatsRadioBandType(survey.getBand());
if (radioType != RadioType.UNSUPPORTED) {
if (apNodeMetrics.getRadioUtilization(radioType) == null) {
apNodeMetrics.setRadioUtilization(radioType, new ArrayList<>());
} }
apNodeMetrics.getRadioUtilization(radioType).add(radioUtil); // we need to perform a weighted average here because the
int noiseAvg = (int) Math.round(DecibelUtils.getAverageDecibel(toIntArray(noiseList))); // samples are in percentage, and may be of different durations
avgNoiseFloor.put(radioType, noiseAvg); busyTx += surveySample.getBusyTx() * surveySample.getDurationMs();
apNodeMetrics.setNoiseFloor(radioType, noiseAvg); busyRx += surveySample.getBusyRx() * surveySample.getDurationMs();
busy += surveySample.getBusy() * surveySample.getDurationMs();
Long totalUtilization = Math.round((double) busy / totalDurationMs); busySelf += surveySample.getBusySelf() * surveySample.getDurationMs();
Long totalNonWifi = totalUtilization - ((busyTx + busyRx) / totalDurationMs); totalDurationMs += surveySample.getDurationMs();
noiseList.add(getNegativeSignedIntFrom8BitUnsigned(surveySample.getNoise()));
EquipmentCapacityDetails cap = new EquipmentCapacityDetails();
cap.setUnavailableCapacity(totalNonWifi.intValue());
int availableCapacity = (int) (100 - totalUtilization);
cap.setAvailableCapacity(availableCapacity);
cap.setUsedCapacity(totalUtilization.intValue());
cap.setUnusedCapacity(availableCapacity - totalUtilization.intValue());
cap.setTotalCapacity(100);
apNodeMetrics.setChannelUtilization(radioType, totalUtilization.intValue());
capacityDetails.put(radioType, cap);
} }
if (totalDurationMs > 0) {
RadioUtilization radioUtil = new RadioUtilization();
radioUtil.setTimestampSeconds((int) ((survey.getTimestampMs()) / 1000));
int pctBusyTx = busyTx / totalDurationMs;
checkIfOutOfBound("pctBusyTx", pctBusyTx, survey, totalDurationMs, busyTx, busyRx, busy, busySelf);
radioUtil.setAssocClientTx(pctBusyTx);
int pctBusyRx = busyRx / totalDurationMs;
checkIfOutOfBound("pctBusyRx", pctBusyRx, survey, totalDurationMs, busyTx, busyRx, busy, busySelf);
radioUtil.setAssocClientRx(pctBusyRx);
double pctIBSS = (busyTx + busySelf) / totalDurationMs;
radioUtil.setIbss(pctIBSS);
int nonWifi = (busy - (busyTx + busyRx)) / totalDurationMs;
checkIfOutOfBound("nonWifi", nonWifi, survey, totalDurationMs, busyTx, busyRx, busy, busySelf);
radioUtil.setNonWifi(nonWifi);
radioType = OvsdbToWlanCloudTypeMappingUtility.getRadioTypeFromOpensyncStatsRadioBandType(survey.getBand());
if (radioType != RadioType.UNSUPPORTED) {
if (apNodeMetrics.getRadioUtilization(radioType) == null) {
apNodeMetrics.setRadioUtilization(radioType, new ArrayList<>());
}
apNodeMetrics.getRadioUtilization(radioType).add(radioUtil);
int noiseAvg = (int) Math.round(DecibelUtils.getAverageDecibel(toIntArray(noiseList)));
avgNoiseFloor.put(radioType, noiseAvg);
apNodeMetrics.setNoiseFloor(radioType, noiseAvg);
Long totalUtilization = Math.round((double) busy / totalDurationMs);
Long totalNonWifi = totalUtilization - ((busyTx + busyRx) / totalDurationMs);
EquipmentCapacityDetails cap = new EquipmentCapacityDetails();
cap.setUnavailableCapacity(totalNonWifi.intValue());
int availableCapacity = (int) (100 - totalUtilization);
cap.setAvailableCapacity(availableCapacity);
cap.setUsedCapacity(totalUtilization.intValue());
cap.setUnusedCapacity(availableCapacity - totalUtilization.intValue());
cap.setTotalCapacity(100);
apNodeMetrics.setChannelUtilization(radioType, totalUtilization.intValue());
capacityDetails.put(radioType, cap);
}
}
} }
} }