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

NetworkStackTrafficGen Class Reference
[IEEE 802.15.4 Narrow band example - Classes from the ieee802154Narrow example]

A module to generate traffic for the NIC, used for testing purposes. More...

#include <NetworkStackTrafficGen.h>

Inherits BaseLayer.

Collaboration diagram for NetworkStackTrafficGen:
Collaboration graph
[legend]

List of all members.

Public Types

enum  TrafficGenMessageKinds { SEND_BROADCAST_TIMER = 1, BROADCAST_MESSAGE }

Public Member Functions

virtual void initialize (int stage)
 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 handleLowerMsg (cMessage *msg)
 Handle messages from lower layer.
virtual void handleLowerControl (cMessage *msg)
 Handle control messages from lower layer.
virtual void handleUpperMsg (cMessage *msg)
 Handle messages from upper layer.
virtual void handleUpperControl (cMessage *msg)
 Handle control messages from upper layer.
virtual void sendBroadcast ()
 Send a broadcast message to lower layer.

Protected Attributes

int packetLength
simtime_t packetTime
double pppt
int burstSize
int remainingBurst
long destination
int catPacket
long nbPacketDropped
BaseArparp
int myNetwAddr
cMessage * delayTimer
BaseWorldUtilityworld

Detailed Description

A module to generate traffic for the NIC, used for testing purposes.

Definition at line 32 of file NetworkStackTrafficGen.h.


Member Function Documentation

void NetworkStackTrafficGen::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 25 of file NetworkStackTrafficGen.cc.

References BaseModule::findHost(), Blackboard::getCategory(), and BaseArp::myNetwAddr().

{
  BaseLayer::initialize(stage);

  if(stage == 0) {
    world = FindModule<BaseWorldUtility*>::findGlobalModule();
    delayTimer = new cMessage("delay-timer", SEND_BROADCAST_TIMER);

    arp = FindModule<BaseArp*>::findSubModule(findHost());
    myNetwAddr = arp->myNetwAddr(this);

    packetLength = par("packetLength");
    packetTime = par("packetTime");
    pppt = par("packetsPerPacketTime");
    burstSize = par("burstSize");
    destination = par("destination");

    nbPacketDropped = 0;

    Packet p(1);
    catPacket = world->getCategory(&p);
  } else if (stage == 1) {
    if(burstSize > 0) {
      remainingBurst = burstSize;
      scheduleAt(dblrand() * packetTime * burstSize / pppt, delayTimer);
    }
  } else {

  }
}


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