35 FlowIdent::FlowIdent(
const string & _qosId,
const string & _srcAddr,
const string & _dstAddr,
const int & _srcCepId,
const int & _dstCepId) :
36 qosId(_qosId), srcAddr(_srcAddr), dstAddr(_dstAddr), srcCepId(_srcCepId), dstCepId(_dstCepId){}
55 next(_next), expiration(_expiration) {}
57 next(nullptr), expiration(0.0) {}
60 vector<RMTPort * > MultiQoSTable::lookup(
const PDU * pdu){
71 simtime_t now = simTime();
72 simtime_t ex = now + exTime;
74 if(cd.next ==
nullptr || cd.expiration < now) {
75 cd.next = search(dstAddr, fId.
qosId);
79 vector<RMTPort * > ret;
80 if(cd.next !=
nullptr) {
81 ret.push_back(cd.next);
106 vector<RMTPort * > MultiQoSTable::lookup(
const Address &dst,
const std::string& qos){
110 vector<RMTPort* > ret;
112 RMTPort * next = search(dstAddr, qos);
114 if(next !=
nullptr) {
122 string MultiQoSTable::toString(){
123 std::ostringstream os;
125 os << this->getName()<<endl;
126 for(
const auto &qosTable : table) {
127 os <<
"\tQoS :" << qosTable.first << endl;
128 for(
const auto & entry : qosTable.second) {
129 os <<
"\t\tQoS :" << entry.first <<
" -> ";
130 for(
RMTPort * p : entry.second){
131 os << p->getParentModule()->getName() <<
" ";
143 RMTPort * MultiQoSTable::search(
const string & dst,
const string & qos) {
146 vector<RMTPort*> & vR = table[qos][dst];
148 if(pS <= 0) {
return nullptr; }
149 if(pS == 1) {
return vR.front(); }
151 int k = intuniform(0, pS-1);
154 return search(dst, MA2QoS);
159 void MultiQoSTable::addReplace(
const std::string &addr,
const std::string &qosId, std::vector<RMTPort * > ports) {
160 vector<RMTPort*> old;
162 for(
RMTPort * p : table[qosId][addr]) {
165 if(p == p2) { found =
true;
break; }
167 if(!found) { old.push_back(p); }
171 table[qosId].erase(addr);
173 table[qosId][addr] = ports;
177 for(
auto it = cache.begin(); it != cache.end();) {
179 if(it->second.next == p && it->first.dstAddr == addr && it->first.qosId == qosId) {
187 void MultiQoSTable::onPolicyInit(){
188 MA2QoS = par(
"MA2QoS").stdstringValue();
189 if(MA2QoS ==
"") { error(
"Management to QoS must be set."); }
190 exTime = par(
"exTime").doubleValue();
193 void MultiQoSTable::finish(){
194 if(par(
"printAtEnd").boolValue() || par(
"printCacheAtEnd").boolValue()){
195 EV <<
"-----------------" << endl;
196 EV << this->getFullPath() << endl;
197 if(par(
"printAtEnd").boolValue()) {
198 EV <<
"Forwarding table::" << endl;
199 EV << toString() <<endl;
201 if(par(
"printCacheAtEnd").boolValue()) {
202 EV <<
"\tCache : "<<endl;
203 for(
const auto &ent : cache) {
205 EV <<
"("<< ent.first.srcAddr <<
"."<< ent.first.srcCepId <<
")";
207 EV <<
"("<< ent.first.dstAddr <<
"."<< ent.first.dstCepId <<
")";
208 EV <<
" ["<< ent.first.qosId <<
"]";
210 EV <<
"\t\t\t" << ent.second.next->getParentModule()->getName();
211 EV <<
"\t\t\tExpires " << ent.second.expiration;
215 EV <<
"-----------------" << endl;
static const QoSCube MANAGEMENT
std::string getQoSId() const
Getter of selected QoS-cube identifier.
const APN & getIpcAddress() const
Getter of IPC Process address which should be unambiguous within DIF.
FlowIdent(const string &_qosId, const string &_srcAddr, const string &_dstAddr, const int &_srcCepId, const int &_dstCepId)
Connection identifier as defined in specifications.
int getSrcCepId() const
Getter of source Connection-Endpoint identifier.
virtual ConnectionId & getConnId()
bool operator<(const FlowIdent &n) const
virtual Address & getDstAddr()
Register_Class(MultiQoSTable::MultiQoSTable)
int getDstCepId() const
Getter of destination Connection-Endpoint identifier.
virtual Address & getSrcAddr()
const std::string & getName() const
Gets APN string name representation.
Address class holds IPC Process identification.