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
ndisc-cache.h
Go to the documentation of this file.
1
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
2
/*
3
* Copyright (c) 2007-2009 Strasbourg University
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: Sebastien Vincent <vincent@clarinet.u-strasbg.fr>
19
*/
20
21
#ifndef NDISC_CACHE_H
22
#define NDISC_CACHE_H
23
24
#include <stdint.h>
25
26
#include <list>
27
28
#include "ns3/packet.h"
29
#include "ns3/nstime.h"
30
#include "ns3/net-device.h"
31
#include "ns3/ipv6-address.h"
32
#include "ns3/ptr.h"
33
#include "ns3/timer.h"
34
#include "ns3/sgi-hashmap.h"
35
36
namespace
ns3
37
{
38
39
class
NetDevice;
40
class
Ipv6Interface;
41
46
class
NdiscCache
:
public
Object
47
{
48
public
:
49
class
Entry
;
50
55
static
TypeId
GetTypeId
();
56
60
static
const
uint32_t
DEFAULT_UNRES_QLEN
= 3;
61
65
NdiscCache
();
66
70
~NdiscCache
();
71
76
Ptr<NetDevice>
GetDevice
()
const
;
77
81
Ptr<Ipv6Interface>
GetInterface
()
const
;
82
88
NdiscCache::Entry
*
Lookup
(
Ipv6Address
dst);
89
95
NdiscCache::Entry
*
Add
(
Ipv6Address
to);
96
101
void
Remove
(
NdiscCache::Entry
* entry);
102
106
void
Flush
();
107
112
void
SetUnresQlen
(uint32_t unresQlen);
113
118
uint32_t
GetUnresQlen
();
119
125
void
SetDevice
(
Ptr<NetDevice>
device,
Ptr<Ipv6Interface>
interface);
126
131
class
Entry
132
{
133
public
:
138
Entry
(
NdiscCache
* nd);
139
144
void
MarkIncomplete
(
Ptr<Packet>
p);
145
151
std::list<Ptr<Packet> >
MarkReachable
(
Address
mac);
152
156
void
MarkProbe
();
157
163
std::list<Ptr<Packet> >
MarkStale
(
Address
mac);
164
168
void
MarkStale
();
169
173
void
MarkReachable
();
174
178
void
MarkDelay
();
179
184
void
AddWaitingPacket
(
Ptr<Packet>
p);
185
189
void
ClearWaitingPacket
();
190
195
bool
IsStale
()
const
;
196
201
bool
IsReachable
()
const
;
202
207
bool
IsDelay
()
const
;
208
213
bool
IsIncomplete
()
const
;
214
219
bool
IsProbe
()
const
;
220
225
Address
GetMacAddress
()
const
;
226
231
void
SetMacAddress
(
Address
mac);
232
237
bool
IsRouter
()
const
;
238
243
void
SetRouter
(
bool
router);
244
249
uint8_t
GetNSRetransmit
()
const
;
250
254
void
IncNSRetransmit
();
255
259
void
ResetNSRetransmit
();
260
265
Time
GetLastReachabilityConfirmation
()
const
;
266
270
void
UpdateLastReachabilityconfirmation
();
271
275
void
StartReachableTimer
();
276
280
void
StopReachableTimer
();
281
285
void
StartRetransmitTimer
();
286
290
void
StopRetransmitTimer
();
291
295
void
StartProbeTimer
();
296
300
void
StopProbeTimer
();
301
305
void
StartDelayTimer
();
306
310
void
StopDelayTimer
();
311
315
void
FunctionReachableTimeout
();
316
322
void
FunctionRetransmitTimeout
();
323
327
void
FunctionProbeTimeout
();
328
332
void
FunctionDelayTimeout
();
333
338
void
SetIpv6Address
(
Ipv6Address
ipv6Address);
339
340
private
:
344
Ipv6Address
m_ipv6Address
;
345
349
enum
NdiscCacheEntryState_e
350
{
351
INCOMPLETE
,
352
REACHABLE
,
353
STALE
,
354
DELAY
,
355
PROBE
356
};
357
361
NdiscCacheEntryState_e
m_state
;
362
366
NdiscCache
*
m_ndCache
;
367
371
Address
m_macAddress
;
372
376
std::list<Ptr<Packet> >
m_waiting
;
377
381
bool
m_router
;
382
386
Timer
m_reachableTimer
;
387
391
Timer
m_retransTimer
;
392
396
Timer
m_probeTimer
;
397
401
Timer
m_delayTimer
;
402
406
Time
m_lastReachabilityConfirmation
;
407
411
uint8_t
m_nsRetransmit
;
412
};
413
414
private
:
415
typedef
sgi::hash_map<Ipv6Address, NdiscCache::Entry *, Ipv6AddressHash>
Cache
;
416
typedef
sgi::hash_map<Ipv6Address, NdiscCache::Entry *, Ipv6AddressHash>::iterator
CacheI
;
417
422
NdiscCache
(
NdiscCache
const
&a);
423
428
NdiscCache
&
operator=
(
NdiscCache
const
&a);
429
433
void
DoDispose
();
434
438
Ptr<NetDevice>
m_device
;
439
443
Ptr<Ipv6Interface>
m_interface
;
444
448
Cache
m_ndCache
;
449
453
uint32_t
m_unresQlen
;
454
};
455
456
}
/* namespace ns3 */
457
458
#endif
/* NDISC_CACHE_H */
459
src
internet
model
ndisc-cache.h
Generated on Tue Nov 13 2012 10:32:15 for ns-3 by
1.8.1.2