diff --git a/ns-3/src/ndnSIM/NFD/daemon/fw/mircc-strategy.cpp b/ns-3/src/ndnSIM/NFD/daemon/fw/mircc-strategy.cpp index 3b86538..8fdac9b 100644 --- a/ns-3/src/ndnSIM/NFD/daemon/fw/mircc-strategy.cpp +++ b/ns-3/src/ndnSIM/NFD/daemon/fw/mircc-strategy.cpp @@ -197,7 +197,7 @@ namespace nfd { } void - MIRCCStrategy::pushQueueInterest(Face &mface, const Interest &interest,const shared_ptr& pitEntry) + MIRCCStrategy::pushQueueInterest(FaceId mface, const Interest &interest,const shared_ptr& pitEntry) { @@ -209,18 +209,18 @@ namespace nfd { if (p == 1) { //如果队列已经满了 - if (m_Queue[mface.getId()].qp.size() + m_Queue[mface.getId()].qs.size() >= QUEUE_MAX) + if (m_Queue[mface].qp.size() + m_Queue[mface].qs.size() >= QUEUE_MAX) { //如果存在第二类兴趣包可以删除 - if (m_Queue[mface.getId()].qs.size() > 0) + if (m_Queue[mface].qs.size() > 0) { //删掉第二类兴趣包最后一个,把当前第一类兴趣包加入 - m_Queue[mface.getId()].qs.pop_back(); - m_Queue[mface.getId()].ts.pop_back(); - m_Queue[mface.getId()].ps.pop_back(); - m_Queue[mface.getId()].qp.push_back(interest); - m_Queue[mface.getId()].tp.push_back(time::steady_clock::now()); - m_Queue[mface.getId()].pp.push_back(pitEntry); + m_Queue[mface].qs.pop_back(); + m_Queue[mface].ts.pop_back(); + m_Queue[mface].ps.pop_back(); + m_Queue[mface].qp.push_back(interest); + m_Queue[mface].tp.push_back(time::steady_clock::now()); + m_Queue[mface].pp.push_back(pitEntry); }else { //否则当前兴趣包丢失 @@ -230,14 +230,14 @@ namespace nfd { }else { //直接将当前兴趣包加入第一类兴趣包队列末尾 - m_Queue[mface.getId()].qp.push_back(interest); - m_Queue[mface.getId()].tp.push_back(time::steady_clock::now()); - m_Queue[mface.getId()].pp.push_back(pitEntry); + m_Queue[mface].qp.push_back(interest); + m_Queue[mface].tp.push_back(time::steady_clock::now()); + m_Queue[mface].pp.push_back(pitEntry); } }else { //如果队列已经满了 - if (m_Queue[mface.getId()].qp.size() + m_Queue[mface.getId()].qs.size() >= QUEUE_MAX) + if (m_Queue[mface].qp.size() + m_Queue[mface].qs.size() >= QUEUE_MAX) { //当前兴趣包丢失 @@ -245,25 +245,25 @@ namespace nfd { }else { //将但钱兴趣包加入第二类末尾 - m_Queue[mface.getId()].qs.push_back(interest); - m_Queue[mface.getId()].ts.push_back(time::steady_clock::now()); - m_Queue[mface.getId()].ps.push_back(pitEntry); + m_Queue[mface].qs.push_back(interest); + m_Queue[mface].ts.push_back(time::steady_clock::now()); + m_Queue[mface].ps.push_back(pitEntry); } } } void - MIRCCStrategy::updateYt(Face &mface, const Interest &interest) + MIRCCStrategy::updateYt(FaceId mface, const Interest &interest) { uint64_t p = *interest.getTag(); if (p == 1) { - m_Yp[mface.getId()] += INTEREST_SIZE * m_ratio[mface.getId()]; + m_Yp[mface] += INTEREST_SIZE * m_ratio[mface]; }else { - m_Ys[mface.getId()] += INTEREST_SIZE * m_ratio[mface.getId()]; + m_Ys[mface] += INTEREST_SIZE * m_ratio[mface]; } } @@ -295,7 +295,7 @@ namespace nfd { uint64_t choosedFace = tmpFace % outFaces.size(); Face& outFace = outFaces[choosedFace].getFace(); //放入对应端口队列进行排队 - this->pushQueueInterest(outFace, interest, pitEntry); + this->pushQueueInterest(outFace.getId(), interest, pitEntry); return; } @@ -368,14 +368,14 @@ namespace nfd { } void - MIRCCStrategy::setHashForData(const Face &mface, const Data &data) + MIRCCStrategy::setHashForData(FaceId mface, const Data &data) {//注意!!HopCountTag的工作情况目前不太了解,似乎ndnsim这个Tag没做处理,后续需要考虑 //处理路径标识id uint64_t hashOld = *data.getTag(); //uint64_t hashNew = (hashOld + hashUnit[data.getTag()] * mface.getFace().getId() % hashMo) % hashMo; //靠近producer的为hash值的高位 - uint64_t hashNew = (hashOld * hashNum % hashMo + mface.getId() % hashMo) % hashMo; + uint64_t hashNew = (hashOld * hashNum % hashMo + mface % hashMo) % hashMo; //给data设置新的hash值 data.setTag(make_shared(hashNew)); @@ -396,7 +396,7 @@ namespace nfd { MIRCCStrategy::afterReceiveData(const shared_ptr &pitEntry, const FaceEndpoint &ingress, const Data &data) { - setHashForData(ingress.face, data); + setHashForData(ingress.face.getId(), data); //修改Rt的值 uint64_t dataRp = *data.getTag(); diff --git a/ns-3/src/ndnSIM/NFD/daemon/fw/mircc-strategy.hpp b/ns-3/src/ndnSIM/NFD/daemon/fw/mircc-strategy.hpp index b140e0c..117f9d8 100644 --- a/ns-3/src/ndnSIM/NFD/daemon/fw/mircc-strategy.hpp +++ b/ns-3/src/ndnSIM/NFD/daemon/fw/mircc-strategy.hpp @@ -118,7 +118,7 @@ namespace nfd { //将兴趣包放入对应端口的队列 void - pushQueueInterest(Face &ingress, const Interest &interest,const shared_ptr& pitEntry); + pushQueueInterest(FaceId mface, const Interest &interest,const shared_ptr& pitEntry); //计算并返回q(t) uint64_t @@ -130,10 +130,10 @@ namespace nfd { //更新Yt void - updateYt(Face &ingress, const Interest &interest); + updateYt(FaceId mface, const Interest &interest); void - setHashForData(const Face &ingress, const Data &data); + setHashForData(FaceId mface, const Data &data); uint64_t diff --git a/ns-3/src/ndnSIM/apps/mircc-consumer.cpp b/ns-3/src/ndnSIM/apps/mircc-consumer.cpp index 6d31551..bf7ac1d 100644 --- a/ns-3/src/ndnSIM/apps/mircc-consumer.cpp +++ b/ns-3/src/ndnSIM/apps/mircc-consumer.cpp @@ -115,7 +115,6 @@ ConsumerMIRCC:: StartApplication() it++; } } - } void @@ -131,7 +130,7 @@ ConsumerMIRCC ::SendPacket(uint64_t pathId,uint64_t classId) if (!m_active) return; uint32_t seq = std::numeric_limits::max(); // invalid - + printf("test\n"); //处理重传兴趣包 //所以重传未必是用之前的子流重传,可能是新的子流 @@ -255,15 +254,11 @@ ConsumerMIRCC:: PathExplorate() { //路径探索的兴趣包全部标为第一类,原论文没有明确说,但是我觉得这样更合理 //因为用于路径探索的兴趣包很重要,如果被丢掉了,consumer可能迟迟无法开始正式发送兴趣包 - pathId2RandomId[-1] = m_rand->GetValue(0, std::numeric_limits::max()); + pathId2RandomId[0] = m_rand->GetValue(0, std::numeric_limits::max()); //PathId为-1表示正在进行路径探索 SendPacket(0,1); - //我们需要记录一下这个随机数用来探索路径了,记录其对应的seq编号 - //用于在收到data时,将新的路径记录下来。 - //还没有写完。 - } void diff --git a/ns-3/src/ndnSIM/examples/ndn-congestion-topo-plugin.cpp b/ns-3/src/ndnSIM/examples/ndn-congestion-topo-plugin.cpp index 427620b..584f742 100644 --- a/ns-3/src/ndnSIM/examples/ndn-congestion-topo-plugin.cpp +++ b/ns-3/src/ndnSIM/examples/ndn-congestion-topo-plugin.cpp @@ -62,7 +62,7 @@ main(int argc, char* argv[]) ndnHelper.InstallAll(); // Choosing forwarding strategy - ndn::StrategyChoiceHelper::InstallAll("/prefix", "/localhost/nfd/strategy/best-route"); + ndn::StrategyChoiceHelper::InstallAll("/prefix", "/localhost/nfd/strategy/MIRCCStrategy"); // Installing global routing interface on all nodes ndn::GlobalRoutingHelper ndnGlobalRoutingHelper; @@ -75,8 +75,8 @@ main(int argc, char* argv[]) Ptr producer1 = Names::Find("Dst1"); Ptr producer2 = Names::Find("Dst2"); - ndn::AppHelper consumerHelper("ns3::ndn::ConsumerCbr"); - consumerHelper.SetAttribute("Frequency", StringValue("100")); // 100 interests a second + ndn::AppHelper consumerHelper("ns3::ndn::ConsumerMIRCC"); + consumerHelper.SetAttribute("MaxSeq", StringValue("10000000")); // 100 interests a second // on the first consumer node install a Consumer application // that will express interests in /dst1 namespace