Loading src/Solution/InfrastructureLayer/Networking/NetworkElement.cc +17 −1 Original line number Diff line number Diff line Loading @@ -22,7 +22,7 @@ void NetworkElement::initialize() cModule* nic = prevGate->getPreviousGate()->getOwnerModule(); string ip = nic->par("networkAddress").stdstringValue(); this->gateIndex->insert(pair<string, int>(ip, i)); this->portQueue->insert(pair<int, cPacketQueue*>(i, new cPacketQueue())); this->portQueue->insert(pair<int, cPacketQueue*>(i, new cPacketQueue("PacketQueue"))); cMessage* aTimer = new cMessage("timer", PacketKind::TIMER); aTimer->addPar("gateIndex").setLongValue(i); this->portScheduler->insert(pair<int, cMessage*>(i, aTimer)); Loading Loading @@ -81,3 +81,19 @@ void NetworkElement::handleMessage(cMessage *msg) } } } NetworkElement::~NetworkElement(){ for (auto queue = this->portQueue->begin(); queue != this->portQueue->end(); ++queue){ while(queue->second->getLength()>0) { cPacket* pkt = queue->second->pop(); cancelAndDelete(pkt); } delete queue->second; } delete portQueue; for (auto scheduler = this->portScheduler->begin(); scheduler != this->portScheduler->end(); ++scheduler){ cancelAndDelete(scheduler->second); } delete portScheduler; } src/Solution/InfrastructureLayer/Networking/NetworkElement.h +2 −0 Original line number Diff line number Diff line Loading @@ -17,6 +17,8 @@ using namespace std; class NetworkElement : public cSimpleModule { public: ~NetworkElement(); protected: virtual void initialize(); virtual void handleMessage(cMessage *msg); Loading src/Solution/InfrastructureLayer/Nodes/Components/NIC.cc +39 −5 Original line number Diff line number Diff line Loading @@ -8,14 +8,48 @@ Define_Module(NIC); void NIC::initialize() { this->portQueue = new cPacketQueue(); this->portScheduler = new cMessage("timer", PacketKind::TIMER); } void NIC::handleMessage(cMessage *msg) { if (msg->arrivedOn("upLink$i")) send(msg, "downLink$o"); if (msg->isName("timer")) { NetworkPacket* pk = (NetworkPacket*)this->portQueue->pop(); send(pk, "downLink$o"); if (this->portQueue->getLength()>0) { simtime_t targetDate = gate("downLink$o")->getTransmissionChannel()->getTransmissionFinishTime(); scheduleAt(targetDate, msg); } } else { if (msg->arrivedOn("upLink$i")){ NetworkPacket* netPacket = dynamic_cast<NetworkPacket*>(msg); simtime_t targetDate = gate("downLink$o")->getTransmissionChannel()->getTransmissionFinishTime(); if (targetDate <= simTime()){ send(netPacket, "downLink$o"); } else { portQueue->insert(netPacket); if (!portScheduler->isScheduled()) scheduleAt(targetDate, portScheduler); } } else { if (msg->arrivedOn("downLink$i")) send(msg, "upLink$o"); } } } NIC::~NIC(){ cancelAndDelete(this->portScheduler); while(this->portQueue->getLength()>0) { cPacket* pkt = this->portQueue->pop(); cancelAndDelete(pkt); } delete this->portQueue; } src/Solution/InfrastructureLayer/Nodes/Components/NIC.h +8 −0 Original line number Diff line number Diff line Loading @@ -7,14 +7,22 @@ #include <omnetpp.h> #include "../../../../lib/constants.hpp" #include "../../../../messages/NetworkPacket_m.h" using namespace omnetpp; class NIC : public cSimpleModule { public: ~NIC(); protected: virtual void initialize(); virtual void handleMessage(cMessage *msg); cPacketQueue* portQueue; cMessage* portScheduler; }; #endif src/Solution/ServiceLayer/Components/Core.cc +19 −0 Original line number Diff line number Diff line Loading @@ -326,3 +326,22 @@ void Core::handleMessage(cMessage *msg) } break; } } Core::~Core() { delete this->perf; delete this->resourceTree; while(this->waiting->getLength()>0) { cPacket* pkt = this->waiting->pop(); cancelAndDelete(pkt); } delete this->waiting; while(this->processing->getLength()>0) { cPacket* pkt = this->processing->pop(); cancelAndDelete(pkt); } delete this->processing; } Loading
src/Solution/InfrastructureLayer/Networking/NetworkElement.cc +17 −1 Original line number Diff line number Diff line Loading @@ -22,7 +22,7 @@ void NetworkElement::initialize() cModule* nic = prevGate->getPreviousGate()->getOwnerModule(); string ip = nic->par("networkAddress").stdstringValue(); this->gateIndex->insert(pair<string, int>(ip, i)); this->portQueue->insert(pair<int, cPacketQueue*>(i, new cPacketQueue())); this->portQueue->insert(pair<int, cPacketQueue*>(i, new cPacketQueue("PacketQueue"))); cMessage* aTimer = new cMessage("timer", PacketKind::TIMER); aTimer->addPar("gateIndex").setLongValue(i); this->portScheduler->insert(pair<int, cMessage*>(i, aTimer)); Loading Loading @@ -81,3 +81,19 @@ void NetworkElement::handleMessage(cMessage *msg) } } } NetworkElement::~NetworkElement(){ for (auto queue = this->portQueue->begin(); queue != this->portQueue->end(); ++queue){ while(queue->second->getLength()>0) { cPacket* pkt = queue->second->pop(); cancelAndDelete(pkt); } delete queue->second; } delete portQueue; for (auto scheduler = this->portScheduler->begin(); scheduler != this->portScheduler->end(); ++scheduler){ cancelAndDelete(scheduler->second); } delete portScheduler; }
src/Solution/InfrastructureLayer/Networking/NetworkElement.h +2 −0 Original line number Diff line number Diff line Loading @@ -17,6 +17,8 @@ using namespace std; class NetworkElement : public cSimpleModule { public: ~NetworkElement(); protected: virtual void initialize(); virtual void handleMessage(cMessage *msg); Loading
src/Solution/InfrastructureLayer/Nodes/Components/NIC.cc +39 −5 Original line number Diff line number Diff line Loading @@ -8,14 +8,48 @@ Define_Module(NIC); void NIC::initialize() { this->portQueue = new cPacketQueue(); this->portScheduler = new cMessage("timer", PacketKind::TIMER); } void NIC::handleMessage(cMessage *msg) { if (msg->arrivedOn("upLink$i")) send(msg, "downLink$o"); if (msg->isName("timer")) { NetworkPacket* pk = (NetworkPacket*)this->portQueue->pop(); send(pk, "downLink$o"); if (this->portQueue->getLength()>0) { simtime_t targetDate = gate("downLink$o")->getTransmissionChannel()->getTransmissionFinishTime(); scheduleAt(targetDate, msg); } } else { if (msg->arrivedOn("upLink$i")){ NetworkPacket* netPacket = dynamic_cast<NetworkPacket*>(msg); simtime_t targetDate = gate("downLink$o")->getTransmissionChannel()->getTransmissionFinishTime(); if (targetDate <= simTime()){ send(netPacket, "downLink$o"); } else { portQueue->insert(netPacket); if (!portScheduler->isScheduled()) scheduleAt(targetDate, portScheduler); } } else { if (msg->arrivedOn("downLink$i")) send(msg, "upLink$o"); } } } NIC::~NIC(){ cancelAndDelete(this->portScheduler); while(this->portQueue->getLength()>0) { cPacket* pkt = this->portQueue->pop(); cancelAndDelete(pkt); } delete this->portQueue; }
src/Solution/InfrastructureLayer/Nodes/Components/NIC.h +8 −0 Original line number Diff line number Diff line Loading @@ -7,14 +7,22 @@ #include <omnetpp.h> #include "../../../../lib/constants.hpp" #include "../../../../messages/NetworkPacket_m.h" using namespace omnetpp; class NIC : public cSimpleModule { public: ~NIC(); protected: virtual void initialize(); virtual void handleMessage(cMessage *msg); cPacketQueue* portQueue; cMessage* portScheduler; }; #endif
src/Solution/ServiceLayer/Components/Core.cc +19 −0 Original line number Diff line number Diff line Loading @@ -326,3 +326,22 @@ void Core::handleMessage(cMessage *msg) } break; } } Core::~Core() { delete this->perf; delete this->resourceTree; while(this->waiting->getLength()>0) { cPacket* pkt = this->waiting->pop(); cancelAndDelete(pkt); } delete this->waiting; while(this->processing->getLength()>0) { cPacket* pkt = this->processing->pop(); cancelAndDelete(pkt); } delete this->processing; }