A Discrete-Event Network Simulator
Home
Tutorials ▼
English
Documentation ▼
Installation
Manual
Models
Contributing
Wiki
Development ▼
API Docs
Issue Tracker
Merge Requests
API
Loading...
Searching...
No Matches
aodv-helper.cc
Go to the documentation of this file.
1
/*
2
* Copyright (c) 2009 IITP RAS
3
*
4
* SPDX-License-Identifier: GPL-2.0-only
5
*
6
* Authors: Pavel Boyko <boyko@iitp.ru>, written after OlsrHelper by Mathieu Lacage
7
* <mathieu.lacage@sophia.inria.fr>
8
*/
9
#include "
aodv-helper.h
"
10
11
#include "ns3/aodv-routing-protocol.h"
12
#include "ns3/ipv4-list-routing.h"
13
#include "ns3/names.h"
14
#include "ns3/node-list.h"
15
#include "ns3/ptr.h"
16
17
namespace
ns3
18
{
19
20
AodvHelper::AodvHelper
()
21
:
Ipv4RoutingHelper
()
22
{
23
m_agentFactory
.
SetTypeId
(
"ns3::aodv::RoutingProtocol"
);
24
}
25
26
AodvHelper
*
27
AodvHelper::Copy
()
const
28
{
29
return
new
AodvHelper
(*
this
);
30
}
31
32
Ptr<Ipv4RoutingProtocol>
33
AodvHelper::Create
(
Ptr<Node>
node)
const
34
{
35
Ptr<aodv::RoutingProtocol>
agent
=
m_agentFactory
.
Create
<
aodv::RoutingProtocol
>();
36
node->AggregateObject(
agent
);
37
return
agent
;
38
}
39
40
void
41
AodvHelper::Set
(std::string name,
const
AttributeValue
&
value
)
42
{
43
m_agentFactory
.
Set
(name,
value
);
44
}
45
46
int64_t
47
AodvHelper::AssignStreams
(
NodeContainer
c
, int64_t stream)
48
{
49
int64_t
currentStream
= stream;
50
Ptr<Node>
node;
51
for
(
auto
i
=
c
.Begin();
i
!=
c
.End(); ++
i
)
52
{
53
node = (*i);
54
Ptr<Ipv4>
ipv4 = node->GetObject<
Ipv4
>();
55
NS_ASSERT_MSG
(ipv4,
"Ipv4 not installed on node"
);
56
Ptr<Ipv4RoutingProtocol>
proto
= ipv4->GetRoutingProtocol();
57
NS_ASSERT_MSG
(
proto
,
"Ipv4 routing not installed on node"
);
58
Ptr<aodv::RoutingProtocol>
aodv =
DynamicCast<aodv::RoutingProtocol>
(
proto
);
59
if
(aodv)
60
{
61
currentStream
+= aodv->AssignStreams(
currentStream
);
62
continue
;
63
}
64
// Aodv may also be in a list
65
Ptr<Ipv4ListRouting>
list
=
DynamicCast<Ipv4ListRouting>
(
proto
);
66
if
(
list
)
67
{
68
int16_t priority;
69
Ptr<Ipv4RoutingProtocol>
listProto
;
70
Ptr<aodv::RoutingProtocol>
listAodv
;
71
for
(
uint32_t
i
= 0;
i
<
list
->GetNRoutingProtocols();
i
++)
72
{
73
listProto
=
list
->GetRoutingProtocol(
i
, priority);
74
listAodv
=
DynamicCast<aodv::RoutingProtocol>
(
listProto
);
75
if
(
listAodv
)
76
{
77
currentStream
+=
listAodv
->AssignStreams(
currentStream
);
78
break
;
79
}
80
}
81
}
82
}
83
return
(
currentStream
- stream);
84
}
85
86
}
// namespace ns3
aodv-helper.h
ns3::AodvHelper
Helper class that adds AODV routing to nodes.
Definition
aodv-helper.h:25
ns3::AodvHelper::AodvHelper
AodvHelper()
Definition
aodv-helper.cc:20
ns3::AodvHelper::AssignStreams
int64_t AssignStreams(NodeContainer c, int64_t stream)
Assign a fixed random variable stream number to the random variables used by this model.
Definition
aodv-helper.cc:47
ns3::AodvHelper::Copy
AodvHelper * Copy() const override
Definition
aodv-helper.cc:27
ns3::AodvHelper::Set
void Set(std::string name, const AttributeValue &value)
Definition
aodv-helper.cc:41
ns3::AodvHelper::m_agentFactory
ObjectFactory m_agentFactory
the factory to create AODV routing object
Definition
aodv-helper.h:69
ns3::AodvHelper::Create
Ptr< Ipv4RoutingProtocol > Create(Ptr< Node > node) const override
Definition
aodv-helper.cc:33
ns3::AttributeValue
Hold a value for an Attribute.
Definition
attribute.h:59
ns3::Ipv4
Access to the IPv4 forwarding table, interfaces, and configuration.
Definition
ipv4.h:69
ns3::Ipv4RoutingHelper
a factory to create ns3::Ipv4RoutingProtocol objects
Definition
ipv4-routing-helper.h:35
ns3::NodeContainer
keep track of a set of node pointers.
Definition
node-container.h:29
ns3::ObjectFactory::Create
Ptr< Object > Create() const
Create an Object instance of the configured TypeId.
Definition
object-factory.cc:82
ns3::ObjectFactory::Set
void Set(const std::string &name, const AttributeValue &value, Args &&... args)
Set an attribute to be set during construction.
Definition
object-factory.h:213
ns3::ObjectFactory::SetTypeId
void SetTypeId(TypeId tid)
Set the TypeId of the Objects to be created by this factory.
Definition
object-factory.cc:31
ns3::Ptr
Smart pointer class similar to boost::intrusive_ptr.
Definition
ptr.h:66
ns3::aodv::RoutingProtocol
AODV routing protocol.
Definition
aodv-routing-protocol.h:48
uint32_t
NS_ASSERT_MSG
#define NS_ASSERT_MSG(condition, message)
At runtime, in debugging builds, if this condition is not true, the program prints the message to out...
Definition
assert.h:75
ns3::Create
Ptr< T > Create(Ts &&... args)
Create class instances by constructors with varying numbers of arguments and return them by Ptr.
Definition
ptr.h:436
ns3
Every class exported by the ns3 library is enclosed in the ns3 namespace.
ns3::value
static unsigned int value(char c)
Definition
qkd-encryptor.cc:267
list
#define list
Definition
openflow-interface.h:35
src
aodv
helper
aodv-helper.cc
Generated on Mon Dec 15 2025 15:21:48 for ns-3 by
1.9.8