42 void MM_PDQ_Drop::initialize() {
44 defaultThreshold = par(
"defaultThreshold").longValue();
45 if(defaultThreshold < 0) { error(
"Error at DL_Drop. defThreshold must be >= 0!"); }
47 cXMLElement* Xml = NULL;
48 if (par(
"data").xmlValue() != NULL && par(
"data").xmlValue()->hasChildren()){
49 Xml = par(
"data").xmlValue();
52 cXMLElementList queues = Xml->getChildrenByTagName(
"queue");
53 for(
auto queue : queues){
54 if (!queue->getAttribute(
"id")) { error(
"Error parsing DQ_Drop Queue. Its ID is missing!"); }
55 std::string
id = queue->getAttribute(
"id");
56 if (
id==
"") { error(
"Error parsing DQ_Drop Queue. Queue ID cannot be empty!"); }
58 if (!queue->getAttribute(
"absThreshold")) { error(
"Error parsing DQ_Drop Queue. Its absThreshold is missing!"); }
59 int absThreshold = atoi(queue->getAttribute(
"absThreshold"));
60 if (absThreshold<0) { error(
"Error parsing DQ_Drop Queue. Queue absThreshold must be >=0!"); }
64 cXMLElementList THs = queue->getChildrenByTagName(
"TH");
67 if(!TH->getAttribute(
"threshold")) { error(
"Error parsing TH. threshold must be defined!"); }
68 int threshold = atoi(TH->getAttribute(
"threshold"));
69 if(threshold<0) { error(
"Error parsing PP. threshold must be >=0!"); }
70 if(absThreshold<=threshold) {
continue; }
72 if(!TH->getAttribute(
"dropProb")) { error(
"Error parsing TH. dropProb must be defined!"); }
73 double dropProb = atof(TH->getAttribute(
"dropProb"));
74 if(dropProb<=0 || dropProb>=1) { error(
"Error parsing TH. dropProb must be in (0,1)!"); }
83 MM_PDQ_Drop::~MM_PDQ_Drop(){
101 vector<string> qv =
split(q->getName(),
'_');
104 error(
"Queue name must be of the form in/outQ_QoS[_*]");
106 string qConf =
join(qv, 2,
'_');
108 if(queuesConf.find(qConf) != queuesConf.end()) {
109 queueConf[q] = &queuesConf[qConf];
114 portQueues[p].insert(q);
118 int count = portCount[p];
138 void MM_PDQ_Drop::finish() {
std::vector< std::string > & split(const std::string &s, char delim, std::vector< std::string > &elems)
std::string join(const std::vector< std::string > &elems, const unsigned int n, const char delim)
vector< Threshold > thresholdList
Define_Module(MM_PDQ_Drop)