Main Page | Modules | Class Hierarchy | Alphabetical List | Class List | Directories | File List | Class Members | Related Pages

CSMAMacLayer Class Reference
[macLayer - MAC layer modules]

MAC module which provides non-persistent CSMA. More...

#include <CSMAMacLayer.h>

Inherits BasicMacLayer.

Inheritance diagram for CSMAMacLayer:

Inheritance graph
[legend]
Collaboration diagram for CSMAMacLayer:

Collaboration graph
[legend]
List of all members.

Public Member Functions

 Module_Class_Members (CSMAMacLayer, BasicMacLayer, 0)
virtual void initialize (int)
 Initialization of the module and some variables.
virtual void finish ()
 Delete all dynamically allocated objects of the module.
virtual void handleLowerMsg (cMessage *)
 Handle messages from lower layer.
virtual void handleUpperMsg (cMessage *)
 Handle messages from upper layer.
virtual void handleSelfMsg (cMessage *)
 Handle self messages such as timers.
virtual void handleLowerControl (cMessage *msg)
 Handle control messages from lower layer.
virtual void receiveBBItem (int category, const BBItem *details, int scopeModuleId)
 Called by the Blackboard whenever a change occurs we're interested in.

Protected Types

typedef std::list< MacPkt * > MacQueue
enum  States { RX, CCA, TX }
 MAC states. More...

Protected Member Functions

virtual void scheduleBackoff ()
 schedule a backoff

Protected Attributes

States macState
 kepp track of MAC state
RadioState::States radioState
 Current state of active channel (radio), set using radio, updated via BB.
int catRadioState
 category number given by bb for RadioState
double rssi
 Last RSSI level.
int catRSSI
 category number given by bb for RSSI
double busyRSSI
 RSSI level where medium is considered busy.
double slotDuration
 Duration of a slot.
double difs
 Maximum time between a packet and its ACK.
SingleChannelRadioradio
 cached pointer to radio module
MacQueue macQueue
 A queue to store packets from upper layer in case another packet is still waiting for transmission..
unsigned queueLength
 length of the queue
cMessage * backoffTimer
 Timer for backoff (non-persistent CSMA).
cMessage * minorMsg
 Multi-purpose message.
unsigned txAttempts
 count the number of tx attempts
unsigned maxTxAttempts
 maximum number of transmission attempts
double bitrate
 the bit rate at which we transmit
unsigned initialCW
 initial contention window size
DroppedPacket droppedPacket
 Inspect reasons for dropped packets.
int catDroppedPacket
 plus category from BB
int nicId
 publish dropped packets nic wide

Detailed Description

MAC module which provides non-persistent CSMA.

This is an implementation of a simple non-persistent CSMA. The idea of nonpersistent CSMA is "listen before talk". Before attempting to transmit, a station will sense the medium for a carrier signal, which, if present, indicates that some other station is sending.

If the channel is busy a random waiting time is computed and after this time the channel is sensed again. Once the channel gets idle the message is sent. (State of the channel is obtained from SnrEval via Blackboard.)

An option of this module is to use a queue. If a packet from the upper layer arrives although there is still another packet waiting for its transmission or being transmitted the new packet can be stored in this queue. The length of this queue can be specified by the user in the omnetpp.ini file. By default the length is 0. If the queue is full or there is no queue (length = 0) new packet(s) will be deleted.

Todo:
Inform upper layers about the full queue!
ATTENTION: Imagine the following scenario:

Several stations receive a broadcast request packet, usally exactly at the same time. They will all try to answer at exactly the same time, i.e. they all will sense the channel at exactly the same time and start to transmit because the channel was sensed idle by all of them. Therefore a small random delay should be built into one/some of the upper layers to simulate a random processing time!

The TestApplLayer e.g. implements such a processing delay!

Author:
Marc Löbbers, Yosia Hadisusanto, Andreas Koepke


Member Enumeration Documentation

enum CSMAMacLayer::States [protected]
 

MAC states.

The MAC states help to keep track what the MAC is actually trying to do -- this is esp. useful when radio switching takes some time. RX -- MAC accepts packets from PHY layer TX -- MAC transmits a packet CCA -- Clear Channel Assessment - MAC checks whether medium is busy


Member Function Documentation

void CSMAMacLayer::handleLowerMsg cMessage *  msg  )  [virtual]
 

Handle messages from lower layer.

Compare the address of this Host with the destination address in frame. If they are equal or the frame is broadcast, we send this frame to the upper layer. If not delete it.

Reimplemented from BasicMacLayer.

void CSMAMacLayer::handleSelfMsg cMessage *  msg  )  [virtual]
 

Handle self messages such as timers.

After the timer expires try to retransmit the message by calling handleUpperMsg again.

Implements BasicLayer.

void CSMAMacLayer::handleUpperMsg cMessage *  msg  )  [virtual]
 

Handle messages from upper layer.

First it has to be checked whether a frame is currently being transmitted or waiting to be transmitted. If so the newly arrived message is stored in a queue. If there is no queue or it is full print a warning.

Before transmitting a frame it is tested whether the channel is busy at the moment or not. If the channel is busy, a short random time will be generated and the MacPkt is buffered for this time, before a next attempt to send the packet is started.

If channel is idle the frame will be transmitted immediately.

Implements BasicMacLayer.

void CSMAMacLayer::receiveBBItem int  category,
const BBItem details,
int  scopeModuleId
[virtual]
 

Called by the Blackboard whenever a change occurs we're interested in.

Update the internal copies of interesting BB variables

Reimplemented from BasicModule.

void CSMAMacLayer::scheduleBackoff  )  [protected, virtual]
 

schedule a backoff

A non-persistent CSMA ideally uses a fixed backoff window, but it could also increase this window in a linear fashion, or even exponential -- here, a linear increase is used. Overwrite this function to define another schedule function. It also checks the retransmission counters -- if you overwrite it, do it with care.


Member Data Documentation

double CSMAMacLayer::difs [protected]
 

Maximum time between a packet and its ACK.

Usually this is slightly more then the tx-rx turnaround time The channel should stay clear within this period of time.

unsigned CSMAMacLayer::maxTxAttempts [protected]
 

maximum number of transmission attempts

The packet is discared when this number is reached.

cMessage* CSMAMacLayer::minorMsg [protected]
 

Multi-purpose message.

Keeps track of things like minimum time of clear channel (important for atomic acks) and race condition avoidance.

double CSMAMacLayer::slotDuration [protected]
 

Duration of a slot.

This duration can be a mini-slot (that is an RX-TX-turnaround time) but in general it should be the time it takes to send a packet plus some guard times (RX-TX-turnaround + a minimum inter-packet space).

unsigned CSMAMacLayer::txAttempts [protected]
 

count the number of tx attempts

This holds the number of transmission attempts, since no Acks are used this is the way how we can empty our queue even with overloaded channels.


The documentation for this class was generated from the following files:
Generated on Fri Jan 12 08:29:55 2007 for Mobility Framework by  doxygen 1.4.4