21 #include "ndn-fib-entry.h"
24 #include "ns3/ndn-name.h"
26 #include "ns3/simulator.h"
28 #define NDN_RTO_ALPHA 0.125
29 #define NDN_RTO_BETA 0.25
32 #include <boost/ref.hpp>
33 #include <boost/lambda/lambda.hpp>
34 #include <boost/lambda/bind.hpp>
35 namespace ll = boost::lambda;
37 NS_LOG_COMPONENT_DEFINE (
"ndn.fib.Entry");
49 typedef FaceMetricContainer::type::index<i_face>::type
63 NS_ASSERT_MSG (m_rttVar.IsZero (),
"SRTT is zero, but variation is not");
66 m_rttVar = Time (m_sRtt / 2.0);
70 m_rttVar = Time ((1 - NDN_RTO_BETA) * m_rttVar + 1.0 * NDN_RTO_BETA * Abs(m_sRtt - rttSample));
71 m_sRtt = Time ((1 - NDN_RTO_ALPHA) * m_sRtt + 1.0 * NDN_RTO_ALPHA * rttSample);
80 FaceMetricByFace::type::iterator record =
m_faces.get<i_face> ().find (face);
81 if (record ==
m_faces.get<i_face> ().end ())
90 m_faces.get<i_nth> ().rearrange (
m_faces.get<i_metric> ().begin ());
96 NS_LOG_FUNCTION (
this << boost::cref(*face) << status);
98 FaceMetricByFace::type::iterator record =
m_faces.get<i_face> ().find (face);
99 if (record ==
m_faces.get<i_face> ().end ())
108 m_faces.get<i_nth> ().rearrange (
m_faces.get<i_metric> ().begin ());
114 NS_LOG_FUNCTION (
this);
115 NS_ASSERT_MSG (face != NULL,
"Trying to Add or Update NULL face");
117 FaceMetricByFace::type::iterator record =
m_faces.get<i_face> ().find (face);
118 if (record ==
m_faces.get<i_face> ().end ())
125 if (record->GetRoutingCost () > metric || record->GetStatus () == FaceMetric::NDN_FIB_RED)
136 m_faces.get<i_nth> ().rearrange (
m_faces.get<i_metric> ().begin ());
142 NS_LOG_FUNCTION (
this);
143 NS_ASSERT_MSG (face != NULL,
"Trying to Update NULL face");
145 FaceMetricByFace::type::iterator record =
m_faces.get<i_face> ().find (face);
146 if (record !=
m_faces.get<i_face> ().end ())
157 for (FaceMetricByFace::type::iterator face =
m_faces.begin ();
174 return m_faces.get<i_nth> () [skip];
184 std::ostream& operator<< (std::ostream& os,
const Entry &entry)
186 for (FaceMetricContainer::type::index<i_nth>::type::iterator metric =
187 entry.
m_faces.get<i_nth> ().begin ();
188 metric != entry.
m_faces.get<i_nth> ().end ();
191 if (metric != entry.
m_faces.get<i_nth> ().begin ())
199 std::ostream& operator<< (std::ostream& os,
const FaceMetric &metric)
201 static const std::string statusString[] = {
"",
"g",
"y",
"r"};
203 os << *metric.m_face <<
"(" << metric.m_routingCost <<
","<< statusString [metric.m_status] <<
"," << metric.m_face->GetMetric () <<
")";
Exception class for the case when FIB entry is not found.
Status
Color codes for FIB face status.
Structure for FIB table entry, holding indexed list of available faces and their respective metrics...
void UpdateStatus(Ptr< Face > face, FaceMetric::Status status)
Update status of FIB next hop.
void SetStatus(Status status)
Set current status of FIB entry.
void AddOrUpdateRoutingMetric(Ptr< Face > face, int32_t metric)
Add or update routing metric of FIB next hop.
void Invalidate()
Invalidate face.
FaceMetricContainer::type m_faces
Indexed list of faces.
void UpdateRtt(const Time &rttSample)
Recalculate smoothed RTT and RTT variation.
Structure holding various parameters associated with a (FibEntry, Face) tuple.
Ptr< Fib > GetFib()
Get pointer to access FIB, to which this entry is added.
void SetRealDelay(Time realDelay)
Set real propagation delay to the producer, calculated based on NS-3 p2p link delays.
void SetRealDelayToProducer(Ptr< Face > face, Time delay)
Set real delay to the producer.
void SetRoutingCost(int32_t routingCost)
Set routing cost.
Ptr< Fib > m_fib
FIB to which entry is added.
const FaceMetric & FindBestCandidate(uint32_t skip=0) const
Find "best route" candidate, skipping `skip' first candidates (modulo # of faces) ...
void UpdateFaceRtt(Ptr< Face > face, const Time &sample)
Update RTT averages for the face.