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
arp-cache.h
Go to the documentation of this file.
1
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
2
/*
3
* Copyright (c) 2006 INRIA
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: Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
19
*/
20
#ifndef ARP_CACHE_H
21
#define ARP_CACHE_H
22
23
#include <stdint.h>
24
#include <list>
25
#include "ns3/simulator.h"
26
#include "ns3/callback.h"
27
#include "ns3/packet.h"
28
#include "ns3/nstime.h"
29
#include "ns3/net-device.h"
30
#include "ns3/ipv4-address.h"
31
#include "ns3/address.h"
32
#include "ns3/ptr.h"
33
#include "ns3/object.h"
34
#include "ns3/traced-callback.h"
35
#include "ns3/sgi-hashmap.h"
36
37
namespace
ns3 {
38
39
class
NetDevice;
40
class
Ipv4Interface;
41
49
class
ArpCache
:
public
Object
50
{
51
private
:
52
ArpCache
(
ArpCache
const
&);
53
ArpCache
&
operator=
(
ArpCache
const
&);
54
55
public
:
56
static
TypeId
GetTypeId
(
void
);
57
class
Entry
;
58
ArpCache
();
59
~ArpCache
();
60
65
void
SetDevice
(
Ptr<NetDevice>
device,
Ptr<Ipv4Interface>
interface);
69
Ptr<NetDevice>
GetDevice
(
void
)
const
;
73
Ptr<Ipv4Interface>
GetInterface
(
void
)
const
;
74
75
void
SetAliveTimeout
(
Time
aliveTimeout);
76
void
SetDeadTimeout
(
Time
deadTimeout);
77
void
SetWaitReplyTimeout
(
Time
waitReplyTimeout);
78
Time
GetAliveTimeout
(
void
)
const
;
79
Time
GetDeadTimeout
(
void
)
const
;
80
Time
GetWaitReplyTimeout
(
void
)
const
;
81
89
void
SetArpRequestCallback
(
Callback
<
void
,
Ptr<const ArpCache>
,
90
Ipv4Address
> arpRequestCallback);
96
void
StartWaitReplyTimer
(
void
);
103
ArpCache::Entry
*
Lookup
(
Ipv4Address
destination);
107
ArpCache::Entry
*
Add
(
Ipv4Address
to);
111
void
Flush
(
void
);
112
116
class
Entry
{
117
public
:
122
Entry
(
ArpCache
*arp);
123
127
void
MarkDead
(
void
);
131
void
MarkAlive
(
Address
macAddress);
135
void
MarkWaitReply
(
Ptr<Packet>
waiting);
140
bool
UpdateWaitReply
(
Ptr<Packet>
waiting);
144
bool
IsDead
(
void
);
148
bool
IsAlive
(
void
);
152
bool
IsWaitReply
(
void
);
153
157
Address
GetMacAddress
(
void
)
const
;
161
Ipv4Address
GetIpv4Address
(
void
)
const
;
165
void
SetIpv4Address
(
Ipv4Address
destination);
172
bool
IsExpired
(
void
)
const
;
177
Ptr<Packet>
DequeuePending
(
void
);
182
uint32_t
GetRetries
(
void
)
const
;
186
void
IncrementRetries
(
void
);
190
void
ClearRetries
(
void
);
191
192
private
:
193
enum
ArpCacheEntryState_e
{
194
ALIVE
,
195
WAIT_REPLY
,
196
DEAD
197
};
198
199
void
UpdateSeen
(
void
);
200
Time
GetTimeout
(
void
)
const
;
201
ArpCache
*
m_arp
;
202
ArpCacheEntryState_e
m_state
;
203
Time
m_lastSeen
;
204
Address
m_macAddress
;
205
Ipv4Address
m_ipv4Address
;
206
std::list<Ptr<Packet> >
m_pending
;
207
uint32_t
m_retries
;
208
};
209
210
private
:
211
typedef
sgi::hash_map<Ipv4Address, ArpCache::Entry *, Ipv4AddressHash>
Cache
;
212
typedef
sgi::hash_map<Ipv4Address, ArpCache::Entry *, Ipv4AddressHash>::iterator
CacheI
;
213
214
virtual
void
DoDispose
(
void
);
215
216
Ptr<NetDevice>
m_device
;
217
Ptr<Ipv4Interface>
m_interface
;
218
Time
m_aliveTimeout
;
219
Time
m_deadTimeout
;
220
Time
m_waitReplyTimeout
;
221
EventId
m_waitReplyTimer
;
222
Callback<void, Ptr<const ArpCache>
,
Ipv4Address
>
m_arpRequestCallback
;
223
uint32_t
m_maxRetries
;
229
void
HandleWaitReplyTimeout
(
void
);
230
uint32_t
m_pendingQueueSize
;
231
Cache
m_arpCache
;
232
TracedCallback<Ptr<const Packet>
>
m_dropTrace
;
233
};
234
235
236
}
// namespace ns3
237
238
#endif
/* ARP_CACHE_H */
src
internet
model
arp-cache.h
Generated on Fri Dec 21 2012 19:00:36 for ns-3 by
1.8.1.2