From 6b7c86c65492603f3ea2d9f18b3912e268feda57 Mon Sep 17 00:00:00 2001 From: SunnyQjm Date: Tue, 21 Jun 2022 21:23:33 +0800 Subject: [PATCH] update --- ns-3/.vscode/settings.json | 6 + ns-3/src/ndnSIM/apps/mircc-consumer.cpp | 22 +- ns-3/src/ndnSIM/apps/ndn-consumer-nwfq.cpp | 37 --- ns-3/src/ndnSIM/apps/ndn-consumer-nwfq.hpp | 30 -- ns-3/src/ndnSIM/apps/ndn-consumer-pcon.cpp | 4 + ns-3/src/ndnSIM/apps/ndn-consumer-window.cpp | 98 +++++-- ns-3/src/ndnSIM/apps/ndn-consumer-window.hpp | 17 ++ pybindgen | 2 +- scenario/.gitignore | 1 + scenario/.vscode/settings.json | 10 + scenario/extensions/PCONStrategy.cpp | 206 +++++++++++++ scenario/extensions/PCONStrategy.hpp | 150 ++++++++++ scenario/extensions/mircc-strategy.cpp | 50 ++-- scenario/extensions/mircc-strategy.hpp | 2 +- scenario/extensions/mt-forward-info.hpp | 115 ++++++++ .../scenarios/{ => disabled}/ndn-test.cpp | 0 .../scenarios/{ => disabled}/ndn-test2.cpp | 0 .../scenarios/{ => disabled}/ndn-test3.cpp | 0 scenario/scenarios/{ => disabled}/no-wfq.cpp | 0 .../{ => disabled}/nwfq-with-pcon.cpp | 0 scenario/scenarios/dsccp3-1-pcon.cpp | 135 +++++++++ scenario/scenarios/dsccp3-1.cpp | 141 +++++++++ scenario/scenarios/dsccp4-1-single.cpp | 277 ++++++++++++++++++ scenario/scenarios/dsccp4-2-multi.cpp | 277 ++++++++++++++++++ scenario/topologies/dsccp3-1.txt | 35 +++ scenario/topologies/dsccp4.txt | 57 ++++ 26 files changed, 1549 insertions(+), 123 deletions(-) create mode 100644 ns-3/.vscode/settings.json delete mode 100644 ns-3/src/ndnSIM/apps/ndn-consumer-nwfq.cpp delete mode 100644 ns-3/src/ndnSIM/apps/ndn-consumer-nwfq.hpp create mode 100644 scenario/.vscode/settings.json create mode 100644 scenario/extensions/PCONStrategy.cpp create mode 100644 scenario/extensions/PCONStrategy.hpp create mode 100644 scenario/extensions/mt-forward-info.hpp rename scenario/scenarios/{ => disabled}/ndn-test.cpp (100%) rename scenario/scenarios/{ => disabled}/ndn-test2.cpp (100%) rename scenario/scenarios/{ => disabled}/ndn-test3.cpp (100%) rename scenario/scenarios/{ => disabled}/no-wfq.cpp (100%) rename scenario/scenarios/{ => disabled}/nwfq-with-pcon.cpp (100%) create mode 100644 scenario/scenarios/dsccp3-1-pcon.cpp create mode 100644 scenario/scenarios/dsccp3-1.cpp create mode 100644 scenario/scenarios/dsccp4-1-single.cpp create mode 100644 scenario/scenarios/dsccp4-2-multi.cpp create mode 100644 scenario/topologies/dsccp3-1.txt create mode 100644 scenario/topologies/dsccp4.txt diff --git a/ns-3/.vscode/settings.json b/ns-3/.vscode/settings.json new file mode 100644 index 0000000..df23587 --- /dev/null +++ b/ns-3/.vscode/settings.json @@ -0,0 +1,6 @@ +{ + "files.associations": { + "*.txt": "cpp", + "fstream": "cpp" + } +} \ No newline at end of file diff --git a/ns-3/src/ndnSIM/apps/mircc-consumer.cpp b/ns-3/src/ndnSIM/apps/mircc-consumer.cpp index 1b4bf91..1a8260c 100644 --- a/ns-3/src/ndnSIM/apps/mircc-consumer.cpp +++ b/ns-3/src/ndnSIM/apps/mircc-consumer.cpp @@ -1,5 +1,3 @@ - - #include "mircc-consumer.hpp" #include "ns3/ptr.h" #include "ns3/log.h" @@ -124,8 +122,11 @@ ConsumerMIRCC:: StopApplication() } void -ConsumerMIRCC:: mircclog() +ConsumerMIRCC::mircclog() { + if (logtms == 0) { + return; + } log_event = Simulator::Schedule(Seconds((double)logtms/1000), &ConsumerMIRCC::mircclog, this); double time = logcnt * (double)logtms / 1000; @@ -174,12 +175,15 @@ ConsumerMIRCC:: StartApplication() // 调用父类开启face等接口服务 App::StartApplication(); - - log_event = Simulator::Schedule(Seconds((double)logtms/1000), &ConsumerMIRCC::mircclog, this); - std::ofstream ofs; - ofs.open(std::to_string(appid) + ".txt",std::ios::app); - ofs << "Time Node FaceId FaceDescr Type Packets Kilobytes PacketRaw KilobytesRaw" << std::endl; - ofs.close(); + + // 如果logtms == 0,不记录客户端日志 + if (logtms > 0) { + log_event = Simulator::Schedule(Seconds((double)logtms/1000), &ConsumerMIRCC::mircclog, this); + std::ofstream ofs; + ofs.open(std::to_string(appid) + ".txt",std::ios::app); + ofs << "Time Node FaceId FaceDescr Type Packets Kilobytes PacketRaw KilobytesRaw" << std::endl; + ofs.close(); + } // 调用路径探索 if (pathId2RandomId.size() == 0) diff --git a/ns-3/src/ndnSIM/apps/ndn-consumer-nwfq.cpp b/ns-3/src/ndnSIM/apps/ndn-consumer-nwfq.cpp deleted file mode 100644 index 934f10e..0000000 --- a/ns-3/src/ndnSIM/apps/ndn-consumer-nwfq.cpp +++ /dev/null @@ -1,37 +0,0 @@ -#include "ndn-consumer-nwfq.hpp" - -NS_LOG_COMPONENT_DEFINE("ndn.ConsumerNWFQ"); -namespace ns3 { -namespace ndn { -NS_OBJECT_ENSURE_REGISTERED(ConsumerNWFQ); - - -TypeId ConsumerNWFQ::GetTypeId() { - static TypeId tid = - TypeId("ns3::ndn::ConsumerNWFQ") - .SetGroupName("Ndn") - .SetParent() - .AddConstructor() - // Add Attribute here - .AddAttribute("Tos", - "Type of service", - UintegerValue(1), - MakeUintegerAccessor(&ConsumerNWFQ::tos), - MakeUintegerChecker()) - .AddAttribute("Dsz", - "Data size", - UintegerValue(1040), - MakeUintegerAccessor(&ConsumerNWFQ::dsz), - MakeUintegerChecker()); - return tid; -} - -ConsumerNWFQ::ConsumerNWFQ() - : tos(1) - , dsz(1040) { - - } - - -} -} diff --git a/ns-3/src/ndnSIM/apps/ndn-consumer-nwfq.hpp b/ns-3/src/ndnSIM/apps/ndn-consumer-nwfq.hpp deleted file mode 100644 index 43a5f7c..0000000 --- a/ns-3/src/ndnSIM/apps/ndn-consumer-nwfq.hpp +++ /dev/null @@ -1,30 +0,0 @@ -#ifndef NDN_CONSUMER_NWFQ_H -#define NDN_CONSUMER_NWFQ_H - -#include "ns3/ndnSIM/model/ndn-common.hpp" -#include "ndn-consumer-pcon.hpp" - -namespace ns3 { -namespace ndn { - -class ConsumerNWFQ : public ConsumerPcon { -public: - static TypeId GetTypeId(); - - explicit ConsumerNWFQ(); - -private: - // private function here - - -private: - // private attribute here - uint64_t tos; // 优先级 - uint64_t dsz; // 数据包大小 -}; - -} -} - -#endif - diff --git a/ns-3/src/ndnSIM/apps/ndn-consumer-pcon.cpp b/ns-3/src/ndnSIM/apps/ndn-consumer-pcon.cpp index 2242740..1860e62 100644 --- a/ns-3/src/ndnSIM/apps/ndn-consumer-pcon.cpp +++ b/ns-3/src/ndnSIM/apps/ndn-consumer-pcon.cpp @@ -114,6 +114,7 @@ ConsumerPcon::OnData(shared_ptr data) } if (data->getCongestionMark() > 0) { + std::cout << "GetCongestionMark: " << data->getCongestionMark() << std::endl; if (m_reactToCongestionMarks) { NS_LOG_DEBUG("Received congestion mark: " << data->getCongestionMark()); WindowDecrease(); @@ -138,6 +139,7 @@ ConsumerPcon::OnData(shared_ptr data) void ConsumerPcon::OnTimeout(uint32_t sequenceNum) { + // std::cout << "OnTimeout" << std::endl; WindowDecrease(); if (m_inFlight > static_cast(0)) { @@ -175,6 +177,7 @@ ConsumerPcon::WindowIncrease() void ConsumerPcon::WindowDecrease() { + // std::cout << "Window Decrease" << std::endl; if (!m_useCwa || m_highData > m_recPoint) { const double diff = m_seq - m_highData; BOOST_ASSERT(diff > 0); @@ -212,6 +215,7 @@ ConsumerPcon::WindowDecrease() void ConsumerPcon::BicIncrease() { + // std::cout << "BIC Increase" << std::endl; if (m_window < BIC_LOW_WINDOW) { // Normal TCP AIMD behavior if (m_window < m_ssthresh) { diff --git a/ns-3/src/ndnSIM/apps/ndn-consumer-window.cpp b/ns-3/src/ndnSIM/apps/ndn-consumer-window.cpp index 79c31e2..6fdd7f1 100644 --- a/ns-3/src/ndnSIM/apps/ndn-consumer-window.cpp +++ b/ns-3/src/ndnSIM/apps/ndn-consumer-window.cpp @@ -78,7 +78,32 @@ ConsumerWindow::GetTypeId(void) "ns3::ndn::ConsumerWindow::WindowTraceCallback") .AddTraceSource("InFlight", "Current number of outstanding interests", MakeTraceSourceAccessor(&ConsumerWindow::m_inFlight), - "ns3::ndn::ConsumerWindow::WindowTraceCallback"); + "ns3::ndn::ConsumerWindow::WindowTraceCallback") + .AddAttribute("TimingStop", + "Timing stop (ms)", + IntegerValue(-1), + MakeIntegerAccessor(&ConsumerWindow::timingStop), + MakeIntegerChecker()) + .AddAttribute("Dsz", + "Data size", + UintegerValue(8800), + MakeUintegerAccessor(&ConsumerWindow::dsz), + MakeUintegerChecker()) + .AddAttribute("DelayGreedy", + "Start greedy after the specified time (ms)", + IntegerValue(-1), + MakeIntegerAccessor(&ConsumerWindow::delayGreedy), + MakeIntegerChecker()) + .AddAttribute("GreedyRate", + "Transmission rate when greedy (bps)", + IntegerValue(-1), + MakeIntegerAccessor(&ConsumerWindow::greedyRate), + MakeIntegerChecker()) + .AddAttribute("DelayStart", + "Delay start time (ms)", + UintegerValue(0), + MakeUintegerAccessor(&ConsumerWindow::delayStart), + MakeUintegerChecker()); return tid; } @@ -152,29 +177,68 @@ ConsumerWindow::SetSeqMax(uint32_t seqMax) // ignore otherwise } +void ConsumerWindow::stop() { + this->stopFlag = true; + Simulator::Remove(m_sendEvent); + this->StopApplication(); +} + +void ConsumerWindow::startGreedy() { + std::cout << "startGreedy" << std::endl; + this->greedyFlag = true; +} + void ConsumerWindow::ScheduleNextPacket() { - if (m_window == static_cast(0)) { - Simulator::Remove(m_sendEvent); + if (this->stopFlag) { + return; + } - NS_LOG_DEBUG( - "Next event in " << (std::min(0.5, m_rtt->RetransmitTimeout().ToDouble(Time::S))) - << " sec"); - m_sendEvent = - Simulator::Schedule(Seconds( - std::min(0.5, m_rtt->RetransmitTimeout().ToDouble(Time::S))), - &Consumer::SendPacket, this); + // 处理贪婪 + if (this->greedyFlag) { + if (!m_sendEvent.IsRunning()) { + auto waitTime = (this->dsz * 1000000000) / this->greedyRate + 1; + + m_sendEvent = Simulator::Schedule(NanoSeconds(waitTime), &Consumer::SendPacket, this); + } + return; } - else if (m_inFlight >= m_window) { - // simply do nothing - } - else { - if (m_sendEvent.IsRunning()) { - Simulator::Remove(m_sendEvent); + + if (this->m_firstTime) { + this->m_firstTime = false; + // 如果开启了指定时间后停止,则设置一个定时事件,在指定时间后停止客户端 + if (this->timingStop > 0) { + Simulator::Schedule(MilliSeconds(this->timingStop), &ConsumerWindow::stop, this); } - m_sendEvent = Simulator::ScheduleNow(&Consumer::SendPacket, this); + // 如果开启了延迟贪婪,则在指定时间后客户端开始贪婪 + if (this->delayGreedy > 0 && this->greedyRate > 0) { + Simulator::Schedule(MilliSeconds(this->delayGreedy), &ConsumerWindow::startGreedy, this); + } else { + } + m_sendEvent = Simulator::Schedule(MilliSeconds(this->delayStart), &Consumer::SendPacket, this); + } else { + if (m_window == static_cast(0)) { + Simulator::Remove(m_sendEvent); + + NS_LOG_DEBUG( + "Next event in " << (std::min(0.5, m_rtt->RetransmitTimeout().ToDouble(Time::S))) + << " sec"); + m_sendEvent = + Simulator::Schedule(Seconds( + std::min(0.5, m_rtt->RetransmitTimeout().ToDouble(Time::S))), + &Consumer::SendPacket, this); + } + else if (m_inFlight >= m_window) { + // simply do nothing + } else { + if (m_sendEvent.IsRunning()) { + Simulator::Remove(m_sendEvent); + } + + m_sendEvent = Simulator::ScheduleNow(&Consumer::SendPacket, this); + } } } diff --git a/ns-3/src/ndnSIM/apps/ndn-consumer-window.hpp b/ns-3/src/ndnSIM/apps/ndn-consumer-window.hpp index c298e17..816b7ee 100644 --- a/ns-3/src/ndnSIM/apps/ndn-consumer-window.hpp +++ b/ns-3/src/ndnSIM/apps/ndn-consumer-window.hpp @@ -92,12 +92,29 @@ private: void SetSeqMax(uint32_t seqMax); +protected: + + // Stop send packet + void stop(); + + // 开始贪婪 + void startGreedy(); + protected: uint32_t m_payloadSize; // expected payload size double m_maxSize; // max size to request uint32_t m_initialWindow; bool m_setInitialWindowOnTimeout; + bool m_firstTime = true; + bool stopFlag = false; // 标识是否停止 + bool greedyFlag = false; // 标识是否贪婪 + uint64_t delayStart; // 延迟启动时间 + int32_t timingStop; // 定时停止 + + uint64_t dsz; // 数据包大小 + int32_t delayGreedy; // 定时贪婪,在指定时间之后开始贪婪 + int32_t greedyRate; // 贪婪速率 TracedValue m_window; TracedValue m_inFlight; diff --git a/pybindgen b/pybindgen index 572e1d9..a619e22 160000 --- a/pybindgen +++ b/pybindgen @@ -1 +1 @@ -Subproject commit 572e1d92d9d0388de86b73d1ee37a10d0b0b633a +Subproject commit a619e22a1492e586f42a688b015c551ea1facd7b diff --git a/scenario/.gitignore b/scenario/.gitignore index 2ca8e0e..a9d6b0c 100644 --- a/scenario/.gitignore +++ b/scenario/.gitignore @@ -6,3 +6,4 @@ .lock* build/ *.pyc +/*.txt diff --git a/scenario/.vscode/settings.json b/scenario/.vscode/settings.json new file mode 100644 index 0000000..2545f40 --- /dev/null +++ b/scenario/.vscode/settings.json @@ -0,0 +1,10 @@ +{ + "files.associations": { + "*.txt": "cpp", + "*.ipp": "cpp", + "deque": "cpp", + "string": "cpp", + "vector": "cpp", + "list": "cpp" + } +} \ No newline at end of file diff --git a/scenario/extensions/PCONStrategy.cpp b/scenario/extensions/PCONStrategy.cpp new file mode 100644 index 0000000..ed7b1b7 --- /dev/null +++ b/scenario/extensions/PCONStrategy.cpp @@ -0,0 +1,206 @@ +#include "PCONStrategy.hpp" +#include + +NFD_LOG_INIT(PCONStrategy); +namespace nfd +{ + namespace fw + { + ////////////////////////////////////////////////////////////////////////////////////////////////////////////////// + //// PCONStrategy + ////////////////////////////////////////////////////////////////////////////////////////////////////////////////// + const time::milliseconds PCONStrategy::RETX_SUPPRESSION_INITIAL(10); + const time::milliseconds PCONStrategy::RETX_SUPPRESSION_MAX(250); + + PCONStrategy::PCONStrategy(nfd::Forwarder &forwarder, const ndn::Name &name) + : Strategy(forwarder), ProcessNackTraits(this), m_retxSuppression(RETX_SUPPRESSION_INITIAL, + RetxSuppressionExponential::DEFAULT_MULTIPLIER, + RETX_SUPPRESSION_MAX) + { + this->setInstanceName(makeInstanceName(name, getStrategyName())); + } + + const Name & + PCONStrategy::getStrategyName() + { + static Name strategyName("/localhost/nfd/strategy/PCON/%FD%01"); + return strategyName; + } + + /** + * 收到 Interest 之后处理 + * @param ingress + * @param interest + * @param pitEntry + */ + void + PCONStrategy::afterReceiveInterest(const nfd::FaceEndpoint &ingress, const ndn::Interest &interest, + const std::shared_ptr &pitEntry) + { + const fib::Entry &fibEntry = this->lookupFib(*pitEntry); + const fib::NextHopList &nexthops = fibEntry.getNextHops(); + // 获取度量信息 + MtForwardingInfo *measurementInfo = this->getPrefixMeasurements(fibEntry); + + // 如果度量信息不存在,则创建一个新的 + if (measurementInfo == nullptr) + { + measurementInfo = this->addPrefixMeasurements(fibEntry); + const Name prefixName = fibEntry.getPrefix(); + measurementInfo->setPrefix(prefixName.toUri()); + // 初始化转发概率 + initializeForwMap(measurementInfo, nexthops); + } + + // Interest 抑制 + RetxSuppressionResult suppression = m_retxSuppression.decidePerPitEntry(*pitEntry); + if (suppression == RetxSuppressionResult::SUPPRESS) + { + NFD_LOG_DEBUG(interest << " from=" << ingress << " suppressed"); + return; + } + + Face *outFace = nullptr; + // 如果face是 LOCAL 的,不做额外的处理,直接按最短路径转发 + if (ingress.face.getScope() != ndn::nfd::FACE_SCOPE_NON_LOCAL) + { + // 对于本地的face,直接按最佳路径走即可 + auto selected = std::find_if(nexthops.begin(), nexthops.end(), [&](const auto &nexthop) { + return isNextHopEligible(ingress.face, interest, nexthop, pitEntry); + }); + if (selected != nexthops.end()) + { + outFace = &((*selected).getFace()); + } + } + else + { + // Random number between 0 and 1. + double r = ((double)rand() / (RAND_MAX)); + + double percSum = 0; + + // Add all eligbile faces to list (excludes current downstream) + std::vector eligbleFaces; + for (auto &n : fibEntry.getNextHops()) + { + if (isNextHopEligible(ingress.face, interest, n, pitEntry)) + { + // Add up percentage Sum. + percSum += measurementInfo->getforwPerc(n.getFace().getId()); + eligbleFaces.push_back(&n.getFace()); + } + } + + if (eligbleFaces.size() < 1) + { + // 回环抑制 + return; + } + else if (eligbleFaces.size() == 1) + { + // 只有一个有效下一跳,直接转发 + outFace = eligbleFaces.front(); + } + else + { + // 有多个下一跳,按概率转发 + // Choose face according to current forwarding percentage: + double forwPerc = 0; + for (auto face : eligbleFaces) + { + forwPerc += measurementInfo->getforwPerc(face->getId()) / percSum; + if (r < forwPerc) + { + outFace = face; + break; + } + } + } + } + + // 无法转发,返回Nack + if (outFace == nullptr) + { + lp::NackHeader nackHeader; + nackHeader.setReason(lp::NackReason::NO_ROUTE); + this->sendNack(pitEntry, ingress, nackHeader); + this->rejectPendingInterest(pitEntry); + return; + } + else + { + // 可以转发则直接转发 + this->sendInterest(pitEntry, FaceEndpoint(*outFace, 0), interest); + } + + // TODO: 探测 + } + + void + PCONStrategy::beforeSatisfyInterest(const shared_ptr &pitEntry, + const FaceEndpoint &ingress, const Data &data) + { + Name currentPrefix; + MtForwardingInfo *measurementInfo; + std::tie(currentPrefix, measurementInfo) = this->findPrefixMeasurementsLPM( + *pitEntry); + + // 判断是否携带拥塞标记,如果携带拥塞标记,则将转发概率转移到其它接口 + if (data.getCongestionMark() > 0) + { + // std::cout << ">>2: " << data.getCongestionMark() << std::endl; + double fwPerc = measurementInfo->getforwPerc(ingress.face.getId()); + double change_perc = CHANGE_PER_MARK * fwPerc; + this->reduceFwPerc(measurementInfo, ingress.face.getId(), change_perc); + } + } + + /** + * 收到 Nack 时处理 + * @param ingress + * @param nack + * @param pitEntry + */ + void PCONStrategy::afterReceiveNack(const nfd::FaceEndpoint &ingress, const ndn::lp::Nack &nack, + const std::shared_ptr &pitEntry) + { + this->processNack(ingress.face, nack, pitEntry); + } + + /** + * @brief 初始化转发概率 + * + * @param measurementInfo + * @param nextHops + */ + void + PCONStrategy::initializeForwMap(MtForwardingInfo *measurementInfo, + const fib::NextHopList &nextHops) + { + int lowestId = std::numeric_limits::max(); + int minCost = std::numeric_limits::max(); + + // 找到开销最小的下一跳 + for (auto &n : nextHops) + { + if (n.getCost() < minCost) + { + minCost = n.getCost(); + lowestId = n.getFace().getId(); + } + } + + // 开销最小的路径转发概率为 100%, 其它为0 + for (auto &n : nextHops) + { + double perc = 0.0; + if (n.getFace().getId() == lowestId) + { + perc = 1.0; + } + measurementInfo->setforwPerc(n.getFace().getId(), perc); + } + } + } +} \ No newline at end of file diff --git a/scenario/extensions/PCONStrategy.hpp b/scenario/extensions/PCONStrategy.hpp new file mode 100644 index 0000000..95cb697 --- /dev/null +++ b/scenario/extensions/PCONStrategy.hpp @@ -0,0 +1,150 @@ +#ifndef NFD_DAEMON_FW_PCON_STRATEGY_HPP +#define NFD_DAEMON_FW_PCON_STRATEGY_HPP + +#include +#include "face/face.hpp" +#include "fw/strategy.hpp" +#include "fw/retx-suppression-exponential.hpp" +#include "fw/algorithm.hpp" +#include "fw/process-nack-traits.hpp" +#include +#include +#include "mt-forward-info.hpp" + +namespace nfd +{ + namespace fw + { + class PCONStrategy : public Strategy, public ProcessNackTraits + { + public: + explicit PCONStrategy(Forwarder &forwarder, const Name &name = getStrategyName()); + + ~PCONStrategy() override = default; + + void + afterReceiveInterest(const FaceEndpoint &ingress, const Interest &interest, + const shared_ptr &pitEntry) override; + + void + beforeSatisfyInterest(const shared_ptr &pitEntry, + const FaceEndpoint &ingress, const Data &data) override; + + void + afterReceiveNack(const FaceEndpoint &ingress, const lp::Nack &nack, + const shared_ptr &pitEntry) override; + + static const Name & + getStrategyName(); + + protected: + friend ProcessNackTraits; + + private: + void + initializeForwMap(MtForwardingInfo *measurementInfo, + const fib::NextHopList &nextHops); + + MtForwardingInfo * + getPrefixMeasurements(const fib::Entry &fibEntry) + { + std::string key = fibEntry.getPrefix().getPrefix(1).toUri(); + if (this->innerMap.count(key) == 0) + { + return nullptr; + } + else + { + return this->innerMap[key].get(); + } + } + + MtForwardingInfo * + addPrefixMeasurements(const fib::Entry &fibEntry) + { + std::string key = fibEntry.getPrefix().getPrefix(1).toUri(); + if (this->innerMap.count(key) == 0) + { + this->innerMap[key] = make_unique(); + } + return this->innerMap[key].get(); + // measurements::Entry* me = measurements.get(fibEntry); + // // std::cout << fibEntry.getPrefix().toUri() << std::endl; + // measurements.extendLifetime(*me, 8_s); + // return me->insertStrategyInfo().first; + } + + std::tuple + findPrefixMeasurementsLPM(const pit::Entry &pitEntry) + { + + std::string key = pitEntry.getName().getPrefix(1).toUri(); + if (this->innerMap.count(key) == 0) { + return std::forward_as_tuple(Name(), nullptr); + } + + return std::forward_as_tuple(pitEntry.getName().getPrefix(1), this->innerMap[key].get()); + // measurements::Entry *me = measurements.findLongestPrefixMatch(pitEntry); + // if (me == nullptr) + // { + // std::cout << "Name " << pitEntry.getName().toUri() << " not found!\n"; + // return std::forward_as_tuple(Name(), nullptr); + // } + // return std::forward_as_tuple(me->getName(), me->getStrategyInfo()); + } + + static void + reduceFwPerc(MtForwardingInfo *forwInfo, + const FaceId reducedFaceId, + const double change) + { + if (forwInfo->getFaceCount() == 1) + { + std::cout << "reduce1" << std::endl; + return; + } + // Reduction is at most the current forwarding percentage of the face that is reduced. + double changeRate = 0 - std::min(change, forwInfo->getforwPerc(reducedFaceId)); + + std::cout << "reduce2: " << changeRate << std::endl; + // Decrease fw percentage of the given face: + forwInfo->increaseforwPerc(reducedFaceId, changeRate); + double sumFWPerc = 0; + sumFWPerc += forwInfo->getforwPerc(reducedFaceId); + const auto forwMap = forwInfo->getForwPercMap(); + + // std::cout << "\n"; + for (auto f : forwMap) + { + auto tempChangeRate = changeRate; + auto &faceId = f.first; + if (faceId == reducedFaceId) + { // Do nothing. Percentage has already been added. + } + else + { + // Increase forwarding percentage of all other faces by and equal amount. + tempChangeRate = std::abs(changeRate / (double)(forwMap.size() - 1)); + forwInfo->increaseforwPerc((faceId), tempChangeRate); + sumFWPerc += forwInfo->getforwPerc(faceId); + } + } + + // if (sumFWPerc < 0.999 || sumFWPerc > 1.001) + // { + // std::cout << StrHelper::getTime() << "ERROR! Sum of fw perc out of range: " << sumFWPerc + // << "\n"; + // } + } + + private: + static const time::milliseconds RETX_SUPPRESSION_INITIAL; + static const time::milliseconds RETX_SUPPRESSION_MAX; + double CHANGE_PER_MARK = 0.1; + std::unordered_map> innerMap; + RetxSuppressionExponential m_retxSuppression; + }; + } +} + +#endif \ No newline at end of file diff --git a/scenario/extensions/mircc-strategy.cpp b/scenario/extensions/mircc-strategy.cpp index 84d31f5..eba3fd2 100644 --- a/scenario/extensions/mircc-strategy.cpp +++ b/scenario/extensions/mircc-strategy.cpp @@ -111,16 +111,16 @@ namespace nfd { Rp = m_Rp_base[inface(mface)] + m_Rp_ex[inface(mface)]; Rs = m_Rs_base[inface(mface)] + m_Rs_ex[inface(mface)]; - NS_LOG_DEBUG("face:" << mface << "d:" << m_d[inface(mface)]); + // NS_LOG_DEBUG("face:" << mface << "d:" << m_d[inface(mface)]); - NS_LOG_DEBUG("Rp: " << Rp << " Rs: " << Rs << " Yt: " << m_Yp[inface(mface)] << " C:" << m_linkC[inface(mface)]); + // NS_LOG_DEBUG("Rp: " << Rp << " Rs: " << Rs << " Yt: " << m_Yp[inface(mface)] << " C:" << m_linkC[inface(mface)]); //Rp计算过程 ia = std::max(m_linkC[inface(mface)],m_Yp[inface(mface)]); ib = std::max(Rp,1ll); double Np = std::max((double)ia / ib,1.0); - NS_LOG_DEBUG(" Np: " << Np); + // NS_LOG_DEBUG(" Np: " << Np); double Bp; if (m_Yp[inface(mface)] >= m_Yp_old[inface(mface)]) @@ -135,16 +135,16 @@ namespace nfd { Bp = m_B; } - NS_LOG_DEBUG(" Bp: " << Bp); + // 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); - NS_LOG_DEBUG("Qt "<< getQt(mface) << " ia " << ia); + // 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); - NS_LOG_DEBUG(" Ppbn:" << Rp_base_n); + // NS_LOG_DEBUG(" Ppbn:" << Rp_base_n); m_Rp_base[inface(mface)] = m_a * m_Rp_base[inface(mface)] + (1 - m_a) * Rp_base_n; - NS_LOG_DEBUG(" Rpb: " << m_Rp_base[inface(mface)]); + // NS_LOG_DEBUG(" Rpb: " << m_Rp_base[inface(mface)]); ia = m_Yp[inface(mface)]; @@ -153,22 +153,22 @@ namespace nfd { long long Rp_ex_n = std::min(std::max((uint64_t)0,(uint64_t)(Rp - ia / db)),(uint64_t)(m_linkC[inface(mface)] - Rp_base_n)); m_Rp_ex[inface(mface)] = m_a * m_Rp_ex[inface(mface)] + (1 - m_a) * Rp_ex_n; - NS_LOG_DEBUG(" Rpe: " << m_Rp_ex[inface(mface)]); - NS_LOG_DEBUG(" !!Ppne:" << Rp_ex_n << " " << (m_linkC[inface(mface)] / Np - Rp_base_n)); + // NS_LOG_DEBUG(" Rpe: " << m_Rp_ex[inface(mface)]); + // NS_LOG_DEBUG(" !!Ppne:" << Rp_ex_n << " " << (m_linkC[inface(mface)] / Np - Rp_base_n)); m_Yp_old[inface(mface)] = m_Yp[inface(mface)]; //Rs计算过程 uint64_t Cs = std::max(m_linkC[inface(mface)] - m_Yp[inface(mface)] ,(uint64_t)0); - NS_LOG_DEBUG(" Cs: " << Cs << " Ys" << m_Ys[inface(mface)]); + // NS_LOG_DEBUG(" Cs: " << Cs << " Ys" << m_Ys[inface(mface)]); //TODO: R(t-T) Rs? Rs+Rp? double Ns = std::max((double)std::max(Cs,m_Ys[inface(mface)]) / std::max(Rp + Rs,1ll) ,1.0); - NS_LOG_DEBUG(" Ns: " << Ns); + // NS_LOG_DEBUG(" Ns: " << Ns); ia = m_Ys[inface(mface)] - m_Ys_old[inface(mface)]; ib = std::max(m_Ys[inface(mface)],(uint64_t)1); @@ -176,13 +176,13 @@ namespace nfd { ia = m_miu * Cs - Bs * getQt(mface) / std::max(m_d[inface(mface)],(double)0.001); - NS_LOG_DEBUG(" ia: " << ia); + // NS_LOG_DEBUG(" ia: " << ia); db = Ns; uint64_t Rs_base_n = std::min((uint64_t)std::max(0.0,ia / db),uint64_t(Cs / Ns)); m_Rs_base[inface(mface)] = m_a * m_Rs_base[inface(mface)] + (1 - m_a) * Rs_base_n; - NS_LOG_DEBUG(" Rsb: " << m_Rs_base[inface(mface)]); + // NS_LOG_DEBUG(" Rsb: " << m_Rs_base[inface(mface)]); ia = m_Ys[inface(mface)]; @@ -194,35 +194,28 @@ namespace nfd { m_Rs_ex[inface(mface)] = m_a * m_Rs_ex[inface(mface)] + (1 - m_a) * Rs_ex_n; - NS_LOG_DEBUG(" Rse: " << m_Rs_ex[inface(mface)]); + // NS_LOG_DEBUG(" Rse: " << m_Rs_ex[inface(mface)]); m_Ys_old[inface(mface)] = m_Ys[inface(mface)]; m_Yp[inface(mface)] = 0; m_Ys[inface(mface)] = 0; - - - } uint64_t MIRCCStrategy::getQt(FaceId mface) { - - //清除队列中过期兴趣包,避免造成干扰 //refreshQueueInterest(mface); //返回兴趣包个数*兴趣包大小*数据包与兴趣包大小之比 uint64_t time = 10;//保持Rt计算周期一致 return (m_Queue[inface(mface)].qp.size() + m_Queue[inface(mface)].qs.size()) * DATA_SIZE * time; - - } void MIRCCStrategy::pushQueueInterest(FaceId mface,const shared_ptr& interest,const shared_ptr& pitEntry) { - //NS_LOG_DEBUG("MIRCC pushQueueInterest"); + //// NS_LOG_DEBUG("MIRCC pushQueueInterest"); uint64_t p = *(interest->getTag()); //如果是第一类兴趣包 if (p == 1) @@ -245,6 +238,7 @@ namespace nfd { //否则当前兴趣包丢失 //这里应该回传Nack,还没有写完 + this->rejectPendingInterest(pitEntry); } }else { @@ -259,7 +253,7 @@ namespace nfd { if (m_Queue[inface(mface)].qp.size() + m_Queue[inface(mface)].qs.size() >= MAX_QUEUE) { //当前兴趣包丢失 - + this->rejectPendingInterest(pitEntry); //这里是否应该回传Nack不确定,需要回去看论文,第二类兴趣包处理方式似乎与第一类不同,还没有写完 }else { @@ -275,7 +269,7 @@ namespace nfd { void MIRCCStrategy::afterReceiveInterest(const FaceEndpoint &ingress, const Interest &interest, const shared_ptr &pitEntry) {//目前在按照标识路径转发,采用MIRCC论文中的方法2 - //NS_LOG_DEBUG("MIRCC afterReceiveInterest"); + //// NS_LOG_DEBUG("MIRCC afterReceiveInterest"); if (hasPendingOutRecords(*pitEntry)) { @@ -331,14 +325,14 @@ namespace nfd { void MIRCCStrategy::afterReceiveNack(const FaceEndpoint &ingress, const lp::Nack &nack, const shared_ptr &pitEntry) { - //NS_LOG_DEBUG("MIRCC afterReceiveNack"); + //// NS_LOG_DEBUG("MIRCC afterReceiveNack"); //nack无需处理 } void MIRCCStrategy::beforeSatisfyInterest(const shared_ptr &pitEntry, const FaceEndpoint &ingress, const Data &data) { - //NS_LOG_DEBUG("MIRCC beforeSatisfyInterest"); + //// NS_LOG_DEBUG("MIRCC beforeSatisfyInterest"); auto now = time::steady_clock::now(); //目前计算中,只考虑没有过期的并成功收到数据包的兴趣包对RTT和ratio的影响.超时的数据包是否对RTT有影响?。 for (const pit::InRecord& inRecord : pitEntry->getInRecords()) { @@ -351,7 +345,7 @@ namespace nfd { //计算收到数据包对RTT的影响。 //RTT暂时为固定值50ms auto dura = now - inRecord.getLastRenewed(); - NS_LOG_DEBUG("RTT:" << dura.count()); + // NS_LOG_DEBUG("RTT:" << dura.count()); m_d[inface(ingress.face.getId())] = m_rtt_a * m_d[inface(ingress.face.getId())] + (1.0 - m_rtt_a) * ((double)dura.count() / 1000000000); } } @@ -361,7 +355,7 @@ namespace nfd { MIRCCStrategy::afterReceiveData(const shared_ptr &pitEntry, const FaceEndpoint &ingress, const Data &data) { - //NS_LOG_DEBUG("MIRCC afterReceiveData"); + //// NS_LOG_DEBUG("MIRCC afterReceiveData"); if (ingress.face.getId() >= 257) { diff --git a/scenario/extensions/mircc-strategy.hpp b/scenario/extensions/mircc-strategy.hpp index b47987f..acf8865 100644 --- a/scenario/extensions/mircc-strategy.hpp +++ b/scenario/extensions/mircc-strategy.hpp @@ -59,7 +59,7 @@ namespace nfd { const double m_B = 0.1;//公式B系数 const double m_a = 0.5;//速率更新系数 - const double m_miu = 0.95;//链路利用率 + const double m_miu = 0.99;//链路利用率 const double m_rtt_a = 0.7;//RTT更新系数 diff --git a/scenario/extensions/mt-forward-info.hpp b/scenario/extensions/mt-forward-info.hpp new file mode 100644 index 0000000..b9465bd --- /dev/null +++ b/scenario/extensions/mt-forward-info.hpp @@ -0,0 +1,115 @@ +#ifndef NFD_DAEMON_FW_MT_FORWARDING_INFO_HPP +#define NFD_DAEMON_FW_MT_FORWARDING_INFO_HPP + +#include "face/face.hpp" +#include "fw/strategy-info.hpp" + +namespace nfd +{ + namespace fw + { + + /** + * Measurement information that can be saved and retrieved per-name-prefix. + */ + class MtForwardingInfo : public StrategyInfo + { + public: + static constexpr int + getTypeId() + { + return 1051; + } + + MtForwardingInfo() + : m_ownPrefix("null") + { + } + + double + getforwPerc(FaceId face) + { + if (m_forwPercMap.find(face) == m_forwPercMap.end()) + { + std::cout << time::steady_clock::now().time_since_epoch().count() / 1000 * 1000 + << " ms, couldn't find face " << face << "\n"; + } + // assert(m_forwPercMap.find(face) != m_forwPercMap.end()); + double forwPerc = m_forwPercMap.at(face); + // assert(forwPerc >= 0 && forwPerc <= 1); + + return forwPerc; + } + + void + setforwPerc(FaceId faceId, double perc) + { + m_forwPercMap[faceId] = perc; + } + + void + increaseforwPerc(FaceId faceId, double changeRate) + { + m_forwPercMap[faceId] += changeRate; + } + + const std::map + getForwPercMap() const + { + return m_forwPercMap; + } + + int + getFaceCount() + { + std::vector faceIdList; + for (auto faceInfo : m_forwPercMap) + { + faceIdList.push_back(faceInfo.first); + } + return faceIdList.size(); + } + + void + setPrefix(std::string prefix) + { + m_ownPrefix = prefix; + } + + std::string + getPrefix() const + { + return m_ownPrefix; + } + + private: + /** These Functions were used to disable faces in the "highly congested" state:*/ + // void + // enableFace(FaceId faceId) + // { + // m_disabledFaces.erase(faceId); + // } + // + // void + // disableFace(FaceId faceId) + // { + // m_disabledFaces.emplace(faceId); + //// std::cout << "Disabling face " << faceId << "\n"; + // } + // + // bool + // isFaceEnabled(FaceId faceId) + // { + // bool disabled = (m_disabledFaces.find(faceId) != m_disabledFaces.end()); + // return !disabled; + // } + std::string m_ownPrefix; + std::map m_forwPercMap; + + std::unordered_set m_disabledFaces; + }; + + } //fw +} //nfd + +#endif \ No newline at end of file diff --git a/scenario/scenarios/ndn-test.cpp b/scenario/scenarios/disabled/ndn-test.cpp similarity index 100% rename from scenario/scenarios/ndn-test.cpp rename to scenario/scenarios/disabled/ndn-test.cpp diff --git a/scenario/scenarios/ndn-test2.cpp b/scenario/scenarios/disabled/ndn-test2.cpp similarity index 100% rename from scenario/scenarios/ndn-test2.cpp rename to scenario/scenarios/disabled/ndn-test2.cpp diff --git a/scenario/scenarios/ndn-test3.cpp b/scenario/scenarios/disabled/ndn-test3.cpp similarity index 100% rename from scenario/scenarios/ndn-test3.cpp rename to scenario/scenarios/disabled/ndn-test3.cpp diff --git a/scenario/scenarios/no-wfq.cpp b/scenario/scenarios/disabled/no-wfq.cpp similarity index 100% rename from scenario/scenarios/no-wfq.cpp rename to scenario/scenarios/disabled/no-wfq.cpp diff --git a/scenario/scenarios/nwfq-with-pcon.cpp b/scenario/scenarios/disabled/nwfq-with-pcon.cpp similarity index 100% rename from scenario/scenarios/nwfq-with-pcon.cpp rename to scenario/scenarios/disabled/nwfq-with-pcon.cpp diff --git a/scenario/scenarios/dsccp3-1-pcon.cpp b/scenario/scenarios/dsccp3-1-pcon.cpp new file mode 100644 index 0000000..c8e967c --- /dev/null +++ b/scenario/scenarios/dsccp3-1-pcon.cpp @@ -0,0 +1,135 @@ +#include "ns3/core-module.h" +#include "ns3/network-module.h" +#include "ns3/ndnSIM-module.h" +#include "../extensions/PCONStrategy.hpp" +#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-1.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("/"); + // ndn::StrategyChoiceHelper::InstallAll("/"); + + // Installing global routing interface on all nodes + ndn::GlobalRoutingHelper ndnGlobalRoutingHelper; + ndnGlobalRoutingHelper.InstallAll(); + + // Getting containers for the consumer/producer + Ptr C1 = Names::Find("C1"); + Ptr C2 = Names::Find("C2"); + Ptr C3 = Names::Find("C3"); + + Ptr P1 = Names::Find("P1"); + Ptr P2 = Names::Find("P2"); + Ptr P3 = Names::Find("P3"); + Ptr P4 = Names::Find("P4"); + + ndn::AppHelper consumerHelper("ns3::ndn::ConsumerPcon"); + consumerHelper.SetAttribute("Dsz", UintegerValue(8696)); + consumerHelper.SetAttribute("CcAlgorithm", StringValue("BIC")); + // consumerHelper.SetAttribute("NumberOfContents", UintegerValue(100000)); + + + // C1 + consumerHelper.SetPrefix("/A"); + // consumerHelper.SetAttribute("Tos", UintegerValue(5)); + consumerHelper.Install("C1"); + + // C2 + consumerHelper.SetPrefix("/B"); + // consumerHelper.SetAttribute("Tos", UintegerValue(5)); + consumerHelper.SetAttribute("DelayStart", UintegerValue(30000)); // 延迟30秒启动 + consumerHelper.Install("C2"); + + // C3 + consumerHelper.SetPrefix("/C"); + // consumerHelper.SetAttribute("Tos", UintegerValue(5)); + consumerHelper.SetAttribute("DelayStart", UintegerValue(60000)); // 延迟60秒启动 + consumerHelper.SetAttribute("DelayGreedy", IntegerValue(150000)); // 150秒开始贪婪 + consumerHelper.SetAttribute("GreedyRate", IntegerValue(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-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)); + Simulator::Run(); + Simulator::Destroy(); + + return 0; + } + +} // namespace ns3 + +int main(int argc, char *argv[]) +{ + return ns3::main(argc, argv); +} \ No newline at end of file diff --git a/scenario/scenarios/dsccp3-1.cpp b/scenario/scenarios/dsccp3-1.cpp new file mode 100644 index 0000000..b5ef7ed --- /dev/null +++ b/scenario/scenarios/dsccp3-1.cpp @@ -0,0 +1,141 @@ +#include "ns3/core-module.h" +#include "ns3/network-module.h" +#include "ns3/ndnSIM-module.h" +#include "../extensions/mircc-strategy.hpp" +#include "../extensions/PCONStrategy.hpp" + +namespace ns3 +{ + + int + main(int argc, char *argv[]) + { + CommandLine cmd; + cmd.Parse(argc, argv); + + AnnotatedTopologyReader topologyReader("", 25); + topologyReader.SetFileName("topologies/dsccp3-1.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("/"); + // ndn::StrategyChoiceHelper::InstallAll("/"); + + // Installing global routing interface on all nodes + ndn::GlobalRoutingHelper ndnGlobalRoutingHelper; + ndnGlobalRoutingHelper.InstallAll(); + + // Getting containers for the consumer/producer + Ptr C1 = Names::Find("C1"); + Ptr C2 = Names::Find("C2"); + Ptr C3 = Names::Find("C3"); + + Ptr P1 = Names::Find("P1"); + Ptr P2 = Names::Find("P2"); + Ptr P3 = Names::Find("P3"); + Ptr P4 = Names::Find("P4"); + + ndn::AppHelper consumerHelper("ns3::ndn::ConsumerMIRCC"); + consumerHelper.SetAttribute("logtms",StringValue("0")); + // consumerHelper.SetAttribute("NumberOfContents", UintegerValue(100000)); + + // 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.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-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)); + Simulator::Run(); + Simulator::Destroy(); + + return 0; + } + +} // namespace ns3 + +int main(int argc, char *argv[]) +{ + return ns3::main(argc, argv); +} \ No newline at end of file diff --git a/scenario/scenarios/dsccp4-1-single.cpp b/scenario/scenarios/dsccp4-1-single.cpp new file mode 100644 index 0000000..5ea2e99 --- /dev/null +++ b/scenario/scenarios/dsccp4-1-single.cpp @@ -0,0 +1,277 @@ +#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/dsccp4.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("/"); + + // Installing global routing interface on all nodes + ndn::GlobalRoutingHelper ndnGlobalRoutingHelper; + ndnGlobalRoutingHelper.InstallAll(); + + // Getting containers for the consumer/producer + Ptr C1 = Names::Find("C1"); + Ptr C2 = Names::Find("C2"); + Ptr C3 = Names::Find("C3"); + Ptr C4 = Names::Find("C4"); + Ptr C5 = Names::Find("C5"); + Ptr C6 = Names::Find("C6"); + Ptr C7 = Names::Find("C7"); + Ptr C8 = Names::Find("C8"); + + Ptr P1 = Names::Find("P1"); + Ptr P2 = Names::Find("P2"); + Ptr P3 = Names::Find("P3"); + + ndn::AppHelper consumerHelper("ns3::ndn::ConsumerMIRCC"); + consumerHelper.SetAttribute("MaxSeq", StringValue("5000")); // 100 interests a second + consumerHelper.SetAttribute("logtms",StringValue("0")); + 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.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")); + + // Register /dst1 prefix with global routing controller and + // install producer that will satisfy Interests in /dst1 namespace + + producerHelper.SetPrefix("/Amazon"); + producerHelper.Install(P1); + + producerHelper.SetPrefix("/Google"); + producerHelper.Install(P2); + + producerHelper.SetPrefix("/Warner"); + producerHelper.Install(P3); + + // ndnGlobalRoutingHelper.AddOrigins("/Amazon", P1); + // ndnGlobalRoutingHelper.AddOrigins("/Google", P2); + // ndnGlobalRoutingHelper.AddOrigins("/Warner", P3); + + // // Calculate all possible routes and install FIBs + // ndn::GlobalRoutingHelper::CalculateRoutes(); + + + // 单路径配置 + ndn::FibHelper::AddRoute("R1", "/Amazon", "P1", 0); + ndn::FibHelper::AddRoute("R1", "/Google", "R2", 0); + + ndn::FibHelper::AddRoute("R2", "/Amazon", "R1", 0); + ndn::FibHelper::AddRoute("R2", "/Google", "R3", 0); + ndn::FibHelper::AddRoute("R2", "/Warner", "R9", 0); + + ndn::FibHelper::AddRoute("R3", "/Amazon", "R2", 0); + ndn::FibHelper::AddRoute("R3", "/Google", "R4", 0); + ndn::FibHelper::AddRoute("R3", "/Warner", "R8", 0); + + ndn::FibHelper::AddRoute("R4", "/Amazon", "R3", 0); + ndn::FibHelper::AddRoute("R4", "/Google", "R5", 0); + ndn::FibHelper::AddRoute("R4", "/Warner", "R3", 0); + + ndn::FibHelper::AddRoute("R5", "/Google", "P2", 0); + + ndn::FibHelper::AddRoute("R6", "/Amazon", "R7", 0); + ndn::FibHelper::AddRoute("R6", "/Google", "R5", 0); + ndn::FibHelper::AddRoute("R6", "/Warner", "R7", 0); + + ndn::FibHelper::AddRoute("R7", "/Amazon", "R8", 0); + ndn::FibHelper::AddRoute("R7", "/Google", "R5", 0); + ndn::FibHelper::AddRoute("R7", "/Warner", "R8", 0); + + ndn::FibHelper::AddRoute("R8", "/Amazon", "R9", 0); + ndn::FibHelper::AddRoute("R8", "/Google", "R7", 0); + ndn::FibHelper::AddRoute("R8", "/Warner", "P3", 0); + + ndn::FibHelper::AddRoute("R9", "/Amazon", "R2", 0); + ndn::FibHelper::AddRoute("R9", "/Google", "R8", 0); + ndn::FibHelper::AddRoute("R9", "/Warner", "R8", 0); + + ndn::FibHelper::AddRoute("R10", "/Amazon", "R9", 0); + ndn::FibHelper::AddRoute("R10", "/Google", "R9", 0); + ndn::FibHelper::AddRoute("R10", "/Warner", "R9", 0); + + ndn::FibHelper::AddRoute("R0", "/Amazon", "R1", 0); + ndn::FibHelper::AddRoute("R0", "/Google", "R1", 0); + ndn::FibHelper::AddRoute("R0", "/Warner", "R10", 0); + + ndn::FibHelper::AddRoute("C1", "/Amazon", "R0", 0); + ndn::FibHelper::AddRoute("C1", "/Google", "R0", 0); + ndn::FibHelper::AddRoute("C1", "/Warner", "R0", 0); + + ndn::FibHelper::AddRoute("C2", "/Amazon", "R2", 0); + ndn::FibHelper::AddRoute("C2", "/Google", "R2", 0); + ndn::FibHelper::AddRoute("C2", "/Warner", "R2", 0); + + ndn::FibHelper::AddRoute("C3", "/Amazon", "R3", 0); + ndn::FibHelper::AddRoute("C3", "/Google", "R3", 0); + ndn::FibHelper::AddRoute("C3", "/Warner", "R3", 0); + + ndn::FibHelper::AddRoute("C4", "/Amazon", "R4", 0); + ndn::FibHelper::AddRoute("C4", "/Google", "R4", 0); + ndn::FibHelper::AddRoute("C4", "/Warner", "R4", 0); + + ndn::FibHelper::AddRoute("C5", "/Amazon", "R6", 0); + ndn::FibHelper::AddRoute("C5", "/Google", "R6", 0); + ndn::FibHelper::AddRoute("C5", "/Warner", "R6", 0); + + ndn::FibHelper::AddRoute("C6", "/Amazon", "R7", 0); + ndn::FibHelper::AddRoute("C6", "/Google", "R7", 0); + ndn::FibHelper::AddRoute("C6", "/Warner", "R7", 0); + + ndn::FibHelper::AddRoute("C7", "/Amazon", "R9", 0); + ndn::FibHelper::AddRoute("C7", "/Google", "R9", 0); + ndn::FibHelper::AddRoute("C7", "/Warner", "R9", 0); + + ndn::FibHelper::AddRoute("C8", "/Amazon", "R10", 0); + ndn::FibHelper::AddRoute("C8", "/Google", "R10", 0); + ndn::FibHelper::AddRoute("C8", "/Warner", "R10", 0); + + // // 多路径配置 + // ndn::FibHelper::AddRoute("R0", "/Warner", "R1", 0); + + // ndn::FibHelper::AddRoute("R1", "/Warner", "R2", 0); + + // ndn::FibHelper::AddRoute("R2", "/Warner", "R3", 0); + + // ndn::FibHelper::AddRoute("R3", "/Google", "R8", 0); + + // ndn::FibHelper::AddRoute("R5", "/Amazon", "R4", 0); + // ndn::FibHelper::AddRoute("R5", "/Warner", "R4", 0); + + // ndn::FibHelper::AddRoute("R6", "/Amazon", "R5", 0); + // ndn::FibHelper::AddRoute("R6", "/Google", "R7", 0); + // ndn::FibHelper::AddRoute("R6", "/Warner", "R5", 0); + + // ndn::FibHelper::AddRoute("R7", "/Amazon", "R5", 0); + + // ndn::FibHelper::AddRoute("R8", "/Amazon", "R3", 0); + + // ndn::FibHelper::AddRoute("R9", "/Google", "R2", 0); + + // ndn::FibHelper::AddRoute("R10", "/Amazon", "R0", 0); + + Simulator::Stop(Seconds(60.0)); + + ndn::L3RateTracer::InstallAll("dsccp4-1-mircc_throughput.txt", Seconds(0.1)); + ndn::AppDelayTracer::InstallAll("dsccp4-1-mircc_delay.txt"); + L2RateTracer::InstallAll("dsccp4-1-mircc_drop.txt", Seconds(0.1)); + Simulator::Run(); + Simulator::Destroy(); + + return 0; + } + +} // namespace ns3 + +int main(int argc, char *argv[]) +{ + return ns3::main(argc, argv); +} \ No newline at end of file diff --git a/scenario/scenarios/dsccp4-2-multi.cpp b/scenario/scenarios/dsccp4-2-multi.cpp new file mode 100644 index 0000000..6270075 --- /dev/null +++ b/scenario/scenarios/dsccp4-2-multi.cpp @@ -0,0 +1,277 @@ +#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/dsccp4.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("/"); + + // Installing global routing interface on all nodes + ndn::GlobalRoutingHelper ndnGlobalRoutingHelper; + ndnGlobalRoutingHelper.InstallAll(); + + // Getting containers for the consumer/producer + Ptr C1 = Names::Find("C1"); + Ptr C2 = Names::Find("C2"); + Ptr C3 = Names::Find("C3"); + Ptr C4 = Names::Find("C4"); + Ptr C5 = Names::Find("C5"); + Ptr C6 = Names::Find("C6"); + Ptr C7 = Names::Find("C7"); + Ptr C8 = Names::Find("C8"); + + Ptr P1 = Names::Find("P1"); + Ptr P2 = Names::Find("P2"); + Ptr P3 = Names::Find("P3"); + + ndn::AppHelper consumerHelper("ns3::ndn::ConsumerMIRCC"); + consumerHelper.SetAttribute("MaxSeq", StringValue("5000")); // 100 interests a second + consumerHelper.SetAttribute("logtms",StringValue("0")); + 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.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")); + + // Register /dst1 prefix with global routing controller and + // install producer that will satisfy Interests in /dst1 namespace + + producerHelper.SetPrefix("/Amazon"); + producerHelper.Install(P1); + + producerHelper.SetPrefix("/Google"); + producerHelper.Install(P2); + + producerHelper.SetPrefix("/Warner"); + producerHelper.Install(P3); + + // ndnGlobalRoutingHelper.AddOrigins("/Amazon", P1); + // ndnGlobalRoutingHelper.AddOrigins("/Google", P2); + // ndnGlobalRoutingHelper.AddOrigins("/Warner", P3); + + // // Calculate all possible routes and install FIBs + // ndn::GlobalRoutingHelper::CalculateRoutes(); + + + // 单路径配置 + ndn::FibHelper::AddRoute("R1", "/Amazon", "P1", 0); + ndn::FibHelper::AddRoute("R1", "/Google", "R2", 0); + + ndn::FibHelper::AddRoute("R2", "/Amazon", "R1", 0); + ndn::FibHelper::AddRoute("R2", "/Google", "R3", 0); + ndn::FibHelper::AddRoute("R2", "/Warner", "R9", 0); + + ndn::FibHelper::AddRoute("R3", "/Amazon", "R2", 0); + ndn::FibHelper::AddRoute("R3", "/Google", "R4", 0); + ndn::FibHelper::AddRoute("R3", "/Warner", "R8", 0); + + ndn::FibHelper::AddRoute("R4", "/Amazon", "R3", 0); + ndn::FibHelper::AddRoute("R4", "/Google", "R5", 0); + ndn::FibHelper::AddRoute("R4", "/Warner", "R3", 0); + + ndn::FibHelper::AddRoute("R5", "/Google", "P2", 0); + + ndn::FibHelper::AddRoute("R6", "/Amazon", "R7", 0); + ndn::FibHelper::AddRoute("R6", "/Google", "R5", 0); + ndn::FibHelper::AddRoute("R6", "/Warner", "R7", 0); + + ndn::FibHelper::AddRoute("R7", "/Amazon", "R8", 0); + ndn::FibHelper::AddRoute("R7", "/Google", "R5", 0); + ndn::FibHelper::AddRoute("R7", "/Warner", "R8", 0); + + ndn::FibHelper::AddRoute("R8", "/Amazon", "R9", 0); + ndn::FibHelper::AddRoute("R8", "/Google", "R7", 0); + ndn::FibHelper::AddRoute("R8", "/Warner", "P3", 0); + + ndn::FibHelper::AddRoute("R9", "/Amazon", "R2", 0); + ndn::FibHelper::AddRoute("R9", "/Google", "R8", 0); + ndn::FibHelper::AddRoute("R9", "/Warner", "R8", 0); + + ndn::FibHelper::AddRoute("R10", "/Amazon", "R9", 0); + ndn::FibHelper::AddRoute("R10", "/Google", "R9", 0); + ndn::FibHelper::AddRoute("R10", "/Warner", "R9", 0); + + ndn::FibHelper::AddRoute("R0", "/Amazon", "R1", 0); + ndn::FibHelper::AddRoute("R0", "/Google", "R1", 0); + ndn::FibHelper::AddRoute("R0", "/Warner", "R10", 0); + + ndn::FibHelper::AddRoute("C1", "/Amazon", "R0", 0); + ndn::FibHelper::AddRoute("C1", "/Google", "R0", 0); + ndn::FibHelper::AddRoute("C1", "/Warner", "R0", 0); + + ndn::FibHelper::AddRoute("C2", "/Amazon", "R2", 0); + ndn::FibHelper::AddRoute("C2", "/Google", "R2", 0); + ndn::FibHelper::AddRoute("C2", "/Warner", "R2", 0); + + ndn::FibHelper::AddRoute("C3", "/Amazon", "R3", 0); + ndn::FibHelper::AddRoute("C3", "/Google", "R3", 0); + ndn::FibHelper::AddRoute("C3", "/Warner", "R3", 0); + + ndn::FibHelper::AddRoute("C4", "/Amazon", "R4", 0); + ndn::FibHelper::AddRoute("C4", "/Google", "R4", 0); + ndn::FibHelper::AddRoute("C4", "/Warner", "R4", 0); + + ndn::FibHelper::AddRoute("C5", "/Amazon", "R6", 0); + ndn::FibHelper::AddRoute("C5", "/Google", "R6", 0); + ndn::FibHelper::AddRoute("C5", "/Warner", "R6", 0); + + ndn::FibHelper::AddRoute("C6", "/Amazon", "R7", 0); + ndn::FibHelper::AddRoute("C6", "/Google", "R7", 0); + ndn::FibHelper::AddRoute("C6", "/Warner", "R7", 0); + + ndn::FibHelper::AddRoute("C7", "/Amazon", "R9", 0); + ndn::FibHelper::AddRoute("C7", "/Google", "R9", 0); + ndn::FibHelper::AddRoute("C7", "/Warner", "R9", 0); + + ndn::FibHelper::AddRoute("C8", "/Amazon", "R10", 0); + ndn::FibHelper::AddRoute("C8", "/Google", "R10", 0); + ndn::FibHelper::AddRoute("C8", "/Warner", "R10", 0); + + // 多路径配置 + ndn::FibHelper::AddRoute("R0", "/Warner", "R1", 0); + + ndn::FibHelper::AddRoute("R1", "/Warner", "R2", 0); + + ndn::FibHelper::AddRoute("R2", "/Warner", "R3", 0); + + ndn::FibHelper::AddRoute("R3", "/Google", "R8", 0); + + ndn::FibHelper::AddRoute("R5", "/Amazon", "R4", 0); + ndn::FibHelper::AddRoute("R5", "/Warner", "R4", 0); + + ndn::FibHelper::AddRoute("R6", "/Amazon", "R5", 0); + ndn::FibHelper::AddRoute("R6", "/Google", "R7", 0); + ndn::FibHelper::AddRoute("R6", "/Warner", "R5", 0); + + ndn::FibHelper::AddRoute("R7", "/Amazon", "R5", 0); + + ndn::FibHelper::AddRoute("R8", "/Amazon", "R3", 0); + + ndn::FibHelper::AddRoute("R9", "/Google", "R2", 0); + + ndn::FibHelper::AddRoute("R10", "/Amazon", "R0", 0); + + Simulator::Stop(Seconds(60.0)); + + ndn::L3RateTracer::InstallAll("dsccp4-2-mircc_throughput.txt", Seconds(0.1)); + ndn::AppDelayTracer::InstallAll("dsccp4-2-mircc_delay.txt"); + L2RateTracer::InstallAll("dsccp4-2-mircc_drop.txt", Seconds(0.1)); + Simulator::Run(); + Simulator::Destroy(); + + return 0; + } + +} // namespace ns3 + +int main(int argc, char *argv[]) +{ + return ns3::main(argc, argv); +} \ No newline at end of file diff --git a/scenario/topologies/dsccp3-1.txt b/scenario/topologies/dsccp3-1.txt new file mode 100644 index 0000000..27c7e11 --- /dev/null +++ b/scenario/topologies/dsccp3-1.txt @@ -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 +R2 R3 1Mbps 1 10ms 20 +R4 R3 2Mbps 1 5ms 20 +R3 R6 3Mbps 1 10ms 20 +R4 R5 3Mbps 1 5ms 20 +R2 R4 5Mbps 1 5ms 20 +R2 R5 4Mbps 1 10ms 20 +R5 R6 7Mbps 1 10ms 20 diff --git a/scenario/topologies/dsccp4.txt b/scenario/topologies/dsccp4.txt new file mode 100644 index 0000000..6348d96 --- /dev/null +++ b/scenario/topologies/dsccp4.txt @@ -0,0 +1,57 @@ +# topo_abilene.txt + +router + +# node comment yPos xPos +C1 NA 3 7 +C2 NA 1 4 +C3 NA 1 3 +C4 NA 3 1 +C5 NA 5 1 +C6 NA 6 3 +C7 NA 6 5 +C8 NA 4 7 +R0 NA 3 6 +R1 NA 2 5 +R2 NA 2 4 +R3 NA 2 3 +R4 NA 3 2 +R5 NA 4 2 +R6 NA 5 2 +R7 NA 5 3 +R8 NA 5 4 +R9 NA 5 5 +R10 NA 4 6 +P1 NA 1 5 +P2 NA 4 1 +P3 NA 6 4 + + +link + +# srcNode dstNode bandwidth metric delay queue +C1 R0 100Mbps 1 10ms 20 +R1 P1 100Mbps 1 10ms 20 +R2 C2 100Mbps 1 10ms 20 +R3 C3 100Mbps 1 10ms 20 +R4 C4 100Mbps 1 10ms 20 +R5 P2 100Mbps 1 10ms 20 +R6 C5 100Mbps 1 10ms 20 +R7 C6 100Mbps 1 10ms 20 +R8 P3 100Mbps 1 10ms 20 +R9 C7 100Mbps 1 10ms 20 +R10 C8 100Mbps 1 10ms 20 +R0 R1 10Mbps 1 10ms 20 +R1 R2 25Mbps 1 10ms 20 +R2 R3 15Mbps 1 10ms 20 +R3 R4 15Mbps 1 10ms 20 +R4 R5 20Mbps 1 10ms 20 +R5 R6 5Mbps 1 10ms 20 +R6 R7 5Mbps 1 10ms 20 +R7 R8 10Mbps 1 10ms 20 +R8 R9 20Mbps 1 10ms 20 +R9 R10 20Mbps 1 10ms 20 +R10 R0 10Mbps 1 10ms 20 +R2 R9 20Mbps 1 10ms 20 +R3 R8 10Mbps 1 10ms 20 +R5 R7 15Mbps 1 10ms 20