preliminary preview

This commit is contained in:
Lv committed 2022-04-28 20:00:38 +08:00
1 parent ed0627cc54
commit e0918c4967
13 files changed
+318 -45

No files matched your search

+11
View File
@@ -0,0 +1,11 @@
Waf: Entering directory `/home/dutacm/mircc/mircc/ns-3/build'
[2694/3114] Compiling src/ndnSIM/examples/ndn-congestion-topo-plugin.cpp
[3073/3114] Linking build/src/ndnSIM/examples/ns3-dev-ndn-congestion-topo-plugin-debug
Waf: Leaving directory `/home/dutacm/mircc/mircc/ns-3/build'
Build commands will be stored in build/compile_commands.json
'build' finished successfully (6.154s)
Start App
test
Start App
test
aa
+41
View File
@@ -0,0 +1,41 @@
+1.031003200s 5 ndn-cxx.nfd.Forwarder:onIncomingData(): [DEBUG] onIncomingData matching=/dst2/%FE%01
+1.031003200s 5 ndn-cxx.nfd.Forwarder:onOutgoingData(): [DEBUG] onOutgoingData out=(257,0) data=/dst2/%FE%01
+1.031003200s 5 ndn-cxx.nfd.Forwarder:onIncomingData(): [DEBUG] onIncomingData finish
+1.031003200s 5 ndn-cxx.nfd.Forwarder:onInterestFinalize(): [DEBUG] onInterestFinalize interest=/dst2/%FE%01 satisfied
+1.031003200s 5 ndn-cxx.nfd.Forwarder:onInterestFinalize(): [DEBUG] onInterestFinalize finish
+1.041400800s 3 ndn-cxx.nfd.Forwarder:onIncomingData(): [DEBUG] onIncomingData in=(258,0) data=/dst1/%FE%01
+1.041400800s 3 ndn-cxx.nfd.Forwarder:onIncomingData(): [DEBUG] onIncomingData if1
+1.041400800s 3 ndn-cxx.nfd.Forwarder:onIncomingData(): [DEBUG] onIncomingData matching=/dst1/%FE%01
+1.041400800s 3 ndn-cxx.nfd.Forwarder:onOutgoingData(): [DEBUG] onOutgoingData out=(257,0) data=/dst1/%FE%01
+1.041400800s 3 ndn-cxx.nfd.Forwarder:onIncomingData(): [DEBUG] onIncomingData finish
+1.041400800s 3 ndn-cxx.nfd.Forwarder:onInterestFinalize(): [DEBUG] onInterestFinalize interest=/dst1/%FE%01 satisfied
+1.041400800s 3 ndn-cxx.nfd.Forwarder:onInterestFinalize(): [DEBUG] onInterestFinalize finish
+1.041856800s 3 ndn-cxx.nfd.Forwarder:onIncomingData(): [DEBUG] onIncomingData in=(259,0) data=/dst2/%FE%01
+1.041856800s 3 ndn-cxx.nfd.Forwarder:onIncomingData(): [DEBUG] onIncomingData if1
+1.041856800s 3 ndn-cxx.nfd.Forwarder:onIncomingData(): [DEBUG] onIncomingData matching=/dst2/%FE%01
+1.041856800s 3 ndn-cxx.nfd.Forwarder:onOutgoingData(): [DEBUG] onOutgoingData out=(257,0) data=/dst2/%FE%01
+1.041856800s 3 ndn-cxx.nfd.Forwarder:onIncomingData(): [DEBUG] onIncomingData finish
+1.041856800s 3 ndn-cxx.nfd.Forwarder:onInterestFinalize(): [DEBUG] onInterestFinalize interest=/dst2/%FE%01 satisfied
+1.041856800s 3 ndn-cxx.nfd.Forwarder:onInterestFinalize(): [DEBUG] onInterestFinalize finish
+1.059936800s 2 ndn-cxx.nfd.Forwarder:onIncomingData(): [DEBUG] onIncomingData in=(259,0) data=/dst1/%FE%01
+1.059936800s 2 ndn-cxx.nfd.Forwarder:onIncomingData(): [DEBUG] onIncomingData if1
+1.059936800s 2 ndn-cxx.nfd.Forwarder:onIncomingData(): [DEBUG] onIncomingData matching=/dst1/%FE%01
+1.059936800s 2 ndn-cxx.nfd.Forwarder:onOutgoingData(): [DEBUG] onOutgoingData out=(257,0) data=/dst1/%FE%01
+1.059936800s 2 ndn-cxx.nfd.Forwarder:onIncomingData(): [DEBUG] onIncomingData finish
+1.059936800s 2 ndn-cxx.nfd.Forwarder:onInterestFinalize(): [DEBUG] onInterestFinalize interest=/dst1/%FE%01 satisfied
+1.059936800s 2 ndn-cxx.nfd.Forwarder:onInterestFinalize(): [DEBUG] onInterestFinalize finish
+1.068472800s 2 ndn-cxx.nfd.Forwarder:onIncomingData(): [DEBUG] onIncomingData in=(259,0) data=/dst2/%FE%01
+1.068472800s 2 ndn-cxx.nfd.Forwarder:onIncomingData(): [DEBUG] onIncomingData if1
+1.068472800s 2 ndn-cxx.nfd.Forwarder:onIncomingData(): [DEBUG] onIncomingData matching=/dst2/%FE%01
+1.068472800s 2 ndn-cxx.nfd.Forwarder:onOutgoingData(): [DEBUG] onOutgoingData out=(258,0) data=/dst2/%FE%01
+1.068472800s 2 ndn-cxx.nfd.Forwarder:onIncomingData(): [DEBUG] onIncomingData finish
+1.068472800s 2 ndn-cxx.nfd.Forwarder:onInterestFinalize(): [DEBUG] onInterestFinalize interest=/dst2/%FE%01 satisfied
+1.068472800s 2 ndn-cxx.nfd.Forwarder:onInterestFinalize(): [DEBUG] onInterestFinalize finish
+1.070790400s 0 ndn-cxx.nfd.Forwarder:onIncomingData(): [DEBUG] onIncomingData in=(257,0) data=/dst1/%FE%01
+1.070790400s 0 ndn-cxx.nfd.Forwarder:onIncomingData(): [DEBUG] onIncomingData if1
+1.070790400s 0 ndn-cxx.nfd.Forwarder:onIncomingData(): [DEBUG] onIncomingData matching=/dst1/%FE%01
+1.070790400s 0 ndn-cxx.nfd.Forwarder:onOutgoingData(): [DEBUG] onOutgoingData out=(258,0) data=/dst1/%FE%01
+1.070790400s 0 ndn-cxx.nfd.Forwarder:onIncomingData(): [DEBUG] onIncomingData finish
+1.070790400s 0 ndn-cxx.nfd.Forwarder:onInterestFinalize(): [DEBUG] onInterestFinalize interest=/dst1/%FE%01 satisfied
+1.070790400s 0 ndn-cxx.nfd.Forwarder:onInterestFinalize(): [DEBUG] onInterestFinalize finish
+4 -1
View File
@@ -277,6 +277,7 @@ Forwarder::onInterestFinalize(const shared_ptr<pit::Entry>& pitEntry)
// PIT delete
pitEntry->expiryTimer.cancel();
m_pit.erase(pitEntry.get());
NFD_LOG_DEBUG("onInterestFinalize finish");
}
void
@@ -309,6 +310,7 @@ Forwarder::onIncomingData(const FaceEndpoint& ingress, const Data& data)
// when only one PIT entry is matched, trigger strategy: after receive Data
if (pitMatches.size() == 1) {
NFD_LOG_DEBUG("onIncomingData if1");
auto& pitEntry = pitMatches.front();
NFD_LOG_DEBUG("onIncomingData matching=" << pitEntry->getName());
@@ -334,6 +336,7 @@ Forwarder::onIncomingData(const FaceEndpoint& ingress, const Data& data)
// when more than one PIT entry is matched, trigger strategy: before satisfy Interest,
// and send Data to all matched out faces
else {
NFD_LOG_DEBUG("onIncomingData if2");
std::set<std::pair<Face*, EndpointId>> pendingDownstreams;
auto now = time::steady_clock::now();
@@ -366,7 +369,6 @@ Forwarder::onIncomingData(const FaceEndpoint& ingress, const Data& data)
pitEntry->clearInRecords();
pitEntry->deleteOutRecord(ingress.face);
}
// foreach pending downstream
for (const auto& pendingDownstream : pendingDownstreams) {
if (pendingDownstream.first->getId() == ingress.face.getId() &&
@@ -378,6 +380,7 @@ Forwarder::onIncomingData(const FaceEndpoint& ingress, const Data& data)
this->onOutgoingData(data, FaceEndpoint(*pendingDownstream.first, pendingDownstream.second));
}
}
NFD_LOG_DEBUG("onIncomingData finish");
}
void
@@ -1,14 +1,14 @@
#include "mircc-strategy.hpp"
NFD_LOG_INIT(MIRCCStrategy);
namespace nfd {
namespace fw {
MIRCCStrategy::MIRCCStrategy(Forwarder &forwarder, const ndn::Name &name)
: Strategy(forwarder), ProcessNackTraits<MIRCCStrategy>(this)
{
this->setInstanceName(makeInstanceName(name, getStrategyName()));
const FaceTable &faceTable = getFaceTable();
for (auto& tmp : faceTable)
{
@@ -25,9 +25,11 @@ namespace nfd {
m_d[tmp.getId()] = 500;
m_ratio[tmp.getId()] = 3000 / INTEREST_SIZE;
m_linkC[tmp.getId()] = 10 * 1000 * 1000 * 8;
sendQueueInterest(tmp.getId());
calcRt(tmp.getId());
}
//初始化hash
@@ -51,8 +53,11 @@ namespace nfd {
void
MIRCCStrategy::sendQueueInterest(FaceId mface)
{
//设置下一次发送,根据兴趣包与数据包的大小之比,计算出兴趣包可用带宽,进而计算出每发送一个兴趣包需要的时间,最小为1ms
time::nanoseconds ttime((int)std::max((double)1,1000000000 * INTEREST_SIZE / (m_linkC[mface] * (1.0 / (m_ratio[mface] + 1)))));
//time::nanoseconds ttime((int)std::max((double)1,1000000000 * INTEREST_SIZE / (m_linkC[mface] * (1.0 / (m_ratio[mface] + 1)))));
time::nanoseconds ttime(100000000);
//NS_LOG_DEBUG(ttime);
getScheduler().schedule(ttime, bind(&MIRCCStrategy::sendQueueInterest, this, mface));
//清空队列中过期的兴趣包
@@ -62,41 +67,51 @@ namespace nfd {
if (m_Queue[mface].qp.size() > 0 and m_Queue[mface].qs.size() == 0)
{
//发送兴趣包
sendInterest(m_Queue[mface].pp.front(),FaceEndpoint(*getFaceTable().get(mface),0),m_Queue[mface].qp.front());
shared_ptr<Interest> interest = m_Queue[mface].qp.front();
sendInterest(m_Queue[mface].pp.front(),FaceEndpoint(*getFaceTable().get(mface),0),*interest);
//这个位置是不是要设置pit记录的过期时间?似乎sendInterest里面实现了这个功能
m_Queue[mface].qp.pop_front();
m_Queue[mface].tp.pop_front();
m_Queue[mface].pp.pop_front();
NS_LOG_DEBUG("MIRCCStrategy::sendQueueInterest1");
}else if (m_Queue[mface].qs.size() > 0 and m_Queue[mface].qp.size() == 0)
{
//发送兴趣包
sendInterest(m_Queue[mface].ps.front(),FaceEndpoint(*getFaceTable().get(mface),0),m_Queue[mface].qs.front());
shared_ptr<Interest> interest = m_Queue[mface].qp.front();
sendInterest(m_Queue[mface].ps.front(),FaceEndpoint(*getFaceTable().get(mface),0),*interest);
//这个位置是不是要设置pit记录的过期时间?似乎sendInterest里面实现了这个功能
m_Queue[mface].qs.pop_front();
m_Queue[mface].ts.pop_front();
m_Queue[mface].ps.pop_front();
}else
NS_LOG_DEBUG("MIRCCStrategy::sendQueueInterest2");
}else if (m_Queue[mface].qs.size() > 0 and m_Queue[mface].qp.size() > 0)
{
//如果第一类兴趣包更早到达
if (m_Queue[mface].tp.front() < m_Queue[mface].ts.front())
{
//发送兴趣包
sendInterest(m_Queue[mface].pp.front(),FaceEndpoint(*getFaceTable().get(mface),0),m_Queue[mface].qp.front());
shared_ptr<Interest> interest =m_Queue[mface].qp.front();
sendInterest(m_Queue[mface].pp.front(),FaceEndpoint(*getFaceTable().get(mface),0),*interest);
//这个位置是不是要设置pit记录的过期时间?似乎sendInterest里面实现了这个功能
m_Queue[mface].qp.pop_front();
m_Queue[mface].tp.pop_front();
m_Queue[mface].pp.pop_front();
NS_LOG_DEBUG("MIRCCStrategy::sendQueueInterest1 e");
}else
{
//发送兴趣包
sendInterest(m_Queue[mface].ps.front(),FaceEndpoint(*getFaceTable().get(mface),0),m_Queue[mface].qs.front());
shared_ptr<Interest> interest = m_Queue[mface].qp.front();
sendInterest(m_Queue[mface].ps.front(),FaceEndpoint(*getFaceTable().get(mface),0),*interest);
//这个位置是不是要设置pit记录的过期时间?似乎sendInterest里面实现了这个功能
m_Queue[mface].qs.pop_front();
m_Queue[mface].ts.pop_front();
m_Queue[mface].ps.pop_front();
NS_LOG_DEBUG("MIRCCStrategy::sendQueueInterest2 e");
}
}else
{
}
}
@@ -139,7 +154,7 @@ namespace nfd {
//Rs计算过程
uint64_t Cs = std::max(m_linkC[mface] - m_Yp[mface],(uint64_t)0);
uint64_t Ns = std::max(std::max(Cs,m_Ys[mface]) / Rs,(uint64_t)1);
uint64_t Ns = std::max(std::max(Cs,m_Ys[mface]) / std::max(Rs,(uint64_t)1) ,(uint64_t)1);
ia = m_Ys[mface] - m_Ys_old[mface];
ib = std::max(m_Ys[mface],(uint64_t)1);
@@ -199,7 +214,7 @@ namespace nfd {
void
MIRCCStrategy::pushQueueInterest(FaceId mface, const Interest &interest,const shared_ptr<pit::Entry>& pitEntry)
{
NS_LOG_DEBUG("MIRCC pushQueueInterest");
//更新Yt
updateYt(mface,interest);
@@ -218,7 +233,7 @@ namespace nfd {
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].qp.push_back(const_cast<Interest&>(interest).shared_from_this());
m_Queue[mface].tp.push_back(time::steady_clock::now());
m_Queue[mface].pp.push_back(pitEntry);
}else
@@ -230,7 +245,7 @@ namespace nfd {
}else
{
//直接将当前兴趣包加入第一类兴趣包队列末尾
m_Queue[mface].qp.push_back(interest);
m_Queue[mface].qp.push_back(const_cast<Interest&>(interest).shared_from_this());
m_Queue[mface].tp.push_back(time::steady_clock::now());
m_Queue[mface].pp.push_back(pitEntry);
}
@@ -245,7 +260,7 @@ namespace nfd {
}else
{
//将但钱兴趣包加入第二类末尾
m_Queue[mface].qs.push_back(interest);
m_Queue[mface].qs.push_back(const_cast<Interest&>(interest).shared_from_this());
m_Queue[mface].ts.push_back(time::steady_clock::now());
m_Queue[mface].ps.push_back(pitEntry);
}
@@ -271,7 +286,7 @@ namespace nfd {
void
MIRCCStrategy::afterReceiveInterest(const FaceEndpoint &ingress, const Interest &interest, const shared_ptr<pit::Entry> &pitEntry)
{//目前在按照标识路径转发,采用MIRCC论文中的方法2
NS_LOG_DEBUG("MIRCC afterReceiveInterest");
//MIRCC似乎不需要判断isNextHopEligible???
//稍微有点不理解Out-record在干啥
@@ -296,7 +311,11 @@ namespace nfd {
Face& outFace = outFaces[choosedFace].getFace();
//放入对应端口队列进行排队
this->pushQueueInterest(outFace.getId(), interest, pitEntry);
NS_LOG_DEBUG("MIRCC : outFace" << outFace.getId());
return;
}else
{
NS_LOG_DEBUG("MIRCC : outFace=0");
}
//如果发现没有端口可以转发,则设置立马删除该条pit
@@ -313,6 +332,7 @@ namespace nfd {
void
MIRCCStrategy::afterReceiveNack(const FaceEndpoint &ingress, const lp::Nack &nack, const shared_ptr<pit::Entry> &pitEntry)
{
NS_LOG_DEBUG("MIRCC afterReceiveNack");
//nack具体怎么处理还需要研究
//nack应该利用预留给data的带宽,返回给consumer
//Forwarder::onIncomingNack似乎已经把Nack返回给consumer了
@@ -322,7 +342,7 @@ namespace nfd {
MIRCCStrategy::beforeSatisfyInterest(const shared_ptr<pit::Entry> &pitEntry, const FaceEndpoint &ingress, const Data &data)
{
NS_LOG_DEBUG("MIRCC beforeSatisfyInterest");
auto now = time::steady_clock::now();
//uint64_t rcd_cnt = 0;
//目前计算中,只考虑没有过期的并成功收到数据包的兴趣包对RTT和ratio的影响,超时的数据包是否对RTT有影响?。
@@ -371,21 +391,29 @@ namespace nfd {
MIRCCStrategy::setHashForData(FaceId mface, const Data &data)
{//注意!!HopCountTag的工作情况目前不太了解,似乎ndnsim这个Tag没做处理,后续需要考虑
NS_LOG_DEBUG("MIRCC setHashForData");
//处理路径标识id
uint64_t hashOld = *data.getTag<lp::PathidTag>();
auto oldPath = data.getTag<lp::PathidTag>();
uint64_t hashOld;
if (oldPath != nullptr)
{
hashOld = *data.getTag<lp::PathidTag>();
}else{
hashOld = 0;
}
//uint64_t hashNew = (hashOld + hashUnit[data.getTag<lp::HopCountTag>()] * mface.getFace().getId() % hashMo) % hashMo;
//靠近producer的为hash值的高位
uint64_t hashNew = (hashOld * hashNum % hashMo + mface % hashMo) % hashMo;
//给data设置新的hash值
data.setTag(make_shared<lp::PathidTag>(hashNew));
}
uint64_t
MIRCCStrategy::chooseFaceForInterestByHash(const Interest &interest)
{
NS_LOG_DEBUG("MIRCC chooseFaceForInterestByHash");
uint64_t hashGuide = *interest.getTag<lp::PathidTag>();
uint64_t Faceid = hashGuide % hashMo % hashNum;
return Faceid;
@@ -396,22 +424,41 @@ namespace nfd {
MIRCCStrategy::afterReceiveData(const shared_ptr<pit::Entry> &pitEntry, const FaceEndpoint &ingress, const Data &data)
{
NS_LOG_DEBUG("MIRCC afterReceiveData");
setHashForData(ingress.face.getId(), data);
//修改Rt的值
uint64_t dataRp = *data.getTag<lp::RpTag>();
uint64_t dataRs = *data.getTag<lp::RsTag>();
if (dataRp > m_Rp_base[ingress.face.getId()] + m_Rp_ex[ingress.face.getId()])
auto oldRp = data.getTag<lp::RpTag>();
uint64_t dataRp;
if (oldRp != nullptr)
{
dataRp = *data.getTag<lp::RpTag>();
if (dataRp > m_Rp_base[ingress.face.getId()] + m_Rp_ex[ingress.face.getId()])
{
data.setTag(make_shared<lp::RpTag>(m_Rp_base[ingress.face.getId()] + m_Rp_ex[ingress.face.getId()]));
}
}else
{
data.setTag(make_shared<lp::RpTag>(m_Rp_base[ingress.face.getId()] + m_Rp_ex[ingress.face.getId()]));
}
if (dataRs > m_Rs_base[ingress.face.getId()] + m_Rs_ex[ingress.face.getId()])
auto oldRs = data.getTag<lp::RsTag>();
uint64_t dataRs;
if (oldRs != nullptr)
{
dataRs =*data.getTag<lp::RsTag>();
if (dataRs > m_Rs_base[ingress.face.getId()] + m_Rs_ex[ingress.face.getId()])
{
data.setTag(make_shared<lp::RsTag>(m_Rs_base[ingress.face.getId()] + m_Rs_ex[ingress.face.getId()]));
}
}else
{
data.setTag(make_shared<lp::RsTag>(m_Rs_base[ingress.face.getId()] + m_Rs_ex[ingress.face.getId()]));
}
beforeSatisfyInterest(pitEntry, ingress, data);
@@ -33,7 +33,7 @@ namespace nfd {
class MIRCCQueue
{
public:
std:: deque<Interest> qp,qs;
std:: deque<shared_ptr<Interest>> qp,qs;
//记录的是过期时间,非达到时间
std:: deque<time::steady_clock::TimePoint> tp,ts;
@@ -40,13 +40,15 @@ namespace nfd {
namespace fw {
NFD_LOG_INIT(SelfLearningStrategy);
NFD_REGISTER_STRATEGY(SelfLearningStrategy);
//NFD_REGISTER_STRATEGY(SelfLearningStrategy);
const time::milliseconds SelfLearningStrategy::ROUTE_RENEW_LIFETIME(10_min);
SelfLearningStrategy::SelfLearningStrategy(Forwarder& forwarder, const Name& name)
: Strategy(forwarder)
{
NS_LOG_DEBUG("trueinit");
printf("trueinit\n");
ParsedInstanceName parsed = parseInstanceName(name);
if (!parsed.parameters.empty()) {
NDN_THROW(std::invalid_argument("SelfLearningStrategy does not accept parameters"));
@@ -103,6 +105,8 @@ void
SelfLearningStrategy::afterReceiveData(const shared_ptr<pit::Entry>& pitEntry,
const FaceEndpoint& ingress, const Data& data)
{
NS_LOG_DEBUG("trueself");
printf("trueselff\n");
auto outRecord = pitEntry->getOutRecord(ingress.face);
if (outRecord == pitEntry->out_end()) {
NFD_LOG_DEBUG("Data " << data.getName() << " from=" << ingress << " no out-record");
@@ -40,7 +40,8 @@ Entry::canMatch(const Interest& interest, size_t nEqualNameComps) const
{
BOOST_ASSERT(m_interest->getName().compare(0, nEqualNameComps,
interest.getName(), 0, nEqualNameComps) == 0);
printf("boost finish%d %d %d\n",m_interest->getName().compare(nEqualNameComps, Name::npos,
interest.getName(), nEqualNameComps) == 0,m_interest->getCanBePrefix() == interest.getCanBePrefix(),m_interest->getMustBeFresh() == interest.getMustBeFresh());
return m_interest->getName().compare(nEqualNameComps, Name::npos,
interest.getName(), nEqualNameComps) == 0 &&
m_interest->getCanBePrefix() == interest.getCanBePrefix() &&
+31 -9
View File
@@ -53,7 +53,7 @@ ConsumerMIRCC::~ConsumerMIRCC()
void
ConsumerMIRCC::ScheduleNextPacket()
{
std::printf("a");
std::printf("");
// double mean = 8.0 * m_payloadSize / m_desiredRate.GetBitRate ();
// std::cout << "next: " << Simulator::Now().ToDouble(Time::S) + mean << "s\n";
/*
@@ -83,7 +83,7 @@ ConsumerMIRCC:: StopApplication()
//迭代器后移
it++;
}
Simulator::Cancel(explore_event);
// 调用父类停止face等接口服务
App::StopApplication();
}
@@ -101,6 +101,7 @@ ConsumerMIRCC:: StartApplication()
{//如果节点刚开始运行
//尝试利用随机数探索路径
PathExplorate();
explore_event = Simulator::Schedule(Seconds(1.0), &ConsumerMIRCC::PathExplorate, this);
}else
{//如果节点之前运行过,可以直接开始发送
@@ -111,7 +112,7 @@ ConsumerMIRCC:: StartApplication()
{
//为这条PathId子流发送兴趣包
SchedulePacketForPathId(it->first,1);
SchedulePacketForPathId(it->first,2);
SchedulePacketForPathId(it->first,2);
it++;
}
}
@@ -129,8 +130,8 @@ ConsumerMIRCC ::SendPacket(uint64_t pathId,uint64_t classId)
{
if (!m_active)
return;
NS_LOG_DEBUG("MIRCC SendPacket");
uint32_t seq = std::numeric_limits<uint32_t>::max(); // invalid
printf("test\n");
//处理重传兴趣包
//所以重传未必是用之前的子流重传,可能是新的子流
@@ -230,7 +231,7 @@ ConsumerMIRCC:: SchedulePacketForPathId(uint64_t pathId,uint64_t classId)
if (classId == 1)
{//发送第一类兴趣包,参考当先path的Rp在所有Rp之和的占比 乘上最大Rp
//计算发送速度
uint64_t tmpRp = pathId2Rp[pathId] / SumRp() * MaxRp();
uint64_t tmpRp = pathId2Rp[pathId] / std::max(SumRp() * MaxRp(),(uint64_t)1);
//发送
SendPacket(pathId,classId);
//预定下一次发送事件
@@ -254,7 +255,7 @@ ConsumerMIRCC:: PathExplorate()
{
//路径探索的兴趣包全部标为第一类,原论文没有明确说,但是我觉得这样更合理
//因为用于路径探索的兴趣包很重要,如果被丢掉了,consumer可能迟迟无法开始正式发送兴趣包
pathId2RandomId[0] = m_rand->GetValue(0, std::numeric_limits<uint32_t>::max());
pathId2RandomId[0] = m_rand->GetValue(0.00001, std::numeric_limits<uint32_t>::max());
//PathId为-1表示正在进行路径探索
SendPacket(0,1);
@@ -287,6 +288,7 @@ ConsumerMIRCC::tryBindRandId(uint64_t seq, uint64_t pathId)
void
ConsumerMIRCC::OnData(shared_ptr<const Data> data)
{
NS_LOG_FUNCTION(this << data);
if (!m_active)
return;
@@ -294,6 +296,7 @@ ConsumerMIRCC::OnData(shared_ptr<const Data> data)
NS_LOG_FUNCTION(this << data);
// NS_LOG_INFO ("Received content object: " << boost::cref(*data));
// This could be a problem......
@@ -301,21 +304,40 @@ ConsumerMIRCC::OnData(shared_ptr<const Data> data)
NS_LOG_INFO("< DATA for " << seq);
//查看当前数据包是否有探索兴趣包产生,如果是的话将探索出的pathid和对应的randId绑定
printf("pathid IN");
auto tmpPathid = data->getTag<lp::PathidTag>();
if (tmpPathid != nullptr)
{
tryBindRandId(seq, *tmpPathid);
}
printf("pathid OUT");
int hopCount = 0;
auto hopCountTag = data->getTag<lp::HopCountTag>();
if (hopCountTag != nullptr) { // e.g., packet came from local node's cache
hopCount = *hopCountTag;
}
NS_LOG_DEBUG("Hop count: " << hopCount);
NS_LOG_DEBUG("Hop count!!: " << hopCount);
uint64_t Rp = 0;
auto rpTag = data->getTag<lp::RpTag>();
if (rpTag != nullptr)
{
Rp = *rpTag;
}
pathId2Rp[*tmpPathid] = Rp;
NS_LOG_INFO("Rp: " << Rp);
uint64_t Rs = 0;
auto rsTag = data->getTag<lp::RsTag>();
if (rsTag != nullptr)
{
Rs = *rsTag;
}
pathId2Rs[*tmpPathid] = Rs;
NS_LOG_INFO("Rs: " << Rs);
SeqTimeoutsContainer::iterator entry = m_seqLastDelay.find(seq);
if (entry != m_seqLastDelay.end()) {
+3
View File
@@ -9,6 +9,7 @@
#include <unordered_map>
#include <ndn-cxx/lp/tags.hpp>
namespace ns3 {
namespace ndn {
@@ -99,6 +100,8 @@ private:
void recordSeq(uint64_t seq,uint64_t randId);
void SendPacket(uint64_t pathId,uint64_t classId);
EventId explore_event;
};
@@ -22,7 +22,8 @@
#include "ns3/core-module.h"
#include "ns3/network-module.h"
#include "ns3/ndnSIM-module.h"
#include "../src/ndnSIM/NFD/daemon/fw/mircc-strategy.hpp"
#include "../src/ndnSIM/NFD/daemon/fw/self-learning-strategy.hpp"
namespace ns3 {
/**
@@ -62,7 +63,9 @@ main(int argc, char* argv[])
ndnHelper.InstallAll();
// Choosing forwarding strategy
ndn::StrategyChoiceHelper::InstallAll("/prefix", "/localhost/nfd/strategy/MIRCCStrategy");
ndn::StrategyChoiceHelper::InstallAll<nfd::fw::MIRCCStrategy>("/");
//ndn::StrategyChoiceHelper::InstallAll<nfd::fw::SelfLearningStrategy>("/prefix");
//ndn::StrategyChoiceHelper::InstallAll("/prefix", "/localhost/nfd/strategy/best-route-strategy");
// Installing global routing interface on all nodes
ndn::GlobalRoutingHelper ndnGlobalRoutingHelper;
@@ -76,6 +79,7 @@ main(int argc, char* argv[])
Ptr<Node> producer2 = Names::Find<Node>("Dst2");
ndn::AppHelper consumerHelper("ns3::ndn::ConsumerMIRCC");
//ndn::AppHelper consumerHelper("ns3::ndn::ConsumerCbr");
consumerHelper.SetAttribute("MaxSeq", StringValue("10000000")); // 100 interests a second
// on the first consumer node install a Consumer application
+114
View File
@@ -0,0 +1,114 @@
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
/**
* Copyright (c) 2011-2015 Regents of the University of California.
*
* This file is part of ndnSIM. See AUTHORS for complete list of ndnSIM authors and
* contributors.
*
* ndnSIM is free software: you can redistribute it and/or modify it under the terms
* of the GNU General Public License as published by the Free Software Foundation,
* either version 3 of the License, or (at your option) any later version.
*
* ndnSIM is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY;
* without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
* PURPOSE. See the GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License along with
* ndnSIM, e.g., in COPYING.md file. If not, see <http://www.gnu.org/licenses/>.
**/
// ndn-congestion-topo-plugin.cpp
#include "ns3/core-module.h"
#include "ns3/network-module.h"
#include "ns3/ndnSIM-module.h"
#include "../src/ndnSIM/NFD/daemon/fw/mircc-strategy.hpp"
#include "../src/ndnSIM/NFD/daemon/fw/self-learning-strategy.hpp"
namespace ns3 {
/**
* This scenario simulates a grid topology (using topology reader module)
*
* /------\ /------\
* | Src1 |<--+ +-->| Dst1 |
* \------/ \ / \------/
* \ /
* +-->/------\ "bottleneck" /------\<-+
* | Rtr1 |<===============>| Rtr2 |
* +-->\------/ \------/<-+
* / \
* /------\ / \ /------\
* | Src2 |<--+ +-->| Dst2 |
* \------/ \------/
*
* To run scenario and see what is happening, use the following command:
*
* NS_LOG=ndn.Consumer:ndn.Producer ./waf --run=ndn-congestion-topo-plugin
*/
int
main(int argc, char* argv[])
{
CommandLine cmd;
cmd.Parse(argc, argv);
AnnotatedTopologyReader topologyReader("", 25);
topologyReader.SetFileName("src/ndnSIM/examples/topologies/topo-4-node.txt");
topologyReader.Read();
// Install NDN stack on all nodes
ndn::StackHelper ndnHelper;
ndnHelper.setPolicy("nfd::cs::lru");
ndnHelper.setCsSize(10000);
ndnHelper.InstallAll();
// Choosing forwarding strategy
ndn::StrategyChoiceHelper::InstallAll<nfd::fw::MIRCCStrategy>("/");
//ndn::StrategyChoiceHelper::InstallAll<nfd::fw::SelfLearningStrategy>("/prefix");
//ndn::StrategyChoiceHelper::InstallAll("/prefix", "/localhost/nfd/strategy/best-route-strategy");
// Installing global routing interface on all nodes
ndn::GlobalRoutingHelper ndnGlobalRoutingHelper;
ndnGlobalRoutingHelper.InstallAll();
// Getting containers for the consumer/producer
Ptr<Node> consumer1 = Names::Find<Node>("Src1");
Ptr<Node> producer1 = Names::Find<Node>("Dst1");
ndn::AppHelper consumerHelper("ns3::ndn::ConsumerMIRCC");
//ndn::AppHelper consumerHelper("ns3::ndn::ConsumerCbr");
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
consumerHelper.SetPrefix("/dst1");
consumerHelper.Install(consumer1);
ndn::AppHelper producerHelper("ns3::ndn::Producer");
producerHelper.SetAttribute("PayloadSize", StringValue("1024"));
// Register /dst1 prefix with global routing controller and
// install producer that will satisfy Interests in /dst1 namespace
ndnGlobalRoutingHelper.AddOrigins("/dst1", producer1);
producerHelper.SetPrefix("/dst1");
producerHelper.Install(producer1);
// Calculate and install FIBs
ndn::GlobalRoutingHelper::CalculateRoutes();
Simulator::Stop(Seconds(20.0));
Simulator::Run();
Simulator::Destroy();
return 0;
}
} // namespace ns3
int
main(int argc, char* argv[])
{
return ns3::main(argc, argv);
}
@@ -0,0 +1,24 @@
# topo-4-node.txt
# /------\0 /------\3
# | Src1 |<--+ +-->| Dst1 |
# \------/ \ / \------/
# \ /
# +-->/------\1 "bottleneck" /------\2<-+
# | Rtr1 |<===============>| Rtr2 |
# \------/ \------/
router
# node comment yPos xPos
Src1 NA 1 3
Rtr1 NA 2 5
Rtr2 NA 2 7
Dst1 NA 1 9
link
# srcNode dstNode bandwidth metric delay queue
Src1 Rtr1 10Mbps 1 10ms 20
Rtr1 Rtr2 1Mbps 1 10ms 20
Dst1 Rtr2 10Mbps 1 10ms 20
@@ -1,15 +1,14 @@
# topo-6-node.txt
# /------\ /------\
# /------\ 0 /------\4
# | Src1 |<--+ +-->| Dst1 |
# \------/ \ / \------/
# \ /
# \ 2 3 /
# +-->/------\ "bottleneck" /------\<-+
# | Rtr1 |<===============>| Rtr2 |
# +-->\------/ \------/<-+
# / \
# /------\ / \ /------\
# | Src2 |<--+ +-->| Dst2 |
# /------\ / \ /------\5
# | Src2 |<--+ 1 +-->| Dst2 |
# \------/ \------/
router