24 void MM_eDL_Drop::initialize() {
26 defaultThreshold = par(
"defThreshold").longValue();
27 if(defaultThreshold <= 0) { error(
"Error at DL_Drop. defThreshold must be >0!"); }
29 defaultAbsThreshold = par(
"defAbsThreshold").longValue();
30 if(defaultAbsThreshold <= 0) { error(
"Error at DL_Drop. defAbsThreshold must be >0!"); }
32 defaultDropProb = par(
"defDropProb").doubleValue();
33 if(defaultDropProb < 0.0 || defaultDropProb > 1.0) { error(
"Error at DL_Drop. defDropProb must be between [0,1]!"); }
35 cXMLElement* Xml = NULL;
36 if (par(
"data").xmlValue() != NULL && par(
"data").xmlValue()->hasChildren()){
37 Xml = par(
"data").xmlValue();
41 cXMLElementList queues = Xml->getChildrenByTagName(
"queue");
42 for(
auto queue : queues){
43 if (!queue->getAttribute(
"id")) { error(
"Error parsing DL_Drop Queue. Its ID is missing!"); }
44 std::string
id = queue->getAttribute(
"id");
45 if (
id==
"") { error(
"Error parsing DL_Drop Queue. Queue ID cannot be empty!"); }
47 if (!queue->getAttribute(
"threshold")) { error(
"Error parsing DL_Drop Queue. Its Threshold is missing!"); }
48 int threshold = atoi(queue->getAttribute(
"threshold"));
49 if (threshold<=0) { error(
"Error parsing DL_Drop Queue. Queue Threshold must be >0!"); }
51 if (!queue->getAttribute(
"dropProb")) { error(
"Error parsing DL_Drop Queue. Its dropProb is missing!"); }
52 double dropProb = atof(queue->getAttribute(
"dropProb"));
53 if (dropProb<0 || dropProb > 1) { error(
"Error parsing DL_Drop Queue. Queue dropProb must be between [0,1]!"); }
55 if (!queue->getAttribute(
"absThreshold")) { error(
"Error parsing DL_Drop Queue. Its absThreshold is missing!"); }
56 int absThreshold = atoi(queue->getAttribute(
"absThreshold"));
57 if (absThreshold<=0) { error(
"Error parsing DL_Drop Queue. Queue absThreshold must be >0!"); }
59 queueName2Threshold[id] = threshold;
60 queueName2DropProb[id] = dropProb;
61 queueName2AbsThreshold[id] = absThreshold;
65 MM_eDL_Drop::~MM_eDL_Drop(){
82 if(queueName2Threshold.find(q->getName()) != queueName2Threshold.end()) {
83 queueThreshold[q] = queueName2Threshold[q->getName()];
85 queueThreshold[q] = defaultThreshold;
88 if(queueName2DropProb.find(q->getName()) != queueName2DropProb.end()) {
89 queueDropProb[q] = queueName2DropProb[q->getName()];
91 queueDropProb[q] = defaultDropProb;
94 if(queueName2AbsThreshold.find(q->getName()) != queueName2AbsThreshold.end()) {
95 queueAbsThreshold[q] = queueName2AbsThreshold[q->getName()];
97 queueAbsThreshold[q] = defaultAbsThreshold;
104 int count = portCount[p];
105 return (count > queueAbsThreshold[q])? 1.0 :
106 (queueThreshold[q] < portCount[p])? queueDropProb[q] : 0.0;
Define_Module(MM_eDL_Drop)