Public Member Functions | Protected Member Functions | Private Attributes

BurstApplLayerBattery Class Reference
[applLayer - application layer modules]

Application layer to test lower layer implementations. More...

#include <BurstApplLayerBattery.h>

Inherits BurstApplLayer.

Collaboration diagram for BurstApplLayerBattery:
Collaboration graph
[legend]

List of all members.

Public Member Functions

virtual void initialize (int)
 Initialite module parameters.
virtual void finish ()
 Called when the simulation has finished.

Protected Member Functions

virtual void handleHostState (const HostState &state)
 Called whenever the hosts state changes.
virtual void handleLowerMsg (cMessage *)
 Handle messages from lower layer.
virtual void handleSelfMsg (cMessage *)
 Handle self messages such as timer...

Private Attributes

int bcastOut
 The number of broadcasts queued so far.
int replyOut
 The number of replies sent so far.
int replyIn
 The number of replies received so far.

Detailed Description

Application layer to test lower layer implementations.

This application layer does exactly the same as the TestApplLayer. The only difference is that is sends a burst of broadcast messages instead of just one. The burst size is specified in burstSize and can be set in omnetpp.ini

See also:
TestApplALyer
Author:
Daniel Willkomm

Definition at line 41 of file BurstApplLayerBattery.h.


Member Function Documentation

void BurstApplLayerBattery::handleHostState ( const HostState state  )  [protected, virtual]

Called whenever the hosts state changes.

Default implementation of this method throws an error whenever the host state changes and the "notAffectedbyHostState" variable is not explicitly set. This is because every module of a host has to make sure to react well to changes in the host state. Or it has to explicitly set its parameter "notAffectedbyHostState" to true.

Reimplemented from BaseModule.

Definition at line 78 of file BurstApplLayerBattery.cc.

References TestApplLayer::delayTimer, HostState::FAILED, and HostState::get().

{
  HostState::States hostState = state.get();

  switch (hostState) {
  case HostState::FAILED:
    debugEV << "t = " << simTime() << " host state FAILED" << endl;
    recordScalar("HostState::FAILED", simTime());

    // BurstApplLayer sends all its frames to the MAC layer at
    // once, so this happens only if the battery fails before the
    // burst.  Frames that are already sendDown() are stopped at
    // the SnrEval.

    // battery is depleted, stop events
    if (delayTimer->isScheduled()) {
      debugEV << "canceling frame burst" << endl;
      cancelEvent(delayTimer);
    }
    break;
  default:
    // ON/OFF aren't used
    break;
  }
}

void BurstApplLayerBattery::handleLowerMsg ( cMessage *  msg  )  [protected, virtual]

Handle messages from lower layer.

There are two kinds of messages that can arrive at this module: The first (kind = BROADCAST_MESSAGE) is a broadcast packet from a neighbor node to which we have to send a reply. The second (kind = BROADCAST_REPLY_MESSAGE) is a reply to a broadcast packet that we have send and just causes some output before it is deleted

Reimplemented from TestApplLayer.

Definition at line 53 of file BurstApplLayerBattery.cc.

References replyIn, replyOut, and TestApplLayer::sendReply().

{
  ApplPkt *m;

  switch( msg->getKind() ) {
  case BROADCAST_MESSAGE:
    m = static_cast<ApplPkt *>(msg);
    debugEV << "Received a broadcast packet from host["<<m->getSrcAddr()<<"] -> sending reply\n";
    replyOut += 1;
    debugEV << simTime() << ": replyOut = " << replyOut << endl;
    sendReply(m);
    break;
  case BROADCAST_REPLY_MESSAGE:
    m = static_cast<ApplPkt *>(msg);
    debugEV << "Received reply from host["<<m->getSrcAddr()<<"]; delete msg\n";
    replyIn += 1;
    debugEV << simTime() << ": replyIn = " << replyIn << endl;
    delete msg;
    break;
  default:
    EV <<"Error! got packet with unknown kind: " << msg->getKind()<<endl;
    break;
  }
}


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