26 rTkBit(0), sTkBit(0), maxTk(0), priority(0) {}
29 hasTk(false), priority(0) {}
32 hasTk(_ht), priority(_pr) {}
59 if(
tk < 0) {
tk = 0; }
67 void MM_WFQ_Out::initialize() {
68 cXMLElement* Xml = NULL;
69 if (par(
"data").xmlValue() != NULL && par(
"data").xmlValue()->hasChildren()){
70 Xml = par(
"data").xmlValue();
73 cXMLElementList queues = Xml->getChildrenByTagName(
"queue");
74 for(
auto queue : queues){
75 if (!queue->getAttribute(
"id")) { error(
"Error parsing WFQ_OUT Queue. Its ID is missing!"); }
76 std::string
id = queue->getAttribute(
"id");
77 if (
id==
"") { error(
"Error parsing WFQ_OUT Queue. Queue ID cannot be empty!"); }
81 if (!queue->getAttribute(
"priority")) { error(
"Error parsing WFQ_OUT Queue. Its Priority is missing!"); }
82 c.
priority = atoi(queue->getAttribute(
"priority"));
83 if (c.
priority<0) { error(
"Error parsing WFQ_OUT Queue. Queue Priority must be >=0!"); }
85 if (!queue->getAttribute(
"rTkBit")) { error(
"Error parsing WFQ_OUT Queue. Its Received tokens per byte is missing!"); }
86 c.
rTkBit = atoi(queue->getAttribute(
"rTkBit"));
87 if (c.
rTkBit<=0) { error(
"Error parsing WFQ_OUT Queue. Queue Received tokens per byte must be >=0!"); }
89 if (!queue->getAttribute(
"sTkBit")) { error(
"Error parsing WFQ_OUT Queue. Its Required tokens per byte is missing!"); }
90 c.
sTkBit = atoi(queue->getAttribute(
"sTkBit"));
91 if (c.
sTkBit<0) { error(
"Error parsing WFQ_OUT Queue. Queue Required tokens per byte must be >=0!"); }
93 if (!queue->getAttribute(
"maxTk")) { error(
"Error parsing WFQ_OUT Queue. Its Max Tokens is missing!"); }
94 c.
maxTk = atoi(queue->getAttribute(
"maxTk"));
95 if (c.
maxTk<=0) { error(
"Error parsing WFQ_OUT Queue. Queue Max Tokens must be >=0!"); }
97 queueName2Config[id] = c;
101 MM_WFQ_Out::~MM_WFQ_Out(){}
103 void MM_WFQ_Out::finish() {
119 qd.
c = queueName2Config[q->getName()];
121 portQueues[p].push_back(q);
128 for(
auto & q : portQueues[p]){
129 QData * qd = &queueData[q];
132 int nextS = q->getFirstPDU()->getByteLength();
141 if(retQ == NULL) {
return NULL; }
145 queueData[retQ].remTk(nextS);
146 for(
auto & q : portQueues[p]){
147 queueData[q].addTk(nextS);
153 simtime_t MM_WFQ_Out::getnextTime(
RMTPort * p) {
const cPacket * getFirstPDU() const
Define_Module(MM_WFQ_Out)
Qinfo getInfo(const int &nextS)
bool compare(const Qinfo &o)