56 void TKMonitor::onPolicyInit(){
58 cXMLElement* tkXml = NULL;
59 if (par(
"tkData").xmlValue() != NULL && par(
"tkData").xmlValue()->hasChildren()){
60 tkXml = par(
"tkData").xmlValue();
62 error(
"cuData parameter not initialized!");
65 cXMLElementList tks = tkXml->getChildrenByTagName(
"TKItem");
66 for(cXMLElement * m : tks){
67 if (!m->getAttribute(
"id")) {
68 EV <<
"Error parsing TK. Its ID is missing!" << endl;
74 cXMLElementList attrs = m->getChildren();
75 for(cXMLElement * n : attrs) {
76 if ( !strcmp(n->getTagName(),
"tokensTic") ) {
77 inf.
tokensTic = n->getNodeValue() ? atoi(n->getNodeValue()) : 0;
81 if ( !strcmp(n->getTagName(),
"maxTokens") ) {
82 inf.
maxTokens = n->getNodeValue() ? atoi(n->getNodeValue()) : 0;
90 tokensPDU = par(
"tokensPDU").longValue();
93 void TKMonitor::postPDUInsertion(
RMTQueue* queue) {
94 RMTPort* port = rmtAllocator->getQueueToPortMapping(queue);
98 inQ[port].push_back(queue);
107 void TKMonitor::onMessageDrop(
RMTQueue* queue,
const cPacket* pdu) {
108 RMTPort* port = rmtAllocator->getQueueToPortMapping(queue);
112 inQ[port].pop_back();
120 void TKMonitor::postQueueCreation(
RMTQueue* queue){
123 for(
auto info : TKs) {
124 if(queue->getName() == info.second.id) {
129 RMTPort* port = rmtAllocator->getQueueToPortMapping(queue);
130 OutSet[port].insert(queue);
159 if(info->
count > 0) {
164 }
else if (info->
tokens == maxT && info->
count > maxC) {
183 double TKMonitor::getInDropProb(
RMTQueue * queue) {
184 RMTPort* port = rmtAllocator->getQueueToPortMapping(queue);
185 if(port == NULL){ error(
"RMTPort for RMTQueue not found."); }
187 return ( (
int)inC[port] < queue->
getMaxLength() )? 0 : 1;
190 double TKMonitor::getOutDropProb(
RMTQueue * queue) {
191 RMTPort* port = rmtAllocator->getQueueToPortMapping(queue);
192 if(port == NULL){ error(
"RMTPort for RMTQueue not found."); }
194 return ( (
int)outC[port] < queue->
getMaxLength() )? 0 : 1;
queueType getType() const
list< RMTQueue * > QueuesList