author | Craig Dowell <craigdo@ee.washington.edu> |
Wed, 17 Feb 2010 21:50:11 -0800 | |
changeset 5994 | ced6c14c957e |
parent 4455 | 0708e7fdf676 |
child 6560 | 771dbe777984 |
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 |
*/ |
|
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", |
3499
a18520551cdf
revised patch to fix bug 253
Tom Henderson <tomh@tomh.org>
parents:
3430
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 ()) |
3499
a18520551cdf
revised patch to fix bug 253
Tom Henderson <tomh@tomh.org>
parents:
3430
diff
changeset
|
58 |
.AddAttribute ("MaxRetries", |
a18520551cdf
revised patch to fix bug 253
Tom Henderson <tomh@tomh.org>
parents:
3430
diff
changeset
|
59 |
"Number of retransmissions of ArpRequest before marking dead", |
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> ()) |
3499
a18520551cdf
revised patch to fix bug 253
Tom Henderson <tomh@tomh.org>
parents:
3430
diff
changeset
|
68 |
.AddTraceSource ("Drop", |
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)) |
3146
98629e087bb1
add attributes to ArpCache
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2834
diff
changeset
|
71 |
; |
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 |
{ |
3430
a8eb6b890f14
Add NS_LOG_FUNCTION calls in arp implementation
Tom Henderson <tomh@tomh.org>
parents:
3260
diff
changeset
|
104 |
NS_LOG_FUNCTION_NOARGS (); |
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 |
{ |
3430
a8eb6b890f14
Add NS_LOG_FUNCTION calls in arp implementation
Tom Henderson <tomh@tomh.org>
parents:
3260
diff
changeset
|
112 |
NS_LOG_FUNCTION_NOARGS (); |
242 | 113 |
return m_device; |
114 |
} |
|
115 |
||
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
|
116 |
Ptr<Ipv4Interface> |
242 | 117 |
ArpCache::GetInterface (void) const |
118 |
{ |
|
3430
a8eb6b890f14
Add NS_LOG_FUNCTION calls in arp implementation
Tom Henderson <tomh@tomh.org>
parents:
3260
diff
changeset
|
119 |
NS_LOG_FUNCTION_NOARGS (); |
242 | 120 |
return m_interface; |
121 |
} |
|
122 |
||
123 |
void |
|
124 |
ArpCache::SetAliveTimeout (Time aliveTimeout) |
|
125 |
{ |
|
3430
a8eb6b890f14
Add NS_LOG_FUNCTION calls in arp implementation
Tom Henderson <tomh@tomh.org>
parents:
3260
diff
changeset
|
126 |
NS_LOG_FUNCTION_NOARGS (); |
242 | 127 |
m_aliveTimeout = aliveTimeout; |
128 |
} |
|
129 |
void |
|
130 |
ArpCache::SetDeadTimeout (Time deadTimeout) |
|
131 |
{ |
|
3430
a8eb6b890f14
Add NS_LOG_FUNCTION calls in arp implementation
Tom Henderson <tomh@tomh.org>
parents:
3260
diff
changeset
|
132 |
NS_LOG_FUNCTION_NOARGS (); |
242 | 133 |
m_deadTimeout = deadTimeout; |
134 |
} |
|
135 |
void |
|
136 |
ArpCache::SetWaitReplyTimeout (Time waitReplyTimeout) |
|
137 |
{ |
|
3430
a8eb6b890f14
Add NS_LOG_FUNCTION calls in arp implementation
Tom Henderson <tomh@tomh.org>
parents:
3260
diff
changeset
|
138 |
NS_LOG_FUNCTION_NOARGS (); |
242 | 139 |
m_waitReplyTimeout = waitReplyTimeout; |
140 |
} |
|
141 |
||
142 |
Time |
|
143 |
ArpCache::GetAliveTimeout (void) const |
|
144 |
{ |
|
3430
a8eb6b890f14
Add NS_LOG_FUNCTION calls in arp implementation
Tom Henderson <tomh@tomh.org>
parents:
3260
diff
changeset
|
145 |
NS_LOG_FUNCTION_NOARGS (); |
242 | 146 |
return m_aliveTimeout; |
147 |
} |
|
148 |
Time |
|
149 |
ArpCache::GetDeadTimeout (void) const |
|
150 |
{ |
|
3430
a8eb6b890f14
Add NS_LOG_FUNCTION calls in arp implementation
Tom Henderson <tomh@tomh.org>
parents:
3260
diff
changeset
|
151 |
NS_LOG_FUNCTION_NOARGS (); |
242 | 152 |
return m_deadTimeout; |
153 |
} |
|
154 |
Time |
|
155 |
ArpCache::GetWaitReplyTimeout (void) const |
|
156 |
{ |
|
3430
a8eb6b890f14
Add NS_LOG_FUNCTION calls in arp implementation
Tom Henderson <tomh@tomh.org>
parents:
3260
diff
changeset
|
157 |
NS_LOG_FUNCTION_NOARGS (); |
242 | 158 |
return m_waitReplyTimeout; |
159 |
} |
|
160 |
||
161 |
void |
|
3499
a18520551cdf
revised patch to fix bug 253
Tom Henderson <tomh@tomh.org>
parents:
3430
diff
changeset
|
162 |
ArpCache::SetArpRequestCallback (Callback<void, Ptr<const ArpCache>, |
a18520551cdf
revised patch to fix bug 253
Tom Henderson <tomh@tomh.org>
parents:
3430
diff
changeset
|
163 |
Ipv4Address> arpRequestCallback) |
a18520551cdf
revised patch to fix bug 253
Tom Henderson <tomh@tomh.org>
parents:
3430
diff
changeset
|
164 |
{ |
a18520551cdf
revised patch to fix bug 253
Tom Henderson <tomh@tomh.org>
parents:
3430
diff
changeset
|
165 |
NS_LOG_FUNCTION_NOARGS (); |
a18520551cdf
revised patch to fix bug 253
Tom Henderson <tomh@tomh.org>
parents:
3430
diff
changeset
|
166 |
m_arpRequestCallback = arpRequestCallback; |
a18520551cdf
revised patch to fix bug 253
Tom Henderson <tomh@tomh.org>
parents:
3430
diff
changeset
|
167 |
} |
a18520551cdf
revised patch to fix bug 253
Tom Henderson <tomh@tomh.org>
parents:
3430
diff
changeset
|
168 |
|
a18520551cdf
revised patch to fix bug 253
Tom Henderson <tomh@tomh.org>
parents:
3430
diff
changeset
|
169 |
void |
a18520551cdf
revised patch to fix bug 253
Tom Henderson <tomh@tomh.org>
parents:
3430
diff
changeset
|
170 |
ArpCache::StartWaitReplyTimer (void) |
a18520551cdf
revised patch to fix bug 253
Tom Henderson <tomh@tomh.org>
parents:
3430
diff
changeset
|
171 |
{ |
a18520551cdf
revised patch to fix bug 253
Tom Henderson <tomh@tomh.org>
parents:
3430
diff
changeset
|
172 |
NS_LOG_FUNCTION_NOARGS (); |
a18520551cdf
revised patch to fix bug 253
Tom Henderson <tomh@tomh.org>
parents:
3430
diff
changeset
|
173 |
if (!m_waitReplyTimer.IsRunning ()) |
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 |
NS_LOG_LOGIC ("Starting WaitReplyTimer at " << Simulator::Now ().GetSeconds ()); |
a18520551cdf
revised patch to fix bug 253
Tom Henderson <tomh@tomh.org>
parents:
3430
diff
changeset
|
176 |
m_waitReplyTimer = Simulator::Schedule (m_waitReplyTimeout, |
a18520551cdf
revised patch to fix bug 253
Tom Henderson <tomh@tomh.org>
parents:
3430
diff
changeset
|
177 |
&ArpCache::HandleWaitReplyTimeout, this); |
a18520551cdf
revised patch to fix bug 253
Tom Henderson <tomh@tomh.org>
parents:
3430
diff
changeset
|
178 |
} |
a18520551cdf
revised patch to fix bug 253
Tom Henderson <tomh@tomh.org>
parents:
3430
diff
changeset
|
179 |
} |
a18520551cdf
revised patch to fix bug 253
Tom Henderson <tomh@tomh.org>
parents:
3430
diff
changeset
|
180 |
|
a18520551cdf
revised patch to fix bug 253
Tom Henderson <tomh@tomh.org>
parents:
3430
diff
changeset
|
181 |
void |
a18520551cdf
revised patch to fix bug 253
Tom Henderson <tomh@tomh.org>
parents:
3430
diff
changeset
|
182 |
ArpCache::HandleWaitReplyTimeout (void) |
a18520551cdf
revised patch to fix bug 253
Tom Henderson <tomh@tomh.org>
parents:
3430
diff
changeset
|
183 |
{ |
a18520551cdf
revised patch to fix bug 253
Tom Henderson <tomh@tomh.org>
parents:
3430
diff
changeset
|
184 |
NS_LOG_FUNCTION_NOARGS (); |
a18520551cdf
revised patch to fix bug 253
Tom Henderson <tomh@tomh.org>
parents:
3430
diff
changeset
|
185 |
ArpCache::Entry* entry; |
a18520551cdf
revised patch to fix bug 253
Tom Henderson <tomh@tomh.org>
parents:
3430
diff
changeset
|
186 |
bool restartWaitReplyTimer = false; |
a18520551cdf
revised patch to fix bug 253
Tom Henderson <tomh@tomh.org>
parents:
3430
diff
changeset
|
187 |
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
|
188 |
{ |
a18520551cdf
revised patch to fix bug 253
Tom Henderson <tomh@tomh.org>
parents:
3430
diff
changeset
|
189 |
entry = (*i).second; |
4250 | 190 |
if (entry != 0 && entry->IsWaitReply ()) |
3499
a18520551cdf
revised patch to fix bug 253
Tom Henderson <tomh@tomh.org>
parents:
3430
diff
changeset
|
191 |
{ |
a18520551cdf
revised patch to fix bug 253
Tom Henderson <tomh@tomh.org>
parents:
3430
diff
changeset
|
192 |
if (entry->GetRetries () < m_maxRetries) |
a18520551cdf
revised patch to fix bug 253
Tom Henderson <tomh@tomh.org>
parents:
3430
diff
changeset
|
193 |
{ |
a18520551cdf
revised patch to fix bug 253
Tom Henderson <tomh@tomh.org>
parents:
3430
diff
changeset
|
194 |
NS_LOG_LOGIC ("node="<< m_device->GetNode ()->GetId () << |
a18520551cdf
revised patch to fix bug 253
Tom Henderson <tomh@tomh.org>
parents:
3430
diff
changeset
|
195 |
", ArpWaitTimeout for " << entry->GetIpv4Address () << |
a18520551cdf
revised patch to fix bug 253
Tom Henderson <tomh@tomh.org>
parents:
3430
diff
changeset
|
196 |
" expired -- retransmitting arp request since retries = " << |
a18520551cdf
revised patch to fix bug 253
Tom Henderson <tomh@tomh.org>
parents:
3430
diff
changeset
|
197 |
entry->GetRetries ()); |
a18520551cdf
revised patch to fix bug 253
Tom Henderson <tomh@tomh.org>
parents:
3430
diff
changeset
|
198 |
m_arpRequestCallback (this, entry->GetIpv4Address ()); |
a18520551cdf
revised patch to fix bug 253
Tom Henderson <tomh@tomh.org>
parents:
3430
diff
changeset
|
199 |
restartWaitReplyTimer = true; |
a18520551cdf
revised patch to fix bug 253
Tom Henderson <tomh@tomh.org>
parents:
3430
diff
changeset
|
200 |
entry->IncrementRetries (); |
a18520551cdf
revised patch to fix bug 253
Tom Henderson <tomh@tomh.org>
parents:
3430
diff
changeset
|
201 |
} |
a18520551cdf
revised patch to fix bug 253
Tom Henderson <tomh@tomh.org>
parents:
3430
diff
changeset
|
202 |
else |
a18520551cdf
revised patch to fix bug 253
Tom Henderson <tomh@tomh.org>
parents:
3430
diff
changeset
|
203 |
{ |
a18520551cdf
revised patch to fix bug 253
Tom Henderson <tomh@tomh.org>
parents:
3430
diff
changeset
|
204 |
NS_LOG_LOGIC ("node="<<m_device->GetNode ()->GetId () << |
a18520551cdf
revised patch to fix bug 253
Tom Henderson <tomh@tomh.org>
parents:
3430
diff
changeset
|
205 |
", wait reply for " << entry->GetIpv4Address () << |
a18520551cdf
revised patch to fix bug 253
Tom Henderson <tomh@tomh.org>
parents:
3430
diff
changeset
|
206 |
" expired -- drop since max retries exceeded: " << |
a18520551cdf
revised patch to fix bug 253
Tom Henderson <tomh@tomh.org>
parents:
3430
diff
changeset
|
207 |
entry->GetRetries ()); |
a18520551cdf
revised patch to fix bug 253
Tom Henderson <tomh@tomh.org>
parents:
3430
diff
changeset
|
208 |
entry->MarkDead (); |
a18520551cdf
revised patch to fix bug 253
Tom Henderson <tomh@tomh.org>
parents:
3430
diff
changeset
|
209 |
entry->ClearRetries (); |
a18520551cdf
revised patch to fix bug 253
Tom Henderson <tomh@tomh.org>
parents:
3430
diff
changeset
|
210 |
Ptr<Packet> pending = entry->DequeuePending(); |
a18520551cdf
revised patch to fix bug 253
Tom Henderson <tomh@tomh.org>
parents:
3430
diff
changeset
|
211 |
while (pending != 0) |
a18520551cdf
revised patch to fix bug 253
Tom Henderson <tomh@tomh.org>
parents:
3430
diff
changeset
|
212 |
{ |
a18520551cdf
revised patch to fix bug 253
Tom Henderson <tomh@tomh.org>
parents:
3430
diff
changeset
|
213 |
m_dropTrace (pending); |
a18520551cdf
revised patch to fix bug 253
Tom Henderson <tomh@tomh.org>
parents:
3430
diff
changeset
|
214 |
pending = entry->DequeuePending(); |
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 |
} |
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 |
|
a18520551cdf
revised patch to fix bug 253
Tom Henderson <tomh@tomh.org>
parents:
3430
diff
changeset
|
219 |
} |
a18520551cdf
revised patch to fix bug 253
Tom Henderson <tomh@tomh.org>
parents:
3430
diff
changeset
|
220 |
if (restartWaitReplyTimer) |
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 |
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
|
223 |
m_waitReplyTimer = Simulator::Schedule (m_waitReplyTimeout, |
a18520551cdf
revised patch to fix bug 253
Tom Henderson <tomh@tomh.org>
parents:
3430
diff
changeset
|
224 |
&ArpCache::HandleWaitReplyTimeout, this); |
a18520551cdf
revised patch to fix bug 253
Tom Henderson <tomh@tomh.org>
parents:
3430
diff
changeset
|
225 |
} |
a18520551cdf
revised patch to fix bug 253
Tom Henderson <tomh@tomh.org>
parents:
3430
diff
changeset
|
226 |
} |
a18520551cdf
revised patch to fix bug 253
Tom Henderson <tomh@tomh.org>
parents:
3430
diff
changeset
|
227 |
|
a18520551cdf
revised patch to fix bug 253
Tom Henderson <tomh@tomh.org>
parents:
3430
diff
changeset
|
228 |
void |
242 | 229 |
ArpCache::Flush (void) |
230 |
{ |
|
3430
a8eb6b890f14
Add NS_LOG_FUNCTION calls in arp implementation
Tom Henderson <tomh@tomh.org>
parents:
3260
diff
changeset
|
231 |
NS_LOG_FUNCTION_NOARGS (); |
242 | 232 |
for (CacheI i = m_arpCache.begin (); i != m_arpCache.end (); i++) |
233 |
{ |
|
234 |
delete (*i).second; |
|
235 |
} |
|
236 |
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
|
237 |
if (m_waitReplyTimer.IsRunning ()) |
761f94afe2a2
Fix bug 362; cancel WaitReplyTimer when ArpCache is flushed
Tom Henderson <tomh@tomh.org>
parents:
3499
diff
changeset
|
238 |
{ |
761f94afe2a2
Fix bug 362; cancel WaitReplyTimer when ArpCache is flushed
Tom Henderson <tomh@tomh.org>
parents:
3499
diff
changeset
|
239 |
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
|
240 |
m_waitReplyTimer.Cancel (); |
761f94afe2a2
Fix bug 362; cancel WaitReplyTimer when ArpCache is flushed
Tom Henderson <tomh@tomh.org>
parents:
3499
diff
changeset
|
241 |
} |
242 | 242 |
} |
243 |
||
244 |
ArpCache::Entry * |
|
245 |
ArpCache::Lookup (Ipv4Address to) |
|
246 |
{ |
|
3430
a8eb6b890f14
Add NS_LOG_FUNCTION calls in arp implementation
Tom Henderson <tomh@tomh.org>
parents:
3260
diff
changeset
|
247 |
NS_LOG_FUNCTION_NOARGS (); |
242 | 248 |
if (m_arpCache.find (to) != m_arpCache.end ()) |
249 |
{ |
|
250 |
ArpCache::Entry *entry = m_arpCache[to]; |
|
251 |
return entry; |
|
252 |
} |
|
253 |
return 0; |
|
254 |
} |
|
255 |
||
256 |
ArpCache::Entry * |
|
257 |
ArpCache::Add (Ipv4Address to) |
|
258 |
{ |
|
3430
a8eb6b890f14
Add NS_LOG_FUNCTION calls in arp implementation
Tom Henderson <tomh@tomh.org>
parents:
3260
diff
changeset
|
259 |
NS_LOG_FUNCTION_NOARGS (); |
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
|
260 |
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
|
261 |
|
242 | 262 |
ArpCache::Entry *entry = new ArpCache::Entry (this); |
263 |
m_arpCache[to] = entry; |
|
3499
a18520551cdf
revised patch to fix bug 253
Tom Henderson <tomh@tomh.org>
parents:
3430
diff
changeset
|
264 |
entry->SetIpv4Address (to); |
242 | 265 |
return entry; |
266 |
} |
|
267 |
||
268 |
ArpCache::Entry::Entry (ArpCache *arp) |
|
269 |
: m_arp (arp), |
|
3499
a18520551cdf
revised patch to fix bug 253
Tom Henderson <tomh@tomh.org>
parents:
3430
diff
changeset
|
270 |
m_state (ALIVE), |
a18520551cdf
revised patch to fix bug 253
Tom Henderson <tomh@tomh.org>
parents:
3430
diff
changeset
|
271 |
m_retries (0) |
3430
a8eb6b890f14
Add NS_LOG_FUNCTION calls in arp implementation
Tom Henderson <tomh@tomh.org>
parents:
3260
diff
changeset
|
272 |
{ |
a8eb6b890f14
Add NS_LOG_FUNCTION calls in arp implementation
Tom Henderson <tomh@tomh.org>
parents:
3260
diff
changeset
|
273 |
NS_LOG_FUNCTION_NOARGS (); |
a8eb6b890f14
Add NS_LOG_FUNCTION calls in arp implementation
Tom Henderson <tomh@tomh.org>
parents:
3260
diff
changeset
|
274 |
} |
242 | 275 |
|
276 |
||
277 |
bool |
|
278 |
ArpCache::Entry::IsDead (void) |
|
279 |
{ |
|
3430
a8eb6b890f14
Add NS_LOG_FUNCTION calls in arp implementation
Tom Henderson <tomh@tomh.org>
parents:
3260
diff
changeset
|
280 |
NS_LOG_FUNCTION_NOARGS (); |
242 | 281 |
return (m_state == DEAD)?true:false; |
282 |
} |
|
283 |
bool |
|
284 |
ArpCache::Entry::IsAlive (void) |
|
285 |
{ |
|
3430
a8eb6b890f14
Add NS_LOG_FUNCTION calls in arp implementation
Tom Henderson <tomh@tomh.org>
parents:
3260
diff
changeset
|
286 |
NS_LOG_FUNCTION_NOARGS (); |
242 | 287 |
return (m_state == ALIVE)?true:false; |
288 |
} |
|
289 |
bool |
|
290 |
ArpCache::Entry::IsWaitReply (void) |
|
291 |
{ |
|
3430
a8eb6b890f14
Add NS_LOG_FUNCTION calls in arp implementation
Tom Henderson <tomh@tomh.org>
parents:
3260
diff
changeset
|
292 |
NS_LOG_FUNCTION_NOARGS (); |
242 | 293 |
return (m_state == WAIT_REPLY)?true:false; |
294 |
} |
|
295 |
||
296 |
||
297 |
void |
|
298 |
ArpCache::Entry::MarkDead (void) |
|
299 |
{ |
|
3430
a8eb6b890f14
Add NS_LOG_FUNCTION calls in arp implementation
Tom Henderson <tomh@tomh.org>
parents:
3260
diff
changeset
|
300 |
NS_LOG_FUNCTION_NOARGS (); |
242 | 301 |
m_state = DEAD; |
3499
a18520551cdf
revised patch to fix bug 253
Tom Henderson <tomh@tomh.org>
parents:
3430
diff
changeset
|
302 |
ClearRetries (); |
242 | 303 |
UpdateSeen (); |
304 |
} |
|
3151
428f8ec6da29
fix bug 185
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
3146
diff
changeset
|
305 |
void |
1161
bb72baff8b26
replace MacAddress by Address
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
568
diff
changeset
|
306 |
ArpCache::Entry::MarkAlive (Address macAddress) |
242 | 307 |
{ |
3430
a8eb6b890f14
Add NS_LOG_FUNCTION calls in arp implementation
Tom Henderson <tomh@tomh.org>
parents:
3260
diff
changeset
|
308 |
NS_LOG_FUNCTION_NOARGS (); |
286
57e6a2006962
convert use of <cassert> to "ns3/assert.h"
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
243
diff
changeset
|
309 |
NS_ASSERT (m_state == WAIT_REPLY); |
242 | 310 |
m_macAddress = macAddress; |
311 |
m_state = ALIVE; |
|
3499
a18520551cdf
revised patch to fix bug 253
Tom Henderson <tomh@tomh.org>
parents:
3430
diff
changeset
|
312 |
ClearRetries (); |
242 | 313 |
UpdateSeen (); |
314 |
} |
|
315 |
||
3151
428f8ec6da29
fix bug 185
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
3146
diff
changeset
|
316 |
bool |
1866
e7dbcc4df546
do not use Packet objects directly. Use Ptr<Packet> instead
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
1341
diff
changeset
|
317 |
ArpCache::Entry::UpdateWaitReply (Ptr<Packet> waiting) |
242 | 318 |
{ |
3430
a8eb6b890f14
Add NS_LOG_FUNCTION calls in arp implementation
Tom Henderson <tomh@tomh.org>
parents:
3260
diff
changeset
|
319 |
NS_LOG_FUNCTION_NOARGS (); |
286
57e6a2006962
convert use of <cassert> to "ns3/assert.h"
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
243
diff
changeset
|
320 |
NS_ASSERT (m_state == WAIT_REPLY); |
242 | 321 |
/* We are already waiting for an answer so |
322 |
* we dump the previously waiting packet and |
|
323 |
* replace it with this one. |
|
324 |
*/ |
|
3151
428f8ec6da29
fix bug 185
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
3146
diff
changeset
|
325 |
if (m_pending.size () >= m_arp->m_pendingQueueSize) |
428f8ec6da29
fix bug 185
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
3146
diff
changeset
|
326 |
{ |
428f8ec6da29
fix bug 185
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
3146
diff
changeset
|
327 |
return false; |
428f8ec6da29
fix bug 185
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
3146
diff
changeset
|
328 |
} |
428f8ec6da29
fix bug 185
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
3146
diff
changeset
|
329 |
m_pending.push_back (waiting); |
428f8ec6da29
fix bug 185
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
3146
diff
changeset
|
330 |
return true; |
242 | 331 |
} |
332 |
void |
|
1866
e7dbcc4df546
do not use Packet objects directly. Use Ptr<Packet> instead
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
1341
diff
changeset
|
333 |
ArpCache::Entry::MarkWaitReply (Ptr<Packet> waiting) |
242 | 334 |
{ |
3430
a8eb6b890f14
Add NS_LOG_FUNCTION calls in arp implementation
Tom Henderson <tomh@tomh.org>
parents:
3260
diff
changeset
|
335 |
NS_LOG_FUNCTION_NOARGS (); |
286
57e6a2006962
convert use of <cassert> to "ns3/assert.h"
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
243
diff
changeset
|
336 |
NS_ASSERT (m_state == ALIVE || m_state == DEAD); |
3151
428f8ec6da29
fix bug 185
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
3146
diff
changeset
|
337 |
NS_ASSERT (m_pending.empty ()); |
242 | 338 |
m_state = WAIT_REPLY; |
3151
428f8ec6da29
fix bug 185
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
3146
diff
changeset
|
339 |
m_pending.push_back (waiting); |
242 | 340 |
UpdateSeen (); |
3499
a18520551cdf
revised patch to fix bug 253
Tom Henderson <tomh@tomh.org>
parents:
3430
diff
changeset
|
341 |
m_arp->StartWaitReplyTimer (); |
242 | 342 |
} |
343 |
||
1161
bb72baff8b26
replace MacAddress by Address
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
568
diff
changeset
|
344 |
Address |
3499
a18520551cdf
revised patch to fix bug 253
Tom Henderson <tomh@tomh.org>
parents:
3430
diff
changeset
|
345 |
ArpCache::Entry::GetMacAddress (void) const |
242 | 346 |
{ |
3430
a8eb6b890f14
Add NS_LOG_FUNCTION calls in arp implementation
Tom Henderson <tomh@tomh.org>
parents:
3260
diff
changeset
|
347 |
NS_LOG_FUNCTION_NOARGS (); |
286
57e6a2006962
convert use of <cassert> to "ns3/assert.h"
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
243
diff
changeset
|
348 |
NS_ASSERT (m_state == ALIVE); |
242 | 349 |
return m_macAddress; |
350 |
} |
|
3499
a18520551cdf
revised patch to fix bug 253
Tom Henderson <tomh@tomh.org>
parents:
3430
diff
changeset
|
351 |
Ipv4Address |
a18520551cdf
revised patch to fix bug 253
Tom Henderson <tomh@tomh.org>
parents:
3430
diff
changeset
|
352 |
ArpCache::Entry::GetIpv4Address (void) const |
a18520551cdf
revised patch to fix bug 253
Tom Henderson <tomh@tomh.org>
parents:
3430
diff
changeset
|
353 |
{ |
a18520551cdf
revised patch to fix bug 253
Tom Henderson <tomh@tomh.org>
parents:
3430
diff
changeset
|
354 |
NS_LOG_FUNCTION_NOARGS (); |
a18520551cdf
revised patch to fix bug 253
Tom Henderson <tomh@tomh.org>
parents:
3430
diff
changeset
|
355 |
return m_ipv4Address; |
a18520551cdf
revised patch to fix bug 253
Tom Henderson <tomh@tomh.org>
parents:
3430
diff
changeset
|
356 |
} |
a18520551cdf
revised patch to fix bug 253
Tom Henderson <tomh@tomh.org>
parents:
3430
diff
changeset
|
357 |
void |
a18520551cdf
revised patch to fix bug 253
Tom Henderson <tomh@tomh.org>
parents:
3430
diff
changeset
|
358 |
ArpCache::Entry::SetIpv4Address (Ipv4Address destination) |
a18520551cdf
revised patch to fix bug 253
Tom Henderson <tomh@tomh.org>
parents:
3430
diff
changeset
|
359 |
{ |
a18520551cdf
revised patch to fix bug 253
Tom Henderson <tomh@tomh.org>
parents:
3430
diff
changeset
|
360 |
NS_LOG_FUNCTION (this << destination); |
a18520551cdf
revised patch to fix bug 253
Tom Henderson <tomh@tomh.org>
parents:
3430
diff
changeset
|
361 |
m_ipv4Address = destination; |
a18520551cdf
revised patch to fix bug 253
Tom Henderson <tomh@tomh.org>
parents:
3430
diff
changeset
|
362 |
} |
4084 | 363 |
Time |
364 |
ArpCache::Entry::GetTimeout (void) const |
|
242 | 365 |
{ |
366 |
switch (m_state) { |
|
367 |
case ArpCache::Entry::WAIT_REPLY: |
|
4084 | 368 |
return m_arp->GetWaitReplyTimeout (); |
242 | 369 |
case ArpCache::Entry::DEAD: |
4084 | 370 |
return m_arp->GetDeadTimeout (); |
242 | 371 |
case ArpCache::Entry::ALIVE: |
4084 | 372 |
return m_arp->GetAliveTimeout (); |
242 | 373 |
default: |
286
57e6a2006962
convert use of <cassert> to "ns3/assert.h"
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
243
diff
changeset
|
374 |
NS_ASSERT (false); |
4084 | 375 |
return Seconds (0); |
242 | 376 |
/* NOTREACHED */ |
377 |
} |
|
4084 | 378 |
} |
379 |
bool |
|
380 |
ArpCache::Entry::IsExpired (void) const |
|
381 |
{ |
|
382 |
NS_LOG_FUNCTION_NOARGS (); |
|
383 |
Time timeout = GetTimeout (); |
|
384 |
Time delta = Simulator::Now () - m_lastSeen; |
|
385 |
NS_LOG_DEBUG ("delta=" << delta.GetSeconds () << "s"); |
|
386 |
if (delta > timeout) |
|
242 | 387 |
{ |
388 |
return true; |
|
389 |
} |
|
4084 | 390 |
return false; |
242 | 391 |
} |
3151
428f8ec6da29
fix bug 185
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
3146
diff
changeset
|
392 |
Ptr<Packet> |
428f8ec6da29
fix bug 185
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
3146
diff
changeset
|
393 |
ArpCache::Entry::DequeuePending (void) |
428f8ec6da29
fix bug 185
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
3146
diff
changeset
|
394 |
{ |
3430
a8eb6b890f14
Add NS_LOG_FUNCTION calls in arp implementation
Tom Henderson <tomh@tomh.org>
parents:
3260
diff
changeset
|
395 |
NS_LOG_FUNCTION_NOARGS (); |
3151
428f8ec6da29
fix bug 185
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
3146
diff
changeset
|
396 |
if (m_pending.empty ()) |
428f8ec6da29
fix bug 185
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
3146
diff
changeset
|
397 |
{ |
428f8ec6da29
fix bug 185
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
3146
diff
changeset
|
398 |
return 0; |
428f8ec6da29
fix bug 185
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
3146
diff
changeset
|
399 |
} |
428f8ec6da29
fix bug 185
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
3146
diff
changeset
|
400 |
else |
428f8ec6da29
fix bug 185
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
3146
diff
changeset
|
401 |
{ |
428f8ec6da29
fix bug 185
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
3146
diff
changeset
|
402 |
Ptr<Packet> p = m_pending.front (); |
428f8ec6da29
fix bug 185
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
3146
diff
changeset
|
403 |
m_pending.pop_front (); |
428f8ec6da29
fix bug 185
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
3146
diff
changeset
|
404 |
return p; |
428f8ec6da29
fix bug 185
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
3146
diff
changeset
|
405 |
} |
428f8ec6da29
fix bug 185
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
3146
diff
changeset
|
406 |
} |
242 | 407 |
void |
408 |
ArpCache::Entry::UpdateSeen (void) |
|
409 |
{ |
|
4084 | 410 |
NS_LOG_FUNCTION (m_macAddress << m_ipv4Address); |
242 | 411 |
m_lastSeen = Simulator::Now (); |
412 |
} |
|
3499
a18520551cdf
revised patch to fix bug 253
Tom Henderson <tomh@tomh.org>
parents:
3430
diff
changeset
|
413 |
uint32_t |
a18520551cdf
revised patch to fix bug 253
Tom Henderson <tomh@tomh.org>
parents:
3430
diff
changeset
|
414 |
ArpCache::Entry::GetRetries (void) const |
a18520551cdf
revised patch to fix bug 253
Tom Henderson <tomh@tomh.org>
parents:
3430
diff
changeset
|
415 |
{ |
4084 | 416 |
NS_LOG_FUNCTION (m_macAddress << m_ipv4Address); |
3499
a18520551cdf
revised patch to fix bug 253
Tom Henderson <tomh@tomh.org>
parents:
3430
diff
changeset
|
417 |
return m_retries; |
a18520551cdf
revised patch to fix bug 253
Tom Henderson <tomh@tomh.org>
parents:
3430
diff
changeset
|
418 |
} |
a18520551cdf
revised patch to fix bug 253
Tom Henderson <tomh@tomh.org>
parents:
3430
diff
changeset
|
419 |
void |
a18520551cdf
revised patch to fix bug 253
Tom Henderson <tomh@tomh.org>
parents:
3430
diff
changeset
|
420 |
ArpCache::Entry::IncrementRetries (void) |
a18520551cdf
revised patch to fix bug 253
Tom Henderson <tomh@tomh.org>
parents:
3430
diff
changeset
|
421 |
{ |
a18520551cdf
revised patch to fix bug 253
Tom Henderson <tomh@tomh.org>
parents:
3430
diff
changeset
|
422 |
NS_LOG_FUNCTION_NOARGS (); |
a18520551cdf
revised patch to fix bug 253
Tom Henderson <tomh@tomh.org>
parents:
3430
diff
changeset
|
423 |
m_retries++; |
a18520551cdf
revised patch to fix bug 253
Tom Henderson <tomh@tomh.org>
parents:
3430
diff
changeset
|
424 |
UpdateSeen (); |
a18520551cdf
revised patch to fix bug 253
Tom Henderson <tomh@tomh.org>
parents:
3430
diff
changeset
|
425 |
} |
a18520551cdf
revised patch to fix bug 253
Tom Henderson <tomh@tomh.org>
parents:
3430
diff
changeset
|
426 |
void |
a18520551cdf
revised patch to fix bug 253
Tom Henderson <tomh@tomh.org>
parents:
3430
diff
changeset
|
427 |
ArpCache::Entry::ClearRetries (void) |
a18520551cdf
revised patch to fix bug 253
Tom Henderson <tomh@tomh.org>
parents:
3430
diff
changeset
|
428 |
{ |
a18520551cdf
revised patch to fix bug 253
Tom Henderson <tomh@tomh.org>
parents:
3430
diff
changeset
|
429 |
NS_LOG_FUNCTION_NOARGS (); |
a18520551cdf
revised patch to fix bug 253
Tom Henderson <tomh@tomh.org>
parents:
3430
diff
changeset
|
430 |
m_retries = 0; |
a18520551cdf
revised patch to fix bug 253
Tom Henderson <tomh@tomh.org>
parents:
3430
diff
changeset
|
431 |
} |
242 | 432 |
|
433 |
} // namespace ns3 |
|
434 |