#include <ChannelControl.h>
Collaboration diagram for ChannelControl:
Public Member Functions  
Module_Class_Members (ChannelControl, cSimpleModule, 0)  
Constructor.  
virtual void  initialize () 
Reads init parameters and calculates a maximal interfence distance.  
bool  registerNic (cModule *, const Coord *) 
Returns the x and y coordinates of the given nic. Registers a nic to have its connections managed by ChannelControl.  
void  updateNicPos (int, const Coord *oldPos, const Coord *newPos) 
Updates the position information of a registered nic.  
const Coord *  getPgs () 
Returns the playgroundSize.  
const NicEntry::GateList &  getGateList (int, const Coord *) 
const cGate *  getOutGateTo (int, int, const Coord *) 
Static Public Attributes  
static const double  speedOfLight = 300000000.0 
Speed of light.  
Protected Types  
typedef std::map< int, NicEntry * >  NicEntries 
typedef std::vector< NicEntries >  RowVector 
typedef std::vector< RowVector >  NicMatrix 
Protected Member Functions  
void  updateConnections (NicEntries &nmap, NicEntry *nic) 
Manages the connections of a registered nic.  
virtual double  calcInterfDist () 
Calculate interference distance.  
void  checkGrid (unsigned oldX, unsigned oldY, unsigned newX, unsigned newY, int id) 
bool  increment (unsigned max, unsigned src, unsigned *target) 
bool  decrement (unsigned max, unsigned src, unsigned *target) 
bool  inRangeEuclid (const Coord &a, const Coord &b) 
bool  inRangeTorus (const Coord &a, const Coord &b) 
Protected Attributes  
bool  coreDebug 
Set debugging for the basic module.  
NicMatrix  nics 
Registry of all Nics.  
bool  sendDirect 
Does the ChannelControl use sendDirect or not?  
Coord  playgroundSize 
x and y size of the area the nodes are in (in meters)  
double  maxInterferenceDistance 
the biggest interference distance in the network.  
double  maxDistSquared 
Square of maxInterferenceDistance cache a value that is often used.  
double  findDistance 
unsigned  maxX 
unsigned  maxY 
bool  useTorus 
The central module that coordinates the connections between all nodes, and handles dynamic gate creation. ChannelControl therefore periodically communicates with the ChannelAccess modules

Calculate interference distance. Calculation of the interference distance based on the transmitter power, wavelength, pathloss coefficient and a threshold for the minimal receive Power You may want to overwrite this function in order to do your own interference calculation 

check connections of a nic in the grid 

find the next smaller coordinate in grid, return true if the connections in this position should be updated. 

Called by P2PPhyLayer. Needed to send a packet directly to a certain nic without other nodes 'hearing' it. This is only useful for physical layers that work with bit error probability like P2PPhyLayer.


find the next larger coordinate in grid, return true if the connections in this position should be updated. 

Reads init parameters and calculates a maximal interfence distance. Sets up the playgroundSize and calculates the maxInterferenceDistance 

check whether nodes are connected in euclidean space 

check whether nodes are connected on torus (connections wrap around corners) 

Returns the x and y coordinates of the given nic. Registers a nic to have its connections managed by ChannelControl. Called by ChannelAccess for the nic module upon initialization. The nics are written into a list.


Manages the connections of a registered nic. Called by ChannelControl::updateNodePosition(...) when a nic has moved. Sets up a new connection between two nics, if they are within interference range. Accordingly tears down a connection, if the nics move out of range.


Updates the position information of a registered nic. Called periodically by ChannelAccess to indicate that the nic with "id" moved. Updates the nics' position and all its connections


Distance that helps to find a node under a certain position. Can be larger then


further cached values 

Registry of all Nics. This matrix keeps all Nics according to their position. It allows to restrict the position update to a subset of all nics. 

If set, node connections wrap arounnd the borders of the playground. This eliminiates certain border effects. 