--- a/src/DIF/RMT/RMTQueue.cc
+++ b/src/DIF/RMT/RMTQueue.cc
@@ -1,5 +1,5 @@
//
-// Copyright © 2014 PRISTINE Consortium (http://ict-pristine.eu)
+// Copyright © 2014 - 2015 PRISTINE Consortium (http://ict-pristine.eu)
//
// This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU Lesser General Public License as published by
@@ -17,13 +17,10 @@
#include "RMTQueue.h"
+const char* SIG_STAT_RMTQUEUE_LENGTH = "RMTQueue_Length";
+const char* SIG_STAT_RMTQUEUE_DROP = "RMTQueue_Drop";
+
Define_Module(RMTQueue);
-
-
-RMTQueue::RMTQueue()
-: queueId("")
-{
-}
RMTQueue::~RMTQueue()
{
@@ -33,6 +30,22 @@
queue.pop_front();
}
}
+
+void RMTQueue::finish()
+{
+ size_t pduCount = queue.size();
+ if (pduCount)
+ {
+ EV << "This queue still contains " << pduCount << " unprocessed PDUs!" << endl;
+
+ for (iterator it = begin(); it != end(); ++it)
+ {
+ cPacket* p = *it;
+ EV << p->getClassName() << " received at " << p->getArrivalTime() << endl;
+ }
+ }
+}
+
void RMTQueue::initialize()
{
@@ -42,11 +55,17 @@
sigRMTPDURcvd = registerSignal(SIG_RMT_QueuePDURcvd);
// message departure signal handler
sigRMTPDUSent = registerSignal(SIG_RMT_QueuePDUSent);
-
- maxQLength = getParentModule()->par("defaultMaxQLength");
- thresholdQLength = getParentModule()->par("defaultThreshQLength");
+ // length for vector stats
+ sigStatRMTQueueLength = registerSignal(SIG_STAT_RMTQUEUE_LENGTH);
+
+ maxQLength = getParentModule()->getParentModule()->par("defaultMaxQLength");
+ thresholdQLength = getParentModule()->getParentModule()->par("defaultThreshQLength");
qTime = simTime();
redrawGUI();
+
+ WATCH(thresholdQLength);
+ WATCH(maxQLength);
+ WATCH(qTime);
}
std::string RMTQueue::info() const
@@ -83,15 +102,15 @@
}
else if (len < thresholdQLength)
{
- disp.setTagArg("i", 1, getParentModule()->par("queueColorBusy").stringValue());
+ disp.setTagArg("i", 1, getParentModule()->getParentModule()->par("queueColorBusy").stringValue());
}
else if (len < maxQLength)
{
- disp.setTagArg("i", 1, getParentModule()->par("queueColorWarn").stringValue());
+ disp.setTagArg("i", 1, getParentModule()->getParentModule()->par("queueColorWarn").stringValue());
}
else
{
- disp.setTagArg("i", 1, getParentModule()->par("queueColorFull").stringValue());
+ disp.setTagArg("i", 1, getParentModule()->getParentModule()->par("queueColorFull").stringValue());
}
// print current saturation in numbers
@@ -103,12 +122,7 @@
void RMTQueue::handleMessage(cMessage* msg)
{
- if (msg->isSelfMessage() && !opp_strcmp(msg->getFullName(), "queueTransmitEnd"))
- {
- releasePDU();
- delete msg;
- }
- else if (dynamic_cast<cPacket*>(msg) != NULL)
+ if (dynamic_cast<cPacket*>(msg) != NULL)
{
enqueuePDU((cPacket*)msg);
}
@@ -122,11 +136,14 @@
{
queue.push_back(pdu);
emit(sigRMTPDURcvd, this);
+ emit(sigStatRMTQueueLength, getLength());
redrawGUI();
}
void RMTQueue::releasePDU(void)
{
+ Enter_Method("releasePDU()");
+
if (this->getLength() > 0)
{
cPacket* pdu = queue.front();
@@ -137,22 +154,12 @@
{
qTime = simTime();
}
- }
-
- emit(sigRMTPDUSent, this);
- redrawGUI();
-}
-
-/**
- * Schedules an end-of-queue-service event.
- *
- */
-void RMTQueue::startTransmitting()
-{
- Enter_Method("startTransmitting()");
-
- scheduleAt(simTime() + queuingTime, new cMessage("queueTransmitEnd"));
- bubble("Releasing a PDU...");
+
+ emit(sigRMTPDUSent, this);
+ emit(sigStatRMTQueueLength, getLength());
+ bubble("Releasing a PDU...");
+ redrawGUI();
+ }
}
cPacket* RMTQueue::dropLast()
@@ -219,27 +226,14 @@
void RMTQueue::setType(queueType type)
{
this->type = type;
- queuingTime = getParentModule()->
- par(type == OUTPUT ? "TxQueuingTime" : "RxQueuingTime").
- doubleValue() / 1000;
-}
-
-const char* RMTQueue::getQueueId() const
-{
- return queueId;
-}
-
-void RMTQueue::setQueueId(const char* queueId)
-{
- this->queueId = queueId;
-}
-
-cGate* RMTQueue::getRmtAccessGate() const
+}
+
+cGate* RMTQueue::getRMTAccessGate() const
{
return rmtAccessGate;
}
-void RMTQueue::setRmtAccessGate(cGate* gate)
+void RMTQueue::setRMTAccessGate(cGate* gate)
{
rmtAccessGate = gate;
}
@@ -254,62 +248,12 @@
return inputGate;
}
-unsigned int RMTQueue::getFirstPDUPayloadLength()
-{
- PDU* pdu = dynamic_cast<PDU*>(queue.front());
-
- if (pdu != NULL)
- {
- return pdu->getSize();
- }
- {
- EV << "The first message isn't a data PDU!" << endl;
- }
-
- return 0;
-}
-
-unsigned int RMTQueue::getLastPDUPayloadLength()
-{
- PDU* pdu = dynamic_cast<PDU*>(queue.back());
-
- if (pdu != NULL)
- {
- return pdu->getSize();
- }
- {
- EV << "The last message isn't a data PDU!" << endl;
- }
-
- return 0;
-}
-
-unsigned short RMTQueue::getFirstPDUQoSID()
-{
- PDU* pdu = dynamic_cast<PDU*>(queue.front());
-
- if (pdu != NULL)
- {
- return pdu->getConnId().getQoSId();
- }
- {
- EV << "The first message isn't a data PDU!" << endl;
- }
-
- return 0;
-}
-
-unsigned short RMTQueue::getLastPDUQoSID()
-{
- PDU* pdu = dynamic_cast<PDU*>(queue.back());
-
- if (pdu != NULL)
- {
- return pdu->getConnId().getQoSId();
- }
- {
- EV << "The last message isn't a data PDU!" << endl;
- }
-
- return 0;
-}
+const cPacket* RMTQueue::getFirstPDU() const
+{
+ return queue.front();
+}
+
+const cPacket* RMTQueue::getLastPDU() const
+{
+ return queue.back();
+}