interfaces
Class ConnectivityGrid

java.lang.Object
  extended by interfaces.ConnectivityOptimizer
      extended by interfaces.ConnectivityGrid

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.


Nested Class Summary
 class ConnectivityGrid.GridCell
          A single cell in the cell grid.
 
Method Summary
 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 cellSize)
          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 netinterf)
          Returns all interfaces using the same technology and channel that are in neighboring cells
 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
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Method Detail

reset

public static void reset()

ConnectivityGridFactory

public static ConnectivityGrid ConnectivityGridFactory(int key,
                                                       double cellSize)
Returns a connectivity grid object based on a hash value

Parameters:
key - A hash value that separates different interfaces from each other
cellSize - Cell's edge's length (must be larger than the largest radio coverage's diameter)
Returns:
The connectivity grid object for a specific interface

addInterface

public void addInterface(NetworkInterface ni)
Adds a network interface to the overlay grid

Specified by:
addInterface in class ConnectivityOptimizer
Parameters:
ni - The new network interface

removeInterface

public void removeInterface(NetworkInterface ni)
Removes a network interface from the overlay grid

Parameters:
ni - The interface to be removed

addInterfaces

public void addInterfaces(java.util.Collection<NetworkInterface> interfaces)
Adds interfaces to overlay grid

Specified by:
addInterfaces in class ConnectivityOptimizer
Parameters:
interfaces - Collection of interfaces to add

updateLocation

public void updateLocation(NetworkInterface ni)
Checks and updates (if necessary) interface's position in the grid

Specified by:
updateLocation in class ConnectivityOptimizer
Parameters:
ni - The interface to update

getAllInterfaces

public java.util.Collection<NetworkInterface> getAllInterfaces()
Returns all interfaces that use the same technology and channel

Specified by:
getAllInterfaces in class ConnectivityOptimizer

getNearInterfaces

public java.util.Collection<NetworkInterface> getNearInterfaces(NetworkInterface netinterf)
Returns all interfaces using the same technology and channel that are in neighboring cells

Specified by:
getNearInterfaces in class ConnectivityOptimizer
Parameters:
netinterf - network interface that needs to be connected
Returns:
A collection of network interfaces within proximity

toString

public java.lang.String toString()
Returns a string representation of the ConnectivityCells object

Overrides:
toString in class java.lang.Object
Returns:
a string representation of the ConnectivityCells object