36 FlowIdent::FlowIdent(
const string & _qosId,
const string & _srcAddr,
const string & _dstAddr,
const int & _srcCepId,
const int & _dstCepId) :
37 qosId(_qosId), srcAddr(_srcAddr), dstAddr(_dstAddr), srcCepId(_srcCepId), dstCepId(_dstCepId){}
56 next(_next), expiration(_expiration) {}
58 next(nullptr), expiration(0.0) {}
61 vector<RMTPort * > IMultiQoSTable::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);
78 vector<RMTPort * > ret;
79 if(cd.next !=
nullptr) {
80 ret.push_back(cd.next);
93 vector<RMTPort * > IMultiQoSTable::lookup(
const Address &dst,
const std::string& qos){
97 vector<RMTPort* > ret;
99 RMTPort * next = search(dstAddr, qos);
101 if(next !=
nullptr) {
109 string IMultiQoSTable::toString(){
110 std::ostringstream os;
112 os << this->getName()<<endl;
113 for(
const auto &qosTable : table) {
114 os <<
"\tQoS :" << qosTable.first << endl;
115 for(
const auto & entry : qosTable.second) {
116 os <<
"\t\tQoS :" << entry.first <<
" -> ";
117 for(
RMTPort * p : entry.second){
118 os << p->getParentModule()->getName() <<
" ";
130 RMTPort * IMultiQoSTable::search(
const string & dst,
const string & qos) {
133 vector<RMTPort*> & vR = table[qos][dst];
135 if(pS <= 0) {
return nullptr; }
136 if(pS == 1) {
return vR.front(); }
138 int k = intuniform(0, pS-1);
141 return search(dst, MA2QoS);
146 void IMultiQoSTable::addReplace(
const std::string &addr,
const std::string &qosId, std::vector<RMTPort * > ports) {
147 vector<RMTPort*> old;
149 for(
RMTPort * p : table[qosId][addr]) {
152 if(p == p2) { found =
true;
break; }
154 if(!found) { old.push_back(p); }
158 table[qosId].erase(addr);
160 table[qosId][addr] = ports;
164 for(
auto it = cache.begin(); it != cache.end();) {
166 if(it->second.next == p && it->first.dstAddr == addr && it->first.qosId == qosId) {
173 void IMultiQoSTable::setPortDelay(
RMTPort* port,
double delay) {
174 portDelay[port] = delay;
178 void IMultiQoSTable::onPolicyInit(){
179 MA2QoS = par(
"MA2QoS").stdstringValue();
180 if(MA2QoS ==
"") { error(
"Management to QoS must be set."); }
181 exTime = par(
"exTime").doubleValue();
184 void IMultiQoSTable::finish(){
185 if(par(
"printAtEnd").boolValue() || par(
"printCacheAtEnd").boolValue()){
186 EV <<
"-----------------" << endl;
187 EV << this->getFullPath() << endl;
188 if(par(
"printAtEnd").boolValue()) {
189 EV <<
"Forwarding table::" << endl;
190 EV << toString() <<endl;
192 if(par(
"printCacheAtEnd").boolValue()) {
193 EV <<
"\tCache : "<<endl;
194 for(
const auto &ent : cache) {
196 EV <<
"("<< ent.first.srcAddr <<
"."<< ent.first.srcCepId <<
")";
198 EV <<
"("<< ent.first.dstAddr <<
"."<< ent.first.dstCepId <<
")";
199 EV <<
" ["<< ent.first.qosId <<
"]";
201 EV <<
"\t\t\t" << ent.second.next->getParentModule()->getName();
202 EV <<
"\t\t\tExpires " << ent.second.expiration;
207 EV <<
"-----------------" << endl;
static const QoSCube MANAGEMENT
bool operator<(const FlowIdent &n) const
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.
Connection identifier as defined in specifications.
int getSrcCepId() const
Getter of source Connection-Endpoint identifier.
virtual ConnectionId & getConnId()
virtual Address & getDstAddr()
int getDstCepId() const
Getter of destination Connection-Endpoint identifier.
virtual Address & getSrcAddr()
Register_Class(IMultiQoSTable::IMultiQoSTable)
FlowIdent(const string &_qosId, const string &_srcAddr, const string &_dstAddr, const int &_srcCepId, const int &_dstCepId)
const std::string & getName() const
Gets APN string name representation.
Address class holds IPC Process identification.