author | Craig Dowell <craigdo@ee.washington.edu> |
Wed, 03 Sep 2008 11:54:46 -0700 | |
changeset 3594 | 8feda39dff1f |
parent 3499 | a18520551cdf |
child 3691 | 372f4475dc47 |
permissions | -rw-r--r-- |
242 | 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> |
|
3151
428f8ec6da29
fix bug 185
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
3146
diff
changeset
|
24 |
#include <list> |
3499
a18520551cdf
revised patch to fix bug 253
Tom Henderson <tomh@tomh.org>
parents:
3260
diff
changeset
|
25 |
#include "ns3/simulator.h" |
a18520551cdf
revised patch to fix bug 253
Tom Henderson <tomh@tomh.org>
parents:
3260
diff
changeset
|
26 |
#include "ns3/callback.h" |
242 | 27 |
#include "ns3/packet.h" |
28 |
#include "ns3/nstime.h" |
|
524
082ffdd8fbd7
move code around
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
474
diff
changeset
|
29 |
#include "ns3/net-device.h" |
082ffdd8fbd7
move code around
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
474
diff
changeset
|
30 |
#include "ns3/ipv4-address.h" |
1161
bb72baff8b26
replace MacAddress by Address
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
632
diff
changeset
|
31 |
#include "ns3/address.h" |
568
e1660959ecbb
use Ptr<> everywhere Object or NsUnknown are used
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
551
diff
changeset
|
32 |
#include "ns3/ptr.h" |
3146
98629e087bb1
add attributes to ArpCache
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2834
diff
changeset
|
33 |
#include "ns3/object.h" |
3499
a18520551cdf
revised patch to fix bug 253
Tom Henderson <tomh@tomh.org>
parents:
3260
diff
changeset
|
34 |
#include "ns3/traced-callback.h" |
242 | 35 |
#include "sgi-hashmap.h" |
36 |
||
37 |
namespace ns3 { |
|
38 |
||
39 |
class NetDevice; |
|
551
12ed30c77cab
revert Ipv4Interface * -> Ptr<Ipv4Interface>
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
548
diff
changeset
|
40 |
class Ipv4Interface; |
242 | 41 |
|
632
1e419ebb4012
Internet-node module dox
Raj Bhattacharjea <raj.b@gatech.edu>
parents:
568
diff
changeset
|
42 |
/** |
1e419ebb4012
Internet-node module dox
Raj Bhattacharjea <raj.b@gatech.edu>
parents:
568
diff
changeset
|
43 |
* \brief An ARP cache |
1e419ebb4012
Internet-node module dox
Raj Bhattacharjea <raj.b@gatech.edu>
parents:
568
diff
changeset
|
44 |
* |
1e419ebb4012
Internet-node module dox
Raj Bhattacharjea <raj.b@gatech.edu>
parents:
568
diff
changeset
|
45 |
* A cached lookup table for translating layer 3 addresses to layer 2. |
1e419ebb4012
Internet-node module dox
Raj Bhattacharjea <raj.b@gatech.edu>
parents:
568
diff
changeset
|
46 |
* This implementation does lookups from IPv4 to a MAC address |
1e419ebb4012
Internet-node module dox
Raj Bhattacharjea <raj.b@gatech.edu>
parents:
568
diff
changeset
|
47 |
*/ |
3146
98629e087bb1
add attributes to ArpCache
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2834
diff
changeset
|
48 |
class ArpCache : public Object |
98629e087bb1
add attributes to ArpCache
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2834
diff
changeset
|
49 |
{ |
242 | 50 |
public: |
3146
98629e087bb1
add attributes to ArpCache
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2834
diff
changeset
|
51 |
static TypeId GetTypeId (void); |
242 | 52 |
class Entry; |
3146
98629e087bb1
add attributes to ArpCache
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2834
diff
changeset
|
53 |
ArpCache (); |
98629e087bb1
add attributes to ArpCache
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2834
diff
changeset
|
54 |
~ArpCache (); |
98629e087bb1
add attributes to ArpCache
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2834
diff
changeset
|
55 |
|
632
1e419ebb4012
Internet-node module dox
Raj Bhattacharjea <raj.b@gatech.edu>
parents:
568
diff
changeset
|
56 |
/** |
1e419ebb4012
Internet-node module dox
Raj Bhattacharjea <raj.b@gatech.edu>
parents:
568
diff
changeset
|
57 |
* \param device The hardware NetDevice associated with this ARP chache |
1e419ebb4012
Internet-node module dox
Raj Bhattacharjea <raj.b@gatech.edu>
parents:
568
diff
changeset
|
58 |
* \param interface the Ipv4Interface associated with this ARP chache |
1e419ebb4012
Internet-node module dox
Raj Bhattacharjea <raj.b@gatech.edu>
parents:
568
diff
changeset
|
59 |
*/ |
3146
98629e087bb1
add attributes to ArpCache
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2834
diff
changeset
|
60 |
void SetDevice (Ptr<NetDevice> device, Ptr<Ipv4Interface> interface); |
632
1e419ebb4012
Internet-node module dox
Raj Bhattacharjea <raj.b@gatech.edu>
parents:
568
diff
changeset
|
61 |
/** |
1e419ebb4012
Internet-node module dox
Raj Bhattacharjea <raj.b@gatech.edu>
parents:
568
diff
changeset
|
62 |
* \return The NetDevice that this ARP cache is associated with |
1e419ebb4012
Internet-node module dox
Raj Bhattacharjea <raj.b@gatech.edu>
parents:
568
diff
changeset
|
63 |
*/ |
568
e1660959ecbb
use Ptr<> everywhere Object or NsUnknown are used
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
551
diff
changeset
|
64 |
Ptr<NetDevice> GetDevice (void) const; |
632
1e419ebb4012
Internet-node module dox
Raj Bhattacharjea <raj.b@gatech.edu>
parents:
568
diff
changeset
|
65 |
/** |
1e419ebb4012
Internet-node module dox
Raj Bhattacharjea <raj.b@gatech.edu>
parents:
568
diff
changeset
|
66 |
* \return the Ipv4Interface that this ARP cache is associated with |
1e419ebb4012
Internet-node module dox
Raj Bhattacharjea <raj.b@gatech.edu>
parents:
568
diff
changeset
|
67 |
*/ |
1341
f685d4bf320f
use the Object::GetTraceResolver tracing support rather than the old adhoc tracing code
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
1161
diff
changeset
|
68 |
Ptr<Ipv4Interface> GetInterface (void) const; |
632
1e419ebb4012
Internet-node module dox
Raj Bhattacharjea <raj.b@gatech.edu>
parents:
568
diff
changeset
|
69 |
|
242 | 70 |
void SetAliveTimeout (Time aliveTimeout); |
71 |
void SetDeadTimeout (Time deadTimeout); |
|
72 |
void SetWaitReplyTimeout (Time waitReplyTimeout); |
|
73 |
Time GetAliveTimeout (void) const; |
|
74 |
Time GetDeadTimeout (void) const; |
|
75 |
Time GetWaitReplyTimeout (void) const; |
|
76 |
||
632
1e419ebb4012
Internet-node module dox
Raj Bhattacharjea <raj.b@gatech.edu>
parents:
568
diff
changeset
|
77 |
/** |
3499
a18520551cdf
revised patch to fix bug 253
Tom Henderson <tomh@tomh.org>
parents:
3260
diff
changeset
|
78 |
* This callback is set when the ArpCache is set up and allows |
a18520551cdf
revised patch to fix bug 253
Tom Henderson <tomh@tomh.org>
parents:
3260
diff
changeset
|
79 |
* the cache to generate an Arp request when the WaitReply |
a18520551cdf
revised patch to fix bug 253
Tom Henderson <tomh@tomh.org>
parents:
3260
diff
changeset
|
80 |
* time expires and a retransmission must be sent |
a18520551cdf
revised patch to fix bug 253
Tom Henderson <tomh@tomh.org>
parents:
3260
diff
changeset
|
81 |
* |
a18520551cdf
revised patch to fix bug 253
Tom Henderson <tomh@tomh.org>
parents:
3260
diff
changeset
|
82 |
* \param arpRequestCallback Callback for transmitting an Arp request. |
a18520551cdf
revised patch to fix bug 253
Tom Henderson <tomh@tomh.org>
parents:
3260
diff
changeset
|
83 |
*/ |
a18520551cdf
revised patch to fix bug 253
Tom Henderson <tomh@tomh.org>
parents:
3260
diff
changeset
|
84 |
void SetArpRequestCallback (Callback<void, Ptr<const ArpCache>, |
a18520551cdf
revised patch to fix bug 253
Tom Henderson <tomh@tomh.org>
parents:
3260
diff
changeset
|
85 |
Ipv4Address> arpRequestCallback); |
a18520551cdf
revised patch to fix bug 253
Tom Henderson <tomh@tomh.org>
parents:
3260
diff
changeset
|
86 |
/** |
a18520551cdf
revised patch to fix bug 253
Tom Henderson <tomh@tomh.org>
parents:
3260
diff
changeset
|
87 |
* This method will schedule a timeout at WaitReplyTimeout interval |
a18520551cdf
revised patch to fix bug 253
Tom Henderson <tomh@tomh.org>
parents:
3260
diff
changeset
|
88 |
* in the future, unless a timer is already running for the cache, |
a18520551cdf
revised patch to fix bug 253
Tom Henderson <tomh@tomh.org>
parents:
3260
diff
changeset
|
89 |
* in which case this method does nothing. |
a18520551cdf
revised patch to fix bug 253
Tom Henderson <tomh@tomh.org>
parents:
3260
diff
changeset
|
90 |
*/ |
a18520551cdf
revised patch to fix bug 253
Tom Henderson <tomh@tomh.org>
parents:
3260
diff
changeset
|
91 |
void StartWaitReplyTimer (void); |
a18520551cdf
revised patch to fix bug 253
Tom Henderson <tomh@tomh.org>
parents:
3260
diff
changeset
|
92 |
/** |
a18520551cdf
revised patch to fix bug 253
Tom Henderson <tomh@tomh.org>
parents:
3260
diff
changeset
|
93 |
* \brief Do lookup in the ARP cache against an IP address |
632
1e419ebb4012
Internet-node module dox
Raj Bhattacharjea <raj.b@gatech.edu>
parents:
568
diff
changeset
|
94 |
* \param destination The destination IPv4 address to lookup the MAC address |
1e419ebb4012
Internet-node module dox
Raj Bhattacharjea <raj.b@gatech.edu>
parents:
568
diff
changeset
|
95 |
* of |
1e419ebb4012
Internet-node module dox
Raj Bhattacharjea <raj.b@gatech.edu>
parents:
568
diff
changeset
|
96 |
* \return An ArpCache::Entry with info about layer 2 |
1e419ebb4012
Internet-node module dox
Raj Bhattacharjea <raj.b@gatech.edu>
parents:
568
diff
changeset
|
97 |
*/ |
242 | 98 |
ArpCache::Entry *Lookup (Ipv4Address destination); |
632
1e419ebb4012
Internet-node module dox
Raj Bhattacharjea <raj.b@gatech.edu>
parents:
568
diff
changeset
|
99 |
/** |
1e419ebb4012
Internet-node module dox
Raj Bhattacharjea <raj.b@gatech.edu>
parents:
568
diff
changeset
|
100 |
* \brief Add an Ipv4Address to this ARP cache |
1e419ebb4012
Internet-node module dox
Raj Bhattacharjea <raj.b@gatech.edu>
parents:
568
diff
changeset
|
101 |
*/ |
242 | 102 |
ArpCache::Entry *Add (Ipv4Address to); |
632
1e419ebb4012
Internet-node module dox
Raj Bhattacharjea <raj.b@gatech.edu>
parents:
568
diff
changeset
|
103 |
/** |
1e419ebb4012
Internet-node module dox
Raj Bhattacharjea <raj.b@gatech.edu>
parents:
568
diff
changeset
|
104 |
* \brief Clear the ArpCache of all entries |
1e419ebb4012
Internet-node module dox
Raj Bhattacharjea <raj.b@gatech.edu>
parents:
568
diff
changeset
|
105 |
*/ |
242 | 106 |
void Flush (void); |
107 |
||
632
1e419ebb4012
Internet-node module dox
Raj Bhattacharjea <raj.b@gatech.edu>
parents:
568
diff
changeset
|
108 |
/** |
1e419ebb4012
Internet-node module dox
Raj Bhattacharjea <raj.b@gatech.edu>
parents:
568
diff
changeset
|
109 |
* \brief A record that that holds information about an ArpCache entry |
1e419ebb4012
Internet-node module dox
Raj Bhattacharjea <raj.b@gatech.edu>
parents:
568
diff
changeset
|
110 |
*/ |
242 | 111 |
class Entry { |
112 |
public: |
|
632
1e419ebb4012
Internet-node module dox
Raj Bhattacharjea <raj.b@gatech.edu>
parents:
568
diff
changeset
|
113 |
/** |
1e419ebb4012
Internet-node module dox
Raj Bhattacharjea <raj.b@gatech.edu>
parents:
568
diff
changeset
|
114 |
* \brief Constructor |
1e419ebb4012
Internet-node module dox
Raj Bhattacharjea <raj.b@gatech.edu>
parents:
568
diff
changeset
|
115 |
* \param arp The ArpCache this entry belongs to |
1e419ebb4012
Internet-node module dox
Raj Bhattacharjea <raj.b@gatech.edu>
parents:
568
diff
changeset
|
116 |
*/ |
242 | 117 |
Entry (ArpCache *arp); |
632
1e419ebb4012
Internet-node module dox
Raj Bhattacharjea <raj.b@gatech.edu>
parents:
568
diff
changeset
|
118 |
|
1e419ebb4012
Internet-node module dox
Raj Bhattacharjea <raj.b@gatech.edu>
parents:
568
diff
changeset
|
119 |
/** |
1e419ebb4012
Internet-node module dox
Raj Bhattacharjea <raj.b@gatech.edu>
parents:
568
diff
changeset
|
120 |
* \brief Changes the state of this entry to dead |
1e419ebb4012
Internet-node module dox
Raj Bhattacharjea <raj.b@gatech.edu>
parents:
568
diff
changeset
|
121 |
*/ |
242 | 122 |
void MarkDead (void); |
632
1e419ebb4012
Internet-node module dox
Raj Bhattacharjea <raj.b@gatech.edu>
parents:
568
diff
changeset
|
123 |
/** |
1e419ebb4012
Internet-node module dox
Raj Bhattacharjea <raj.b@gatech.edu>
parents:
568
diff
changeset
|
124 |
* \param macAddress |
1e419ebb4012
Internet-node module dox
Raj Bhattacharjea <raj.b@gatech.edu>
parents:
568
diff
changeset
|
125 |
*/ |
3151
428f8ec6da29
fix bug 185
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
3146
diff
changeset
|
126 |
void MarkAlive (Address macAddress); |
632
1e419ebb4012
Internet-node module dox
Raj Bhattacharjea <raj.b@gatech.edu>
parents:
568
diff
changeset
|
127 |
/** |
1e419ebb4012
Internet-node module dox
Raj Bhattacharjea <raj.b@gatech.edu>
parents:
568
diff
changeset
|
128 |
* \param waiting |
1e419ebb4012
Internet-node module dox
Raj Bhattacharjea <raj.b@gatech.edu>
parents:
568
diff
changeset
|
129 |
*/ |
1866
e7dbcc4df546
do not use Packet objects directly. Use Ptr<Packet> instead
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
1341
diff
changeset
|
130 |
void MarkWaitReply (Ptr<Packet> waiting); |
632
1e419ebb4012
Internet-node module dox
Raj Bhattacharjea <raj.b@gatech.edu>
parents:
568
diff
changeset
|
131 |
/** |
1e419ebb4012
Internet-node module dox
Raj Bhattacharjea <raj.b@gatech.edu>
parents:
568
diff
changeset
|
132 |
* \param waiting |
1e419ebb4012
Internet-node module dox
Raj Bhattacharjea <raj.b@gatech.edu>
parents:
568
diff
changeset
|
133 |
* \return |
1e419ebb4012
Internet-node module dox
Raj Bhattacharjea <raj.b@gatech.edu>
parents:
568
diff
changeset
|
134 |
*/ |
3151
428f8ec6da29
fix bug 185
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
3146
diff
changeset
|
135 |
bool UpdateWaitReply (Ptr<Packet> waiting); |
632
1e419ebb4012
Internet-node module dox
Raj Bhattacharjea <raj.b@gatech.edu>
parents:
568
diff
changeset
|
136 |
/** |
1e419ebb4012
Internet-node module dox
Raj Bhattacharjea <raj.b@gatech.edu>
parents:
568
diff
changeset
|
137 |
* \return True if the state of this entry is dead; false otherwise. |
1e419ebb4012
Internet-node module dox
Raj Bhattacharjea <raj.b@gatech.edu>
parents:
568
diff
changeset
|
138 |
*/ |
242 | 139 |
bool IsDead (void); |
632
1e419ebb4012
Internet-node module dox
Raj Bhattacharjea <raj.b@gatech.edu>
parents:
568
diff
changeset
|
140 |
/** |
1e419ebb4012
Internet-node module dox
Raj Bhattacharjea <raj.b@gatech.edu>
parents:
568
diff
changeset
|
141 |
* \return True if the state of this entry is alive; false otherwise. |
1e419ebb4012
Internet-node module dox
Raj Bhattacharjea <raj.b@gatech.edu>
parents:
568
diff
changeset
|
142 |
*/ |
242 | 143 |
bool IsAlive (void); |
632
1e419ebb4012
Internet-node module dox
Raj Bhattacharjea <raj.b@gatech.edu>
parents:
568
diff
changeset
|
144 |
/** |
1e419ebb4012
Internet-node module dox
Raj Bhattacharjea <raj.b@gatech.edu>
parents:
568
diff
changeset
|
145 |
* \return True if the state of this entry is wait_reply; false otherwise. |
1e419ebb4012
Internet-node module dox
Raj Bhattacharjea <raj.b@gatech.edu>
parents:
568
diff
changeset
|
146 |
*/ |
242 | 147 |
bool IsWaitReply (void); |
148 |
||
632
1e419ebb4012
Internet-node module dox
Raj Bhattacharjea <raj.b@gatech.edu>
parents:
568
diff
changeset
|
149 |
/** |
1e419ebb4012
Internet-node module dox
Raj Bhattacharjea <raj.b@gatech.edu>
parents:
568
diff
changeset
|
150 |
* \return The MacAddress of this entry |
1e419ebb4012
Internet-node module dox
Raj Bhattacharjea <raj.b@gatech.edu>
parents:
568
diff
changeset
|
151 |
*/ |
3499
a18520551cdf
revised patch to fix bug 253
Tom Henderson <tomh@tomh.org>
parents:
3260
diff
changeset
|
152 |
Address GetMacAddress (void) const; |
a18520551cdf
revised patch to fix bug 253
Tom Henderson <tomh@tomh.org>
parents:
3260
diff
changeset
|
153 |
/** |
a18520551cdf
revised patch to fix bug 253
Tom Henderson <tomh@tomh.org>
parents:
3260
diff
changeset
|
154 |
* \return The Ipv4Address for this entry |
a18520551cdf
revised patch to fix bug 253
Tom Henderson <tomh@tomh.org>
parents:
3260
diff
changeset
|
155 |
*/ |
a18520551cdf
revised patch to fix bug 253
Tom Henderson <tomh@tomh.org>
parents:
3260
diff
changeset
|
156 |
Ipv4Address GetIpv4Address (void) const; |
a18520551cdf
revised patch to fix bug 253
Tom Henderson <tomh@tomh.org>
parents:
3260
diff
changeset
|
157 |
/** |
a18520551cdf
revised patch to fix bug 253
Tom Henderson <tomh@tomh.org>
parents:
3260
diff
changeset
|
158 |
* \param The Ipv4Address for this entry |
a18520551cdf
revised patch to fix bug 253
Tom Henderson <tomh@tomh.org>
parents:
3260
diff
changeset
|
159 |
*/ |
a18520551cdf
revised patch to fix bug 253
Tom Henderson <tomh@tomh.org>
parents:
3260
diff
changeset
|
160 |
void SetIpv4Address (Ipv4Address destination); |
632
1e419ebb4012
Internet-node module dox
Raj Bhattacharjea <raj.b@gatech.edu>
parents:
568
diff
changeset
|
161 |
/** |
1e419ebb4012
Internet-node module dox
Raj Bhattacharjea <raj.b@gatech.edu>
parents:
568
diff
changeset
|
162 |
* \return True if this entry has timedout; false otherwise. |
1e419ebb4012
Internet-node module dox
Raj Bhattacharjea <raj.b@gatech.edu>
parents:
568
diff
changeset
|
163 |
*/ |
242 | 164 |
bool IsExpired (void); |
3151
428f8ec6da29
fix bug 185
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
3146
diff
changeset
|
165 |
|
428f8ec6da29
fix bug 185
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
3146
diff
changeset
|
166 |
/** |
428f8ec6da29
fix bug 185
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
3146
diff
changeset
|
167 |
* \returns 0 is no packet is pending, the next packet to send if |
428f8ec6da29
fix bug 185
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
3146
diff
changeset
|
168 |
* packets are pending. |
428f8ec6da29
fix bug 185
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
3146
diff
changeset
|
169 |
*/ |
428f8ec6da29
fix bug 185
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
3146
diff
changeset
|
170 |
Ptr<Packet> DequeuePending (void); |
3499
a18520551cdf
revised patch to fix bug 253
Tom Henderson <tomh@tomh.org>
parents:
3260
diff
changeset
|
171 |
/** |
a18520551cdf
revised patch to fix bug 253
Tom Henderson <tomh@tomh.org>
parents:
3260
diff
changeset
|
172 |
* \returns number of retries that have been sent for an ArpRequest |
a18520551cdf
revised patch to fix bug 253
Tom Henderson <tomh@tomh.org>
parents:
3260
diff
changeset
|
173 |
* in WaitReply state. |
a18520551cdf
revised patch to fix bug 253
Tom Henderson <tomh@tomh.org>
parents:
3260
diff
changeset
|
174 |
*/ |
a18520551cdf
revised patch to fix bug 253
Tom Henderson <tomh@tomh.org>
parents:
3260
diff
changeset
|
175 |
uint32_t GetRetries (void) const; |
a18520551cdf
revised patch to fix bug 253
Tom Henderson <tomh@tomh.org>
parents:
3260
diff
changeset
|
176 |
/** |
a18520551cdf
revised patch to fix bug 253
Tom Henderson <tomh@tomh.org>
parents:
3260
diff
changeset
|
177 |
* \brief Increment the counter of number of retries for an entry |
a18520551cdf
revised patch to fix bug 253
Tom Henderson <tomh@tomh.org>
parents:
3260
diff
changeset
|
178 |
*/ |
a18520551cdf
revised patch to fix bug 253
Tom Henderson <tomh@tomh.org>
parents:
3260
diff
changeset
|
179 |
void IncrementRetries (void); |
a18520551cdf
revised patch to fix bug 253
Tom Henderson <tomh@tomh.org>
parents:
3260
diff
changeset
|
180 |
/** |
a18520551cdf
revised patch to fix bug 253
Tom Henderson <tomh@tomh.org>
parents:
3260
diff
changeset
|
181 |
* \brief Zero the counter of number of retries for an entry |
a18520551cdf
revised patch to fix bug 253
Tom Henderson <tomh@tomh.org>
parents:
3260
diff
changeset
|
182 |
*/ |
a18520551cdf
revised patch to fix bug 253
Tom Henderson <tomh@tomh.org>
parents:
3260
diff
changeset
|
183 |
void ClearRetries (void); |
a18520551cdf
revised patch to fix bug 253
Tom Henderson <tomh@tomh.org>
parents:
3260
diff
changeset
|
184 |
|
242 | 185 |
private: |
186 |
enum ArpCacheEntryState_e { |
|
187 |
ALIVE, |
|
188 |
WAIT_REPLY, |
|
189 |
DEAD |
|
190 |
}; |
|
191 |
||
192 |
void UpdateSeen (void); |
|
193 |
ArpCache *m_arp; |
|
194 |
ArpCacheEntryState_e m_state; |
|
195 |
Time m_lastSeen; |
|
1161
bb72baff8b26
replace MacAddress by Address
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
632
diff
changeset
|
196 |
Address m_macAddress; |
3499
a18520551cdf
revised patch to fix bug 253
Tom Henderson <tomh@tomh.org>
parents:
3260
diff
changeset
|
197 |
Ipv4Address m_ipv4Address; |
3151
428f8ec6da29
fix bug 185
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
3146
diff
changeset
|
198 |
std::list<Ptr<Packet> > m_pending; |
3499
a18520551cdf
revised patch to fix bug 253
Tom Henderson <tomh@tomh.org>
parents:
3260
diff
changeset
|
199 |
uint32_t m_retries; |
242 | 200 |
}; |
201 |
||
202 |
private: |
|
203 |
typedef sgi::hash_map<Ipv4Address, ArpCache::Entry *, Ipv4AddressHash> Cache; |
|
204 |
typedef sgi::hash_map<Ipv4Address, ArpCache::Entry *, Ipv4AddressHash>::iterator CacheI; |
|
205 |
||
3151
428f8ec6da29
fix bug 185
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
3146
diff
changeset
|
206 |
virtual void DoDispose (void); |
428f8ec6da29
fix bug 185
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
3146
diff
changeset
|
207 |
|
568
e1660959ecbb
use Ptr<> everywhere Object or NsUnknown are used
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
551
diff
changeset
|
208 |
Ptr<NetDevice> m_device; |
1341
f685d4bf320f
use the Object::GetTraceResolver tracing support rather than the old adhoc tracing code
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
1161
diff
changeset
|
209 |
Ptr<Ipv4Interface> m_interface; |
242 | 210 |
Time m_aliveTimeout; |
211 |
Time m_deadTimeout; |
|
212 |
Time m_waitReplyTimeout; |
|
3499
a18520551cdf
revised patch to fix bug 253
Tom Henderson <tomh@tomh.org>
parents:
3260
diff
changeset
|
213 |
EventId m_waitReplyTimer; |
a18520551cdf
revised patch to fix bug 253
Tom Henderson <tomh@tomh.org>
parents:
3260
diff
changeset
|
214 |
Callback<void, Ptr<const ArpCache>, Ipv4Address> m_arpRequestCallback; |
a18520551cdf
revised patch to fix bug 253
Tom Henderson <tomh@tomh.org>
parents:
3260
diff
changeset
|
215 |
uint32_t m_maxRetries; |
a18520551cdf
revised patch to fix bug 253
Tom Henderson <tomh@tomh.org>
parents:
3260
diff
changeset
|
216 |
/** |
a18520551cdf
revised patch to fix bug 253
Tom Henderson <tomh@tomh.org>
parents:
3260
diff
changeset
|
217 |
* This function is an event handler for the event that the |
a18520551cdf
revised patch to fix bug 253
Tom Henderson <tomh@tomh.org>
parents:
3260
diff
changeset
|
218 |
* ArpCache wants to check whether it must retry any Arp requests. |
a18520551cdf
revised patch to fix bug 253
Tom Henderson <tomh@tomh.org>
parents:
3260
diff
changeset
|
219 |
* If there are no Arp requests pending, this event is not scheduled. |
a18520551cdf
revised patch to fix bug 253
Tom Henderson <tomh@tomh.org>
parents:
3260
diff
changeset
|
220 |
*/ |
a18520551cdf
revised patch to fix bug 253
Tom Henderson <tomh@tomh.org>
parents:
3260
diff
changeset
|
221 |
void HandleWaitReplyTimeout (void); |
3151
428f8ec6da29
fix bug 185
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
3146
diff
changeset
|
222 |
uint32_t m_pendingQueueSize; |
242 | 223 |
Cache m_arpCache; |
3499
a18520551cdf
revised patch to fix bug 253
Tom Henderson <tomh@tomh.org>
parents:
3260
diff
changeset
|
224 |
TracedCallback<Ptr<const Packet> > m_dropTrace; |
242 | 225 |
}; |
226 |
||
227 |
||
228 |
}; // namespace ns3 |
|
229 |
||
230 |
#endif /* ARP_CACHE_H */ |