fix: 修复链路利用率计算不准确问题;ConsumerMIRCC 修复seq2P结构内存未释放问题

This commit is contained in:
SunnyQjm committed 2022-06-25 16:35:20 +08:00
1 parent e4763b35ab
commit b5b9169297
9 files changed
+327 -92

No files matched your search

+17 -6
View File
@@ -206,14 +206,14 @@ ConsumerMIRCC ::StartGreedy()
}
void
ConsumerMIRCC ::recordSeq(uint64_t seq,uint64_t randId)
ConsumerMIRCC::recordSeq(uint64_t seq,uint64_t randId)
{//记录seq到当时使用的randId
seq2RandomId[seq] = randId;
return;
}
void
ConsumerMIRCC ::SendPacket(uint64_t pathId,uint64_t classId)
ConsumerMIRCC::SendPacket(uint64_t pathId,uint64_t classId)
{
if (!m_active)
return;
@@ -330,7 +330,7 @@ ConsumerMIRCC:: MaxRp()
}
void
ConsumerMIRCC:: SchedulePacketForPathId(uint64_t pathId,uint64_t classId)
ConsumerMIRCC::SchedulePacketForPathId(uint64_t pathId,uint64_t classId)
{
SendPacket(pathId,classId);
if (classId == 1)
@@ -497,6 +497,7 @@ ConsumerMIRCC::OnData(shared_ptr<const Data> data)
{
pktcnt_s += 1;
}
seq2P.erase(seq);
@@ -550,9 +551,19 @@ ConsumerMIRCC::OnData(shared_ptr<const Data> data)
m_seqTimeouts.erase(seq);
m_retxSeqs.erase(seq);
}
void
Consumer::OnTimeout(uint32_t sequenceNumber) {
NS_LOG_FUNCTION(sequenceNumber);
// std::cout << Simulator::Now () << ", TO: " << sequenceNumber << ", current RTO: " <<
// m_rtt->RetransmitTimeout ().ToDouble (Time::S) << "s\n";
m_rtt->IncreaseMultiplier(); // Double the next RTO
m_rtt->SentSeq(SequenceNumber32(sequenceNumber),
1); // make sure to disable RTT calculation for this sample
m_retxSeqs.insert(sequenceNumber);
ScheduleNextPacket();
}
}// namespace ndn
} // namespace ns3
+3
View File
@@ -52,6 +52,9 @@ protected:
void
OnData(shared_ptr<const Data> data) override;
void
OnTimeout(uint32_t sequenceNumber)
protected:
//这两个目前没有用处
double m_frequency; // Frequency of interest packets (in hertz)
+66 -1
View File
@@ -5,6 +5,71 @@
"deque": "cpp",
"string": "cpp",
"vector": "cpp",
"list": "cpp"
"list": "cpp",
"cctype": "cpp",
"clocale": "cpp",
"cmath": "cpp",
"csignal": "cpp",
"cstdarg": "cpp",
"cstddef": "cpp",
"cstdio": "cpp",
"cstdlib": "cpp",
"cstring": "cpp",
"ctime": "cpp",
"cwchar": "cpp",
"cwctype": "cpp",
"any": "cpp",
"array": "cpp",
"atomic": "cpp",
"hash_map": "cpp",
"strstream": "cpp",
"bit": "cpp",
"*.tcc": "cpp",
"bitset": "cpp",
"chrono": "cpp",
"codecvt": "cpp",
"complex": "cpp",
"condition_variable": "cpp",
"cstdint": "cpp",
"map": "cpp",
"set": "cpp",
"unordered_map": "cpp",
"unordered_set": "cpp",
"exception": "cpp",
"algorithm": "cpp",
"functional": "cpp",
"iterator": "cpp",
"memory": "cpp",
"memory_resource": "cpp",
"numeric": "cpp",
"optional": "cpp",
"random": "cpp",
"ratio": "cpp",
"string_view": "cpp",
"system_error": "cpp",
"tuple": "cpp",
"type_traits": "cpp",
"utility": "cpp",
"fstream": "cpp",
"future": "cpp",
"initializer_list": "cpp",
"iomanip": "cpp",
"iosfwd": "cpp",
"iostream": "cpp",
"istream": "cpp",
"limits": "cpp",
"mutex": "cpp",
"new": "cpp",
"ostream": "cpp",
"sstream": "cpp",
"stdexcept": "cpp",
"streambuf": "cpp",
"thread": "cpp",
"cfenv": "cpp",
"cinttypes": "cpp",
"typeindex": "cpp",
"typeinfo": "cpp",
"valarray": "cpp",
"variant": "cpp"
}
}
+4 -4
View File
@@ -137,7 +137,7 @@ namespace nfd {
// NS_LOG_DEBUG(" Bp: " << Bp);
ia = m_miu * m_linkC[inface(mface)] - Bp * getQt(mface) / std::max((double)m_d[inface(mface)],(double)0.001);
ia = m_linkC[inface(mface)] - Bp * getQt(mface) / std::max((double)m_d[inface(mface)],(double)0.001);
// NS_LOG_DEBUG("Qt "<< getQt(mface) << " ia " << ia);
db = std::max(Np,(double)1);
long long Rp_base_n = std::min(std::max(ia / db,0.0),m_linkC[inface(mface)] / Np);
@@ -175,7 +175,7 @@ namespace nfd {
double Bs = std::max(m_B,(double)ia / ib);
ia = m_miu * Cs - Bs * getQt(mface) / std::max(m_d[inface(mface)],(double)0.001);
ia = Cs - Bs * getQt(mface) / std::max(m_d[inface(mface)],(double)0.001);
// NS_LOG_DEBUG(" ia: " << ia);
db = Ns;
@@ -376,11 +376,11 @@ namespace nfd {
auto FaceRateTag = data.getTag<lp::PTag>();
if (FaceRateTag != nullptr)
{
m_linkC[inface(ingress.face.getId())] = *FaceRateTag;
m_linkC[inface(ingress.face.getId())] = m_miu * (*FaceRateTag);
}else
{
//认定为app线路,速率设置为100MB/s
m_linkC[inface(ingress.face.getId())] = 8 * 100 * 1000 * 1000;
m_linkC[inface(ingress.face.getId())] = m_miu * 8 * 100 * 1000 * 1000;
}
//修改Rt的值
+1 -1
View File
@@ -58,7 +58,7 @@ namespace nfd {
const uint64_t MAX_QUEUE = 10;//固定队列大小
const double m_B = 0.1;//公式B系数
const double m_a = 0.5;//速率更新系数
const double m_a = 0.8;//速率更新系数
const double m_miu = 0.99;//链路利用率
const double m_rtt_a = 0.7;//RTT更新系数
+8 -18
View File
@@ -2,7 +2,6 @@
#include "ns3/network-module.h"
#include "ns3/ndnSIM-module.h"
#include "../extensions/mircc-strategy.hpp"
#include "../extensions/PCONStrategy.hpp"
namespace ns3
{
@@ -26,7 +25,6 @@ namespace ns3
// Choosing forwarding strategy
ndn::StrategyChoiceHelper::InstallAll<nfd::fw::MIRCCStrategy>("/");
// ndn::StrategyChoiceHelper::InstallAll<nfd::fw::PCONStrategy>("/");
// Installing global routing interface on all nodes
ndn::GlobalRoutingHelper ndnGlobalRoutingHelper;
@@ -44,33 +42,25 @@ namespace ns3
ndn::AppHelper consumerHelper("ns3::ndn::ConsumerMIRCC");
consumerHelper.SetAttribute("logtms",StringValue("0"));
// consumerHelper.SetAttribute("NumberOfContents", UintegerValue(100000));
consumerHelper.SetAttribute("start_ms",StringValue("0"));
consumerHelper.SetAttribute("end_ms",StringValue("200000"));
// C1
consumerHelper.SetPrefix("/A");
consumerHelper.SetAttribute("appid",StringValue("1"));
consumerHelper.SetAttribute("start_ms",StringValue("0"));
consumerHelper.SetAttribute("end_ms",StringValue("200000"));
consumerHelper.Install("C1");
// C2
consumerHelper.SetPrefix("/B");
// consumerHelper.SetAttribute("DelayStart", UintegerValue(30000)); // 延迟10秒启动
consumerHelper.SetAttribute("start_ms",StringValue("30000"));
consumerHelper.SetAttribute("end_ms",StringValue("200000"));
consumerHelper.SetAttribute("appid",StringValue("2"));
consumerHelper.Install("C2");
// C3
consumerHelper.SetPrefix("/C");
// consumerHelper.SetAttribute("DelayStart", UintegerValue(60000)); // 延迟20秒启动
// consumerHelper.SetAttribute("DelayGreedy", IntegerValue(150000));
// consumerHelper.SetAttribute("GreedyRate", IntegerValue(6000000));
consumerHelper.SetAttribute("greedy_ms",StringValue("150000"));
consumerHelper.SetAttribute("greedy_rate",StringValue("6000000"));
consumerHelper.SetAttribute("start_ms",StringValue("60000"));
consumerHelper.SetAttribute("end_ms",StringValue("200000"));
consumerHelper.SetAttribute("appid",StringValue("3"));
consumerHelper.SetAttribute("greedy_ms",StringValue("150000"));
consumerHelper.SetAttribute("greedy_rate",StringValue("6000000"));
consumerHelper.Install("C3");
@@ -124,9 +114,9 @@ namespace ns3
Simulator::Stop(Seconds(200.0));
ndn::L3RateTracer::InstallAll("dsccp3-1-zipf_throughput.txt", Seconds(0.5));
ndn::AppDelayTracer::InstallAll("dsccp3-1-zipf_delay.txt");
L2RateTracer::InstallAll("dsccp3-1-zipf_drop.txt", Seconds(0.5));
ndn::L3RateTracer::InstallAll("dsccp3-1_throughput.txt", Seconds(0.1));
ndn::AppDelayTracer::InstallAll("dsccp3-1_delay.txt");
L2RateTracer::InstallAll("dsccp3-1_drop.txt", Seconds(0.1));
Simulator::Run();
Simulator::Destroy();
@@ -138,4 +128,4 @@ namespace ns3
int main(int argc, char *argv[])
{
return ns3::main(argc, argv);
}
}
+131
View File
@@ -0,0 +1,131 @@
#include "ns3/core-module.h"
#include "ns3/network-module.h"
#include "ns3/ndnSIM-module.h"
#include "../extensions/mircc-strategy.hpp"
namespace ns3
{
int
main(int argc, char *argv[])
{
CommandLine cmd;
cmd.Parse(argc, argv);
AnnotatedTopologyReader topologyReader("", 25);
topologyReader.SetFileName("topologies/dsccp3-2.txt");
topologyReader.Read();
// Install NDN stack on all nodes
ndn::StackHelper ndnHelper;
ndnHelper.setPolicy("nfd::cs::lru");
// ndnHelper.setCsSize(10000);
ndnHelper.setCsSize(0);
ndnHelper.InstallAll();
// Choosing forwarding strategy
ndn::StrategyChoiceHelper::InstallAll<nfd::fw::MIRCCStrategy>("/");
// Installing global routing interface on all nodes
ndn::GlobalRoutingHelper ndnGlobalRoutingHelper;
ndnGlobalRoutingHelper.InstallAll();
// Getting containers for the consumer/producer
Ptr<Node> C1 = Names::Find<Node>("C1");
Ptr<Node> C2 = Names::Find<Node>("C2");
Ptr<Node> C3 = Names::Find<Node>("C3");
Ptr<Node> P1 = Names::Find<Node>("P1");
Ptr<Node> P2 = Names::Find<Node>("P2");
Ptr<Node> P3 = Names::Find<Node>("P3");
Ptr<Node> P4 = Names::Find<Node>("P4");
ndn::AppHelper consumerHelper("ns3::ndn::ConsumerMIRCC");
consumerHelper.SetAttribute("logtms",StringValue("0"));
consumerHelper.SetAttribute("start_ms",StringValue("0"));
consumerHelper.SetAttribute("end_ms",StringValue("200000"));
// C1
consumerHelper.SetPrefix("/A");
consumerHelper.Install("C1");
// C2
consumerHelper.SetPrefix("/B");
consumerHelper.SetAttribute("start_ms",StringValue("30000"));
consumerHelper.SetAttribute("end_ms",StringValue("200000"));
consumerHelper.Install("C2");
// C3
consumerHelper.SetPrefix("/C");
consumerHelper.SetAttribute("start_ms",StringValue("60000"));
consumerHelper.SetAttribute("end_ms",StringValue("200000"));
consumerHelper.SetAttribute("greedy_ms",StringValue("150000"));
consumerHelper.SetAttribute("greedy_rate",StringValue("6000000"));
consumerHelper.Install("C3");
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
// P1
ndnGlobalRoutingHelper.AddOrigins("/A", P1);
ndnGlobalRoutingHelper.AddOrigins("/B", P2);
ndnGlobalRoutingHelper.AddOrigins("/C", P3);
ndnGlobalRoutingHelper.AddOrigins("/A", P4);
ndnGlobalRoutingHelper.AddOrigins("/B", P4);
ndnGlobalRoutingHelper.AddOrigins("/C", P4);
producerHelper.SetPrefix("/A");
producerHelper.Install(P1);
producerHelper.Install(P4);
producerHelper.SetPrefix("/B");
producerHelper.Install(P2);
producerHelper.Install(P4);
producerHelper.SetPrefix("/C");
producerHelper.Install(P3);
producerHelper.Install(P4);
// Calculate all possible routes and install FIBs
ndn::GlobalRoutingHelper::CalculateRoutes();
ndn::FibHelper::AddRoute("R2", "/A", "R3", 0);
ndn::FibHelper::AddRoute("R2", "/B", "R3", 0);
ndn::FibHelper::AddRoute("R2", "/C", "R3", 0);
ndn::FibHelper::AddRoute("R2", "/A", "R4", 0);
ndn::FibHelper::AddRoute("R2", "/B", "R4", 0);
ndn::FibHelper::AddRoute("R2", "/C", "R4", 0);
ndn::FibHelper::AddRoute("R2", "/A", "R5", 0);
ndn::FibHelper::AddRoute("R2", "/B", "R5", 0);
ndn::FibHelper::AddRoute("R2", "/C", "R5", 0);
ndn::FibHelper::AddRoute("R4", "/A", "R3", 0);
ndn::FibHelper::AddRoute("R4", "/B", "R3", 0);
ndn::FibHelper::AddRoute("R4", "/C", "R3", 0);
ndn::FibHelper::AddRoute("R4", "/A", "R5", 0);
ndn::FibHelper::AddRoute("R4", "/B", "R5", 0);
ndn::FibHelper::AddRoute("R4", "/C", "R5", 0);
Simulator::Stop(Seconds(200.0));
ndn::L3RateTracer::InstallAll("dsccp3-2_throughput.txt", Seconds(0.1));
ndn::AppDelayTracer::InstallAll("dsccp3-2_delay.txt");
L2RateTracer::InstallAll("dsccp3-2_drop.txt", Seconds(0.1));
Simulator::Run();
Simulator::Destroy();
return 0;
}
} // namespace ns3
int main(int argc, char *argv[])
{
return ns3::main(argc, argv);
}
+62 -62
View File
@@ -20,7 +20,7 @@ namespace ns3
ndn::StackHelper ndnHelper;
ndnHelper.setPolicy("nfd::cs::lru");
// ndnHelper.setCsSize(10000);
ndnHelper.setCsSize(1000);
ndnHelper.setCsSize(0);
ndnHelper.InstallAll();
// Choosing forwarding strategy
@@ -50,93 +50,93 @@ namespace ns3
consumerHelper.SetAttribute("start_ms",StringValue("0"));
consumerHelper.SetAttribute("end_ms",StringValue("60000"));
// // /Amazon
// consumerHelper.SetPrefix("/Amazon");
// consumerHelper.Install(C1);
// consumerHelper.Install(C2);
// consumerHelper.Install(C3);
// consumerHelper.Install(C4);
// consumerHelper.Install(C5);
// consumerHelper.Install(C6);
// consumerHelper.Install(C7);
// consumerHelper.Install(C8);
// // /Google
// consumerHelper.SetPrefix("/Google");
// consumerHelper.Install(C1);
// consumerHelper.Install(C2);
// consumerHelper.Install(C3);
// consumerHelper.Install(C4);
// consumerHelper.Install(C5);
// consumerHelper.Install(C6);
// consumerHelper.Install(C7);
// consumerHelper.Install(C8);
// // /Warner
// consumerHelper.SetPrefix("/Warner");
// consumerHelper.Install(C1);
// consumerHelper.Install(C2);
// consumerHelper.Install(C3);
// consumerHelper.Install(C4);
// consumerHelper.Install(C5);
// consumerHelper.Install(C6);
// consumerHelper.Install(C7);
// consumerHelper.Install(C8);
// /Amazon
consumerHelper.SetPrefix("/Amazon/1");
consumerHelper.SetPrefix("/Amazon");
consumerHelper.Install(C1);
consumerHelper.SetPrefix("/Amazon/2");
consumerHelper.Install(C2);
consumerHelper.SetPrefix("/Amazon/3");
consumerHelper.Install(C3);
consumerHelper.SetPrefix("/Amazon/4");
consumerHelper.Install(C4);
consumerHelper.SetPrefix("/Amazon/5");
consumerHelper.Install(C5);
consumerHelper.SetPrefix("/Amazon/6");
consumerHelper.Install(C6);
consumerHelper.SetPrefix("/Amazon/7");
consumerHelper.Install(C7);
consumerHelper.SetPrefix("/Amazon/8");
consumerHelper.Install(C8);
// /Google
consumerHelper.SetPrefix("/Google/1");
consumerHelper.SetPrefix("/Google");
consumerHelper.Install(C1);
consumerHelper.SetPrefix("/Google/2");
consumerHelper.Install(C2);
consumerHelper.SetPrefix("/Google/3");
consumerHelper.Install(C3);
consumerHelper.SetPrefix("/Google/4");
consumerHelper.Install(C4);
consumerHelper.SetPrefix("/Google/5");
consumerHelper.Install(C5);
consumerHelper.SetPrefix("/Google/6");
consumerHelper.Install(C6);
consumerHelper.SetPrefix("/Google/7");
consumerHelper.Install(C7);
consumerHelper.SetPrefix("/Google/8");
consumerHelper.Install(C8);
// /Warner
consumerHelper.SetPrefix("/Warner/1");
consumerHelper.SetPrefix("/Warner");
consumerHelper.Install(C1);
consumerHelper.SetPrefix("/Warner/2");
consumerHelper.Install(C2);
consumerHelper.SetPrefix("/Warner/3");
consumerHelper.Install(C3);
consumerHelper.SetPrefix("/Warner/4");
consumerHelper.Install(C4);
consumerHelper.SetPrefix("/Warner/5");
consumerHelper.Install(C5);
consumerHelper.SetPrefix("/Warner/6");
consumerHelper.Install(C6);
consumerHelper.SetPrefix("/Warner/7");
consumerHelper.Install(C7);
consumerHelper.SetPrefix("/Warner/8");
consumerHelper.Install(C8);
// // /Amazon
// consumerHelper.SetPrefix("/Amazon/1");
// consumerHelper.Install(C1);
// consumerHelper.SetPrefix("/Amazon/2");
// consumerHelper.Install(C2);
// consumerHelper.SetPrefix("/Amazon/3");
// consumerHelper.Install(C3);
// consumerHelper.SetPrefix("/Amazon/4");
// consumerHelper.Install(C4);
// consumerHelper.SetPrefix("/Amazon/5");
// consumerHelper.Install(C5);
// consumerHelper.SetPrefix("/Amazon/6");
// consumerHelper.Install(C6);
// consumerHelper.SetPrefix("/Amazon/7");
// consumerHelper.Install(C7);
// consumerHelper.SetPrefix("/Amazon/8");
// consumerHelper.Install(C8);
// // /Google
// consumerHelper.SetPrefix("/Google/1");
// consumerHelper.Install(C1);
// consumerHelper.SetPrefix("/Google/2");
// consumerHelper.Install(C2);
// consumerHelper.SetPrefix("/Google/3");
// consumerHelper.Install(C3);
// consumerHelper.SetPrefix("/Google/4");
// consumerHelper.Install(C4);
// consumerHelper.SetPrefix("/Google/5");
// consumerHelper.Install(C5);
// consumerHelper.SetPrefix("/Google/6");
// consumerHelper.Install(C6);
// consumerHelper.SetPrefix("/Google/7");
// consumerHelper.Install(C7);
// consumerHelper.SetPrefix("/Google/8");
// consumerHelper.Install(C8);
// // /Warner
// consumerHelper.SetPrefix("/Warner/1");
// consumerHelper.Install(C1);
// consumerHelper.SetPrefix("/Warner/2");
// consumerHelper.Install(C2);
// consumerHelper.SetPrefix("/Warner/3");
// consumerHelper.Install(C3);
// consumerHelper.SetPrefix("/Warner/4");
// consumerHelper.Install(C4);
// consumerHelper.SetPrefix("/Warner/5");
// consumerHelper.Install(C5);
// consumerHelper.SetPrefix("/Warner/6");
// consumerHelper.Install(C6);
// consumerHelper.SetPrefix("/Warner/7");
// consumerHelper.Install(C7);
// consumerHelper.SetPrefix("/Warner/8");
// consumerHelper.Install(C8);
ndn::AppHelper producerHelper("ns3::ndn::Producer");
producerHelper.SetAttribute("PayloadSize", StringValue("1024"));
@@ -260,9 +260,9 @@ namespace ns3
Simulator::Stop(Seconds(60.0));
ndn::L3RateTracer::InstallAll("dsccp4-1-mircc_throughput-no-pit-merge.txt", Seconds(0.1));
ndn::AppDelayTracer::InstallAll("dsccp4-1-mircc_delay-no-pit-merge.txt");
L2RateTracer::InstallAll("dsccp4-1-mircc_drop-no-pit-merge.txt", Seconds(0.1));
ndn::L3RateTracer::InstallAll("dsccp4-1-mircc_throughput-pit-merge.txt", Seconds(0.1));
ndn::AppDelayTracer::InstallAll("dsccp4-1-mircc_delay--pit-merge.txt");
L2RateTracer::InstallAll("dsccp4-1-mircc_drop-pit-merge.txt", Seconds(0.1));
Simulator::Run();
Simulator::Destroy();
@@ -274,4 +274,4 @@ namespace ns3
int main(int argc, char *argv[])
{
return ns3::main(argc, argv);
}
}
+35
View File
@@ -0,0 +1,35 @@
router
# node comment yPos xPos
R1 NA 5 3
R2 NA 5 5
R4 NA 5 7
R6 NA 5 9
C1 NA 7 1
C2 NA 5 1
C3 NA 3 1
P1 NA 8 11
P2 NA 6 11
P3 NA 4 11
P4 NA 2 11
R3 NA 7 8
R5 NA 3 8
link
# srcNode dstNode bandwidth metric delay queue
C1 R1 100Mbps 1 10ms 20
C2 R1 100Mbps 1 10ms 20
C3 R1 100Mbps 1 10ms 20
R6 P1 100Mbps 1 10ms 20
R6 P2 100Mbps 1 10ms 20
R6 P3 100Mbps 1 10ms 20
R6 P4 100Mbps 1 10ms 20
R1 R2 8Mbps 1 10ms 20
R5 R6 5Mbps 1 10ms 20
R2 R3 2.5Mbps 1 10ms 20
R2 R4 5Mbps 1 10ms 20
R3 R6 5Mbps 1 5ms 20
R4 R3 2.5Mbps 1 5ms 20
R4 R5 2.5Mbps 1 5ms 20
R2 R5 2.5Mbps 1 20ms 20