114 lines
3.8 KiB
C++
114 lines
3.8 KiB
C++
|
|
#include "face/face.hpp"
|
|
#include "fw/strategy.hpp"
|
|
#include "fw/algorithm.hpp"
|
|
#include "fw/process-nack-traits.hpp"
|
|
#include <unordered_map>
|
|
#include <limits>
|
|
#include <deque>
|
|
#include "ndn-cxx/lp/tags.hpp"
|
|
#include "common/global.hpp"
|
|
#include "ns3/simulator.h"
|
|
|
|
|
|
namespace nfd {
|
|
namespace fw {
|
|
class MIRCCQueue
|
|
{
|
|
public:
|
|
std:: deque<shared_ptr<Interest>> qp,qs;
|
|
//记录的是过期时间,非达到时间
|
|
std:: deque<time::steady_clock::TimePoint> tp,ts;
|
|
|
|
std:: deque<shared_ptr<pit::Entry>> pp,ps;
|
|
|
|
};
|
|
|
|
/*
|
|
MIRCC 策略实现
|
|
*/
|
|
class MIRCCStrategy : public Strategy, public ProcessNackTraits<MIRCCStrategy>
|
|
{
|
|
public:
|
|
explicit MIRCCStrategy(Forwarder &forwarder, const ndn::Name &name);
|
|
|
|
~MIRCCStrategy() override = default;
|
|
|
|
void
|
|
afterReceiveInterest(const FaceEndpoint &ingress, const Interest &interest,const shared_ptr<pit::Entry> &pitEntry) override;
|
|
|
|
void
|
|
afterReceiveNack(const FaceEndpoint &ingress, const lp::Nack &nack,const shared_ptr<pit::Entry> &pitEntry) override;
|
|
|
|
void
|
|
beforeSatisfyInterest(const shared_ptr<pit::Entry> &pitEntry,const FaceEndpoint &ingress, const Data &data) override;
|
|
|
|
void
|
|
afterReceiveData(const shared_ptr<pit::Entry> &pitEntry,const FaceEndpoint &ingress, const Data &data) override;
|
|
|
|
static const Name &
|
|
getStrategyName();
|
|
|
|
protected:
|
|
friend ProcessNackTraits<MIRCCStrategy>;
|
|
|
|
private:
|
|
static const uint64_t MAX_FACE = 10;//单一节点最多支持10个外部端口,涉及到hash的计算
|
|
const uint64_t DATA_SIZE = 8696;//固定数据包大小
|
|
const uint64_t MAX_QUEUE = 10;//固定队列大小
|
|
|
|
const double m_B = 0.1;//公式B系数
|
|
const double m_a = 0.5;//速率更新系数
|
|
const double m_miu = 0.95;//链路利用率
|
|
const double m_rtt_a = 0.7;//RTT更新系数
|
|
|
|
|
|
uint64_t m_Rp_base[MAX_FACE];//Rp的base速率
|
|
uint64_t m_Rp_ex[MAX_FACE];//Rp的ex速率
|
|
uint64_t m_Rs_base[MAX_FACE];//Rs的base速率
|
|
uint64_t m_Rs_ex[MAX_FACE];//Rs的ex速率
|
|
uint64_t m_Yp[MAX_FACE];//本周期的Yp(t)
|
|
uint64_t m_Yp_old[MAX_FACE];//上一个周期的Yp(t)
|
|
uint64_t m_Ys[MAX_FACE];//本周起的Ys(t)
|
|
uint64_t m_Ys_old[MAX_FACE];//上一个周期的Ys(t)
|
|
uint64_t m_linkC[MAX_FACE];//每一个链路的带宽,单位为比特
|
|
|
|
double m_d[MAX_FACE];//维护每一个face的RTT 秒
|
|
//注意,此处没有维护数据包/兴趣包,算法中采用固定的数据包大小
|
|
|
|
MIRCCQueue m_Queue[MAX_FACE];//用于出口排队转发兴趣
|
|
|
|
//发送mface端口1个正在排队的兴趣包,并设置下一次发送时间
|
|
void
|
|
sendQueueInterest(FaceId mface);
|
|
|
|
//将兴趣包放入mface端口的队列
|
|
void
|
|
pushQueueInterest(FaceId mface, const shared_ptr<Interest>& interest,const shared_ptr<pit::Entry>& pitEntry);
|
|
|
|
//计算并返回mface端口的q(t)
|
|
uint64_t
|
|
getQt(FaceId mface);
|
|
|
|
//对于mface端口周期性计算Rt
|
|
void
|
|
calcRt(FaceId mface);
|
|
|
|
//拖延1ns后进行初始化,避免发现端口失败
|
|
void
|
|
mirccinit();
|
|
|
|
//将端口号映射至从0开始
|
|
uint64_t
|
|
inface(FaceId mface)
|
|
{
|
|
return mface - 257;
|
|
}
|
|
};
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|