A Discrete-Event Network Simulator
Home
Tutorials ▼
English
Docs ▼
Wiki
Manual
Models
Develop ▼
API
Bugs
API
aodv-helper.cc
Go to the documentation of this file.
1
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
2
/*
3
* Copyright (c) 2009 IITP RAS
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
* Authors: Pavel Boyko <boyko@iitp.ru>, written after OlsrHelper by Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
19
*/
20
#include "
aodv-helper.h
"
21
#include "ns3/aodv-routing-protocol.h"
22
#include "ns3/node-list.h"
23
#include "ns3/names.h"
24
#include "ns3/ptr.h"
25
#include "ns3/ipv4-list-routing.h"
26
27
namespace
ns3
28
{
29
30
AodvHelper::AodvHelper
() :
31
Ipv4RoutingHelper
()
32
{
33
m_agentFactory
.
SetTypeId
(
"ns3::aodv::RoutingProtocol"
);
34
}
35
36
AodvHelper
*
37
AodvHelper::Copy
(
void
)
const
38
{
39
return
new
AodvHelper
(*
this
);
40
}
41
42
Ptr<Ipv4RoutingProtocol>
43
AodvHelper::Create
(
Ptr<Node>
node)
const
44
{
45
Ptr<aodv::RoutingProtocol>
agent =
m_agentFactory
.
Create
<
aodv::RoutingProtocol
> ();
46
node->
AggregateObject
(agent);
47
return
agent;
48
}
49
50
void
51
AodvHelper::Set
(std::string name,
const
AttributeValue
&value)
52
{
53
m_agentFactory
.
Set
(name, value);
54
}
55
56
int64_t
57
AodvHelper::AssignStreams
(
NodeContainer
c, int64_t stream)
58
{
59
int64_t currentStream = stream;
60
Ptr<Node>
node;
61
for
(
NodeContainer::Iterator
i = c.
Begin
(); i != c.
End
(); ++i)
62
{
63
node = (*i);
64
Ptr<Ipv4>
ipv4 = node->
GetObject
<
Ipv4
> ();
65
NS_ASSERT_MSG
(ipv4,
"Ipv4 not installed on node"
);
66
Ptr<Ipv4RoutingProtocol>
proto = ipv4->GetRoutingProtocol ();
67
NS_ASSERT_MSG
(proto,
"Ipv4 routing not installed on node"
);
68
Ptr<aodv::RoutingProtocol>
aodv = DynamicCast<aodv::RoutingProtocol> (proto);
69
if
(aodv)
70
{
71
currentStream += aodv->AssignStreams (currentStream);
72
continue
;
73
}
74
// Aodv may also be in a list
75
Ptr<Ipv4ListRouting>
list
= DynamicCast<Ipv4ListRouting> (proto);
76
if
(
list
)
77
{
78
int16_t priority;
79
Ptr<Ipv4RoutingProtocol>
listProto;
80
Ptr<aodv::RoutingProtocol>
listAodv;
81
for
(uint32_t i = 0; i <
list
->GetNRoutingProtocols (); i++)
82
{
83
listProto =
list
->GetRoutingProtocol (i, priority);
84
listAodv = DynamicCast<aodv::RoutingProtocol> (listProto);
85
if
(listAodv)
86
{
87
currentStream += listAodv->AssignStreams (currentStream);
88
break
;
89
}
90
}
91
}
92
}
93
return
(currentStream - stream);
94
}
95
96
}
ns3::AodvHelper::Copy
AodvHelper * Copy(void) const
Definition:
aodv-helper.cc:37
ns3
Every class exported by the ns3 library is enclosed in the ns3 namespace.
ns3::AodvHelper
Helper class that adds AODV routing to nodes.
Definition:
aodv-helper.h:35
ns3::Object::GetObject
Ptr< T > GetObject(void) const
Get a pointer to the requested aggregated Object.
Definition:
object.h:470
ns3::AttributeValue
Hold a value for an Attribute.
Definition:
attribute.h:69
ns3::Ipv4RoutingHelper
a factory to create ns3::Ipv4RoutingProtocol objects
Definition:
ipv4-routing-helper.h:46
ns3::AodvHelper::Set
void Set(std::string name, const AttributeValue &value)
Definition:
aodv-helper.cc:51
ns3::Ipv4
Access to the IPv4 forwarding table, interfaces, and configuration.
Definition:
ipv4.h:77
ns3::AodvHelper::AodvHelper
AodvHelper()
Definition:
aodv-helper.cc:30
ns3::Ptr
Smart pointer class similar to boost::intrusive_ptr.
Definition:
ptr.h:74
ns3::NodeContainer::Begin
Iterator Begin(void) const
Get an iterator which refers to the first Node in the container.
Definition:
node-container.cc:77
ns3::AodvHelper::m_agentFactory
ObjectFactory m_agentFactory
the factory to create AODV routing object
Definition:
aodv-helper.h:79
ns3::Object::AggregateObject
void AggregateObject(Ptr< Object > other)
Aggregate two Objects together.
Definition:
object.cc:252
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:88
list
#define list
Definition:
openflow-interface.h:47
aodv-helper.h
ns3::AodvHelper::Create
virtual Ptr< Ipv4RoutingProtocol > Create(Ptr< Node > node) const
Definition:
aodv-helper.cc:43
ns3::NodeContainer::Iterator
std::vector< Ptr< Node > >::const_iterator Iterator
Node container iterator.
Definition:
node-container.h:42
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:223
ns3::NodeContainer
keep track of a set of node pointers.
Definition:
node-container.h:39
ns3::aodv::RoutingProtocol
AODV routing protocol.
Definition:
aodv-routing-protocol.h:56
ns3::NodeContainer::End
Iterator End(void) const
Get an iterator which indicates past-the-last Node in the container.
Definition:
node-container.cc:82
ns3::ObjectFactory::SetTypeId
void SetTypeId(TypeId tid)
Set the TypeId of the Objects to be created by this factory.
Definition:
object-factory.cc:40
ns3::ObjectFactory::Create
Ptr< Object > Create(void) const
Create an Object instance of the configured TypeId.
Definition:
object-factory.cc:98
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:57
src
aodv
helper
aodv-helper.cc
Generated on Fri Oct 1 2021 17:02:54 for ns-3 by
1.8.20