olsr: Convert Willingness to enum
This commit is contained in:
committed by
Tommaso Pecorella
parent
d10004d006
commit
9a8a2640a8
@@ -52,6 +52,7 @@ Changes from ns-3.38 to ns-3-dev
|
||||
* (lr-wpan) Added `macShortAddress`, `macExtendendAddress` and `macPanId` to the attributes that can be use with MLME-GET and MLME-SET functions.
|
||||
* (wifi) The QosBlockedDestinations class has been removed and its functionality is now provided via a new framework for blocking/unblocking packets that is based on the queue scheduler.
|
||||
* (internet) The function signature of `Ipv4RoutingProtocol::RouteInput` and `Ipv6RoutingProtocol::RouteInput` have changed. The `UnicastForwardCallback` (ucb), `MulticastForwardCallback` (mcb), `LocalDeliverCallback` (lcb) and `ErrorCallback` (ecb) should now be passed as const references.
|
||||
* (olsr) The defines `OLSR_WILL_*` have been replaced by enum `Willingness`.
|
||||
|
||||
### Changes to build system
|
||||
|
||||
|
||||
@@ -115,7 +115,7 @@ The list of configurabel attributes is:
|
||||
* TcInterval (time, default 5s), TC messages emission interval.
|
||||
* MidInterval (time, default 5s), MID messages emission interval.
|
||||
* HnaInterval (time, default 5s), HNA messages emission interval.
|
||||
* Willingness (enum, default OLSR_WILL_DEFAULT), Willingness of a node to carry and forward traffic for other nodes.
|
||||
* Willingness (enum, default olsr::Willingness::DEFAULT), Willingness of a node to carry and forward traffic for other nodes.
|
||||
|
||||
Tracing
|
||||
+++++++
|
||||
|
||||
@@ -104,19 +104,6 @@
|
||||
/// Asymmetric neighbor type.
|
||||
#define OLSR_MPR_NEIGH 2
|
||||
|
||||
/********** Willingness **********/
|
||||
|
||||
/// Willingness for forwarding packets from other nodes: never.
|
||||
#define OLSR_WILL_NEVER 0
|
||||
/// Willingness for forwarding packets from other nodes: low.
|
||||
#define OLSR_WILL_LOW 1
|
||||
/// Willingness for forwarding packets from other nodes: medium.
|
||||
#define OLSR_WILL_DEFAULT 3
|
||||
/// Willingness for forwarding packets from other nodes: high.
|
||||
#define OLSR_WILL_HIGH 6
|
||||
/// Willingness for forwarding packets from other nodes: always.
|
||||
#define OLSR_WILL_ALWAYS 7
|
||||
|
||||
/********** Miscellaneous constants **********/
|
||||
|
||||
/// Maximum allowed jitter.
|
||||
@@ -180,17 +167,17 @@ RoutingProtocol::GetTypeId()
|
||||
MakeTimeChecker())
|
||||
.AddAttribute("Willingness",
|
||||
"Willingness of a node to carry and forward traffic for other nodes.",
|
||||
EnumValue(OLSR_WILL_DEFAULT),
|
||||
EnumValue(Willingness::DEFAULT),
|
||||
MakeEnumAccessor(&RoutingProtocol::m_willingness),
|
||||
MakeEnumChecker(OLSR_WILL_NEVER,
|
||||
MakeEnumChecker(Willingness::NEVER,
|
||||
"never",
|
||||
OLSR_WILL_LOW,
|
||||
Willingness::LOW,
|
||||
"low",
|
||||
OLSR_WILL_DEFAULT,
|
||||
Willingness::DEFAULT,
|
||||
"default",
|
||||
OLSR_WILL_HIGH,
|
||||
Willingness::HIGH,
|
||||
"high",
|
||||
OLSR_WILL_ALWAYS,
|
||||
Willingness::ALWAYS,
|
||||
"always"))
|
||||
.AddTraceSource("Rx",
|
||||
"Receive OLSR packet.",
|
||||
@@ -696,7 +683,7 @@ RoutingProtocol::MprComputation()
|
||||
|
||||
// N2 is the set of 2-hop neighbors reachable from "the interface
|
||||
// I", excluding:
|
||||
// (i) the nodes only reachable by members of N with willingness WILL_NEVER
|
||||
// (i) the nodes only reachable by members of N with willingness Willingness::NEVER
|
||||
// (ii) the node performing the computation
|
||||
// (iii) all the symmetric neighbors: the nodes for which there exists a symmetric
|
||||
// link to this node on some interface.
|
||||
@@ -713,13 +700,13 @@ RoutingProtocol::MprComputation()
|
||||
}
|
||||
|
||||
// excluding:
|
||||
// (i) the nodes only reachable by members of N with willingness WILL_NEVER
|
||||
// (i) the nodes only reachable by members of N with willingness Willingness::NEVER
|
||||
bool ok = false;
|
||||
for (NeighborSet::const_iterator neigh = N.begin(); neigh != N.end(); neigh++)
|
||||
{
|
||||
if (neigh->neighborMainAddr == twoHopNeigh->neighborMainAddr)
|
||||
{
|
||||
if (neigh->willingness == OLSR_WILL_NEVER)
|
||||
if (neigh->willingness == Willingness::NEVER)
|
||||
{
|
||||
ok = false;
|
||||
break;
|
||||
@@ -774,10 +761,10 @@ RoutingProtocol::MprComputation()
|
||||
#endif // NS3_LOG_ENABLE
|
||||
|
||||
// 1. Start with an MPR set made of all members of N with
|
||||
// N_willingness equal to WILL_ALWAYS
|
||||
// N_willingness equal to Willingness::ALWAYS
|
||||
for (NeighborSet::const_iterator neighbor = N.begin(); neighbor != N.end(); neighbor++)
|
||||
{
|
||||
if (neighbor->willingness == OLSR_WILL_ALWAYS)
|
||||
if (neighbor->willingness == Willingness::ALWAYS)
|
||||
{
|
||||
mprSet.insert(neighbor->neighborMainAddr);
|
||||
// (not in RFC but I think is needed: remove the 2-hop
|
||||
@@ -1058,7 +1045,7 @@ RoutingProtocol::RoutingTableComputation()
|
||||
// neighbor node or the node itself, and such that there exist at
|
||||
// least one entry in the 2-hop neighbor set where
|
||||
// N_neighbor_main_addr correspond to a neighbor node with
|
||||
// willingness different of WILL_NEVER,
|
||||
// willingness different of Willingness::NEVER,
|
||||
const TwoHopNeighborSet& twoHopNeighbors = m_state.GetTwoHopNeighbors();
|
||||
for (TwoHopNeighborSet::const_iterator it = twoHopNeighbors.begin();
|
||||
it != twoHopNeighbors.end();
|
||||
@@ -1083,14 +1070,14 @@ RoutingProtocol::RoutingTableComputation()
|
||||
|
||||
// ...and such that there exist at least one entry in the 2-hop
|
||||
// neighbor set where N_neighbor_main_addr correspond to a
|
||||
// neighbor node with willingness different of WILL_NEVER...
|
||||
// neighbor node with willingness different of Willingness::NEVER...
|
||||
bool nb2hopOk = false;
|
||||
for (NeighborSet::const_iterator neighbor = neighborSet.begin();
|
||||
neighbor != neighborSet.end();
|
||||
neighbor++)
|
||||
{
|
||||
if (neighbor->neighborMainAddr == nb2hop_tuple.neighborMainAddr &&
|
||||
neighbor->willingness != OLSR_WILL_NEVER)
|
||||
neighbor->willingness != Willingness::NEVER)
|
||||
{
|
||||
nb2hopOk = true;
|
||||
break;
|
||||
@@ -2386,7 +2373,7 @@ RoutingProtocol::NeighborLoss(const LinkTuple& tuple)
|
||||
{
|
||||
NS_LOG_DEBUG(Simulator::Now().As(Time::S) << ": OLSR Node " << m_mainAddress << " LinkTuple "
|
||||
<< tuple.neighborIfaceAddr << " -> neighbor loss.");
|
||||
LinkTupleUpdated(tuple, OLSR_WILL_DEFAULT);
|
||||
LinkTupleUpdated(tuple, Willingness::DEFAULT);
|
||||
m_state.EraseTwoHopNeighborTuples(GetMainAddress(tuple.neighborIfaceAddr));
|
||||
m_state.EraseMprSelectorTuples(GetMainAddress(tuple.neighborIfaceAddr));
|
||||
|
||||
|
||||
@@ -76,6 +76,21 @@ struct RoutingTableEntry
|
||||
|
||||
class RoutingProtocol;
|
||||
|
||||
/**
|
||||
* \ingroup olsr
|
||||
*
|
||||
* Willingness for forwarding packets from other nodes
|
||||
* See \RFC{3626} section 18.8
|
||||
*/
|
||||
enum Willingness
|
||||
{
|
||||
NEVER = 0,
|
||||
LOW = 1,
|
||||
DEFAULT = 3, // medium
|
||||
HIGH = 6,
|
||||
ALWAYS = 7,
|
||||
};
|
||||
|
||||
///
|
||||
/// \ingroup olsr
|
||||
///
|
||||
|
||||
@@ -28,19 +28,6 @@
|
||||
* \defgroup olsr-test olsr module tests
|
||||
*/
|
||||
|
||||
/********** Willingness **********/
|
||||
|
||||
/// Willingness for forwarding packets from other nodes: never.
|
||||
#define OLSR_WILL_NEVER 0
|
||||
/// Willingness for forwarding packets from other nodes: low.
|
||||
#define OLSR_WILL_LOW 1
|
||||
/// Willingness for forwarding packets from other nodes: medium.
|
||||
#define OLSR_WILL_DEFAULT 3
|
||||
/// Willingness for forwarding packets from other nodes: high.
|
||||
#define OLSR_WILL_HIGH 6
|
||||
/// Willingness for forwarding packets from other nodes: always.
|
||||
#define OLSR_WILL_ALWAYS 7
|
||||
|
||||
using namespace ns3;
|
||||
using namespace olsr;
|
||||
|
||||
@@ -83,7 +70,7 @@ OlsrMprTestCase::DoRun()
|
||||
*/
|
||||
NeighborTuple neighbor;
|
||||
neighbor.status = NeighborTuple::STATUS_SYM;
|
||||
neighbor.willingness = OLSR_WILL_DEFAULT;
|
||||
neighbor.willingness = Willingness::DEFAULT;
|
||||
neighbor.neighborMainAddr = Ipv4Address("10.0.0.2");
|
||||
protocol->m_state.InsertNeighborTuple(neighbor);
|
||||
neighbor.neighborMainAddr = Ipv4Address("10.0.0.3");
|
||||
@@ -139,7 +126,7 @@ OlsrMprTestCase::DoRun()
|
||||
true,
|
||||
"Node 1 must select node 3 as MPR");
|
||||
/*
|
||||
* 7 (OLSR_WILL_ALWAYS)
|
||||
* 7 (Willingness::ALWAYS)
|
||||
* |
|
||||
* 1 -- 2 -- 5
|
||||
* | |
|
||||
@@ -147,9 +134,9 @@ OlsrMprTestCase::DoRun()
|
||||
* |
|
||||
* 6
|
||||
*
|
||||
* Node 1 must select nodes 2, 3 and 7 (since it is WILL_ALWAYS) as MPRs.
|
||||
* Node 1 must select nodes 2, 3 and 7 (since it is Willingness::ALWAYS) as MPRs.
|
||||
*/
|
||||
neighbor.willingness = OLSR_WILL_ALWAYS;
|
||||
neighbor.willingness = olsr::Willingness::ALWAYS;
|
||||
neighbor.neighborMainAddr = Ipv4Address("10.0.0.7");
|
||||
protocol->m_state.InsertNeighborTuple(neighbor);
|
||||
|
||||
@@ -160,18 +147,18 @@ OlsrMprTestCase::DoRun()
|
||||
true,
|
||||
"Node 1 must select node 7 as MPR");
|
||||
/*
|
||||
* 7 <- WILL_ALWAYS
|
||||
* |
|
||||
* 9 -- 8 -- 1 -- 2 -- 5
|
||||
* | |
|
||||
* ^ 3 -- 4
|
||||
* | |
|
||||
* WILL_NEVER 6
|
||||
* 7 <- Willingness::ALWAYS
|
||||
* |
|
||||
* 9 -- 8 -- 1 -- 2 -- 5
|
||||
* | |
|
||||
* ^ 3 -- 4
|
||||
* | |
|
||||
* Willingness::NEVER 6
|
||||
*
|
||||
* Node 1 must select nodes 2, 3 and 7 (since it is WILL_ALWAYS) as MPRs.
|
||||
* Node 1 must NOT select node 8 as MPR since it is WILL_NEVER
|
||||
* Node 1 must select nodes 2, 3 and 7 (since it is Willingness::ALWAYS) as MPRs.
|
||||
* Node 1 must NOT select node 8 as MPR since it is Willingness::NEVER
|
||||
*/
|
||||
neighbor.willingness = OLSR_WILL_NEVER;
|
||||
neighbor.willingness = Willingness::NEVER;
|
||||
neighbor.neighborMainAddr = Ipv4Address("10.0.0.8");
|
||||
protocol->m_state.InsertNeighborTuple(neighbor);
|
||||
tuple.neighborMainAddr = Ipv4Address("10.0.0.8");
|
||||
|
||||
Reference in New Issue
Block a user