NS-3 based Named Data Networking (NDN) simulator
ndnSIM 2.5: NDN, CCN, CCNx, content centric networks
API Documentation
fib-nexthop.cpp
Go to the documentation of this file.
1
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
21
#include "
fib-nexthop.hpp
"
22
23
#include <boost/functional/hash.hpp>
24
#include <ostream>
25
26
namespace
ns3
{
27
namespace
ndn
{
28
29
constexpr
int
NODE_ID_LIMIT
= 1000;
30
31
FibNextHop::FibNextHop
(
int
cost,
int
nhId,
int
costDelta,
NextHopType
type)
32
{
33
NS_ABORT_UNLESS(cost > 0 && cost <=
MAX_COST
);
34
NS_ABORT_UNLESS(nhId >= 0 && nhId <=
NODE_ID_LIMIT
);
35
36
this->m_nhId = nhId;
37
this->m_cost = cost;
38
this->m_type = type;
39
this->m_costDelta = costDelta;
40
}
41
42
std::ostream&
43
operator<<
(std::ostream& os,
const
NextHopType
& type)
44
{
45
switch
(type) {
46
case
NextHopType::DOWNWARD
:
47
return
os <<
"DOWNWARD"
;
48
case
NextHopType::UPWARD
:
49
return
os <<
"UPWARD"
;
50
case
NextHopType::DISABLED
:
51
return
os <<
"DISABLED"
;
52
}
53
return
os << static_cast<int>(type);
54
}
55
56
std::ostream&
57
operator<<
(std::ostream& os,
const
FibNextHop
& a)
58
{
59
return
os <<
"Id: "
<< a.
getNexthopId
() <<
", cost: "
<< a.m_cost <<
", type: "
<< a.m_type;
60
}
61
62
}
// namespace ndn
63
}
// namespace ns-3
64
65
namespace
std {
66
67
using
ns3::ndn::FibNextHop
;
68
69
template
<>
70
struct
hash<
FibNextHop
> {
71
size_t
72
operator()
(
const
FibNextHop
& k)
const
73
{
74
// Combine hash via boost library
75
std::size_t seed = 0;
76
boost::hash_combine(seed, k.
getNexthopId
());
77
boost::hash_combine(seed, k.
getCost
());
78
79
return
seed;
80
}
81
};
82
83
}
ns3::ndn::operator<<
std::ostream & operator<<(std::ostream &os, const AbstractFib &fib)
Definition:
abstract-fib.cpp:175
ns3
Copyright (c) 2011-2015 Regents of the University of California.
Definition:
ndn-app-link-service.cpp:32
ns3::ndn::FibNextHop::FibNextHop
FibNextHop(int cost, int nhId, int costDelta=-1, NextHopType type=NextHopType::DISABLED)
Definition:
fib-nexthop.cpp:31
ns3::ndn::NextHopType
NextHopType
Definition:
fib-nexthop.hpp:32
ns3::ndn::FibNextHop::getCost
int getCost() const
Definition:
fib-nexthop.hpp:56
ns3::ndn::NextHopType::DOWNWARD
@ DOWNWARD
ns3::ndn::FibNextHop::getNexthopId
int getNexthopId() const
Definition:
fib-nexthop.hpp:50
std::hash< FibNextHop >::operator()
size_t operator()(const FibNextHop &k) const
Definition:
fib-nexthop.cpp:72
ns3::ndn::NextHopType::DISABLED
@ DISABLED
ns3::ndn::NextHopType::UPWARD
@ UPWARD
ns3::ndn::FibNextHop::MAX_COST
static constexpr int MAX_COST
Definition:
fib-nexthop.hpp:38
ns3::ndn::FibNextHop
Definition:
fib-nexthop.hpp:36
ns3::ndn::NODE_ID_LIMIT
constexpr int NODE_ID_LIMIT
Definition:
fib-nexthop.cpp:29
fib-nexthop.hpp
ndn
Copyright (c) 2011-2015 Regents of the University of California.
Definition:
ndn-strategy-choice-helper.hpp:34
ndnSIM
helper
lfid
fib-nexthop.cpp
Generated on Mon Jun 1 2020 22:32:14 for ndnSIM by
1.8.18