ChannelAccess Class Reference

#include <ChannelAccess.h>

Inheritance diagram for ChannelAccess:

BasicModule INotifiable AbstractRadio BasicSnrEval GenericRadio Ieee80211Radio 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

virtual void sendToChannel (AirFrame *msg)
 Sends a message to all hosts in range.
const CoordgetMyPosition ()
 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::sendToChannel ( AirFrame *  msg  )  [protected, virtual]

Sends a message to all hosts in range.

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!

Referenced by BasicSnrEval::sendDown(), and AbstractRadio::sendDown().

00060 {
00061     const ChannelControl::ModuleList& neighbors = cc->getNeighbors(myHostRef);
00062     coreEV << "sendToChannel: sending to gates\n";
00063 
00064     // loop through all hosts in range
00065     ChannelControl::ModuleList::const_iterator it;
00066     for (it = neighbors.begin(); it != neighbors.end(); ++it)
00067     {
00068         cModule *mod = *it;
00069 
00070         // we need to send to each radioIn[] gate
00071         cGate *radioGate = mod->gate("radioIn");
00072 
00073         if (radioGate == NULL)
00074             error("module %s must have a gate called radioIn", mod->getFullPath().c_str());
00075 
00076         for (int i = 0; i < radioGate->size(); i++)
00077         {
00078             ChannelControl::HostRef h = cc->lookupHost(mod);
00079 
00080             if (h == NULL)
00081                 error("cannot find module in channel control");
00082 
00083             if (h->channel == msg->getChannelNumber())
00084             {
00085                 coreEV << "sending message to host listening on the same channel\n";
00086                 // account for propagation delay, based on distance in meters
00087                 // Over 300m, dt=1us=10 bit times @ 10Mbps
00088                 sendDirect((cMessage *)msg->dup(), myHostRef->pos.distance(h->pos) / LIGHT_SPEED, msg->getDuration(), mod, radioGate->getId() + i);
00089             }
00090             else
00091                 coreEV << "skipping host listening on a different channel\n";
00092         }
00093     }
00094 
00095     // register transmission in ChannelControl
00096     cc->addOngoingTransmission(myHostRef, msg);
00097 }

const Coord& ChannelAccess::getMyPosition (  )  [inline, protected]

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, BasicSnrEval, and AbstractRadio.

Referenced by BasicSnrEval::initialize(), and AbstractRadio::initialize().

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

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.

00067 {return 3;}


Member Data Documentation


The documentation for this class was generated from the following files:

Generated on Fri Mar 20 18:51:18 2009 for INET Framework for OMNeT++/OMNEST by  doxygen 1.5.5