|
NETWORK ATTACKS FRAMEWORK
1.0.0
A NETwork Attacks framework. Making network attacks impact evaluation easier!
|
UDP application. More...
#include <NA_UDPBasicBurst.h>
Protected Member Functions | |
| virtual void | processPacket (cPacket *msg) |
| Overridden function. | |
| virtual void | initialize (int stage) |
| Method from cSimpleModule class, to initialize the simple module. | |
Protected Attributes | |
| int | numHopsTotal |
| Number of hops for all the packets. | |
| double | avHopCount |
| Average hop count. | |
Static Protected Attributes | |
| static simsignal_t | hopCountSignal = SIMSIGNAL_NULL |
| Hop count signal for statistics. | |
| void NA_UDPBasicBurst::initialize | ( | int | stage | ) | [protected, virtual] |
Method from cSimpleModule class, to initialize the simple module.
Overridden function.
Definition at line 39 of file NA_UDPBasicBurst.cc.
{
// because of IPvXAddressResolver, we need to wait until interfaces are registered,
// address auto-assignment takes place etc.
if (stage != 3)
return;
// Initialization
numHopsTotal = 0;
avHopCount = 0;
hopCountSignal = registerSignal("hopCount");
UDPBasicBurst::initialize(stage);
}
| void NA_UDPBasicBurst::processPacket | ( | cPacket * | msg | ) | [protected, virtual] |
Overridden function.
Definition at line 55 of file NA_UDPBasicBurst.cc.
{
if (pk->getKind() == UDP_I_ERROR)
{
EV << "UDP error received\n";
delete pk;
return;
}
if (pk->hasPar("sourceId") && pk->hasPar("msgId"))
{
// duplicate control
int moduleId = (int)pk->par("sourceId");
int msgId = (int)pk->par("msgId");
SourceSequence::iterator it = sourceSequence.find(moduleId);
if (it != sourceSequence.end())
{
if (it->second >= msgId)
{
EV << "Out of order packet: " << UDPSocket::getReceivedPacketInfo(pk) << endl;
emit(outOfOrderPkSignal, pk);
delete pk;
numDuplicated++;
return;
}
else
it->second = msgId;
}
else
sourceSequence[moduleId] = msgId;
}
if (delayLimit > 0)
{
if (simTime() - pk->getTimestamp() > delayLimit)
{
EV << "Old packet: " << UDPSocket::getReceivedPacketInfo(pk) << endl;
emit(dropPkSignal, pk);
delete pk;
numDeleted++;
return;
}
}
EV << "Received packet: " << UDPSocket::getReceivedPacketInfo(pk) << endl;
emit(rcvdPkSignal, pk);
numReceived++;
cObject *ctrl = pk->getControlInfo();
if (dynamic_cast<UDPDataIndication *>(ctrl)!=NULL) {
UDPDataIndication *udpCtrl = (UDPDataIndication *)ctrl;
short hopCnt = 32 - udpCtrl->getTtl(); // travelled hops of IP packet
numHopsTotal = numHopsTotal + hopCnt;
if ( numReceived > 0 )
avHopCount = (double)numHopsTotal/(double)numReceived;
else
avHopCount = 0;
//cout << "Hop Count = " << hopCnt << endl;
//cout << "Num Hop total = " << numHopsTotal << endl;
//cout << "Average Hop Count = " << numHopsTotal << " / " << numReceived << " = "<< avHopCount << endl << endl;
emit(hopCountSignal, avHopCount);
}
delete pk;
}
double NA_UDPBasicBurst::avHopCount [protected] |
Average hop count.
Definition at line 50 of file NA_UDPBasicBurst.h.
simsignal_t NA_UDPBasicBurst::hopCountSignal = SIMSIGNAL_NULL [static, protected] |
Hop count signal for statistics.
Definition at line 55 of file NA_UDPBasicBurst.h.
int NA_UDPBasicBurst::numHopsTotal [protected] |
Number of hops for all the packets.
Definition at line 45 of file NA_UDPBasicBurst.h.