Module Class Reference

#include <module.h>

Inheritance diagram for Module:

Inheritance graph
[legend]
Collaboration diagram for Module:

Collaboration graph
[legend]
List of all members.

Public Member Functions

 Module ()
virtual ~Module ()
virtual int command (int argc, const char *const *argv)
virtual void recv (Packet *p, Handler *callback)
virtual void recv (Packet *p, int idSrc)
virtual void recv (Packet *p)=0
int getUpLaySAPnum ()
SAPgetUpLaySAP (int i)
int getDownLaySAPnum ()
SAPgetDownLaySAP (int i)
void swapUpLaySAP (int i, int j)
void swapDownLaySAP (int i, int j)

Protected Member Functions

void addUpSAP (SAP *sap)
void addDownSAP (SAP *sap)
void sendUp (Packet *p, double delay=0)
void sendDown (Packet *p, double delay=0)
void sendUp (int moduleId, Packet *p, double delay=0)
void sendDown (int moduleId, Packet *p, double delay=0)
void sendAsyncClMsgUp (ClMessage *m, double delay=0)
void sendAsyncClMsgDown (ClMessage *m, double delay=0)
void sendSyncClMsgDown (ClMessage *m)
void sendSyncClMsgUp (ClMessage *m)
void drop (Packet *p, int depth, const char *reason="---")
virtual Packet * copy (Packet *p)
void sendUp (ClMessage *m, double delay=0)
void sendUp (int moduleId, ClMessage *m, double delay=0)
void sendDown (ClMessage *m, double delay=0)
void sendDown (int moduleId, ClMessage *p, double delay=0)
void sendSynchronousDown (ClMessage *m)
void sendSynchronousUp (ClMessage *m)
void sendSynchronousUp (int moduleId, ClMessage *m)
void sendSynchronousDown (int moduleId, ClMessage *m)

Private Attributes

SAP ** upLayerSAP_
int upLaySAPnum_
SAP ** downLayerSAP_
int downLaySAPnum_

Detailed Description

The MODULE class is a PlugIn which is forced to be in a stack It may have several connections both to module(s) of the up layer in the stack (through SAP) and to the modules(s) of the above layer. It may also have a connection to a cross-layer bus (through ClSAP) in order to communicate to module of un-adjacent layer (by means of ad-hoc messages, extended by ClMessage class)

See also:
PlugIn, SAP, CLSAP, ClMessage, NodeCore

Definition at line 60 of file module.h.


Constructor & Destructor Documentation

Module::Module (  ) 

Module constructor

Definition at line 47 of file module.cc.

Module::~Module (  )  [virtual]

Module destructor

Definition at line 52 of file module.cc.


Member Function Documentation

int Module::command ( int  argc,
const char *const *  argv 
) [virtual]

TCL command interpreter. It implements the following OTcl methods:

Moreover it inherits all the OTcl method of PlugIn

Parameters:
argc number of arguments in argv
argv array of strings which are the comand parameters (Note that argv[0] is the name of the object)
Returns:
TCL_OK or TCL_ERROR whether the command has been dispatched succesfully or no
See also:
PlugIn

Reimplemented from PlugIn.

Reimplemented in ChannelModule, IPInterfaceModule, IPRoutingModule, IPModule, PortMap, PortMux, CbrModule, TcpModule, LinkChannelModule, MPhy, MMacModule, MMac, MLLModule, UmtsMacModule, RlcModule, UmtsIPInterfaceModule, UmtsPhy, UmtsPhyME, UmtsWirelessChModule, DumbWirelessChModule, WirelessChModule, WirelessPhyModule, MacModule802_11, IPAddressCodec, MrclRoutingStatic, MrclRouting, and AodvModule.

Definition at line 57 of file module.cc.

References addDownSAP(), addUpSAP(), PlugIn::command(), and PlugIn::setLayer().

Referenced by RlcModule::command(), UmtsMacModule::command(), TcpModule::command(), MrclRouting::command(), IPAddressCodec::command(), PortMux::command(), PortMap::command(), WirelessPhyModule::command(), ChannelModule::command(), MPhy::command(), MMac::command(), MMacModule::command(), MLLModule::command(), MacModule802_11::command(), IPModule::command(), IPRoutingModule::command(), and CbrModule::command().

Here is the call graph for this function:

void Module::recv ( Packet *  p,
Handler *  callback 
) [virtual]

Call the recv method with only the Packet parameter in order to hide the callback (not used in this implementation) and mantain compatibility with the old ns2 code

Parameters:
p pointer to the packet will be received
callback pointer to a Handler class
See also:
SAP, ChSAP

Reimplemented from PlugIn.

Reimplemented in ChannelModule, CbrModule, TcpModule, LinkChannelModule, MMacModule, RlcModule, WirelessPhyModule, and MacModule802_11.

Definition at line 528 of file module.cc.

Referenced by SAP::handle(), ChSAP::handle(), recv(), SAP::sendDown(), SAP::sendUp(), and ChSAP::sendUp().

void Module::recv ( Packet *  p,
int  idSrc 
) [virtual]

Call the recv method with only the Packet parameter, by extending it it is possible to use the information stored in idSrc to understand with module has sent this packet

Parameters:
p pointer to the packet will be received
idSrc unique id of the module that has sent the packet
See also:
SAP, ChSAP

Reimplemented in PortMap, PortMux, TcpModule, and MLLModule.

Definition at line 533 of file module.cc.

References recv().

Here is the call graph for this function:

virtual void Module::recv ( Packet *  p  )  [pure virtual]

Abstract method which has to be filled with the ad-hoc operations that the module has to do to the packet received

Parameters:
p pointer to the packet will be received
See also:
SAP, ChSAP

Implemented in ChannelModule, IPInterfaceModule, IPRoutingModule, IPModule, PortMap, PortMux, CbrModule, TcpModule, MPhy, MMacModule, MMac, MLLModule, UmtsMacModule, RlcModule, UmtsIPInterfaceModule, WirelessPhyModule, MacModule802_11, IPAddressCodec, and MrclRouting.

int Module::getUpLaySAPnum (  ) 

Returns the number of the SAP installed in the above layer side

Returns:
the number od SAP installed in the above layer side
See also:
SAP

Definition at line 90 of file module.cc.

References upLaySAPnum_.

Referenced by PortMux::command(), ChannelModule::getChSAPnum(), MrclRouting::getConfiguration(), and sendUp().

SAP * Module::getUpLaySAP ( int  i  ) 

Returns the pointer to the instance of the i-SAP installed in the above layer side

Parameters:
i id of the SAP (SAPs are logically placed as an array)
Returns:
the pointer to the instance of the i-SAP installed in the above layer side
See also:
SAP

Definition at line 95 of file module.cc.

References upLayerSAP_, and upLaySAPnum_.

Referenced by PortMux::command(), ChannelModule::getChSAP(), MrclRouting::getConfiguration(), sendAsyncClMsgUp(), sendSyncClMsgUp(), and sendUp().

int Module::getDownLaySAPnum (  ) 

Returns the number of the SAP installed in the bottom layer side

Returns:
the number od SAP installed in the bottom layer side
See also:
SAP

Definition at line 104 of file module.cc.

References downLaySAPnum_.

Referenced by MrclRouting::getConfiguration(), and sendUp().

SAP * Module::getDownLaySAP ( int  i  ) 

Returns the pointer to the instance of the i-SAP installed in the bottom layer side

Parameters:
i id of the SAP (SAPs are logically placed as an array)
Returns:
the pointer to the instance of the i-SAP installed in the bottom layer side
See also:
SAP

Definition at line 109 of file module.cc.

References downLayerSAP_, and downLaySAPnum_.

Referenced by MrclRouting::getConfiguration(), sendAsyncClMsgDown(), sendDown(), and sendSyncClMsgDown().

void Module::swapUpLaySAP ( int  i,
int  j 
)

Swap the SAPs in the above layer indicated, i.e., i becomes the id of the instance of the j-SAP and j becomes the instance of the i-SAP

Parameters:
i id of first SAP
j id of second SAP
See also:
SAP

Definition at line 158 of file module.cc.

References upLayerSAP_, and upLaySAPnum_.

Referenced by ChannelModule::swapChSAP().

void Module::swapDownLaySAP ( int  i,
int  j 
)

Swap the SAPs in the bottom layer indicated, i.e., i becomes the id of the instance of the j-SAP and j becomes the instance of the i-SAP

Parameters:
i id of first SAP
j id of second SAP
See also:
SAP

Definition at line 173 of file module.cc.

References downLayerSAP_, and downLaySAPnum_.

void Module::addUpSAP ( SAP sap  )  [protected]

Install a new SAP in the above layer side

Parameters:
sap instance of the SAP to be installed
See also:
SAP

Definition at line 119 of file module.cc.

References upLayerSAP_, and upLaySAPnum_.

Referenced by command(), and ChannelModule::command().

void Module::addDownSAP ( SAP sap  )  [protected]

Install a new SAP in the bottom layer side

Parameters:
sap instance of the SAP to be installed
See also:
SAP

Definition at line 142 of file module.cc.

References downLayerSAP_, downLaySAPnum_, and PlugIn::getId().

Referenced by command().

Here is the call graph for this function:

void Module::sendUp ( Packet *  p,
double  delay = 0 
) [protected]

Send a packet to the module(s) of the above layer after the delay specified (if they are more than one, it sends a copy to each one)

Parameters:
p pointer of the packet which has to be sent
delay (optional) delay introduced before transmission [sec.]
See also:
SAP

Definition at line 190 of file module.cc.

References copy(), PlugIn::getId(), SAP::sendUp(), upLayerSAP_, and upLaySAPnum_.

Referenced by UmtsPhy::endRx(), MPhy_Bpsk::endRx(), MrclRoutingStatic::forward(), AodvModule::forward(), MMacAloha::Phy2MacEndRx(), RlcModule::recv(), UmtsMacModule::recv(), MrclRouting::recv(), IPAddressCodec::recv(), PortMux::recv(), PortMap::recv(), WirelessPhyModule::recv(), MacModule802_11::recv(), LLInterface::recv(), IPModule::recv(), IPRoutingModule::recv(), IPInterfaceModule::recv(), MMacCsma::recvData4Me(), MrclRoutingStatic::resolve(), GenericMacModule::rx(), and MLLModule::sendUp().

Here is the call graph for this function:

void Module::sendDown ( Packet *  p,
double  delay = 0 
) [protected]

Send a packet to the module(s) of the bottom layer after the delay specified (if they are more than one, it sends a copy to each one)

Parameters:
p pointer of the packet which has to be sent
delay (optional) delay introduced before transmission [sec.]
See also:
SAP

Definition at line 218 of file module.cc.

References copy(), downLayerSAP_, downLaySAPnum_, PlugIn::getId(), and SAP::sendDown().

Referenced by MLLModule::arpRequest(), AodvModule::forward(), MMac::Mac2PhyStartTx(), MLLModule::processARP(), RlcModule::recv(), TcpModule::recv(), MrclRouting::recv(), IPAddressCodec::recv(), PortMux::recv(), PortMap::recv(), WirelessPhyModule::recv(), MacModule802_11::recv(), IPModule::recv(), IPRoutingModule::recv(), IPInterfaceModule::recv(), MrclRoutingStatic::resolve(), MLLModule::sendDown(), AodvModule::sendError(), AodvModule::sendHello(), CbrModule::sendPkt(), AodvModule::sendReply(), AodvModule::sendRequest(), UmtsPhy::startTx(), MPhy_Bpsk::startTx(), UmtsMacModule::transmit(), and GenericMacModule::tx().

Here is the call graph for this function:

void Module::sendUp ( int  moduleId,
Packet *  p,
double  delay = 0 
) [protected]

Send a packet to the requested module of the above layer after the delay specified (if they are more than one, it sends a copy to each one)

Parameters:
moduleId ID of the up module at which you would send the packet
p pointer of the packet which has to be sent
delay (optional) delay introduced before transmission [sec.]
See also:
SAP

Definition at line 254 of file module.cc.

References getDownLaySAPnum(), PlugIn::getId(), SAP::getModuleDownId(), SAP::getModuleUpId(), PlugIn::getTag(), getUpLaySAP(), getUpLaySAPnum(), SAP::sendUp(), and upLaySAPnum_.

Here is the call graph for this function:

void Module::sendDown ( int  moduleId,
Packet *  p,
double  delay = 0 
) [protected]

Send a packet to the requested module of the bottom layer after the delay specified (if they are more than one, it sends a copy to each one)

Parameters:
moduleId ID of the down module at which you would send the packet
p pointer of the packet which has to be sent
delay (optional) delay introduced before transmission [sec.]
See also:
SAP

Definition at line 284 of file module.cc.

References downLaySAPnum_, getDownLaySAP(), SAP::getModuleDownId(), and SAP::sendDown().

Here is the call graph for this function:

void Module::sendAsyncClMsgUp ( ClMessage m,
double  delay = 0 
) [protected]

Send a ClMessage to the module(s) of the above layer after the delay specified (if they are more than one, it sends a copy to each one)

Parameters:
m pointer of the ClMessage which has to be sent
delay (optional) delay introduced before transmission [sec.]
See also:
SAP

Definition at line 366 of file module.cc.

References BROADCAST, CLBROADCASTADDR, ClMessage::copy(), ClMessage::getDest(), ClMessage::getDestType(), PlugIn::getId(), getUpLaySAP(), SAP::sendUp(), ClMessage::setSource(), and upLaySAPnum_.

Referenced by sendUp().

Here is the call graph for this function:

void Module::sendAsyncClMsgDown ( ClMessage m,
double  delay = 0 
) [protected]

Send a ClMessage to the module(s) of the bottom layer after the delay specified (if they are more than one, it sends a copy to each one)

Parameters:
m pointer of the ClMessage which has to be sent
delay (optional) delay introduced before transmission [sec.]
See also:
SAP

Definition at line 407 of file module.cc.

References BROADCAST, CLBROADCASTADDR, ClMessage::copy(), downLaySAPnum_, ClMessage::getDest(), ClMessage::getDestType(), getDownLaySAP(), PlugIn::getId(), SAP::sendDown(), and ClMessage::setSource().

Referenced by IPModule::recvSyncClMsg(), and sendDown().

Here is the call graph for this function:

void Module::sendSyncClMsgDown ( ClMessage m  )  [protected]

Send a synchronous ClMessage to the module(s) of the bottom layer (it sends the same the synchronous ClMessage to each one)

Parameters:
m pointer of the ClMessage which has to be sent
See also:
SAP

Definition at line 476 of file module.cc.

References BROADCAST, CLBROADCASTADDR, downLaySAPnum_, ClMessage::getDest(), ClMessage::getDestType(), getDownLaySAP(), PlugIn::getId(), SAP::sendSynchronousDown(), and ClMessage::setSource().

Referenced by MrclRouting::getConfiguration(), MLLModule::getDownAddr(), MMac::Mac2PhyOnOffSwitchStatus(), MMac::Mac2PhyTurnOff(), MMac::Mac2PhyTurnOn(), MMac::Mac2PhyTxDuration(), and sendSynchronousDown().

Here is the call graph for this function:

void Module::sendSyncClMsgUp ( ClMessage m  )  [protected]

Send a synchronous ClMessage to the module(s) of the above layer (it sends the same the synchronous ClMessage to each one)

Parameters:
m pointer of the ClMessage which has to be sent
See also:
SAP

Definition at line 446 of file module.cc.

References BROADCAST, CLBROADCASTADDR, ClMessage::getDest(), ClMessage::getDestType(), PlugIn::getId(), getUpLaySAP(), SAP::sendSynchronousUp(), ClMessage::setSource(), and upLaySAPnum_.

Referenced by MLLModule::fillNetAddrTable(), MrclRouting::getConfiguration(), MPhy::Phy2MacCCA(), MPhy::Phy2MacEndTx(), MPhy::Phy2MacStartRx(), and sendSynchronousUp().

Here is the call graph for this function:

void Module::drop ( Packet *  p,
int  depth,
const char *  reason = "---" 
) [protected]

Drop a packet, i.e., send it to the instance of the Bin in order to manage its tracing and deallocation

Parameters:
p pointer of the packet which has to be dropped
depth define the depth of the tracing
reason stores the string in which is indicated the motivation of the drop
See also:
Bin, Tracer, PacketTracer

Definition at line 509 of file module.cc.

References PlugIn::binPtr_, Bin::drop(), MAX_TAG_LENGTH, and PlugIn::tag_.

Referenced by MLLModule::arpResolve(), RoutingQueue::enque(), AodvModule::forward(), MrclRoutingStatic::getNextHop(), MMacAloha::Phy2MacEndRx(), RoutingQueue::purge(), RlcModule::recv(), UmtsMacModule::recv(), PortMap::recv(), LogInterface::recv(), MacInterface::recv(), LinkChannelModule::recv(), DropInterface::recv(), IPModule::recv(), IPRoutingModule::recv(), IPInterfaceModule::recv(), CbrModule::recv(), AodvModule::recvError(), AodvModule::recvHello(), AodvModule::recvReply(), AodvModule::recvRequest(), MrclRoutingStatic::resolve(), AodvModule::resolve(), AodvModule::rt_ll_failed(), AodvModule::rt_purge(), and AodvModule::sendRequest().

Here is the call graph for this function:

Packet * Module::copy ( Packet *  p  )  [protected, virtual]

Return a copy of the given packet

Parameters:
p pointer of the packet which has to be copied
Returns:
A copy of the original packet

Definition at line 538 of file module.cc.

Referenced by sendDown(), and sendUp().

void Module::sendUp ( ClMessage m,
double  delay = 0 
) [protected]

Deprecated:
use sendAsyncClMsgUp(ClMessage* m, double delay=0)
Parameters:
m 
delay 

Definition at line 308 of file module.cc.

References PRINT_WARNING_DEPRECATED_FUNCTION, and sendAsyncClMsgUp().

Here is the call graph for this function:

void Module::sendUp ( int  moduleId,
ClMessage m,
double  delay = 0 
) [protected]

Deprecated:
use sendAsyncClMsUp(ClMessage* m, double delay=0) and specify the destination module Id using ClMessage->dest_
Parameters:
moduleId 
m 
delay 

Definition at line 329 of file module.cc.

References PRINT_WARNING_DEPRECATED_FUNCTION, sendAsyncClMsgUp(), and ClMessage::setDest().

Here is the call graph for this function:

void Module::sendDown ( ClMessage m,
double  delay = 0 
) [protected]

Deprecated:
use sendAsyncClMsgDown(ClMessage* m, double delay=0)
Parameters:
m 
delay 

Definition at line 314 of file module.cc.

References PRINT_WARNING_DEPRECATED_FUNCTION, and sendAsyncClMsgDown().

Here is the call graph for this function:

void Module::sendDown ( int  moduleId,
ClMessage p,
double  delay = 0 
) [protected]

Deprecated:
use sendAsyncClMsgDown(ClMessage* p, double delay=0) and specify the destination module Id using ClMessage->dest_
Parameters:
moduleId 
p 
delay 

Definition at line 321 of file module.cc.

References PRINT_WARNING_DEPRECATED_FUNCTION, sendAsyncClMsgDown(), and ClMessage::setDest().

Here is the call graph for this function:

void Module::sendSynchronousDown ( ClMessage m  )  [protected]

Deprecated:
use sendSyncClMsgDown(ClMessage* m)
Parameters:
m 

Definition at line 344 of file module.cc.

References PRINT_WARNING_DEPRECATED_FUNCTION, and sendSyncClMsgDown().

Here is the call graph for this function:

void Module::sendSynchronousUp ( ClMessage m  )  [protected]

Deprecated:
use sendSyncClMsgUp(ClMessage* m);
Parameters:
m 

Definition at line 337 of file module.cc.

References PRINT_WARNING_DEPRECATED_FUNCTION, and sendSyncClMsgUp().

Here is the call graph for this function:

void Module::sendSynchronousUp ( int  moduleId,
ClMessage m 
) [protected]

Deprecated:
use sendSyncClMsgUp(int moduleId, ClMessage* m); and specify the destination module Id using ClMessage->dest_
Parameters:
moduleId 
m 

Definition at line 358 of file module.cc.

References PRINT_WARNING_DEPRECATED_FUNCTION, sendSyncClMsgUp(), and ClMessage::setDest().

Here is the call graph for this function:

void Module::sendSynchronousDown ( int  moduleId,
ClMessage m 
) [protected]

Deprecated:
use sendSyncClMsgDown(int moduleId, ClMessage* m); and specify the destination module Id using ClMessage->dest_
Parameters:
moduleId 
m 

Definition at line 351 of file module.cc.

References PRINT_WARNING_DEPRECATED_FUNCTION, sendSyncClMsgDown(), and ClMessage::setDest().

Here is the call graph for this function:


Member Data Documentation

SAP** Module::upLayerSAP_ [private]

Array of the pointers to the instance of the SAP installed in the above layer side

Definition at line 326 of file module.h.

Referenced by addUpSAP(), getUpLaySAP(), sendUp(), and swapUpLaySAP().

int Module::upLaySAPnum_ [private]

Number of SAP installed in the above layer side

Definition at line 328 of file module.h.

Referenced by addUpSAP(), getUpLaySAP(), getUpLaySAPnum(), sendAsyncClMsgUp(), sendSyncClMsgUp(), sendUp(), and swapUpLaySAP().

SAP** Module::downLayerSAP_ [private]

Array of the pointers to the instance of the SAP installed in the bottom layer side

Definition at line 330 of file module.h.

Referenced by addDownSAP(), getDownLaySAP(), sendDown(), and swapDownLaySAP().

int Module::downLaySAPnum_ [private]

Number of SAP installed in the bottom layer side

Definition at line 332 of file module.h.

Referenced by addDownSAP(), getDownLaySAP(), getDownLaySAPnum(), sendAsyncClMsgDown(), sendDown(), sendSyncClMsgDown(), and swapDownLaySAP().


The documentation for this class was generated from the following files:
Generated on Wed Nov 26 15:50:31 2008 for NS-MIRACLE library by  doxygen 1.5.2