- Main Page
- Classes
- Files
- Directories
- Related Pages

- Class List
- Class Hierarchy
- Class Members

# Tic7 Class Reference

Inheritance diagram for Tic7:

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
| Tic7 ()
virtual | ~Tic7 ()
## Protected Member Functions
virtual void | initialize ()
virtual void | handleMessage (cMessage *msg)
## Private Attributes
double | timeout
cMessage * | timeoutEvent

## Constructor & Destructor Documentation

Tic7::Tic7 | ( |  | ) |

    00041 {
    00042     timeoutEvent = NULL;
    00043 }

Tic7::~Tic7 | ( |  | ) | `[virtual]`

    00046 {
    00047     cancelAndDelete(timeoutEvent);
    00048 }

## Member Function Documentation

void Tic7::handleMessage | ( | cMessage * | msg | ) | `[protected, virtual]`

| Reimplemented from cSimpleModule.
    00064 {
    00065     if (msg==timeoutEvent)
    00066     {
    00067         // If we receive the timeout event, that means the packet hasn't
    00068         // arrived in time and we have to re-send it.
    00069         ev << "Timeout expired, resending message and restarting timer\n";
    00070         cMessage *msg = new cMessage("tictocMsg");
    00071         send(msg, "out");
    00072         scheduleAt(simTime()+timeout, timeoutEvent);
    00073     }
    00074     else // message arrived
    00075     {
    00076         // Acknowledgement received -- delete the stored message and cancel
    00077         // the timeout event.
    00078         ev << "Timer cancelled.\n";
    00079         cancelEvent(timeoutEvent);
    00080
    00081         // Ready to send another one.
    00082         cMessage *msg = new cMessage("tictocMsg");
    00083         send(msg, "out");
    00084         scheduleAt(simTime()+timeout, timeoutEvent);
    00085     }
    00086 }

void Tic7::initialize | ( |  | ) | `[protected, virtual]`

| Reimplemented from cModule.
    00051 {
    00052     // Initialize variables.
    00053     timeout = 1.0;
    00054     timeoutEvent = new cMessage("timeoutEvent");
    00055
    00056     // Generate and send initial message.
    00057     ev << "Sending initial message\n";
    00058     cMessage *msg = new cMessage("tictocMsg");
    00059     send(msg, "out");
    00060     scheduleAt(simTime()+timeout, timeoutEvent);
    00061 }

## Member Data Documentation

double Tic7::timeout`[private]`

cMessage* Tic7::timeoutEvent`[private]`

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

- txc7.cc