NS-3 based Named Data Networking (NDN) simulator
ndnSIM: NDN, CCN, CCNx, content centric networks
API Documentation
Main Page
Related Pages
Modules
Namespaces
Classes
Files
File List
All
Classes
Namespaces
Files
Functions
Variables
Typedefs
Enumerations
Enumerator
Groups
Pages
best-route.cc
1
/* -*- Mode: C++; c-file-style: "gnu"; indent-tabs-mode:nil; -*- */
2
/*
3
* Copyright (c) 2011 University of California, Los Angeles
4
*
5
* This program is free software; you can redistribute it and/or modify
6
* it under the terms of the GNU General Public License version 2 as
7
* published by the Free Software Foundation;
8
*
9
* This program is distributed in the hope that it will be useful,
10
* but WITHOUT ANY WARRANTY; without even the implied warranty of
11
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12
* GNU General Public License for more details.
13
*
14
* You should have received a copy of the GNU General Public License
15
* along with this program; if not, write to the Free Software
16
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
17
*
18
* Author: Alexander Afanasyev <alexander.afanasyev@ucla.edu>
19
* Ilya Moiseenko <iliamo@cs.ucla.edu>
20
*/
21
22
#include "best-route.h"
23
24
#include "ns3/ndn-interest.h"
25
#include "ns3/ndn-pit.h"
26
#include "ns3/ndn-pit-entry.h"
27
28
#include "ns3/assert.h"
29
#include "ns3/log.h"
30
31
#include <boost/foreach.hpp>
32
#include <boost/lambda/lambda.hpp>
33
#include <boost/lambda/bind.hpp>
34
namespace
ll = boost::lambda;
35
36
namespace
ns3 {
37
namespace
ndn {
38
namespace
fw {
39
40
NS_OBJECT_ENSURE_REGISTERED (
BestRoute
);
41
42
LogComponent BestRoute::g_log = LogComponent (
BestRoute::GetLogName
().c_str ());
43
44
std::string
45
BestRoute::GetLogName
()
46
{
47
return
super::GetLogName
()+
".BestRoute"
;
48
}
49
50
51
TypeId
52
BestRoute::GetTypeId (
void
)
53
{
54
static
TypeId tid = TypeId (
"ns3::ndn::fw::BestRoute"
)
55
.SetGroupName (
"Ndn"
)
56
.SetParent <super> ()
57
.AddConstructor <BestRoute> ()
58
;
59
return
tid;
60
}
61
62
BestRoute::BestRoute
()
63
{
64
}
65
66
bool
67
BestRoute::DoPropagateInterest
(Ptr<Face> inFace,
68
Ptr<const Interest> interest,
69
Ptr<pit::Entry> pitEntry)
70
{
71
NS_LOG_FUNCTION (
this
<< interest->GetName ());
72
73
// No real need to call parent's (green-yellow-red's strategy) method, since it is incorporated
74
// in the logic of the BestRoute strategy
75
//
76
// // Try to work out with just green faces
77
// bool greenOk = super::DoPropagateInterest (inFace, interest, origPacket, pitEntry);
78
// if (greenOk)
79
// return true;
80
81
int
propagatedCount = 0;
82
83
BOOST_FOREACH (
const
fib::FaceMetric
&metricFace, pitEntry->GetFibEntry ()->m_faces.get<fib::i_metric> ())
84
{
85
NS_LOG_DEBUG (
"Trying "
<< boost::cref(metricFace));
86
if
(metricFace.
GetStatus
() == fib::FaceMetric::NDN_FIB_RED)
// all non-read faces are in front
87
break
;
88
89
if
(!
TrySendOutInterest
(inFace, metricFace.
GetFace
(), interest, pitEntry))
90
{
91
continue
;
92
}
93
94
propagatedCount++;
95
break
;
// do only once
96
}
97
98
NS_LOG_INFO (
"Propagated to "
<< propagatedCount <<
" faces"
);
99
return
propagatedCount > 0;
100
}
101
102
}
// namespace fw
103
}
// namespace ndn
104
}
// namespace ns3
ns3::ndn::fib::FaceMetric::GetFace
Ptr< Face > GetFace() const
Return Face associated with FaceMetric.
Definition:
ndn-fib-entry.h:99
ns3::ndn::ForwardingStrategy::GetLogName
static std::string GetLogName()
Helper function to retrieve logging name for the forwarding strategy.
Definition:
ndn-forwarding-strategy.cc:57
ns3::ndn::fw::BestRoute::DoPropagateInterest
virtual bool DoPropagateInterest(Ptr< Face > incomingFace, Ptr< const Interest > interest, Ptr< pit::Entry > pitEntry)
Virtual method to perform Interest propagation according to the forwarding strategy logic...
Definition:
best-route.cc:67
ns3::ndn::fib::FaceMetric
Structure holding various parameters associated with a (FibEntry, Face) tuple.
Definition:
ndn-fib-entry.h:58
ns3::ndn::fw::BestRoute::GetLogName
static std::string GetLogName()
Helper function to retrieve logging name for the forwarding strategy.
Definition:
best-route.cc:45
ns3::ndn::fib::FaceMetric::GetStatus
Status GetStatus() const
Get current status of FIB entry.
Definition:
ndn-fib-entry.h:112
ns3::ndn::fw::BestRoute
Best route strategy.
Definition:
best-route.h:37
ns3::ndn::fw::BestRoute::BestRoute
BestRoute()
Default constructor.
Definition:
best-route.cc:62
ns3::ndn::ForwardingStrategy::TrySendOutInterest
virtual bool TrySendOutInterest(Ptr< Face > inFace, Ptr< Face > outFace, Ptr< const Interest > interest, Ptr< pit::Entry > pitEntry)
Method implementing actual interest forwarding, taking into account CanSendOutInterest decision...
Definition:
ndn-forwarding-strategy.cc:523
ndnSIM
model
fw
best-route.cc
Generated on Mon Jan 19 2015 11:27:03 for ndnSIM by
1.8.7