Main Page | Namespace List | Class Hierarchy | Class List | Directories | File List | Namespace Members | Class Members | File Members | Related Pages

ChannelAccess Class Reference

#include <ChannelAccess.h>

Inheritance diagram for ChannelAccess:

BasicModule INotifiable BasicSnrEval SnrEval GilbertElliotSnr SnrEval80211 List of all members.

Detailed Description

Basic class for all physical layers, please don't touch!!

This class is not supposed to work on its own, but it contains functions and lists that cooperate with ChannelControl to handle the dynamically created gates. This means EVERY SnrEval (the lowest layer in a host) has to be derived from this class!!!! And please follow the instructions on how to declare a physical layer in a .ned file in "The Design of a Mobility Framework in OMNeT++" paper.

Please don't touch this class.

Author:
Marc Löbbers


Protected Member Functions

void sendToChannel (cMessage *msg, double delay)
 Sends a message to all hosts in range, after delay seconds.
const CoordmyPosition ()
 Returns the host's position.
virtual void initialize (int stage)
 Register with ChannelControl and subscribe to hostPos.
virtual int numInitStages () const
 Divide initialization into two stages.

Protected Attributes

ChannelControlcc
 Pointer to the ChannelControl module.
ChannelControl::HostRef myHostRef
 Identifies this host in the ChannelControl module.


Member Function Documentation

void ChannelAccess::initialize int  stage  )  [protected, virtual]
 

Register with ChannelControl and subscribe to hostPos.

Upon initialization ChannelAccess registers the nic parent module to have all its connections handled by ChannelControl

Reimplemented from BasicModule.

Reimplemented in GilbertElliotSnr, SnrEval, SnrEval80211, and BasicSnrEval.

00031 {
00032     BasicModule::initialize(stage);
00033 
00034     if (stage == 0)
00035     {
00036         cc = dynamic_cast<ChannelControl *>(simulation.moduleByPath("channelcontrol"));
00037         if (cc == 0)
00038             error("Could not find channelcontrol module");
00039 
00040         // register to get a notification when position changes
00041         nb->subscribe(this, NF_HOSTPOSITION_UPDATED);
00042     }
00043     else if (stage == 2)
00044     {
00045         cModule *hostModule = findHost();
00046         myHostRef = cc->lookupHost(hostModule);
00047         if (myHostRef==0)
00048             error("host not registered yet in ChannelControl (this should be done by "
00049                   "the Mobility module -- maybe this host doesn't have one?)");
00050     }
00051 }

const Coord& ChannelAccess::myPosition  )  [inline, protected]
 

Returns the host's position.

00060 {return cc->getHostPosition(myHostRef);}

virtual int ChannelAccess::numInitStages  )  const [inline, protected, virtual]
 

Divide initialization into two stages.

In the first stage (stage==0), modules subscribe to notification categories at NotificationBoard. The first notifications (e.g. about the initial values of some variables such as RadioState) should take place earliest in the second stage (stage==1), when everyone interested in them has already subscribed.

Reimplemented from BasicModule.

00066 {return 3;}

void ChannelAccess::sendToChannel cMessage *  msg,
double  delay
[protected]
 

Sends a message to all hosts in range, after delay seconds.

This function has to be called whenever a packet is supposed to be sent to the channel.

This function really sends the message away, so if you still want to work with it you should send a duplicate!

00062 {
00063     const ChannelControl::ModuleList& neighbors = cc->getNeighbors(myHostRef);
00064     coreEV << "sendToChannel: sending to gates\n";
00065 
00066     // loop through all hosts in range
00067     ChannelControl::ModuleList::const_iterator it;
00068     for (it = neighbors.begin(); it != neighbors.end(); ++it)
00069     {
00070         cModule *mod = *it;
00071 
00072         // we need to send to each radioIn[] gate
00073         cGate *radioGate = mod->gate("radioIn");
00074         if (!radioGate)
00075             continue;
00076         int radioStart = radioGate->id();
00077         int radioEnd = radioStart + radioGate->size();
00078         // TODO account for propagation delay, based on distance?
00079         // Over 300m, dt=1us=10 bit times @ 10Mbps
00080         for (int g = radioStart; g != radioEnd; ++g)
00081             sendDirect((cMessage *)msg->dup(), delay, mod, g);
00082     }
00083     delete msg;
00084 }


Member Data Documentation

ChannelControl* ChannelAccess::cc [protected]
 

Pointer to the ChannelControl module.

ChannelControl::HostRef ChannelAccess::myHostRef [protected]
 

Identifies this host in the ChannelControl module.


The documentation for this class was generated from the following files:
Generated on Sat Apr 1 20:52:21 2006 for INET Framework for OMNeT++/OMNEST by  doxygen 1.4.1