Main Page | Class Hierarchy | Class List | Directories | File List | Class Members | File Members | Related Pages

Tic7 Class Reference

Inheritance diagram for Tic7:

cSimpleModule cModule cDefaultList cObject cPolymorphic List of all members.

Detailed Description

Let us take a step back, and remove random delaying from the code. We'll leave in, however, losing the packet with a small probability. And, we'll we do something very common in telecommunication networks: if the packet doesn't arrive within a certain period, we'll assume it was lost and create another one. The timeout will be handled using (what else?) a self-message.


Public Member Functions

 Module_Class_Members (Tic7, cSimpleModule, 0)
virtual void initialize ()
virtual void handleMessage (cMessage *msg)

Protected Attributes

double timeout
cMessage * timeoutEvent


Member Function Documentation

void Tic7::handleMessage (  cMessage *  msg  )  [virtual]
 

Reimplemented from cSimpleModule.

00051 {
00052     if (msg==timeoutEvent)
00053     {
00054         // If we receive the timeout event, that means the packet hasn't
00055         // arrived in time and we have to re-send it.
00056         ev << "Timeout expired, resending message and restarting timer\n";
00057         cMessage *msg = new cMessage("tictocMsg");
00058         send(msg, "out");
00059         scheduleAt(simTime()+timeout, timeoutEvent);
00060     }
00061     else // message arrived
00062     {
00063         // Acknowledgement received -- delete the stored message and cancel
00064         // the timeout event.
00065         ev << "Timer cancelled.\n";
00066         cancelEvent(timeoutEvent);
00067 
00068         // Ready to send another one.
00069         cMessage *msg = new cMessage("tictocMsg");
00070         send(msg, "out");
00071         scheduleAt(simTime()+timeout, timeoutEvent);
00072     }
00073 }

void Tic7::initialize (   )  [virtual]
 

Reimplemented from cModule.

00038 {
00039     // Initialize variables.
00040     timeout = 1.0;
00041     timeoutEvent = new cMessage("timeoutEvent");
00042 
00043     // Generate and send initial message.
00044     ev << "Sending initial message\n";
00045     cMessage *msg = new cMessage("tictocMsg");
00046     send(msg, "out");
00047     scheduleAt(simTime()+timeout, timeoutEvent);
00048 }

Tic7::Module_Class_Members (  Tic7  ,
cSimpleModule  ,
0 
) 
 


Member Data Documentation

double Tic7::timeout [protected]
 

cMessage* Tic7::timeoutEvent [protected]
 


The documentation for this class was generated from the following file:
Generated on Fri Apr 1 12:25:42 2005 for Tictoc Tutorial by  doxygen 1.3.9.1