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

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.

00062 {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.

00068 {return 3;}

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!

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 
00075         if (radioGate == NULL)
00076             error("module %s must have a gate called radioIn", mod->fullPath().c_str());
00077 
00078         for (int i = 0; i < radioGate->size(); i++)
00079         {
00080             ChannelControl::HostRef h = cc->lookupHost(mod);
00081 
00082             if (h == NULL)
00083                 error("cannot find module in channel control");
00084 
00085             if (h->channel == msg->getChannelNumber())
00086             {
00087                 coreEV << "sending message to host listening on the same channel\n";
00088                 // account for propagation delay, based on distance in meters
00089                 // Over 300m, dt=1us=10 bit times @ 10Mbps
00090                 sendDirect((cMessage *)msg->dup(), myHostRef->pos.distance(h->pos) / LIGHT_SPEED, mod, radioGate->id() + i);
00091             }
00092             else
00093                 coreEV << "skipping host listening on a different channel\n";
00094         }
00095     }
00096 
00097     // register transmission in ChannelControl
00098     cc->addOngoingTransmission(myHostRef, msg);
00099 }


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 Thu Oct 19 18:22:21 2006 for INET Framework for OMNeT++/OMNEST by  doxygen 1.4.0