Public Member Functions | Protected Member Functions | Private Types | Private Member Functions | Private Attributes

Aggregation Class Reference

this class aggregates the packets received from the application layer and separates packet emissions by a time InterPacketDelay. More...

#include <Aggregation.h>

Inherits BaseLayer.

Collaboration diagram for Aggregation:
Collaboration graph
[legend]

List of all members.

Public Member Functions

virtual void initialize (int)
 Initialization of the module and some variables.
virtual void finish ()
 Called when the simulation has finished.

Protected Member Functions

virtual void handleSelfMsg (cMessage *msg)
 Handle self messages such as timer...
virtual void handleUpperMsg (cMessage *msg)
 Handle messages from upper layer.
virtual void handleLowerMsg (cMessage *msg)
 Handle messages from lower layer.
virtual void handleLowerControl (cMessage *msg)
 Handle control messages from lower layer.
virtual void handleUpperControl (cMessage *msg)
 Handle control messages from upper layer.

Private Types

typedef pair< simtime_t, list
< ApplPkt * > > 
destInfo

Private Member Functions

virtual bool isOkToSendNow (int dest)
void sendAggregatedPacketNow (int dest)

Private Attributes

map< int, destInfo > destInfos
cMessage * aggregationTimer
simtime_t interPacketDelay
int nbMaxPacketsPerAggregation
long nbAggrPktSentDown
long nbAggrPktReceived

Detailed Description

this class aggregates the packets received from the application layer and separates packet emissions by a time InterPacketDelay.

Definition at line 39 of file Aggregation.h.


Member Function Documentation

void Aggregation::handleUpperMsg ( cMessage *  msg  )  [protected, virtual]

Handle messages from upper layer.

This function is pure virtual here, because there is no reasonable guess what to do with it by default.

Implements BaseLayer.

Definition at line 43 of file Aggregation.cc.

References BaseLayer::sendDown().

                                              {
  ApplPkt* pkt = check_and_cast<ApplPkt*> (msg);
  if (interPacketDelay == 0) {
    sendDown(msg);
  } else {
    int dest = pkt->getDestAddr();
    if (!isOkToSendNow(dest)) {
      // store packet
      destInfos[dest].second.push_back(pkt);
      // reschedule aggregation timer to "earliest destination"
      simtime_t destTxTime = destInfos[dest].first + interPacketDelay;
      if (aggregationTimer->isScheduled()) {
        if (aggregationTimer->getArrivalTime() > destTxTime) {
          cancelEvent( aggregationTimer);
          scheduleAt(destTxTime, aggregationTimer);
        }
      } else {
        scheduleAt(destTxTime, aggregationTimer);
      }
    } else {
      // send now
      destInfos[dest].second.push_back(pkt);
      sendAggregatedPacketNow(dest);
    }
  }
}

void Aggregation::initialize ( int  stage  )  [virtual]

Initialization of the module and some variables.

First we have to initialize the module from which we derived ours, in this case BaseModule. This module takes care of the gate initialization.

Reimplemented from BaseLayer.

Definition at line 13 of file Aggregation.cc.

                                      {
    BaseLayer::initialize(stage);
  if(stage == 0) {
    interPacketDelay = par("interPacketDelay").doubleValue();
    if(interPacketDelay > 0) {
      nbMaxPacketsPerAggregation = par("nbMaxPacketsPerAggregation");
      assert(nbMaxPacketsPerAggregation > 0);
      aggregationTimer = new cMessage("AggregationTimer");
      nbAggrPktSentDown = 0;
      nbAggrPktReceived = 0;
    } else {
      interPacketDelay = 0;
    }
  }
}


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