Inheritance diagram for Txc12:

We also collect basic statistics (min, max, mean, std.dev.) and histogram about the hop count which we'll print out at the end of the simulation.
Public Member Functions | |
| Module_Class_Members (Txc12, cSimpleModule, 0) | |
| virtual TicTocMsg12 * | generateMessage () |
| virtual void | forwardMessage (TicTocMsg12 *msg) |
| virtual void | initialize () |
| virtual void | handleMessage (cMessage *msg) |
| virtual void | finish () |
Protected Attributes | |
| long | numSent |
| long | numReceived |
| cLongHistogram | hopCountStats |
| cOutVector | hopCountVector |
|
|
Reimplemented from cModule. 00133 {
00134 // This function is called by OMNeT++ at the end of the simulation.
00135 ev << "Sent: " << numSent << endl;
00136 ev << "Received: " << numReceived << endl;
00137 ev << "Hop count, min: " << hopCountStats.min() << endl;
00138 ev << "Hop count, max: " << hopCountStats.max() << endl;
00139 ev << "Hop count, mean: " << hopCountStats.mean() << endl;
00140 ev << "Hop count, stddev: " << hopCountStats.stddev() << endl;
00141
00142 recordScalar("#sent", numSent);
00143 recordScalar("#received", numReceived);
00144 hopCountStats.recordScalar("hop count");
00145 }
|
|
|
00120 {
00121 // Increment hop count.
00122 msg->setHopCount(msg->getHopCount()+1);
00123
00124 // Same routing as before: random gate.
00125 int n = gate("out")->size();
00126 int k = intuniform(0,n-1);
00127
00128 ev << "Forwarding message " << msg << " on port out[" << k << "]\n";
00129 send(msg, "out", k);
00130 }
|
|
|
00102 {
00103 // Produce source and destination addresses.
00104 int src = index();
00105 int n = size();
00106 int dest = intuniform(0,n-2);
00107 if (dest>=src) dest++;
00108
00109 char msgname[20];
00110 sprintf(msgname, "tic-%d-to-%d", src, dest);
00111
00112 // Create message object and set source and destination field.
00113 TicTocMsg12 *msg = new TicTocMsg12(msgname);
00114 msg->setSource(src);
00115 msg->setDestination(dest);
00116 return msg;
00117 }
|
|
|
Reimplemented from cSimpleModule. 00070 {
00071 TicTocMsg12 *ttmsg = check_and_cast<TicTocMsg12 *>(msg);
00072
00073 if (ttmsg->getDestination()==index())
00074 {
00075 // Message arrived
00076 int hopcount = ttmsg->getHopCount();
00077 ev << "Message " << ttmsg << " arrived after " << hopcount << " hops.\n";
00078 bubble("ARRIVED, starting new one!");
00079
00080 // update statistics.
00081 numReceived++;
00082 hopCountVector.record(hopcount);
00083 hopCountStats.collect(hopcount);
00084
00085 delete ttmsg;
00086
00087 // Generate another one.
00088 ev << "Generating another message: ";
00089 TicTocMsg12 *newmsg = generateMessage();
00090 ev << newmsg << endl;
00091 forwardMessage(newmsg);
00092 numSent++;
00093 }
00094 else
00095 {
00096 // We need to forward the message.
00097 forwardMessage(ttmsg);
00098 }
00099 }
|
|
|
Reimplemented from cModule. 00049 {
00050 // Initialize variables
00051 numSent = 0;
00052 numReceived = 0;
00053 WATCH(numSent);
00054 WATCH(numReceived);
00055
00056 hopCountStats.setName("hopCountStats");
00057 hopCountStats.setRangeAutoUpper(0, 10, 1.5);
00058 hopCountVector.setName("HopCount");
00059
00060 // Module 0 sends the first message
00061 if (index()==0)
00062 {
00063 // Boot the process scheduling the initial message as a self-message.
00064 TicTocMsg12 *msg = generateMessage();
00065 scheduleAt(0.0, msg);
00066 }
00067 }
|
|
||||||||||||||||
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1.3.9.1