Fixed some known issues, mainly in the consumer

This commit is contained in:
Lv committed 2022-04-16 09:33:03 +08:00
1 parent b74b0ac7c2
commit ed0627cc54
4 files changed
+31 -36

No files matched your search

@@ -197,7 +197,7 @@ namespace nfd {
}
void
MIRCCStrategy::pushQueueInterest(Face &mface, const Interest &interest,const shared_ptr<pit::Entry>& pitEntry)
MIRCCStrategy::pushQueueInterest(FaceId mface, const Interest &interest,const shared_ptr<pit::Entry>& 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<lp::PTag>();
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<lp::PathidTag>();
//uint64_t hashNew = (hashOld + hashUnit[data.getTag<lp::HopCountTag>()] * 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<lp::PathidTag>(hashNew));
@@ -396,7 +396,7 @@ namespace nfd {
MIRCCStrategy::afterReceiveData(const shared_ptr<pit::Entry> &pitEntry, const FaceEndpoint &ingress, const Data &data)
{
setHashForData(ingress.face, data);
setHashForData(ingress.face.getId(), data);
//修改Rt的值
uint64_t dataRp = *data.getTag<lp::RpTag>();
@@ -118,7 +118,7 @@ namespace nfd {
//将兴趣包放入对应端口的队列
void
pushQueueInterest(Face &ingress, const Interest &interest,const shared_ptr<pit::Entry>& pitEntry);
pushQueueInterest(FaceId mface, const Interest &interest,const shared_ptr<pit::Entry>& 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
+2 -7
View File
@@ -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<uint32_t>::max(); // invalid
printf("test\n");
//处理重传兴趣包
//所以重传未必是用之前的子流重传,可能是新的子流
@@ -255,15 +254,11 @@ ConsumerMIRCC:: PathExplorate()
{
//路径探索的兴趣包全部标为第一类,原论文没有明确说,但是我觉得这样更合理
//因为用于路径探索的兴趣包很重要,如果被丢掉了,consumer可能迟迟无法开始正式发送兴趣包
pathId2RandomId[-1] = m_rand->GetValue(0, std::numeric_limits<uint32_t>::max());
pathId2RandomId[0] = m_rand->GetValue(0, std::numeric_limits<uint32_t>::max());
//PathId为-1表示正在进行路径探索
SendPacket(0,1);
//我们需要记录一下这个随机数用来探索路径了,记录其对应的seq编号
//用于在收到data时,将新的路径记录下来。
//还没有写完。
}
void
@@ -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<Node> producer1 = Names::Find<Node>("Dst1");
Ptr<Node> producer2 = Names::Find<Node>("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