public class ConnectivityGrid extends ConnectivityOptimizer
Overlay grid of the world where each interface is put on a cell depending of its location. This is used in cell-based optimization of connecting the interfaces.
The idea in short:
Instead of checking for every interface if some of the other interfaces are close
enough (this approach obviously doesn't scale) we check only interfaces that
are "close enough" to be possibly connected. Being close enough is
determined by keeping track of the approximate location of the interfaces
by storing them in overlay grid's cells and updating the cell information
every time the interfaces move. If two interfaces are in the same cell or in
neighboring cells, they have a chance of being close enough for
connection. Then only that subset of interfaces is checked for possible
connectivity.
Note: this class does NOT support negative coordinates. Also, it makes sense to normalize the coordinates to start from zero to conserve memory.
| Modifier and Type | Class and Description |
|---|---|
class |
ConnectivityGrid.GridCell
A single cell in the cell grid.
|
| Modifier and Type | Field and Description |
|---|---|
static java.lang.String |
CELL_SIZE_MULT_S
Cell based optimization cell size multiplier -setting id ("cellSizeMult").
|
static int |
DEF_CON_CELL_SIZE_MULT
default value for cell size multiplier (5)
|
| Modifier and Type | Method and Description |
|---|---|
void |
addInterface(NetworkInterface ni)
Adds a network interface to the overlay grid
|
void |
addInterfaces(java.util.Collection<NetworkInterface> interfaces)
Adds interfaces to overlay grid
|
static ConnectivityGrid |
ConnectivityGridFactory(int key,
double maxRange)
Returns a connectivity grid object based on a hash value
|
java.util.Collection<NetworkInterface> |
getAllInterfaces()
Returns all interfaces that use the same technology and channel
|
java.util.Collection<NetworkInterface> |
getNearInterfaces(NetworkInterface ni)
Returns all interfaces that are "near" (i.e., in neighboring grid cells)
and use the same technology and channel as the given interface
|
void |
removeInterface(NetworkInterface ni)
Removes a network interface from the overlay grid
|
static void |
reset() |
java.lang.String |
toString()
Returns a string representation of the ConnectivityCells object
|
void |
updateLocation(NetworkInterface ni)
Checks and updates (if necessary) interface's position in the grid
|
public static final java.lang.String CELL_SIZE_MULT_S
World.OPTIMIZATION_SETTINGS_NS name space.
Single ConnectivityCell's size is the biggest radio range times this.
Larger values save memory and decrease startup time but may result in
slower simulation.
Default value is DEF_CON_CELL_SIZE_MULT.
Smallest accepted value is 1.public static final int DEF_CON_CELL_SIZE_MULT
public static void reset()
public static ConnectivityGrid ConnectivityGridFactory(int key, double maxRange)
key - A hash value that separates different interfaces from each othermaxRange - Maximum range used by the radio technology using this
connectivity grid.public void addInterface(NetworkInterface ni)
addInterface in class ConnectivityOptimizerni - The new network interfacepublic void removeInterface(NetworkInterface ni)
ni - The interface to be removedpublic void addInterfaces(java.util.Collection<NetworkInterface> interfaces)
addInterfaces in class ConnectivityOptimizerinterfaces - Collection of interfaces to addpublic void updateLocation(NetworkInterface ni)
updateLocation in class ConnectivityOptimizerni - The interface to updatepublic java.util.Collection<NetworkInterface> getAllInterfaces()
getAllInterfaces in class ConnectivityOptimizerpublic java.util.Collection<NetworkInterface> getNearInterfaces(NetworkInterface ni)
getNearInterfaces in class ConnectivityOptimizerni - The interface whose neighboring interfaces are returnedpublic java.lang.String toString()
toString in class java.lang.Object