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-routing-protocol.h
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
* Based on
19
* NS-2 AODV model developed by the CMU/MONARCH group and optimized and
20
* tuned by Samir Das and Mahesh Marina, University of Cincinnati;
21
*
22
* AODV-UU implementation by Erik Nordström of Uppsala University
23
* http://core.it.uu.se/core/index.php/AODV-UU
24
*
25
* Authors: Elena Buchatskaia <borovkovaes@iitp.ru>
26
* Pavel Boyko <boyko@iitp.ru>
27
*/
28
#ifndef AODVROUTINGPROTOCOL_H
29
#define AODVROUTINGPROTOCOL_H
30
31
#include "
aodv-rtable.h
"
32
#include "
aodv-rqueue.h
"
33
#include "
aodv-packet.h
"
34
#include "
aodv-neighbor.h
"
35
#include "
aodv-dpd.h
"
36
#include "ns3/node.h"
37
#include "ns3/random-variable-stream.h"
38
#include "ns3/output-stream-wrapper.h"
39
#include "ns3/ipv4-routing-protocol.h"
40
#include "ns3/ipv4-interface.h"
41
#include "ns3/ipv4-l3-protocol.h"
42
#include <map>
43
44
namespace
ns3
45
{
46
namespace
aodv
47
{
53
class
RoutingProtocol
:
public
Ipv4RoutingProtocol
54
{
55
public
:
56
static
TypeId
GetTypeId
(
void
);
57
static
const
uint32_t
AODV_PORT
;
58
60
RoutingProtocol
();
61
virtual
~RoutingProtocol
();
62
virtual
void
DoDispose
();
63
65
//\{
66
Ptr<Ipv4Route>
RouteOutput
(
Ptr<Packet>
p,
const
Ipv4Header
&header,
Ptr<NetDevice>
oif,
Socket::SocketErrno
&sockerr);
67
bool
RouteInput
(
Ptr<const Packet>
p,
const
Ipv4Header
&header,
Ptr<const NetDevice>
idev,
68
UnicastForwardCallback
ucb,
MulticastForwardCallback
mcb,
69
LocalDeliverCallback
lcb,
ErrorCallback
ecb);
70
virtual
void
NotifyInterfaceUp
(uint32_t interface);
71
virtual
void
NotifyInterfaceDown
(uint32_t interface);
72
virtual
void
NotifyAddAddress
(uint32_t interface,
Ipv4InterfaceAddress
address);
73
virtual
void
NotifyRemoveAddress
(uint32_t interface,
Ipv4InterfaceAddress
address);
74
virtual
void
SetIpv4
(
Ptr<Ipv4>
ipv4);
75
virtual
void
PrintRoutingTable
(
Ptr<OutputStreamWrapper>
stream)
const
;
76
//\}
77
79
//\{
80
Time
GetMaxQueueTime
()
const
{
return
MaxQueueTime
; }
81
void
SetMaxQueueTime
(
Time
t);
82
uint32_t
GetMaxQueueLen
()
const
{
return
MaxQueueLen
; }
83
void
SetMaxQueueLen
(uint32_t len);
84
bool
GetDesinationOnlyFlag
()
const
{
return
DestinationOnly
; }
85
void
SetDesinationOnlyFlag
(
bool
f) {
DestinationOnly
= f; }
86
bool
GetGratuitousReplyFlag
()
const
{
return
GratuitousReply
; }
87
void
SetGratuitousReplyFlag
(
bool
f) {
GratuitousReply
= f; }
88
void
SetHelloEnable
(
bool
f) {
EnableHello
= f; }
89
bool
GetHelloEnable
()
const
{
return
EnableHello
; }
90
void
SetBroadcastEnable
(
bool
f) {
EnableBroadcast
= f; }
91
bool
GetBroadcastEnable
()
const
{
return
EnableBroadcast
; }
92
//\}
93
102
int64_t
AssignStreams
(int64_t stream);
103
104
private
:
106
//\{
107
uint32_t
RreqRetries
;
108
uint16_t
RreqRateLimit
;
109
uint16_t
RerrRateLimit
;
110
Time
ActiveRouteTimeout
;
111
uint32_t
NetDiameter
;
112
116
Time
NodeTraversalTime
;
117
Time
NetTraversalTime
;
118
Time
PathDiscoveryTime
;
119
Time
MyRouteTimeout
;
120
124
Time
HelloInterval
;
125
uint32_t
AllowedHelloLoss
;
126
130
Time
DeletePeriod
;
131
Time
NextHopWait
;
132
136
uint16_t
TimeoutBuffer
;
137
Time
BlackListTimeout
;
138
uint32_t
MaxQueueLen
;
139
Time
MaxQueueTime
;
140
bool
DestinationOnly
;
141
bool
GratuitousReply
;
142
bool
EnableHello
;
143
bool
EnableBroadcast
;
144
//\}
145
147
Ptr<Ipv4>
m_ipv4
;
149
std::map< Ptr<Socket>,
Ipv4InterfaceAddress
>
m_socketAddresses
;
151
Ptr<NetDevice>
m_lo
;
152
154
RoutingTable
m_routingTable
;
156
RequestQueue
m_queue
;
158
uint32_t
m_requestId
;
160
uint32_t
m_seqNo
;
162
IdCache
m_rreqIdCache
;
164
DuplicatePacketDetection
m_dpd
;
166
Neighbors
m_nb
;
168
uint16_t
m_rreqCount
;
170
uint16_t
m_rerrCount
;
171
172
private
:
174
void
Start
();
176
void
DeferredRouteOutput
(
Ptr<const Packet>
p,
const
Ipv4Header
& header,
UnicastForwardCallback
ucb,
ErrorCallback
ecb);
178
bool
Forwarding
(
Ptr<const Packet>
p,
const
Ipv4Header
& header,
UnicastForwardCallback
ucb,
ErrorCallback
ecb);
183
void
ScheduleRreqRetry
(
Ipv4Address
dst);
190
bool
UpdateRouteLifeTime
(
Ipv4Address
addr,
Time
lt);
196
void
UpdateRouteToNeighbor
(
Ipv4Address
sender,
Ipv4Address
receiver);
198
bool
IsMyOwnAddress
(
Ipv4Address
src);
200
Ptr<Socket>
FindSocketWithInterfaceAddress
(
Ipv4InterfaceAddress
iface)
const
;
202
void
ProcessHello
(
RrepHeader
const
& rrepHeader,
Ipv4Address
receiverIfaceAddr);
204
Ptr<Ipv4Route>
LoopbackRoute
(
const
Ipv4Header
& header,
Ptr<NetDevice>
oif)
const
;
205
207
//\{
209
void
RecvAodv
(
Ptr<Socket>
socket);
211
void
RecvRequest
(
Ptr<Packet>
p,
Ipv4Address
receiver,
Ipv4Address
src);
213
void
RecvReply
(
Ptr<Packet>
p,
Ipv4Address
my,
Ipv4Address
src);
215
void
RecvReplyAck
(
Ipv4Address
neighbor);
217
void
RecvError
(
Ptr<Packet>
p,
Ipv4Address
src);
218
//\}
219
221
//\{
223
void
SendPacketFromQueue
(
Ipv4Address
dst,
Ptr<Ipv4Route>
route);
225
void
SendHello
();
227
void
SendRequest
(
Ipv4Address
dst);
229
void
SendReply
(
RreqHeader
const
& rreqHeader,
RoutingTableEntry
const
& toOrigin);
235
void
SendReplyByIntermediateNode
(
RoutingTableEntry
& toDst,
RoutingTableEntry
& toOrigin,
bool
gratRep);
237
void
SendReplyAck
(
Ipv4Address
neighbor);
239
void
SendRerrWhenBreaksLinkToNextHop
(
Ipv4Address
nextHop);
241
void
SendRerrMessage
(
Ptr<Packet>
packet, std::vector<Ipv4Address> precursors);
248
void
SendRerrWhenNoRouteToForward
(
Ipv4Address
dst, uint32_t dstSeqNo,
Ipv4Address
origin);
249
//\}
250
252
Timer
m_htimer
;
254
void
HelloTimerExpire
();
256
Timer
m_rreqRateLimitTimer
;
258
void
RreqRateLimitTimerExpire
();
260
Timer
m_rerrRateLimitTimer
;
262
void
RerrRateLimitTimerExpire
();
264
std::map<Ipv4Address, Timer>
m_addressReqTimer
;
266
void
RouteRequestTimerExpire
(
Ipv4Address
dst);
268
void
AckTimerExpire
(
Ipv4Address
neighbor,
Time
blacklistTimeout);
269
271
Ptr<UniformRandomVariable>
m_uniformRandomVariable
;
272
};
273
274
}
275
}
276
#endif
/* AODVROUTINGPROTOCOL_H */
src
aodv
model
aodv-routing-protocol.h
Generated on Tue Nov 13 2012 10:32:08 for ns-3 by
1.8.1.2