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
dsr-rreq-table.h
Go to the documentation of this file.
1
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
2
/*
3
* Copyright (c) 2011 Yufei Cheng
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: Yufei Cheng <yfcheng@ittc.ku.edu>
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 DSR_RREQ_TABLE_H
33
#define DSR_RREQ_TABLE_H
34
35
#include "ns3/simulator.h"
36
#include "ns3/timer.h"
37
#include "ns3/ipv4-address.h"
38
#include "ns3/callback.h"
39
#include <list>
40
#include <vector>
41
#include <map>
42
43
namespace
ns3 {
44
namespace
dsr {
45
46
enum
LinkStates
47
{
48
PROBABLE
= 0,
// !< PROBABLE
49
QUESTIONABLE
= 1,
// !< QUESTIONABLE
50
};
51
// / BlackList description
52
struct
BlackList
53
{
54
Ipv4Address
m_neighborAddress
;
55
Time
m_expireTime
;
56
LinkStates
m_linkStates
;
57
58
BlackList
(
Ipv4Address
ip,
Time
t)
59
:
m_neighborAddress
(ip),
60
m_expireTime
(t),
61
m_linkStates
(
PROBABLE
)
62
{
63
}
64
};
65
/*
66
* The route request table entries
67
*/
68
struct
RreqTableEntry
69
{
70
uint32_t
m_reqNo
;
71
Time
m_expire
;
72
};
73
/*
74
* The route request table id for originators
75
* It is responsible for checking duplicate requests from a single source to a specific destination
76
*/
77
struct
SourceRreqEntry
78
{
79
uint32_t
m_identification
;
80
Ipv4Address
m_dst
;
81
bool
m_isError
;
82
Time
m_expire
;
83
};
88
class
RreqTable
:
public
Object
89
{
90
public
:
91
// / c-tor
96
static
TypeId
GetTypeId
();
100
RreqTable
();
104
virtual
~RreqTable
();
105
106
// /\name Fields
107
// \{
108
void
SetInitHopLimit
(uint32_t hl)
109
{
110
m_initHopLimit
= hl;
111
}
112
uint32_t
GetInitHopLimit
()
const
113
{
114
return
m_initHopLimit
;
115
}
116
void
SetRreqTableSize
(uint32_t rt)
117
{
118
m_requestTableSize
= rt;
119
}
120
uint32_t
GetRreqTableSize
()
const
121
{
122
return
m_requestTableSize
;
123
}
124
void
SetRreqIdSize
(uint32_t
id
)
125
{
126
m_requestIdSize
= id;
127
}
128
uint32_t
GetRreqIdSize
()
const
129
{
130
return
m_requestIdSize
;
131
}
132
void
SetUniqueRreqIdSize
(uint32_t uid)
133
{
134
m_maxRreqId
= uid;
135
}
136
uint32_t
GetUniqueRreqIdSize
()
const
137
{
138
return
m_maxRreqId
;
139
}
140
141
// \}
142
// / Remove the least used entry
143
void
RemoveLeastExpire
(std::map<Ipv4Address, RreqTableEntry > & rreqDstMap);
144
// / Find the entry in the route request queue to see if already exists
145
void
FindAndUpdate
(
Ipv4Address
dst);
146
// / Remove route request entry for dst
147
void
RemoveRreqEntry
(
Ipv4Address
dst);
148
// / Get the request count number for one destination address
149
uint32_t
GetRreqCnt
(
Ipv4Address
dst);
150
151
//----------------------------------------------------------------------------------------------------------
152
/*
153
* The following code generates new request id for each destination
154
*/
155
// / Check for duplicate ids and save new entries if the id is not present in the table
156
uint32_t
CheckUniqueRreqId
(
Ipv4Address
dst);
157
// / Get the request id size
158
uint32_t
GetRreqSize
();
159
160
// ---------------------------------------------------------------------------------------------------------
161
/*
162
* set the unidirectional entry as QUESTIONABLE state
163
*/
164
void
Invalidate
();
169
BlackList
*
FindUnidirectional
(
Ipv4Address
neighbor);
175
bool
MarkLinkAsUnidirectional
(
Ipv4Address
neighbor,
Time
blacklistTimeout);
176
// / Remove all expired black list entries
177
void
PurgeNeighbor
();
178
179
private
:
180
// / Timer for neighbor's list. Schedule Purge().
181
Timer
m_ntimer
;
182
// / The max # of requests to retransmit
183
uint32_t
MaxRequestRexmt
;
184
// / The max request period among requests
185
Time
MaxRequestPeriod
;
186
// / The original request period
187
Time
RequestPeriod
;
188
// / The non-propagaton request timeout
189
Time
NonpropRequestTimeout
;
190
// / The source route entry expire time
191
Time
m_rreqEntryExpire
;
192
// / The initial hop limit
193
uint32_t
m_initHopLimit
;
194
// / The request table size
195
uint32_t
m_requestTableSize
;
196
// / The request source id size
197
uint32_t
m_requestIdSize
;
198
// / The unique request id for any destination
199
uint32_t
m_maxRreqId
;
200
// / The state of the unidirectional link
201
LinkStates
m_linkStates
;
202
// / Map of entries
203
std::list<SourceRreqEntry>
m_sourceRreq
;
204
// / The id cache to ensure all the ids are unique
205
std::map<Ipv4Address, uint32_t>
m_rreqIdCache
;
206
// / The cache to save route request table entries indexed with destination address
207
std::map<Ipv4Address, RreqTableEntry >
m_rreqDstMap
;
208
// / The cache to ensure all the route request from unique source
209
std::map<Ipv4Address, std::list<SourceRreqEntry> >
m_rreqMap
;
210
// / The Black list
211
std::vector<BlackList>
m_blackList
;
212
// / Check if the entry is expired or not
213
struct
IsExpired
214
{
215
bool
operator()
(
const
struct
BlackList
& b)
const
216
{
217
return
(b.
m_expireTime
<
Simulator::Now
());
218
}
219
};
220
};
221
}
// namespace dsr
222
}
// namespace ns3
223
224
#endif
/* DSR_RREQ_TABLE_H */
src
dsr
model
dsr-rreq-table.h
Generated on Fri Dec 21 2012 19:00:35 for ns-3 by
1.8.1.2