#include <DTApp.h>
Protected Types | |
| typedef std::map< int, std::vector< int > > | SourceSequence |
Protected Member Functions | |
| virtual void | finish () |
| the finish function of the module | |
| virtual void | processPacket (cPacket *msg) |
| processes the received packets | |
Protected Attributes | |
| SourceSequence | sourceSequence |
| To be used for recording the received packets. | |
typedef std::map<int,std::vector<int> > DTApp::SourceSequence [protected] |
| void DTApp::finish | ( | ) | [protected, virtual] |
the finish function of the module
00034 { 00035 00036 00037 simtime_t t = simTime(); 00038 if (t==0) return; 00039 00040 recordScalar("Total send", numSent); 00041 recordScalar("Total received", numReceived); 00042 recordScalar("Total deleted", numDeleted); 00043 // recordScalar("Mean delay", meanDelay/numReceived); 00044 recordScalar("Mean delay", pktDelay->getMean()); 00045 recordScalar("Min delay", pktDelay->getMin()); 00046 recordScalar("Max delay", pktDelay->getMax()); 00047 recordScalar("Deviation delay", pktDelay->getStddev()); 00048 if(numSent!=0) 00049 recordScalar("AvgDelivery", (numReceived*100)/numSent); 00050 else 00051 recordScalar("AvgDelivery", 0); 00052 delete pktDelay; 00053 pktDelay = NULL; 00054 }
| void DTApp::processPacket | ( | cPacket * | msg | ) | [protected, virtual] |
processes the received packets
00061 { 00062 00063 if (msg->getKind()== UDP_I_ERROR) 00064 { 00065 delete msg; 00066 return; 00067 } 00068 00069 if (msg->hasPar("sourceId")) 00070 { 00071 // duplicate control 00072 int moduleId = (int) msg->par("sourceId"); 00073 int msgId = msg->par("msgId"); 00074 SourceSequence::iterator i; 00075 i = sourceSequence.find(moduleId); 00076 //If we have received before from this node 00077 if (i!=sourceSequence.end()) 00078 { 00079 if (std::find(i->second.begin(),i->second.end(), msgId)!=i->second.end()) 00080 { 00081 EV << "Duplicated packet: "; 00082 printPacket(msg); 00083 delete msg; 00084 numDeleted++; 00085 return; 00086 } 00087 else 00088 i->second.push_back(msgId); 00089 } 00090 //Else create new record 00091 else { 00092 std::vector<int> tmp_vector; 00093 tmp_vector.push_back(msgId); 00094 sourceSequence[moduleId] = tmp_vector; 00095 } 00096 00097 } 00098 if (limitDelay>=0) 00099 if (simTime()-msg->getTimestamp()>limitDelay) 00100 { 00101 EV << "Old packet: "; 00102 printPacket(msg); 00103 delete msg; 00104 numDeleted++; 00105 return; 00106 } 00107 00108 EV << "Received packet: "; 00109 printPacket(msg); 00110 pktDelay->collect(simTime()-msg->getTimestamp()); 00111 //meanDelay += (msg->getTimestamp()-simTime()); 00112 delete msg; 00113 00114 numReceived++; 00115 if (numShare) 00116 numShare[1]++; 00117 }
SourceSequence DTApp::sourceSequence [protected] |
To be used for recording the received packets.
1.6.3