A Discrete-Event Network Simulator
Home
Tutorials ▼
English
Portuguese
Docs ▼
Wiki
Manual
Models
Develop ▼
API
Bugs
API
Main Page
Related Pages
Modules
Namespaces
Classes
Files
File List
File Members
All
Classes
Namespaces
Files
Functions
Variables
Typedefs
Enumerations
Enumerator
Properties
Friends
Macros
Groups
Pages
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
}
src
aodv
helper
aodv-helper.cc
Generated on Fri Dec 21 2012 19:00:30 for ns-3 by
1.8.1.2