Class ChannelOptimizer
- java.lang.Object
-
- com.facebook.openwifi.rrm.optimizers.channel.ChannelOptimizer
-
- Direct Known Subclasses:
LeastUsedChannelOptimizer
,RandomChannelInitializer
public abstract class ChannelOptimizer extends Object
Channel optimizer base class.
-
-
Field Summary
Fields Modifier and Type Field Description protected static Map<Integer,List<Integer>>
AVAILABLE_CHANNELS_WIDTH
Map of channel width (MHz) to available (primary) channelsprotected Map<String,DeviceConfig>
deviceConfigs
The device configs withinzone
, keyed on serial number.static int
MIN_CHANNEL_WIDTH
Minimum supported channel width (MHz), inclusive.protected Modeler.DataModel
model
The input data model.protected static List<Integer>
PRIORITY_CHANNELS_2G
List of priority channels on 2.4GHz.protected String
zone
The RF zone.
-
Constructor Summary
Constructors Constructor Description ChannelOptimizer(Modeler.DataModel model, String zone, DeviceDataManager deviceDataManager)
Constructor.
-
Method Summary
All Methods Static Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description protected void
calculatePerfMetrics(Map<String,Integer> tempChannelMap, Map<String,List<WifiScanEntry>> deviceToWifiScans, Map<String,String> bssidsMap, boolean mode)
Calculate the performance metrics based on the given assignment.abstract Map<String,Map<String,Integer>>
computeChannelMap()
Compute channel assignments.protected static int
getChannelWidthFromWiFiScan(int channel, String htOper, String vhtOper)
Get the channel width based on the HT operation and VHT operation in wifi scan.protected static List<Integer>
getCoveredChannels(int channel, int primaryChannel, int channelWidth)
Get the actual covered channels of a neighboring AP based on the given channel and channel width.protected static int[]
getCurrentChannel(String band, String serialNumber, State state, Map<String,Map<String,Capabilities.Phy>> latestDeviceCapabilitiesPhy)
Get the current channel and channel width (MHz) of the device (from state data).protected static Map<String,List<WifiScanEntry>>
getDeviceToWiFiScans(String band, Map<String,List<List<WifiScanEntry>>> latestWifiScans, Map<String,List<String>> bandsMap)
Get the filtered and reorganized wifiscan results per device.protected static int
getPrimaryChannel(int channel, int channelWidth)
Get the primary channel depending on the given channel and channel width.protected void
logPerfMetrics(Map<String,Integer> oldChannelMap, Map<String,Integer> newChannelMap, Map<String,List<WifiScanEntry>> deviceToWifiScans, Map<String,String> bssidsMap)
Log the performance metrics before and after the algorithm.protected List<Integer>
updateAvailableChannelsList(String band, String serialNumber, int channelWidth, List<Integer> availableChannelsList)
Update the available channels based on bandwidth-specific, user, allowed channels (the last two are from deviceConfig).void
updateDeviceApConfig(DeviceDataManager deviceDataManager, ConfigManager configManager, Map<String,Map<String,Integer>> channelMap)
Program the given channel map into the AP config.
-
-
-
Field Detail
-
MIN_CHANNEL_WIDTH
public static final int MIN_CHANNEL_WIDTH
Minimum supported channel width (MHz), inclusive.- See Also:
- Constant Field Values
-
AVAILABLE_CHANNELS_WIDTH
protected static final Map<Integer,List<Integer>> AVAILABLE_CHANNELS_WIDTH
Map of channel width (MHz) to available (primary) channels
-
PRIORITY_CHANNELS_2G
protected static final List<Integer> PRIORITY_CHANNELS_2G
List of priority channels on 2.4GHz.
-
model
protected final Modeler.DataModel model
The input data model.
-
zone
protected final String zone
The RF zone.
-
deviceConfigs
protected final Map<String,DeviceConfig> deviceConfigs
The device configs withinzone
, keyed on serial number.
-
-
Constructor Detail
-
ChannelOptimizer
public ChannelOptimizer(Modeler.DataModel model, String zone, DeviceDataManager deviceDataManager)
Constructor.
-
-
Method Detail
-
getPrimaryChannel
protected static int getPrimaryChannel(int channel, int channelWidth)
Get the primary channel depending on the given channel and channel width.- Parameters:
channel
- the current channel (from the scan result)channelWidth
- the channel bandwidth (MHz)- Returns:
- the primary channel, 0 if error
-
getChannelWidthFromWiFiScan
protected static int getChannelWidthFromWiFiScan(int channel, String htOper, String vhtOper)
Get the channel width based on the HT operation and VHT operation in wifi scan.- Parameters:
channel
- the current channel (from the scan result)htOper
- the HT operation information elementvhtOper
- the VHT operation information element- Returns:
- the channel width, default = MIN_CHANNEL_WIDTH
-
getCoveredChannels
protected static List<Integer> getCoveredChannels(int channel, int primaryChannel, int channelWidth)
Get the actual covered channels of a neighboring AP based on the given channel and channel width.- Parameters:
channel
- the current channel (from the scan result)primaryChannel
- the primary channel corresponding to the channelWidthchannelWidth
- the channel bandwidth (MHz)- Returns:
- the list of the covered channels, the current channel if it is 2.4 GHz or error
-
getDeviceToWiFiScans
protected static Map<String,List<WifiScanEntry>> getDeviceToWiFiScans(String band, Map<String,List<List<WifiScanEntry>>> latestWifiScans, Map<String,List<String>> bandsMap)
Get the filtered and reorganized wifiscan results per device.- Parameters:
band
- the operational bandlatestWifiScans
- the raw wifiscan results from upstreambandsMap
- the participated OWF APs on this band- Returns:
- map of device (serial number) to wifiscan results
-
getCurrentChannel
protected static int[] getCurrentChannel(String band, String serialNumber, State state, Map<String,Map<String,Capabilities.Phy>> latestDeviceCapabilitiesPhy)
Get the current channel and channel width (MHz) of the device (from state data).- Parameters:
band
- the operational band (e.g., "2G")serialNumber
- the device's serial numberstate
- the latest state of all the deviceslatestDeviceCapabilitiesPhy
- latest device phy from capabilities- Returns:
- the current channel and channel width (MHz) of the device in the given band; returns a current channel of 0 if no channel in the given band is found.
-
updateAvailableChannelsList
protected List<Integer> updateAvailableChannelsList(String band, String serialNumber, int channelWidth, List<Integer> availableChannelsList)
Update the available channels based on bandwidth-specific, user, allowed channels (the last two are from deviceConfig).- Parameters:
band
- the operational bandserialNumber
- the devicechannelWidth
- the channel bandwidth (MHz)availableChannelsList
- the available channels of the device- Returns:
- the updated available channels of the device
-
calculatePerfMetrics
protected void calculatePerfMetrics(Map<String,Integer> tempChannelMap, Map<String,List<WifiScanEntry>> deviceToWifiScans, Map<String,String> bssidsMap, boolean mode)
Calculate the performance metrics based on the given assignment.- Parameters:
tempChannelMap
- the map of device (serial number) to its given channeldeviceToWifiScans
- the map of device (serial number) to wifiscan resultsbssidsMap
- the map of bssid to device (serial number)mode
- true for the new assignment and false for the current assignment
-
logPerfMetrics
protected void logPerfMetrics(Map<String,Integer> oldChannelMap, Map<String,Integer> newChannelMap, Map<String,List<WifiScanEntry>> deviceToWifiScans, Map<String,String> bssidsMap)
Log the performance metrics before and after the algorithm.- Parameters:
oldChannelMap
- the map of device (serial number) to its current channelnewChannelMap
- the map of device (serial number) to its new channeldeviceToWifiScans
- the map of device (serial number) to wifiscan resultsbssidsMap
- the map of bssid to device (serial number)
-
computeChannelMap
public abstract Map<String,Map<String,Integer>> computeChannelMap()
Compute channel assignments.- Returns:
- the map of devices (by serial number) to radio to channel
-
updateDeviceApConfig
public void updateDeviceApConfig(DeviceDataManager deviceDataManager, ConfigManager configManager, Map<String,Map<String,Integer>> channelMap)
Program the given channel map into the AP config.- Parameters:
deviceDataManager
- the DeviceDataManager instanceconfigManager
- the ConfigManager instancechannelMap
- the map of devices (by serial number) to radio to channel
-
-