Txc7 Class Reference

Inheritance diagram for Txc7:
cSimpleModule cModule cComponent cDefaultList cNoncopyableOwnedObject cOwnedObject noncopyable cNamedObject cObject

List of all members.

Public Member Functions

 Txc7 ()
virtual ~Txc7 ()

Protected Member Functions

virtual void initialize ()
virtual void handleMessage (cMessage *msg)

Private Attributes

cMessageevent
cMessagetictocMsg

Detailed Description

In this step we'll introduce random numbers. We change the delay from 1s to a random value which can be set from the NED file or from omnetpp.ini. In addition, we'll "lose" (delete) the packet with a small probability.


Constructor & Destructor Documentation

Txc7::Txc7 (  ) 

00038 {
00039     event = tictocMsg = NULL;
00040 }

Txc7::~Txc7 (  )  [virtual]

00043 {
00044     cancelAndDelete(event);
00045     delete tictocMsg;
00046 }


Member Function Documentation

void Txc7::handleMessage ( cMessage msg  )  [protected, virtual]

Reimplemented from cSimpleModule.

00062 {
00063     if (msg==event)
00064     {
00065         EV << "Wait period is over, sending back message\n";
00066         send(tictocMsg, "out");
00067         tictocMsg = NULL;
00068     }
00069     else
00070     {
00071         // "Lose" the message with 0.1 probability:
00072         if (uniform(0,1) < 0.1)
00073         {
00074             EV << "\"Losing\" message\n";
00075             delete msg;
00076         }
00077         else
00078         {
00079             // The "delayTime" module parameter can be set to values like
00080             // "exponential(5)" (tictoc7.ned, omnetpp.ini), and then here
00081             // we'll get a different delay every time.
00082             simtime_t delay = par("delayTime");
00083 
00084             EV << "Message arrived, starting to wait " << delay << " secs...\n";
00085             tictocMsg = msg;
00086             scheduleAt(simTime()+delay, event);
00087         }
00088     }
00089 }

void Txc7::initialize (  )  [protected, virtual]

Reimplemented from cComponent.

00049 {
00050     event = new cMessage("event");
00051     tictocMsg = NULL;
00052 
00053     if (strcmp("tic", getName()) == 0)
00054     {
00055         EV << "Scheduling first send to t=5.0s\n";
00056         scheduleAt(5.0, event);
00057         tictocMsg = new cMessage("tictocMsg");
00058     }
00059 }


Member Data Documentation

cMessage* Txc7::event [private]

Referenced by handleMessage(), initialize(), and ~Txc7().

Referenced by handleMessage(), initialize(), Txc7(), and ~Txc7().


The documentation for this class was generated from the following file:
Generated on Tue Dec 2 11:16:33 2014 for Tictoc Tutorial by  doxygen 1.6.3