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
dsdv-rtable.h
Go to the documentation of this file.
1
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
2
/*
3
* Copyright (c) 2010 Hemanth Narra
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
* Author: Hemanth Narra <hemanth@ittc.ku.com>
19
*
20
* James P.G. Sterbenz <jpgs@ittc.ku.edu>, director
21
* ResiliNets Research Group http://wiki.ittc.ku.edu/resilinets
22
* Information and Telecommunication Technology Center (ITTC)
23
* and Department of Electrical Engineering and Computer Science
24
* The University of Kansas Lawrence, KS USA.
25
*
26
* Work supported in part by NSF FIND (Future Internet Design) Program
27
* under grant CNS-0626918 (Postmodern Internet Architecture),
28
* NSF grant CNS-1050226 (Multilayer Network Resilience Analysis and Experimentation on GENI),
29
* US Department of Defense (DoD), and ITTC at The University of Kansas.
30
*/
31
32
#ifndef DSDV_RTABLE_H
33
#define DSDV_RTABLE_H
34
35
#include <cassert>
36
#include <map>
37
#include <sys/types.h>
38
#include "ns3/ipv4.h"
39
#include "ns3/ipv4-route.h"
40
#include "ns3/timer.h"
41
#include "ns3/net-device.h"
42
#include "ns3/output-stream-wrapper.h"
43
44
namespace
ns3 {
45
namespace
dsdv {
46
enum
RouteFlags
47
{
48
VALID
= 0,
// !< VALID
49
INVALID
= 1,
// !< INVALID
50
};
51
56
class
RoutingTableEntry
57
{
58
public
:
60
RoutingTableEntry
(
Ptr<NetDevice>
dev = 0,
Ipv4Address
dst =
Ipv4Address
(), u_int32_t
m_seqNo
= 0,
61
Ipv4InterfaceAddress
iface =
Ipv4InterfaceAddress
(), u_int32_t hops = 0,
Ipv4Address
nextHop =
Ipv4Address
(),
62
Time
lifetime =
Simulator::Now
(),
Time
SettlingTime =
Simulator::Now
(),
bool
changedEntries =
false
);
63
64
~RoutingTableEntry
();
65
Ipv4Address
66
GetDestination
()
const
67
{
68
return
m_ipv4Route
->
GetDestination
();
69
}
70
Ptr<Ipv4Route>
71
GetRoute
()
const
72
{
73
return
m_ipv4Route
;
74
}
75
void
76
SetRoute
(
Ptr<Ipv4Route>
route)
77
{
78
m_ipv4Route
= route;
79
}
80
void
81
SetNextHop
(
Ipv4Address
nextHop)
82
{
83
m_ipv4Route
->
SetGateway
(nextHop);
84
}
85
Ipv4Address
86
GetNextHop
()
const
87
{
88
return
m_ipv4Route
->
GetGateway
();
89
}
90
void
91
SetOutputDevice
(
Ptr<NetDevice>
device)
92
{
93
m_ipv4Route
->
SetOutputDevice
(device);
94
}
95
Ptr<NetDevice>
96
GetOutputDevice
()
const
97
{
98
return
m_ipv4Route
->
GetOutputDevice
();
99
}
100
Ipv4InterfaceAddress
101
GetInterface
()
const
102
{
103
return
m_iface
;
104
}
105
void
106
SetInterface
(
Ipv4InterfaceAddress
iface)
107
{
108
m_iface
= iface;
109
}
110
void
111
SetSeqNo
(uint32_t sequenceNumber)
112
{
113
m_seqNo
= sequenceNumber;
114
}
115
uint32_t
116
GetSeqNo
()
const
117
{
118
return
m_seqNo
;
119
}
120
void
121
SetHop
(uint32_t hopCount)
122
{
123
m_hops
= hopCount;
124
}
125
uint32_t
126
GetHop
()
const
127
{
128
return
m_hops
;
129
}
130
void
131
SetLifeTime
(
Time
lifeTime)
132
{
133
m_lifeTime
= lifeTime;
134
}
135
Time
136
GetLifeTime
()
const
137
{
138
return
(
Simulator::Now
() -
m_lifeTime
);
139
}
140
void
141
SetSettlingTime
(
Time
settlingTime)
142
{
143
m_settlingTime
= settlingTime;
144
}
145
Time
146
GetSettlingTime
()
const
147
{
148
return
(
m_settlingTime
);
149
}
150
void
151
SetFlag
(
RouteFlags
flag)
152
{
153
m_flag
= flag;
154
}
155
RouteFlags
156
GetFlag
()
const
157
{
158
return
m_flag
;
159
}
160
void
161
SetEntriesChanged
(
bool
entriesChanged)
162
{
163
m_entriesChanged
= entriesChanged;
164
}
165
bool
166
GetEntriesChanged
()
const
167
{
168
return
m_entriesChanged
;
169
}
174
bool
175
operator==
(
Ipv4Address
const
destination)
const
176
{
177
return
(
m_ipv4Route
->
GetDestination
() == destination);
178
}
179
void
180
Print
(
Ptr<OutputStreamWrapper>
stream)
const
;
181
182
private
:
184
// \{
186
uint32_t
m_seqNo
;
188
uint32_t
m_hops
;
195
Time
m_lifeTime
;
202
Ptr<Ipv4Route>
m_ipv4Route
;
204
Ipv4InterfaceAddress
m_iface
;
206
RouteFlags
m_flag
;
209
Time
m_settlingTime
;
211
uint32_t
m_entriesChanged
;
212
//\}
213
};
214
219
class
RoutingTable
220
{
221
public
:
223
RoutingTable
();
229
bool
230
AddRoute
(
RoutingTableEntry
& r);
236
bool
237
DeleteRoute
(
Ipv4Address
dst);
244
bool
245
LookupRoute
(
Ipv4Address
dst,
RoutingTableEntry
& rt);
246
bool
247
LookupRoute
(
Ipv4Address
id
,
RoutingTableEntry
& rt,
bool
forRouteInput);
253
bool
254
Update
(
RoutingTableEntry
& rt);
260
void
261
GetListOfDestinationWithNextHop
(
Ipv4Address
nxtHp, std::map<Ipv4Address, RoutingTableEntry> & dstList);
266
void
267
GetListOfAllRoutes
(std::map<Ipv4Address, RoutingTableEntry> & allRoutes);
269
void
270
DeleteAllRoutesFromInterface
(
Ipv4InterfaceAddress
iface);
272
void
273
Clear
()
274
{
275
m_ipv4AddressEntry
.clear ();
276
}
278
void
279
Purge
(std::map<Ipv4Address, RoutingTableEntry> & removedAddresses);
281
void
282
Print
(
Ptr<OutputStreamWrapper>
stream)
const
;
284
uint32_t
285
RoutingTableSize
();
292
bool
293
AddIpv4Event
(
Ipv4Address
address,
EventId
id
);
299
bool
300
DeleteIpv4Event
(
Ipv4Address
address);
307
bool
308
AnyRunningEvent
(
Ipv4Address
address);
315
bool
316
ForceDeleteIpv4Event
(
Ipv4Address
address);
322
EventId
323
GetEventId
(
Ipv4Address
address);
325
// \{
326
Time
Getholddowntime
()
const
327
{
328
return
m_holddownTime
;
329
}
330
void
Setholddowntime
(
Time
t)
331
{
332
m_holddownTime
= t;
333
}
334
// \}
335
336
private
:
338
// \{
340
std::map<Ipv4Address, RoutingTableEntry>
m_ipv4AddressEntry
;
342
std::map<Ipv4Address, EventId>
m_ipv4Events
;
344
Time
m_holddownTime
;
345
// \}
346
};
347
}
348
}
349
#endif
/* DSDV_RTABLE_H */
src
dsdv
model
dsdv-rtable.h
Generated on Tue May 14 2013 11:08:19 for ns-3 by
1.8.1.2