Classes | Public Types | Public Member Functions | Protected Types | Protected Member Functions | Protected Attributes

ChannelInfo Class Reference
[phyLayer - physical layer modules]

This class is used by the BasePhyLayer to keep track of the AirFrames on the channel. More...

#include <ChannelInfo.h>

List of all members.

Classes

class  BaseIntersectionIterator
 Iterator for every intersection of a specific interval in a AirFrameMatrix. More...
class  IntersectionIterator
 Type for a iterator over an AirFrame interval matrix. More...

Public Types

typedef std::list< AirFrame * > AirFrameVector
 Type for a container of AirFrames.

Public Member Functions

void addAirFrame (AirFrame *a, simtime_t startTime)
 Tells the ChannelInfo that an AirFrame has started.
simtime_t removeAirFrame (AirFrame *a)
 Tells the ChannelInfo that an AirFrame is over.
void getAirFrames (simtime_t from, simtime_t to, AirFrameVector &out) const
 Fills the passed AirFrameVector reference with the AirFrames which intersect with the given time interval.
simtime_t getEarliestInfoPoint ()
 Returns the current time-point from that information concerning AirFrames is needed to be stored.
void startRecording (simtime_t start)
 Tells ChannelInfo to keep from now on all channel information until the passed time in history.
void stopRecording ()
 Tells ChannelInfo to stop recording Information from now on.
bool isRecording () const
 Returns true if ChannelInfo is currently recording.
bool isChannelEmpty () const
 Returns true if there are currently no active or inactive AirFrames on the channel.

Protected Types

typedef std::pair< simtime_t,
AirFrame * > 
AirFrameTimePair
 Type for a pair of an AirFrame and a simulation time.
typedef std::list
< AirFrameTimePair
AirFrameTimeList
 Type for a list of AirFrames and a simulation time.
typedef std::map< simtime_t,
AirFrameTimeList
AirFrameMatrix
typedef
BaseIntersectionIterator
< const AirFrameMatrix,
AirFrameMatrix::const_iterator,
AirFrameTimeList::const_iterator > 
ConstIntersectionIterator
 Type for a const-iterator over an AirFrame interval matrix.
typedef std::map< AirFrame
*, simtime_t > 
AirFrameStartMap
 Type for a map of AirFrame pointers to their start time.

Protected Member Functions

void assertNoIntersections ()
 Asserts that every inactive AirFrame is still intersecting with at least one active airframe or with the current record start time.
void getIntersections (const AirFrameMatrix &airFrames, simtime_t from, simtime_t to, AirFrameVector &outVector) const
 Returns every AirFrame of an AirFrameMatrix which intersect with a given interval.
bool isIntersecting (const AirFrameMatrix &airFrames, simtime_t from, simtime_t to) const
 Returns true if there is at least one AirFrame in the passed AirFrameMatrix which intersect with the given interval.
void addToInactives (AirFrame *a, simtime_t startTime, simtime_t endTime)
 Moves a previously active AirFrame to the inactive AirFrames.
void deleteAirFrame (AirFrameMatrix &airFrames, AirFrame *a, simtime_t startTime, simtime_t endTime)
 Deletes an AirFrame from an AirFrameMatrix.
simtime_t findEarliestInfoPoint ()
 Returns the start time of the odlest AirFrame on the channel.
void checkAndCleanInterval (simtime_t startTime, simtime_t endTime)
 Checks if any information inside the passed interval can be discarded.
bool canDiscardInterval (simtime_t startTime, simtime_t endTime)
 Returns true if all information inside the passed interval can be deleted.
void checkAndCleanFrom (simtime_t start)
 Checks if any information up from the passed start time can be discarded.

Protected Attributes

AirFrameMatrix activeAirFrames
 Stores the currently active AirFrames.
AirFrameMatrix inactiveAirFrames
 Stores inactive AirFrames.
AirFrameStartMap airFrameStarts
 Stores the start time of every AirFrame.
simtime_t earliestInfoPoint
 Stores the point in history up to which we have some (but not necessarily all) channel information stored.
simtime_t recordStartTime
 Stores a point in history up to which we need to keep all channel information stored.

Detailed Description

This class is used by the BasePhyLayer to keep track of the AirFrames on the channel.

ChannelInfo is able to return every AirFrame which intersects with a specified interval. This is mainly used to get the noise for a received signal.

ChannelInfo is a passive class meaning the user has to tell it when a new AirFrame starts and an existing ends.

Once an AirFrame has been added to the ChannelInfo the ChannelInfo holds the ownership of this AirFrame even if the AirFrame is removed again from the ChannelInfo. This is necessary because the ChannelInfo has to be able to store also the AirFrames which are over but still intersect with an currently running AirFrame.

Note: ChannelInfo assumes that the AirFrames are added and removed chronologically. This means every time you add an AirFrame with a specific start time ChannelInfo assumes that start time as the current time and assumes that every following action happens after that moment. The same goes for "removeAirFrame". When removing an AirFrames, ChannelInfo assumes the start time plus the duration of the AirFrame as the current time. This also affects "getAirFrames" in the way that you may only ask for intervals which lie before the "current time" of ChannelInfo.

A state-machine-diagram for Radio, RadioStateAnalogueModel and ChannelInfo showing how they work together under control of BasePhyLayer as well as some documentation on how RadioStateAnalogueModel works is available in phyLayer - physical layer modules.

Definition at line 42 of file ChannelInfo.h.


Member Typedef Documentation

typedef std::map<simtime_t, AirFrameTimeList > ChannelInfo::AirFrameMatrix [protected]

The AirFrames are stored in a Matrix with start- and end time as dimensions.

Definition at line 54 of file ChannelInfo.h.

typedef std::list<AirFrame*> ChannelInfo::AirFrameVector

Type for a container of AirFrames.

Used as out type for "getAirFrames" method.

Definition at line 267 of file ChannelInfo.h.


Member Function Documentation

void ChannelInfo::addAirFrame ( AirFrame *  a,
simtime_t  startTime 
)

Tells the ChannelInfo that an AirFrame has started.

From this point ChannelInfo gets the ownership of the AirFrame.

parameter startTime holds the time the receiving of the AirFrame has started in seconds.

Definition at line 6 of file ChannelInfo.cc.

References activeAirFrames, airFrameStarts, earliestInfoPoint, and isChannelEmpty().

Referenced by BasePhyLayer::handleAirFrameStartReceive().

{
  assert(airFrameStarts.count(frame) == 0);

  //check if we were previously empty
  if(isChannelEmpty()) {
    //earliest time point is current sim time
    earliestInfoPoint = startTime;
  }

  //calculate endTime of AirFrame
  simtime_t endTime = startTime + frame->getDuration();

  //add AirFrame to active AirFrames
  activeAirFrames[endTime].push_back(AirFrameTimePair(startTime, frame));

  //add to start time map
  airFrameStarts[frame] = startTime;

  assert(!isChannelEmpty());
}

void ChannelInfo::addToInactives ( AirFrame *  a,
simtime_t  startTime,
simtime_t  endTime 
) [protected]

Moves a previously active AirFrame to the inactive AirFrames.

This methods checks if there are some inactive AirFrames which can be deleted because the AirFrame to in-activate was the last one they intersected with. It also checks if the AirFrame to in-activate still intersect with at least one active AirFrame before it is moved to inactive AirFrames.

Definition at line 177 of file ChannelInfo.cc.

References airFrameStarts, canDiscardInterval(), checkAndCleanInterval(), and inactiveAirFrames.

Referenced by removeAirFrame().

{
  // At first, check if some inactive AirFrames can be removed because the
  // AirFrame to in-activate was the last one they intersected with.
  checkAndCleanInterval(startTime, endTime);

  if(!canDiscardInterval(startTime, endTime))
  {
    inactiveAirFrames[endTime].push_back(AirFrameTimePair(startTime, frame));
  }
  else
  {
    airFrameStarts.erase(frame);

    delete frame;
  }
}

bool ChannelInfo::canDiscardInterval ( simtime_t  startTime,
simtime_t  endTime 
) [protected]

Returns true if all information inside the passed interval can be deleted.

For example this method is used to check if information for the duration of an AirFrame is needed anymore and if not the AirFrame is deleted.

Parameters:
startTime The start time of the interval (e.g. AirFrame start)
endTime The end time of the interval (e.g. AirFrame end)
Returns:
returns true if any information for the passed interval can be discarded.

Definition at line 136 of file ChannelInfo.cc.

References activeAirFrames, isIntersecting(), and recordStartTime.

Referenced by addToInactives(), and checkAndCleanInterval().

{
  assert(recordStartTime >= 0 || recordStartTime == -1);

  // only if it ends before the point in time we started recording or if
  // we aren't recording at all and it does not intersect with any active one
  // anymore this AirFrame can be deleted
  return (recordStartTime > endTime || recordStartTime == -1)
       && !isIntersecting(activeAirFrames, startTime, endTime);
}

void ChannelInfo::checkAndCleanFrom ( simtime_t  start  )  [inline, protected]

Checks if any information up from the passed start time can be discarded.

Parameters:
startTime The start of the interval to check

Definition at line 350 of file ChannelInfo.h.

References checkAndCleanInterval(), and inactiveAirFrames.

Referenced by stopRecording().

                                          {
    //nothing to do
    if(inactiveAirFrames.empty())
      return;

    //take last ended inactive airframe as end of interval
    checkAndCleanInterval(start, inactiveAirFrames.rbegin()->first);
  }

void ChannelInfo::checkAndCleanInterval ( simtime_t  startTime,
simtime_t  endTime 
) [protected]

Checks if any information inside the passed interval can be discarded.

This method should be called every time the information for a certain interval changes (AirFrame is removed or record time changed).

Parameters:
startTime The start of the interval to check
endTime The end of the interval to check

Definition at line 148 of file ChannelInfo.cc.

References airFrameStarts, canDiscardInterval(), ChannelInfo::IntersectionIterator::eraseAirFrame(), inactiveAirFrames, and ChannelInfo::BaseIntersectionIterator< C, ItMatrix, ItList >::next().

Referenced by addToInactives(), checkAndCleanFrom(), and startRecording().

{


  // get through inactive AirFrame which intersected with the passed interval
  IntersectionIterator inactiveIntersectIt(&inactiveAirFrames,
                       startTime,
                       endTime);

  AirFrame* inactiveIntersect = inactiveIntersectIt.next();
  while(inactiveIntersect != 0)
  {
    simtime_t currentStart = airFrameStarts[inactiveIntersect];
    simtime_t currentEnd = currentStart + inactiveIntersect->getDuration();

    if(canDiscardInterval(currentStart, currentEnd))
    {
      inactiveIntersectIt.eraseAirFrame();

      airFrameStarts.erase(inactiveIntersect);

      delete inactiveIntersect;
      inactiveIntersect = 0;
    }
    inactiveIntersect = inactiveIntersectIt.next();
  }
}

void ChannelInfo::getAirFrames ( simtime_t  from,
simtime_t  to,
AirFrameVector out 
) const

Fills the passed AirFrameVector reference with the AirFrames which intersect with the given time interval.

Note: Completeness of the list of AirFrames for specific interval can only be assured if start and end point of the interval lies inside the duration of at least one currently active AirFrame. An AirFrame is called active if it has been added but not yet removed from ChannelInfo.

Definition at line 218 of file ChannelInfo.cc.

References activeAirFrames, getIntersections(), and inactiveAirFrames.

Referenced by BasePhyLayer::getChannelInfo(), and BasePhyLayer::~BasePhyLayer().

{
  //check for intersecting inactive AirFrames
  getIntersections(inactiveAirFrames, from, to, out);

  //check for intersecting active AirFrames
  getIntersections(activeAirFrames, from, to, out);
}

void ChannelInfo::getIntersections ( const AirFrameMatrix airFrames,
simtime_t  from,
simtime_t  to,
AirFrameVector outVector 
) const [protected]

Returns every AirFrame of an AirFrameMatrix which intersect with a given interval.

The intersecting AirFrames are stored in the AirFrameVector reference passed as parameter.

Definition at line 204 of file ChannelInfo.cc.

References ChannelInfo::BaseIntersectionIterator< C, ItMatrix, ItList >::next().

Referenced by getAirFrames().

{
  ConstIntersectionIterator it(&airFrames, from, to);

  AirFrame* intersect = it.next();
  while(intersect != 0)
  {
    outVector.push_back(intersect);
    intersect = it.next();
  }
}

bool ChannelInfo::isRecording (  )  const [inline]

Returns true if ChannelInfo is currently recording.

Returns:
true if ChannelInfo is recording

Definition at line 454 of file ChannelInfo.h.

References recordStartTime.

Referenced by BasePhyLayer::handleChannelSenseRequest(), and BasePhyLayer::sendControlMsg().

  {
    return recordStartTime > -1;
  }

simtime_t ChannelInfo::removeAirFrame ( AirFrame *  a  ) 

Tells the ChannelInfo that an AirFrame is over.

This does not mean that it loses ownership of the AirFrame.

Returns:
The current time-point from on which information concerning AirFrames is needed to be stored.

Definition at line 55 of file ChannelInfo.cc.

References activeAirFrames, addToInactives(), airFrameStarts, deleteAirFrame(), earliestInfoPoint, findEarliestInfoPoint(), and isChannelEmpty().

Referenced by BasePhyLayer::handleAirFrameEndReceive().

{
  assert(airFrameStarts.count(frame) > 0);

  //get start of AirFrame
  simtime_t startTime = airFrameStarts[frame];

  //calculate end time
  simtime_t endTime = startTime + frame->getDuration();

  //remove this AirFrame from active AirFrames
  deleteAirFrame(activeAirFrames, frame, startTime, endTime);

  //add to inactive AirFrames
  addToInactives(frame, startTime, endTime);


  // Now check, whether the earliest time-point we need to store information
  // for might have moved on in time, since an AirFrame has been deleted.
  if(isChannelEmpty()) {
    earliestInfoPoint = -1;
  } else {
    earliestInfoPoint = findEarliestInfoPoint();
  }

  return earliestInfoPoint;
}

void ChannelInfo::startRecording ( simtime_t  start  )  [inline]

Tells ChannelInfo to keep from now on all channel information until the passed time in history.

The passed start-time should be the current simulation time, otherwise ChannelInfo can't assure that it hasn't already thrown away some information for that passed time period.

Subsequent calls to this method will update the recording start time and information from old start times is thrown away.

Parameters:
start The point in time from which to keep all channel information stored.

Definition at line 424 of file ChannelInfo.h.

References checkAndCleanInterval(), and recordStartTime.

Referenced by BasePhyLayer::handleChannelSenseRequest().

  {
    // clean up until old record start
    if(recordStartTime > -1) {
      recordStartTime = start;
      checkAndCleanInterval(0, recordStartTime);
    } else {
      recordStartTime = start;
    }
  }

void ChannelInfo::stopRecording (  )  [inline]

Tells ChannelInfo to stop recording Information from now on.

Its up to ChannelInfo to decide when to actually throw away the information it doesn't need to store anymore now.

Definition at line 441 of file ChannelInfo.h.

References checkAndCleanFrom(), and recordStartTime.

Referenced by BasePhyLayer::sendControlMsg().

  {
    if(recordStartTime > -1) {
      simtime_t old = recordStartTime;
      recordStartTime = -1;
      checkAndCleanFrom(old);
    }
  }


Member Data Documentation

Stores the currently active AirFrames.

This means every AirFrame which was added but not yet removed.

Definition at line 237 of file ChannelInfo.h.

Referenced by addAirFrame(), assertNoIntersections(), canDiscardInterval(), getAirFrames(), isChannelEmpty(), and removeAirFrame().

Stores inactive AirFrames.

This means every AirFrame which has been already removed but still is needed because it intersect with one or more active AirFrames.

Definition at line 245 of file ChannelInfo.h.

Referenced by addToInactives(), assertNoIntersections(), checkAndCleanFrom(), checkAndCleanInterval(), and getAirFrames().


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