author | Vedran Miletić <rivanvx@gmail.com> |
Tue, 02 Aug 2011 17:42:33 -0400 | |
changeset 7385 | 10beb0e53130 |
parent 7256 | b04ba6772f8c |
child 9704 | 1db7690f8e8f |
permissions | -rw-r--r-- |
7385
10beb0e53130
standardize emacs c++ mode comments
Vedran Miletić <rivanvx@gmail.com>
parents:
7256
diff
changeset
|
1 |
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */ |
242 | 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 |
*/ |
|
286
57e6a2006962
convert use of <cassert> to "ns3/assert.h"
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
243
diff
changeset
|
20 |
#include "ns3/assert.h" |
242 | 21 |
#include "ns3/packet.h" |
22 |
#include "ns3/simulator.h" |
|
3151
428f8ec6da29
fix bug 185
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
3146
diff
changeset
|
23 |
#include "ns3/uinteger.h" |
428f8ec6da29
fix bug 185
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
3146
diff
changeset
|
24 |
#include "ns3/log.h" |
3499
a18520551cdf
revised patch to fix bug 253
Tom Henderson <tomh@tomh.org>
parents:
3430
diff
changeset
|
25 |
#include "ns3/node.h" |
a18520551cdf
revised patch to fix bug 253
Tom Henderson <tomh@tomh.org>
parents:
3430
diff
changeset
|
26 |
#include "ns3/trace-source-accessor.h" |
242 | 27 |
|
28 |
#include "arp-cache.h" |
|
29 |
#include "arp-header.h" |
|
1341
f685d4bf320f
use the Object::GetTraceResolver tracing support rather than the old adhoc tracing code
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
1167
diff
changeset
|
30 |
#include "ipv4-interface.h" |
242 | 31 |
|
3151
428f8ec6da29
fix bug 185
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
3146
diff
changeset
|
32 |
NS_LOG_COMPONENT_DEFINE ("ArpCache"); |
428f8ec6da29
fix bug 185
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
3146
diff
changeset
|
33 |
|
242 | 34 |
namespace ns3 { |
35 |
||
4455
0708e7fdf676
Fix bug 570 (ArpCache not registered)
Tom Henderson <tomh@tomh.org>
parents:
4250
diff
changeset
|
36 |
NS_OBJECT_ENSURE_REGISTERED (ArpCache); |
0708e7fdf676
Fix bug 570 (ArpCache not registered)
Tom Henderson <tomh@tomh.org>
parents:
4250
diff
changeset
|
37 |
|
3146
98629e087bb1
add attributes to ArpCache
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2834
diff
changeset
|
38 |
TypeId |
98629e087bb1
add attributes to ArpCache
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2834
diff
changeset
|
39 |
ArpCache::GetTypeId (void) |
98629e087bb1
add attributes to ArpCache
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2834
diff
changeset
|
40 |
{ |
98629e087bb1
add attributes to ArpCache
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2834
diff
changeset
|
41 |
static TypeId tid = TypeId ("ns3::ArpCache") |
98629e087bb1
add attributes to ArpCache
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2834
diff
changeset
|
42 |
.SetParent<Object> () |
98629e087bb1
add attributes to ArpCache
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2834
diff
changeset
|
43 |
.AddAttribute ("AliveTimeout", |
98629e087bb1
add attributes to ArpCache
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2834
diff
changeset
|
44 |
"When this timeout expires, the matching cache entry needs refreshing", |
98629e087bb1
add attributes to ArpCache
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2834
diff
changeset
|
45 |
TimeValue (Seconds (120)), |
98629e087bb1
add attributes to ArpCache
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2834
diff
changeset
|
46 |
MakeTimeAccessor (&ArpCache::m_aliveTimeout), |
98629e087bb1
add attributes to ArpCache
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2834
diff
changeset
|
47 |
MakeTimeChecker ()) |
98629e087bb1
add attributes to ArpCache
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2834
diff
changeset
|
48 |
.AddAttribute ("DeadTimeout", |
98629e087bb1
add attributes to ArpCache
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2834
diff
changeset
|
49 |
"When this timeout expires, a new attempt to resolve the matching entry is made", |
98629e087bb1
add attributes to ArpCache
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2834
diff
changeset
|
50 |
TimeValue (Seconds (100)), |
98629e087bb1
add attributes to ArpCache
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2834
diff
changeset
|
51 |
MakeTimeAccessor (&ArpCache::m_deadTimeout), |
98629e087bb1
add attributes to ArpCache
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2834
diff
changeset
|
52 |
MakeTimeChecker ()) |
98629e087bb1
add attributes to ArpCache
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2834
diff
changeset
|
53 |
.AddAttribute ("WaitReplyTimeout", |
7176
9f2663992e99
internet coding style changes
Josh Pelkey <jpelkey@gatech.edu>
parents:
6834
diff
changeset
|
54 |
"When this timeout expires, the cache entries will be scanned and entries in WaitReply state will resend ArpRequest unless MaxRetries has been exceeded, in which case the entry is marked dead", |
3146
98629e087bb1
add attributes to ArpCache
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2834
diff
changeset
|
55 |
TimeValue (Seconds (1)), |
98629e087bb1
add attributes to ArpCache
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2834
diff
changeset
|
56 |
MakeTimeAccessor (&ArpCache::m_waitReplyTimeout), |
98629e087bb1
add attributes to ArpCache
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2834
diff
changeset
|
57 |
MakeTimeChecker ()) |
7176
9f2663992e99
internet coding style changes
Josh Pelkey <jpelkey@gatech.edu>
parents:
6834
diff
changeset
|
58 |
.AddAttribute ("MaxRetries", |
9f2663992e99
internet coding style changes
Josh Pelkey <jpelkey@gatech.edu>
parents:
6834
diff
changeset
|
59 |
"Number of retransmissions of ArpRequest before marking dead", |
3499
a18520551cdf
revised patch to fix bug 253
Tom Henderson <tomh@tomh.org>
parents:
3430
diff
changeset
|
60 |
UintegerValue (3), |
a18520551cdf
revised patch to fix bug 253
Tom Henderson <tomh@tomh.org>
parents:
3430
diff
changeset
|
61 |
MakeUintegerAccessor (&ArpCache::m_maxRetries), |
a18520551cdf
revised patch to fix bug 253
Tom Henderson <tomh@tomh.org>
parents:
3430
diff
changeset
|
62 |
MakeUintegerChecker<uint32_t> ()) |
3151
428f8ec6da29
fix bug 185
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
3146
diff
changeset
|
63 |
.AddAttribute ("PendingQueueSize", |
428f8ec6da29
fix bug 185
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
3146
diff
changeset
|
64 |
"The size of the queue for packets pending an arp reply.", |
428f8ec6da29
fix bug 185
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
3146
diff
changeset
|
65 |
UintegerValue (3), |
428f8ec6da29
fix bug 185
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
3146
diff
changeset
|
66 |
MakeUintegerAccessor (&ArpCache::m_pendingQueueSize), |
428f8ec6da29
fix bug 185
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
3146
diff
changeset
|
67 |
MakeUintegerChecker<uint32_t> ()) |
7176
9f2663992e99
internet coding style changes
Josh Pelkey <jpelkey@gatech.edu>
parents:
6834
diff
changeset
|
68 |
.AddTraceSource ("Drop", |
3499
a18520551cdf
revised patch to fix bug 253
Tom Henderson <tomh@tomh.org>
parents:
3430
diff
changeset
|
69 |
"Packet dropped due to ArpCache entry in WaitReply expiring.", |
a18520551cdf
revised patch to fix bug 253
Tom Henderson <tomh@tomh.org>
parents:
3430
diff
changeset
|
70 |
MakeTraceSourceAccessor (&ArpCache::m_dropTrace)) |
7176
9f2663992e99
internet coding style changes
Josh Pelkey <jpelkey@gatech.edu>
parents:
6834
diff
changeset
|
71 |
; |
3146
98629e087bb1
add attributes to ArpCache
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2834
diff
changeset
|
72 |
return tid; |
98629e087bb1
add attributes to ArpCache
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2834
diff
changeset
|
73 |
} |
98629e087bb1
add attributes to ArpCache
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2834
diff
changeset
|
74 |
|
98629e087bb1
add attributes to ArpCache
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2834
diff
changeset
|
75 |
ArpCache::ArpCache () |
98629e087bb1
add attributes to ArpCache
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2834
diff
changeset
|
76 |
: m_device (0), |
98629e087bb1
add attributes to ArpCache
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2834
diff
changeset
|
77 |
m_interface (0) |
3151
428f8ec6da29
fix bug 185
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
3146
diff
changeset
|
78 |
{ |
428f8ec6da29
fix bug 185
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
3146
diff
changeset
|
79 |
NS_LOG_FUNCTION (this); |
428f8ec6da29
fix bug 185
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
3146
diff
changeset
|
80 |
} |
242 | 81 |
|
82 |
ArpCache::~ArpCache () |
|
83 |
{ |
|
3151
428f8ec6da29
fix bug 185
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
3146
diff
changeset
|
84 |
NS_LOG_FUNCTION (this); |
428f8ec6da29
fix bug 185
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
3146
diff
changeset
|
85 |
} |
428f8ec6da29
fix bug 185
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
3146
diff
changeset
|
86 |
|
428f8ec6da29
fix bug 185
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
3146
diff
changeset
|
87 |
void |
428f8ec6da29
fix bug 185
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
3146
diff
changeset
|
88 |
ArpCache::DoDispose (void) |
428f8ec6da29
fix bug 185
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
3146
diff
changeset
|
89 |
{ |
428f8ec6da29
fix bug 185
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
3146
diff
changeset
|
90 |
NS_LOG_FUNCTION (this); |
242 | 91 |
Flush (); |
3151
428f8ec6da29
fix bug 185
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
3146
diff
changeset
|
92 |
m_device = 0; |
428f8ec6da29
fix bug 185
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
3146
diff
changeset
|
93 |
m_interface = 0; |
3499
a18520551cdf
revised patch to fix bug 253
Tom Henderson <tomh@tomh.org>
parents:
3430
diff
changeset
|
94 |
if (!m_waitReplyTimer.IsRunning ()) |
a18520551cdf
revised patch to fix bug 253
Tom Henderson <tomh@tomh.org>
parents:
3430
diff
changeset
|
95 |
{ |
a18520551cdf
revised patch to fix bug 253
Tom Henderson <tomh@tomh.org>
parents:
3430
diff
changeset
|
96 |
Simulator::Remove (m_waitReplyTimer); |
a18520551cdf
revised patch to fix bug 253
Tom Henderson <tomh@tomh.org>
parents:
3430
diff
changeset
|
97 |
} |
3151
428f8ec6da29
fix bug 185
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
3146
diff
changeset
|
98 |
Object::DoDispose (); |
242 | 99 |
} |
100 |
||
3146
98629e087bb1
add attributes to ArpCache
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2834
diff
changeset
|
101 |
void |
98629e087bb1
add attributes to ArpCache
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2834
diff
changeset
|
102 |
ArpCache::SetDevice (Ptr<NetDevice> device, Ptr<Ipv4Interface> interface) |
98629e087bb1
add attributes to ArpCache
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2834
diff
changeset
|
103 |
{ |
6560
771dbe777984
get rid of NOARGS logging statements and log statements in getters
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
4455
diff
changeset
|
104 |
NS_LOG_FUNCTION (this << device << interface); |
3146
98629e087bb1
add attributes to ArpCache
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2834
diff
changeset
|
105 |
m_device = device; |
98629e087bb1
add attributes to ArpCache
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2834
diff
changeset
|
106 |
m_interface = interface; |
98629e087bb1
add attributes to ArpCache
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2834
diff
changeset
|
107 |
} |
98629e087bb1
add attributes to ArpCache
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2834
diff
changeset
|
108 |
|
568
e1660959ecbb
use Ptr<> everywhere Object or NsUnknown are used
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
551
diff
changeset
|
109 |
Ptr<NetDevice> |
e1660959ecbb
use Ptr<> everywhere Object or NsUnknown are used
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
551
diff
changeset
|
110 |
ArpCache::GetDevice (void) const |
242 | 111 |
{ |
112 |
return m_device; |
|
113 |
} |
|
114 |
||
1341
f685d4bf320f
use the Object::GetTraceResolver tracing support rather than the old adhoc tracing code
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
1167
diff
changeset
|
115 |
Ptr<Ipv4Interface> |
242 | 116 |
ArpCache::GetInterface (void) const |
117 |
{ |
|
118 |
return m_interface; |
|
119 |
} |
|
120 |
||
121 |
void |
|
122 |
ArpCache::SetAliveTimeout (Time aliveTimeout) |
|
123 |
{ |
|
6560
771dbe777984
get rid of NOARGS logging statements and log statements in getters
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
4455
diff
changeset
|
124 |
NS_LOG_FUNCTION (this << aliveTimeout); |
242 | 125 |
m_aliveTimeout = aliveTimeout; |
126 |
} |
|
127 |
void |
|
128 |
ArpCache::SetDeadTimeout (Time deadTimeout) |
|
129 |
{ |
|
6560
771dbe777984
get rid of NOARGS logging statements and log statements in getters
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
4455
diff
changeset
|
130 |
NS_LOG_FUNCTION (this << deadTimeout); |
242 | 131 |
m_deadTimeout = deadTimeout; |
132 |
} |
|
133 |
void |
|
134 |
ArpCache::SetWaitReplyTimeout (Time waitReplyTimeout) |
|
135 |
{ |
|
6560
771dbe777984
get rid of NOARGS logging statements and log statements in getters
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
4455
diff
changeset
|
136 |
NS_LOG_FUNCTION (this << waitReplyTimeout); |
242 | 137 |
m_waitReplyTimeout = waitReplyTimeout; |
138 |
} |
|
139 |
||
140 |
Time |
|
141 |
ArpCache::GetAliveTimeout (void) const |
|
142 |
{ |
|
143 |
return m_aliveTimeout; |
|
144 |
} |
|
145 |
Time |
|
146 |
ArpCache::GetDeadTimeout (void) const |
|
147 |
{ |
|
148 |
return m_deadTimeout; |
|
149 |
} |
|
150 |
Time |
|
151 |
ArpCache::GetWaitReplyTimeout (void) const |
|
152 |
{ |
|
153 |
return m_waitReplyTimeout; |
|
154 |
} |
|
155 |
||
156 |
void |
|
3499
a18520551cdf
revised patch to fix bug 253
Tom Henderson <tomh@tomh.org>
parents:
3430
diff
changeset
|
157 |
ArpCache::SetArpRequestCallback (Callback<void, Ptr<const ArpCache>, |
7176
9f2663992e99
internet coding style changes
Josh Pelkey <jpelkey@gatech.edu>
parents:
6834
diff
changeset
|
158 |
Ipv4Address> arpRequestCallback) |
3499
a18520551cdf
revised patch to fix bug 253
Tom Henderson <tomh@tomh.org>
parents:
3430
diff
changeset
|
159 |
{ |
6560
771dbe777984
get rid of NOARGS logging statements and log statements in getters
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
4455
diff
changeset
|
160 |
NS_LOG_FUNCTION (this); |
3499
a18520551cdf
revised patch to fix bug 253
Tom Henderson <tomh@tomh.org>
parents:
3430
diff
changeset
|
161 |
m_arpRequestCallback = arpRequestCallback; |
a18520551cdf
revised patch to fix bug 253
Tom Henderson <tomh@tomh.org>
parents:
3430
diff
changeset
|
162 |
} |
a18520551cdf
revised patch to fix bug 253
Tom Henderson <tomh@tomh.org>
parents:
3430
diff
changeset
|
163 |
|
a18520551cdf
revised patch to fix bug 253
Tom Henderson <tomh@tomh.org>
parents:
3430
diff
changeset
|
164 |
void |
a18520551cdf
revised patch to fix bug 253
Tom Henderson <tomh@tomh.org>
parents:
3430
diff
changeset
|
165 |
ArpCache::StartWaitReplyTimer (void) |
a18520551cdf
revised patch to fix bug 253
Tom Henderson <tomh@tomh.org>
parents:
3430
diff
changeset
|
166 |
{ |
6560
771dbe777984
get rid of NOARGS logging statements and log statements in getters
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
4455
diff
changeset
|
167 |
NS_LOG_FUNCTION (this); |
3499
a18520551cdf
revised patch to fix bug 253
Tom Henderson <tomh@tomh.org>
parents:
3430
diff
changeset
|
168 |
if (!m_waitReplyTimer.IsRunning ()) |
a18520551cdf
revised patch to fix bug 253
Tom Henderson <tomh@tomh.org>
parents:
3430
diff
changeset
|
169 |
{ |
6561
d22119d6f382
log timeout duration
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
6560
diff
changeset
|
170 |
NS_LOG_LOGIC ("Starting WaitReplyTimer at " << Simulator::Now () << " for " << |
d22119d6f382
log timeout duration
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
6560
diff
changeset
|
171 |
m_waitReplyTimeout); |
3499
a18520551cdf
revised patch to fix bug 253
Tom Henderson <tomh@tomh.org>
parents:
3430
diff
changeset
|
172 |
m_waitReplyTimer = Simulator::Schedule (m_waitReplyTimeout, |
6561
d22119d6f382
log timeout duration
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
6560
diff
changeset
|
173 |
&ArpCache::HandleWaitReplyTimeout, this); |
3499
a18520551cdf
revised patch to fix bug 253
Tom Henderson <tomh@tomh.org>
parents:
3430
diff
changeset
|
174 |
} |
a18520551cdf
revised patch to fix bug 253
Tom Henderson <tomh@tomh.org>
parents:
3430
diff
changeset
|
175 |
} |
a18520551cdf
revised patch to fix bug 253
Tom Henderson <tomh@tomh.org>
parents:
3430
diff
changeset
|
176 |
|
a18520551cdf
revised patch to fix bug 253
Tom Henderson <tomh@tomh.org>
parents:
3430
diff
changeset
|
177 |
void |
a18520551cdf
revised patch to fix bug 253
Tom Henderson <tomh@tomh.org>
parents:
3430
diff
changeset
|
178 |
ArpCache::HandleWaitReplyTimeout (void) |
a18520551cdf
revised patch to fix bug 253
Tom Henderson <tomh@tomh.org>
parents:
3430
diff
changeset
|
179 |
{ |
6560
771dbe777984
get rid of NOARGS logging statements and log statements in getters
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
4455
diff
changeset
|
180 |
NS_LOG_FUNCTION (this); |
3499
a18520551cdf
revised patch to fix bug 253
Tom Henderson <tomh@tomh.org>
parents:
3430
diff
changeset
|
181 |
ArpCache::Entry* entry; |
a18520551cdf
revised patch to fix bug 253
Tom Henderson <tomh@tomh.org>
parents:
3430
diff
changeset
|
182 |
bool restartWaitReplyTimer = false; |
a18520551cdf
revised patch to fix bug 253
Tom Henderson <tomh@tomh.org>
parents:
3430
diff
changeset
|
183 |
for (CacheI i = m_arpCache.begin (); i != m_arpCache.end (); i++) |
a18520551cdf
revised patch to fix bug 253
Tom Henderson <tomh@tomh.org>
parents:
3430
diff
changeset
|
184 |
{ |
a18520551cdf
revised patch to fix bug 253
Tom Henderson <tomh@tomh.org>
parents:
3430
diff
changeset
|
185 |
entry = (*i).second; |
4250 | 186 |
if (entry != 0 && entry->IsWaitReply ()) |
7176
9f2663992e99
internet coding style changes
Josh Pelkey <jpelkey@gatech.edu>
parents:
6834
diff
changeset
|
187 |
{ |
3499
a18520551cdf
revised patch to fix bug 253
Tom Henderson <tomh@tomh.org>
parents:
3430
diff
changeset
|
188 |
if (entry->GetRetries () < m_maxRetries) |
a18520551cdf
revised patch to fix bug 253
Tom Henderson <tomh@tomh.org>
parents:
3430
diff
changeset
|
189 |
{ |
a18520551cdf
revised patch to fix bug 253
Tom Henderson <tomh@tomh.org>
parents:
3430
diff
changeset
|
190 |
NS_LOG_LOGIC ("node="<< m_device->GetNode ()->GetId () << |
7176
9f2663992e99
internet coding style changes
Josh Pelkey <jpelkey@gatech.edu>
parents:
6834
diff
changeset
|
191 |
", ArpWaitTimeout for " << entry->GetIpv4Address () << |
9f2663992e99
internet coding style changes
Josh Pelkey <jpelkey@gatech.edu>
parents:
6834
diff
changeset
|
192 |
" expired -- retransmitting arp request since retries = " << |
9f2663992e99
internet coding style changes
Josh Pelkey <jpelkey@gatech.edu>
parents:
6834
diff
changeset
|
193 |
entry->GetRetries ()); |
3499
a18520551cdf
revised patch to fix bug 253
Tom Henderson <tomh@tomh.org>
parents:
3430
diff
changeset
|
194 |
m_arpRequestCallback (this, entry->GetIpv4Address ()); |
a18520551cdf
revised patch to fix bug 253
Tom Henderson <tomh@tomh.org>
parents:
3430
diff
changeset
|
195 |
restartWaitReplyTimer = true; |
a18520551cdf
revised patch to fix bug 253
Tom Henderson <tomh@tomh.org>
parents:
3430
diff
changeset
|
196 |
entry->IncrementRetries (); |
a18520551cdf
revised patch to fix bug 253
Tom Henderson <tomh@tomh.org>
parents:
3430
diff
changeset
|
197 |
} |
a18520551cdf
revised patch to fix bug 253
Tom Henderson <tomh@tomh.org>
parents:
3430
diff
changeset
|
198 |
else |
a18520551cdf
revised patch to fix bug 253
Tom Henderson <tomh@tomh.org>
parents:
3430
diff
changeset
|
199 |
{ |
a18520551cdf
revised patch to fix bug 253
Tom Henderson <tomh@tomh.org>
parents:
3430
diff
changeset
|
200 |
NS_LOG_LOGIC ("node="<<m_device->GetNode ()->GetId () << |
7176
9f2663992e99
internet coding style changes
Josh Pelkey <jpelkey@gatech.edu>
parents:
6834
diff
changeset
|
201 |
", wait reply for " << entry->GetIpv4Address () << |
9f2663992e99
internet coding style changes
Josh Pelkey <jpelkey@gatech.edu>
parents:
6834
diff
changeset
|
202 |
" expired -- drop since max retries exceeded: " << |
9f2663992e99
internet coding style changes
Josh Pelkey <jpelkey@gatech.edu>
parents:
6834
diff
changeset
|
203 |
entry->GetRetries ()); |
3499
a18520551cdf
revised patch to fix bug 253
Tom Henderson <tomh@tomh.org>
parents:
3430
diff
changeset
|
204 |
entry->MarkDead (); |
a18520551cdf
revised patch to fix bug 253
Tom Henderson <tomh@tomh.org>
parents:
3430
diff
changeset
|
205 |
entry->ClearRetries (); |
7256
b04ba6772f8c
rerun check-style.py at default level to enforce space after function name
Tom Henderson <tomh@tomh.org>
parents:
7176
diff
changeset
|
206 |
Ptr<Packet> pending = entry->DequeuePending (); |
3499
a18520551cdf
revised patch to fix bug 253
Tom Henderson <tomh@tomh.org>
parents:
3430
diff
changeset
|
207 |
while (pending != 0) |
a18520551cdf
revised patch to fix bug 253
Tom Henderson <tomh@tomh.org>
parents:
3430
diff
changeset
|
208 |
{ |
a18520551cdf
revised patch to fix bug 253
Tom Henderson <tomh@tomh.org>
parents:
3430
diff
changeset
|
209 |
m_dropTrace (pending); |
7256
b04ba6772f8c
rerun check-style.py at default level to enforce space after function name
Tom Henderson <tomh@tomh.org>
parents:
7176
diff
changeset
|
210 |
pending = entry->DequeuePending (); |
3499
a18520551cdf
revised patch to fix bug 253
Tom Henderson <tomh@tomh.org>
parents:
3430
diff
changeset
|
211 |
} |
a18520551cdf
revised patch to fix bug 253
Tom Henderson <tomh@tomh.org>
parents:
3430
diff
changeset
|
212 |
} |
7176
9f2663992e99
internet coding style changes
Josh Pelkey <jpelkey@gatech.edu>
parents:
6834
diff
changeset
|
213 |
} |
3499
a18520551cdf
revised patch to fix bug 253
Tom Henderson <tomh@tomh.org>
parents:
3430
diff
changeset
|
214 |
|
a18520551cdf
revised patch to fix bug 253
Tom Henderson <tomh@tomh.org>
parents:
3430
diff
changeset
|
215 |
} |
a18520551cdf
revised patch to fix bug 253
Tom Henderson <tomh@tomh.org>
parents:
3430
diff
changeset
|
216 |
if (restartWaitReplyTimer) |
a18520551cdf
revised patch to fix bug 253
Tom Henderson <tomh@tomh.org>
parents:
3430
diff
changeset
|
217 |
{ |
a18520551cdf
revised patch to fix bug 253
Tom Henderson <tomh@tomh.org>
parents:
3430
diff
changeset
|
218 |
NS_LOG_LOGIC ("Restarting WaitReplyTimer at " << Simulator::Now ().GetSeconds ()); |
a18520551cdf
revised patch to fix bug 253
Tom Henderson <tomh@tomh.org>
parents:
3430
diff
changeset
|
219 |
m_waitReplyTimer = Simulator::Schedule (m_waitReplyTimeout, |
7176
9f2663992e99
internet coding style changes
Josh Pelkey <jpelkey@gatech.edu>
parents:
6834
diff
changeset
|
220 |
&ArpCache::HandleWaitReplyTimeout, this); |
3499
a18520551cdf
revised patch to fix bug 253
Tom Henderson <tomh@tomh.org>
parents:
3430
diff
changeset
|
221 |
} |
a18520551cdf
revised patch to fix bug 253
Tom Henderson <tomh@tomh.org>
parents:
3430
diff
changeset
|
222 |
} |
a18520551cdf
revised patch to fix bug 253
Tom Henderson <tomh@tomh.org>
parents:
3430
diff
changeset
|
223 |
|
a18520551cdf
revised patch to fix bug 253
Tom Henderson <tomh@tomh.org>
parents:
3430
diff
changeset
|
224 |
void |
242 | 225 |
ArpCache::Flush (void) |
226 |
{ |
|
6560
771dbe777984
get rid of NOARGS logging statements and log statements in getters
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
4455
diff
changeset
|
227 |
NS_LOG_FUNCTION (this); |
242 | 228 |
for (CacheI i = m_arpCache.begin (); i != m_arpCache.end (); i++) |
229 |
{ |
|
230 |
delete (*i).second; |
|
231 |
} |
|
232 |
m_arpCache.erase (m_arpCache.begin (), m_arpCache.end ()); |
|
3823
761f94afe2a2
Fix bug 362; cancel WaitReplyTimer when ArpCache is flushed
Tom Henderson <tomh@tomh.org>
parents:
3499
diff
changeset
|
233 |
if (m_waitReplyTimer.IsRunning ()) |
761f94afe2a2
Fix bug 362; cancel WaitReplyTimer when ArpCache is flushed
Tom Henderson <tomh@tomh.org>
parents:
3499
diff
changeset
|
234 |
{ |
761f94afe2a2
Fix bug 362; cancel WaitReplyTimer when ArpCache is flushed
Tom Henderson <tomh@tomh.org>
parents:
3499
diff
changeset
|
235 |
NS_LOG_LOGIC ("Stopping WaitReplyTimer at " << Simulator::Now ().GetSeconds () << " due to ArpCache flush"); |
761f94afe2a2
Fix bug 362; cancel WaitReplyTimer when ArpCache is flushed
Tom Henderson <tomh@tomh.org>
parents:
3499
diff
changeset
|
236 |
m_waitReplyTimer.Cancel (); |
761f94afe2a2
Fix bug 362; cancel WaitReplyTimer when ArpCache is flushed
Tom Henderson <tomh@tomh.org>
parents:
3499
diff
changeset
|
237 |
} |
242 | 238 |
} |
239 |
||
240 |
ArpCache::Entry * |
|
241 |
ArpCache::Lookup (Ipv4Address to) |
|
242 |
{ |
|
243 |
if (m_arpCache.find (to) != m_arpCache.end ()) |
|
244 |
{ |
|
245 |
ArpCache::Entry *entry = m_arpCache[to]; |
|
246 |
return entry; |
|
247 |
} |
|
248 |
return 0; |
|
249 |
} |
|
250 |
||
251 |
ArpCache::Entry * |
|
252 |
ArpCache::Add (Ipv4Address to) |
|
253 |
{ |
|
6560
771dbe777984
get rid of NOARGS logging statements and log statements in getters
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
4455
diff
changeset
|
254 |
NS_LOG_FUNCTION (this << to); |
933
df68dad55087
WAF: add a --command-template option to e.g. allow running programs with valgrind, gdb, etc.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
568
diff
changeset
|
255 |
NS_ASSERT (m_arpCache.find (to) == m_arpCache.end ()); |
df68dad55087
WAF: add a --command-template option to e.g. allow running programs with valgrind, gdb, etc.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
568
diff
changeset
|
256 |
|
242 | 257 |
ArpCache::Entry *entry = new ArpCache::Entry (this); |
7176
9f2663992e99
internet coding style changes
Josh Pelkey <jpelkey@gatech.edu>
parents:
6834
diff
changeset
|
258 |
m_arpCache[to] = entry; |
3499
a18520551cdf
revised patch to fix bug 253
Tom Henderson <tomh@tomh.org>
parents:
3430
diff
changeset
|
259 |
entry->SetIpv4Address (to); |
242 | 260 |
return entry; |
261 |
} |
|
262 |
||
263 |
ArpCache::Entry::Entry (ArpCache *arp) |
|
264 |
: m_arp (arp), |
|
3499
a18520551cdf
revised patch to fix bug 253
Tom Henderson <tomh@tomh.org>
parents:
3430
diff
changeset
|
265 |
m_state (ALIVE), |
a18520551cdf
revised patch to fix bug 253
Tom Henderson <tomh@tomh.org>
parents:
3430
diff
changeset
|
266 |
m_retries (0) |
3430
a8eb6b890f14
Add NS_LOG_FUNCTION calls in arp implementation
Tom Henderson <tomh@tomh.org>
parents:
3260
diff
changeset
|
267 |
{ |
6560
771dbe777984
get rid of NOARGS logging statements and log statements in getters
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
4455
diff
changeset
|
268 |
NS_LOG_FUNCTION (this << arp); |
3430
a8eb6b890f14
Add NS_LOG_FUNCTION calls in arp implementation
Tom Henderson <tomh@tomh.org>
parents:
3260
diff
changeset
|
269 |
} |
242 | 270 |
|
271 |
||
272 |
bool |
|
273 |
ArpCache::Entry::IsDead (void) |
|
274 |
{ |
|
7176
9f2663992e99
internet coding style changes
Josh Pelkey <jpelkey@gatech.edu>
parents:
6834
diff
changeset
|
275 |
return (m_state == DEAD) ? true : false; |
242 | 276 |
} |
277 |
bool |
|
278 |
ArpCache::Entry::IsAlive (void) |
|
279 |
{ |
|
7176
9f2663992e99
internet coding style changes
Josh Pelkey <jpelkey@gatech.edu>
parents:
6834
diff
changeset
|
280 |
return (m_state == ALIVE) ? true : false; |
242 | 281 |
} |
282 |
bool |
|
283 |
ArpCache::Entry::IsWaitReply (void) |
|
284 |
{ |
|
7176
9f2663992e99
internet coding style changes
Josh Pelkey <jpelkey@gatech.edu>
parents:
6834
diff
changeset
|
285 |
return (m_state == WAIT_REPLY) ? true : false; |
242 | 286 |
} |
287 |
||
288 |
||
289 |
void |
|
290 |
ArpCache::Entry::MarkDead (void) |
|
291 |
{ |
|
6560
771dbe777984
get rid of NOARGS logging statements and log statements in getters
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
4455
diff
changeset
|
292 |
NS_LOG_FUNCTION (this); |
242 | 293 |
m_state = DEAD; |
3499
a18520551cdf
revised patch to fix bug 253
Tom Henderson <tomh@tomh.org>
parents:
3430
diff
changeset
|
294 |
ClearRetries (); |
242 | 295 |
UpdateSeen (); |
296 |
} |
|
3151
428f8ec6da29
fix bug 185
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
3146
diff
changeset
|
297 |
void |
1161
bb72baff8b26
replace MacAddress by Address
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
568
diff
changeset
|
298 |
ArpCache::Entry::MarkAlive (Address macAddress) |
242 | 299 |
{ |
6560
771dbe777984
get rid of NOARGS logging statements and log statements in getters
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
4455
diff
changeset
|
300 |
NS_LOG_FUNCTION (this << macAddress); |
286
57e6a2006962
convert use of <cassert> to "ns3/assert.h"
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
243
diff
changeset
|
301 |
NS_ASSERT (m_state == WAIT_REPLY); |
242 | 302 |
m_macAddress = macAddress; |
303 |
m_state = ALIVE; |
|
3499
a18520551cdf
revised patch to fix bug 253
Tom Henderson <tomh@tomh.org>
parents:
3430
diff
changeset
|
304 |
ClearRetries (); |
242 | 305 |
UpdateSeen (); |
306 |
} |
|
307 |
||
3151
428f8ec6da29
fix bug 185
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
3146
diff
changeset
|
308 |
bool |
1866
e7dbcc4df546
do not use Packet objects directly. Use Ptr<Packet> instead
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
1341
diff
changeset
|
309 |
ArpCache::Entry::UpdateWaitReply (Ptr<Packet> waiting) |
242 | 310 |
{ |
6560
771dbe777984
get rid of NOARGS logging statements and log statements in getters
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
4455
diff
changeset
|
311 |
NS_LOG_FUNCTION (this << waiting); |
286
57e6a2006962
convert use of <cassert> to "ns3/assert.h"
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
243
diff
changeset
|
312 |
NS_ASSERT (m_state == WAIT_REPLY); |
242 | 313 |
/* We are already waiting for an answer so |
314 |
* we dump the previously waiting packet and |
|
315 |
* replace it with this one. |
|
316 |
*/ |
|
3151
428f8ec6da29
fix bug 185
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
3146
diff
changeset
|
317 |
if (m_pending.size () >= m_arp->m_pendingQueueSize) |
428f8ec6da29
fix bug 185
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
3146
diff
changeset
|
318 |
{ |
428f8ec6da29
fix bug 185
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
3146
diff
changeset
|
319 |
return false; |
428f8ec6da29
fix bug 185
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
3146
diff
changeset
|
320 |
} |
428f8ec6da29
fix bug 185
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
3146
diff
changeset
|
321 |
m_pending.push_back (waiting); |
428f8ec6da29
fix bug 185
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
3146
diff
changeset
|
322 |
return true; |
242 | 323 |
} |
324 |
void |
|
1866
e7dbcc4df546
do not use Packet objects directly. Use Ptr<Packet> instead
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
1341
diff
changeset
|
325 |
ArpCache::Entry::MarkWaitReply (Ptr<Packet> waiting) |
242 | 326 |
{ |
6560
771dbe777984
get rid of NOARGS logging statements and log statements in getters
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
4455
diff
changeset
|
327 |
NS_LOG_FUNCTION (this << waiting); |
286
57e6a2006962
convert use of <cassert> to "ns3/assert.h"
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
243
diff
changeset
|
328 |
NS_ASSERT (m_state == ALIVE || m_state == DEAD); |
3151
428f8ec6da29
fix bug 185
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
3146
diff
changeset
|
329 |
NS_ASSERT (m_pending.empty ()); |
242 | 330 |
m_state = WAIT_REPLY; |
3151
428f8ec6da29
fix bug 185
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
3146
diff
changeset
|
331 |
m_pending.push_back (waiting); |
242 | 332 |
UpdateSeen (); |
3499
a18520551cdf
revised patch to fix bug 253
Tom Henderson <tomh@tomh.org>
parents:
3430
diff
changeset
|
333 |
m_arp->StartWaitReplyTimer (); |
242 | 334 |
} |
335 |
||
1161
bb72baff8b26
replace MacAddress by Address
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
568
diff
changeset
|
336 |
Address |
3499
a18520551cdf
revised patch to fix bug 253
Tom Henderson <tomh@tomh.org>
parents:
3430
diff
changeset
|
337 |
ArpCache::Entry::GetMacAddress (void) const |
242 | 338 |
{ |
286
57e6a2006962
convert use of <cassert> to "ns3/assert.h"
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
243
diff
changeset
|
339 |
NS_ASSERT (m_state == ALIVE); |
242 | 340 |
return m_macAddress; |
341 |
} |
|
3499
a18520551cdf
revised patch to fix bug 253
Tom Henderson <tomh@tomh.org>
parents:
3430
diff
changeset
|
342 |
Ipv4Address |
a18520551cdf
revised patch to fix bug 253
Tom Henderson <tomh@tomh.org>
parents:
3430
diff
changeset
|
343 |
ArpCache::Entry::GetIpv4Address (void) const |
a18520551cdf
revised patch to fix bug 253
Tom Henderson <tomh@tomh.org>
parents:
3430
diff
changeset
|
344 |
{ |
a18520551cdf
revised patch to fix bug 253
Tom Henderson <tomh@tomh.org>
parents:
3430
diff
changeset
|
345 |
return m_ipv4Address; |
a18520551cdf
revised patch to fix bug 253
Tom Henderson <tomh@tomh.org>
parents:
3430
diff
changeset
|
346 |
} |
a18520551cdf
revised patch to fix bug 253
Tom Henderson <tomh@tomh.org>
parents:
3430
diff
changeset
|
347 |
void |
a18520551cdf
revised patch to fix bug 253
Tom Henderson <tomh@tomh.org>
parents:
3430
diff
changeset
|
348 |
ArpCache::Entry::SetIpv4Address (Ipv4Address destination) |
a18520551cdf
revised patch to fix bug 253
Tom Henderson <tomh@tomh.org>
parents:
3430
diff
changeset
|
349 |
{ |
a18520551cdf
revised patch to fix bug 253
Tom Henderson <tomh@tomh.org>
parents:
3430
diff
changeset
|
350 |
NS_LOG_FUNCTION (this << destination); |
a18520551cdf
revised patch to fix bug 253
Tom Henderson <tomh@tomh.org>
parents:
3430
diff
changeset
|
351 |
m_ipv4Address = destination; |
a18520551cdf
revised patch to fix bug 253
Tom Henderson <tomh@tomh.org>
parents:
3430
diff
changeset
|
352 |
} |
4084 | 353 |
Time |
354 |
ArpCache::Entry::GetTimeout (void) const |
|
242 | 355 |
{ |
356 |
switch (m_state) { |
|
7176
9f2663992e99
internet coding style changes
Josh Pelkey <jpelkey@gatech.edu>
parents:
6834
diff
changeset
|
357 |
case ArpCache::Entry::WAIT_REPLY: |
9f2663992e99
internet coding style changes
Josh Pelkey <jpelkey@gatech.edu>
parents:
6834
diff
changeset
|
358 |
return m_arp->GetWaitReplyTimeout (); |
9f2663992e99
internet coding style changes
Josh Pelkey <jpelkey@gatech.edu>
parents:
6834
diff
changeset
|
359 |
case ArpCache::Entry::DEAD: |
9f2663992e99
internet coding style changes
Josh Pelkey <jpelkey@gatech.edu>
parents:
6834
diff
changeset
|
360 |
return m_arp->GetDeadTimeout (); |
9f2663992e99
internet coding style changes
Josh Pelkey <jpelkey@gatech.edu>
parents:
6834
diff
changeset
|
361 |
case ArpCache::Entry::ALIVE: |
9f2663992e99
internet coding style changes
Josh Pelkey <jpelkey@gatech.edu>
parents:
6834
diff
changeset
|
362 |
return m_arp->GetAliveTimeout (); |
9f2663992e99
internet coding style changes
Josh Pelkey <jpelkey@gatech.edu>
parents:
6834
diff
changeset
|
363 |
default: |
9f2663992e99
internet coding style changes
Josh Pelkey <jpelkey@gatech.edu>
parents:
6834
diff
changeset
|
364 |
NS_ASSERT (false); |
9f2663992e99
internet coding style changes
Josh Pelkey <jpelkey@gatech.edu>
parents:
6834
diff
changeset
|
365 |
return Seconds (0); |
9f2663992e99
internet coding style changes
Josh Pelkey <jpelkey@gatech.edu>
parents:
6834
diff
changeset
|
366 |
/* NOTREACHED */ |
9f2663992e99
internet coding style changes
Josh Pelkey <jpelkey@gatech.edu>
parents:
6834
diff
changeset
|
367 |
} |
4084 | 368 |
} |
369 |
bool |
|
370 |
ArpCache::Entry::IsExpired (void) const |
|
371 |
{ |
|
372 |
Time timeout = GetTimeout (); |
|
373 |
Time delta = Simulator::Now () - m_lastSeen; |
|
374 |
NS_LOG_DEBUG ("delta=" << delta.GetSeconds () << "s"); |
|
375 |
if (delta > timeout) |
|
242 | 376 |
{ |
377 |
return true; |
|
378 |
} |
|
4084 | 379 |
return false; |
242 | 380 |
} |
3151
428f8ec6da29
fix bug 185
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
3146
diff
changeset
|
381 |
Ptr<Packet> |
428f8ec6da29
fix bug 185
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
3146
diff
changeset
|
382 |
ArpCache::Entry::DequeuePending (void) |
428f8ec6da29
fix bug 185
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
3146
diff
changeset
|
383 |
{ |
6560
771dbe777984
get rid of NOARGS logging statements and log statements in getters
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
4455
diff
changeset
|
384 |
NS_LOG_FUNCTION (this); |
3151
428f8ec6da29
fix bug 185
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
3146
diff
changeset
|
385 |
if (m_pending.empty ()) |
428f8ec6da29
fix bug 185
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
3146
diff
changeset
|
386 |
{ |
428f8ec6da29
fix bug 185
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
3146
diff
changeset
|
387 |
return 0; |
428f8ec6da29
fix bug 185
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
3146
diff
changeset
|
388 |
} |
428f8ec6da29
fix bug 185
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
3146
diff
changeset
|
389 |
else |
428f8ec6da29
fix bug 185
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
3146
diff
changeset
|
390 |
{ |
428f8ec6da29
fix bug 185
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
3146
diff
changeset
|
391 |
Ptr<Packet> p = m_pending.front (); |
428f8ec6da29
fix bug 185
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
3146
diff
changeset
|
392 |
m_pending.pop_front (); |
428f8ec6da29
fix bug 185
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
3146
diff
changeset
|
393 |
return p; |
428f8ec6da29
fix bug 185
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
3146
diff
changeset
|
394 |
} |
428f8ec6da29
fix bug 185
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
3146
diff
changeset
|
395 |
} |
242 | 396 |
void |
397 |
ArpCache::Entry::UpdateSeen (void) |
|
398 |
{ |
|
6560
771dbe777984
get rid of NOARGS logging statements and log statements in getters
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
4455
diff
changeset
|
399 |
NS_LOG_FUNCTION (this << m_macAddress << m_ipv4Address); |
242 | 400 |
m_lastSeen = Simulator::Now (); |
401 |
} |
|
3499
a18520551cdf
revised patch to fix bug 253
Tom Henderson <tomh@tomh.org>
parents:
3430
diff
changeset
|
402 |
uint32_t |
a18520551cdf
revised patch to fix bug 253
Tom Henderson <tomh@tomh.org>
parents:
3430
diff
changeset
|
403 |
ArpCache::Entry::GetRetries (void) const |
a18520551cdf
revised patch to fix bug 253
Tom Henderson <tomh@tomh.org>
parents:
3430
diff
changeset
|
404 |
{ |
a18520551cdf
revised patch to fix bug 253
Tom Henderson <tomh@tomh.org>
parents:
3430
diff
changeset
|
405 |
return m_retries; |
a18520551cdf
revised patch to fix bug 253
Tom Henderson <tomh@tomh.org>
parents:
3430
diff
changeset
|
406 |
} |
a18520551cdf
revised patch to fix bug 253
Tom Henderson <tomh@tomh.org>
parents:
3430
diff
changeset
|
407 |
void |
a18520551cdf
revised patch to fix bug 253
Tom Henderson <tomh@tomh.org>
parents:
3430
diff
changeset
|
408 |
ArpCache::Entry::IncrementRetries (void) |
a18520551cdf
revised patch to fix bug 253
Tom Henderson <tomh@tomh.org>
parents:
3430
diff
changeset
|
409 |
{ |
6560
771dbe777984
get rid of NOARGS logging statements and log statements in getters
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
4455
diff
changeset
|
410 |
NS_LOG_FUNCTION (this); |
3499
a18520551cdf
revised patch to fix bug 253
Tom Henderson <tomh@tomh.org>
parents:
3430
diff
changeset
|
411 |
m_retries++; |
a18520551cdf
revised patch to fix bug 253
Tom Henderson <tomh@tomh.org>
parents:
3430
diff
changeset
|
412 |
UpdateSeen (); |
a18520551cdf
revised patch to fix bug 253
Tom Henderson <tomh@tomh.org>
parents:
3430
diff
changeset
|
413 |
} |
a18520551cdf
revised patch to fix bug 253
Tom Henderson <tomh@tomh.org>
parents:
3430
diff
changeset
|
414 |
void |
a18520551cdf
revised patch to fix bug 253
Tom Henderson <tomh@tomh.org>
parents:
3430
diff
changeset
|
415 |
ArpCache::Entry::ClearRetries (void) |
a18520551cdf
revised patch to fix bug 253
Tom Henderson <tomh@tomh.org>
parents:
3430
diff
changeset
|
416 |
{ |
6560
771dbe777984
get rid of NOARGS logging statements and log statements in getters
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
4455
diff
changeset
|
417 |
NS_LOG_FUNCTION (this); |
3499
a18520551cdf
revised patch to fix bug 253
Tom Henderson <tomh@tomh.org>
parents:
3430
diff
changeset
|
418 |
m_retries = 0; |
a18520551cdf
revised patch to fix bug 253
Tom Henderson <tomh@tomh.org>
parents:
3430
diff
changeset
|
419 |
} |
242 | 420 |
|
421 |
} // namespace ns3 |
|
422 |