47 dlCUInfo::dlCUInfo(std::string
id, std::string _queue,
int urg,
int thre,
double dropP,
int absThre){
56 void eDLMonitor::onPolicyInit(){
58 cXMLElement* cuXml = NULL;
59 if (par(
"cuData").xmlValue() != NULL && par(
"cuData").xmlValue()->hasChildren()){
60 cuXml = par(
"cuData").xmlValue();
62 error(
"cuData parameter not initialized!");
65 cXMLElementList cus = cuXml->getChildrenByTagName(
"CUItem");
66 for (cXMLElementList::iterator it = cus.begin(); it != cus.end(); ++it) {
68 if (!m->getAttribute(
"id")) {
69 EV <<
"Error parsing CU. Its ID is missing!" << endl;
73 std::string cu = m->getAttribute(
"id");
75 EV <<
"Error parsing CU. Its ID is missing!" << endl;
81 cXMLElementList attrs = m->getChildren();
82 for (cXMLElementList::iterator jt = attrs.begin(); jt != attrs.end(); ++jt) {
84 if ( !strcmp(n->getTagName(),
"urgency") ) {
85 inf.
urgency = n->getNodeValue() ? atoi(n->getNodeValue()) : 0;
88 }
else if ( !strcmp(n->getTagName(),
"cherishThreshold") ) {
89 inf.
threshold = n->getNodeValue() ? atoi(n->getNodeValue()) : 0;
92 }
else if ( !strcmp(n->getTagName(),
"cherishAbsThreshold") ) {
93 inf.
absThreshold = n->getNodeValue() ? atoi(n->getNodeValue()) : 0;
96 }
else if ( !strcmp(n->getTagName(),
"cherishDropProbability") ) {
97 inf.
dropProb = n->getNodeValue() ? atof(n->getNodeValue()) : 0.0;
111 cXMLElement* urgXml = NULL;
112 if (par(
"urgData").xmlValue() != NULL && par(
"urgData").xmlValue()->hasChildren()){
113 urgXml = par(
"urgData").xmlValue();
115 error(
"urgData parameter not initialized!");
118 cXMLElementList urgs = urgXml->getChildrenByTagName(
"urgency");
119 for (cXMLElementList::iterator it = urgs.begin(); it != urgs.end(); ++it) {
120 cXMLElement* m = *it;
121 if (!m->getAttribute(
"val")) {
122 EV <<
"Error parsing urgency. Its val is missing!" << endl;
125 std::string valS = m->getAttribute(
"val");
127 EV <<
"Error parsing urgency. Its val is missing!" << endl;
131 if (!m->getAttribute(
"prob")) {
132 EV <<
"Error parsing urgency. Its prob is missing!" << endl;
135 std::string probS = m->getAttribute(
"prob");
137 EV <<
"Error parsing urgency. Its prob is missing!" << endl;
141 int val = atoi(valS.c_str());
142 if(val<0) { val = 0; }
144 double prob = atof(probS.c_str());
145 if(prob<0) { prob = 0; }
146 if(prob>1) { prob = 1; }
152 void eDLMonitor::postPDUInsertion(
RMTQueue* queue) {
153 RMTPort* port = rmtAllocator->getQueueToPortMapping(queue);
157 inQ[port].push_back(queue);
161 std::string cu = Q2CU[queue];
162 int urgency = CUs[cu].urgency;
163 outQs[port][urgency].push_back(queue);
164 lastInsertedUrgency[port] = urgency;
169 void eDLMonitor::onMessageDrop(
RMTQueue* queue,
const cPacket* pdu) {
170 RMTPort* port = rmtAllocator->getQueueToPortMapping(queue);
174 inQ[port].pop_back();
177 outQs[port][lastInsertedUrgency[port]].pop_back();
182 void eDLMonitor::postQueueCreation(
RMTQueue* queue){
184 std::string cu =
"BE";
187 if(it->second.queue == queue->getName()){
217 for(
PQListRIterator it = qs->rbegin(); it != qs->rend() && q == NULL; it++){
218 if(!it->second.empty()){
220 double tP = probs[it->first];
221 if(tP <= 0 || tP < uniform(0,1) ){
222 q = it->second.front();
223 it->second.pop_front();
227 if(q == NULL && tit != qs->rend()){
228 q = tit->second.front();
229 tit->second.pop_front();
235 error(
"No queue found");
242 double eDLMonitor::getInDropProb(
RMTQueue * queue) {
243 RMTPort* port = rmtAllocator->getQueueToPortMapping(queue);
244 if(port == NULL){ error(
"RMTPort for RMTQueue not found."); }
246 return ( (
int)inC[port] < queue->
getMaxLength() )? 0 : 1;
249 double eDLMonitor::getOutDropProb(
RMTQueue * queue) {
250 RMTPort* port = rmtAllocator->getQueueToPortMapping(queue);
251 if(port == NULL){ error(
"RMTPort for RMTQueue not found."); }
254 int count = outC[port];
list< RMTQueue * > QueuesList
queueType getType() const
PriorityQueuesList::reverse_iterator PQListRIterator
cuRepo::iterator cuRepoiterator
std::map< int, QueuesList > PriorityQueuesList
Define_Module(eDLMonitor)