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-rtable.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 AODV_RTABLE_H
29
#define AODV_RTABLE_H
30
31
#include <stdint.h>
32
#include <cassert>
33
#include <map>
34
#include <sys/types.h>
35
#include "ns3/ipv4.h"
36
#include "ns3/ipv4-route.h"
37
#include "ns3/timer.h"
38
#include "ns3/net-device.h"
39
#include "ns3/output-stream-wrapper.h"
40
41
namespace
ns3 {
42
namespace
aodv {
43
48
enum
RouteFlags
49
{
50
VALID
= 0,
51
INVALID
= 1,
52
IN_SEARCH
= 2,
53
};
54
59
class
RoutingTableEntry
60
{
61
public
:
63
RoutingTableEntry
(
Ptr<NetDevice>
dev = 0,
Ipv4Address
dst =
Ipv4Address
(),
bool
vSeqNo =
false
, uint32_t
m_seqNo
= 0,
64
Ipv4InterfaceAddress
iface =
Ipv4InterfaceAddress
(), uint16_t hops = 0,
65
Ipv4Address
nextHop =
Ipv4Address
(),
Time
lifetime =
Simulator::Now
());
66
67
~RoutingTableEntry
();
68
70
//\{
76
bool
InsertPrecursor
(
Ipv4Address
id
);
82
bool
LookupPrecursor
(
Ipv4Address
id
);
88
bool
DeletePrecursor
(
Ipv4Address
id
);
90
void
DeleteAllPrecursors
();
95
bool
IsPrecursorListEmpty
()
const
;
99
void
GetPrecursors
(std::vector<Ipv4Address> & prec)
const
;
100
//\}
101
103
void
Invalidate
(
Time
badLinkLifetime);
105
//\{
106
Ipv4Address
GetDestination
()
const
{
return
m_ipv4Route
->
GetDestination
(); }
107
Ptr<Ipv4Route>
GetRoute
()
const
{
return
m_ipv4Route
; }
108
void
SetRoute
(
Ptr<Ipv4Route>
r) {
m_ipv4Route
= r; }
109
void
SetNextHop
(
Ipv4Address
nextHop) {
m_ipv4Route
->
SetGateway
(nextHop); }
110
Ipv4Address
GetNextHop
()
const
{
return
m_ipv4Route
->
GetGateway
(); }
111
void
SetOutputDevice
(
Ptr<NetDevice>
dev) {
m_ipv4Route
->
SetOutputDevice
(dev); }
112
Ptr<NetDevice>
GetOutputDevice
()
const
{
return
m_ipv4Route
->
GetOutputDevice
(); }
113
Ipv4InterfaceAddress
GetInterface
()
const
{
return
m_iface
; }
114
void
SetInterface
(
Ipv4InterfaceAddress
iface) {
m_iface
= iface; }
115
void
SetValidSeqNo
(
bool
s) {
m_validSeqNo
= s; }
116
bool
GetValidSeqNo
()
const
{
return
m_validSeqNo
; }
117
void
SetSeqNo
(uint32_t sn) {
m_seqNo
= sn; }
118
uint32_t
GetSeqNo
()
const
{
return
m_seqNo
; }
119
void
SetHop
(uint16_t hop) {
m_hops
= hop; }
120
uint16_t
GetHop
()
const
{
return
m_hops
; }
121
void
SetLifeTime
(
Time
lt) {
m_lifeTime
= lt +
Simulator::Now
(); }
122
Time
GetLifeTime
()
const
{
return
m_lifeTime
-
Simulator::Now
(); }
123
void
SetFlag
(
RouteFlags
flag) {
m_flag
= flag; }
124
RouteFlags
GetFlag
()
const
{
return
m_flag
; }
125
void
SetRreqCnt
(uint8_t n) {
m_reqCount
= n; }
126
uint8_t
GetRreqCnt
()
const
{
return
m_reqCount
; }
127
void
IncrementRreqCnt
() {
m_reqCount
++; }
128
void
SetUnidirectional
(
bool
u) {
m_blackListState
= u; }
129
bool
IsUnidirectional
()
const
{
return
m_blackListState
; }
130
void
SetBalcklistTimeout
(
Time
t) {
m_blackListTimeout
= t; }
131
Time
GetBlacklistTimeout
()
const
{
return
m_blackListTimeout
; }
133
Timer
m_ackTimer
;
134
//\}
135
140
bool
operator==
(
Ipv4Address
const
dst)
const
141
{
142
return
(
m_ipv4Route
->
GetDestination
() == dst);
143
}
144
void
Print
(
Ptr<OutputStreamWrapper>
stream)
const
;
145
146
private
:
148
bool
m_validSeqNo
;
150
uint32_t
m_seqNo
;
152
uint16_t
m_hops
;
159
Time
m_lifeTime
;
166
Ptr<Ipv4Route>
m_ipv4Route
;
168
Ipv4InterfaceAddress
m_iface
;
170
RouteFlags
m_flag
;
171
173
std::vector<Ipv4Address>
m_precursorList
;
175
Time
m_routeRequestTimout
;
177
uint8_t
m_reqCount
;
179
bool
m_blackListState
;
181
Time
m_blackListTimeout
;
182
};
183
188
class
RoutingTable
189
{
190
public
:
192
RoutingTable
(
Time
t);
194
//\{
195
Time
GetBadLinkLifetime
()
const
{
return
m_badLinkLifetime
; }
196
void
SetBadLinkLifetime
(
Time
t) {
m_badLinkLifetime
= t; }
197
//\}
203
bool
AddRoute
(
RoutingTableEntry
& r);
209
bool
DeleteRoute
(
Ipv4Address
dst);
216
bool
LookupRoute
(
Ipv4Address
dst,
RoutingTableEntry
& rt);
218
bool
LookupValidRoute
(
Ipv4Address
dst,
RoutingTableEntry
& rt);
220
bool
Update
(
RoutingTableEntry
& rt);
222
bool
SetEntryState
(
Ipv4Address
dst,
RouteFlags
state);
224
void
GetListOfDestinationWithNextHop
(
Ipv4Address
nextHop, std::map<Ipv4Address, uint32_t> & unreachable);
232
void
InvalidateRoutesWithDst
(std::map<Ipv4Address, uint32_t>
const
& unreachable);
234
void
DeleteAllRoutesFromInterface
(
Ipv4InterfaceAddress
iface);
236
void
Clear
() {
m_ipv4AddressEntry
.clear (); }
238
void
Purge
();
244
bool
MarkLinkAsUnidirectional
(
Ipv4Address
neighbor,
Time
blacklistTimeout);
246
void
Print
(
Ptr<OutputStreamWrapper>
stream)
const
;
247
248
private
:
249
std::map<Ipv4Address, RoutingTableEntry>
m_ipv4AddressEntry
;
251
Time
m_badLinkLifetime
;
253
void
Purge
(std::map<Ipv4Address, RoutingTableEntry> &table)
const
;
254
};
255
256
}
257
}
258
259
#endif
/* AODV_RTABLE_H */
src
aodv
model
aodv-rtable.h
Generated on Fri Dec 21 2012 19:00:30 for ns-3 by
1.8.1.2