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

SimpleNetwLayer Class Reference
[CSMAMac example - Classes from the CSMAMac example]

This is an implementation of a simple network layer which provides only some simple routing (next hop) and message forwarding (only switches). More...

#include <SimpleNetwLayer.h>

Inherits BaseModule.

Collaboration diagram for SimpleNetwLayer:
Collaboration graph
[legend]

List of all members.

Public Member Functions

virtual void initialize (int stage)
 Basic initialization for all modules.
virtual void handleMessage (cMessage *msg)

Protected Types

enum  NetwPktKind { HELLO_WORLD = 4200, JABBER, START_TO_JABBER }
typedef std::map< int, int > RoutingTable

Protected Member Functions

void scheduleJabbering ()
void broadcastHelloWorld ()
void sendDown (cPacket *pkt)
void forwardPacket (NetwPkt *pkt, int nextHop)
void handleHelloWorld (NetwPkt *pkt)
void jabberToSomeone ()
void handleIncomingJabber (NetwPkt *pkt)

Protected Attributes

bool isSwitch
simtime_t boredTime
 time after when the module gets bored and starts jabbering.
int maxTtl
int ip
int dataIn
int dataOut
cMessage * startJabberTimer
unsigned long runningSeqNumber
RoutingTable routingTable

Detailed Description

This is an implementation of a simple network layer which provides only some simple routing (next hop) and message forwarding (only switches).

This network layer isn't a real network layer its only purpose is to provide some message sending for the CSMA-Mac layer.

At first there is a small "saying hello"-phase where the several network layers saying hello to each other and creating their routing table.

After that phase the non-switch instances start to babbling randomly to other instances without caring if they here them. The switch instances does only provide packet forwarding from there on.

The several instances can babble directly to each other or over a switch instance.

Definition at line 41 of file SimpleNetwLayer.h.


Member Function Documentation

virtual void SimpleNetwLayer::initialize ( int  stage  )  [inline, virtual]

Basic initialization for all modules.

Subscription to Blackboard should be in stage==0, and firing notifications in stage==1 or later.

NOTE: You have to call this in the initialize() function of the inherited class!

Reimplemented from BaseModule.

Definition at line 230 of file SimpleNetwLayer.h.

References boredTime.

                                    {

    if(stage == 0){
      dataOut = findGate("lowerGateOut");
      dataIn = findGate("lowerGateIn");

      isSwitch = par("isSwitch").boolValue();

      if(isSwitch)
        getParentModule()->getParentModule()->getDisplayString().setTagArg("i",0,"device/accesspoint");

      ip = par("ip").longValue();
      maxTtl = par("maxTtl").longValue();
      boredTime = par("boredTime").doubleValue();
    } else if(stage == 1) {
      startJabberTimer = new cMessage("jabber!", START_TO_JABBER);
      broadcastHelloWorld();
    }
  }


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