|
Lines 159-164
ArpL3Protocol::Receive(Ptr<NetDevice> de
|
Link Here
|
|---|
|
| 159 |
<< " for waiting entry -- flush"); |
159 |
<< " for waiting entry -- flush"); |
| 160 |
Address from_mac = arp.GetSourceHardwareAddress (); |
160 |
Address from_mac = arp.GetSourceHardwareAddress (); |
| 161 |
entry->MarkAlive (from_mac); |
161 |
entry->MarkAlive (from_mac); |
|
|
162 |
entry->ClearRetries (); |
| 163 |
entry->GetWaitTimer ()->Cancel (); |
| 162 |
Ptr<Packet> pending = entry->DequeuePending(); |
164 |
Ptr<Packet> pending = entry->DequeuePending(); |
| 163 |
while (pending != 0) |
165 |
while (pending != 0) |
| 164 |
{ |
166 |
{ |
|
Lines 190-195
ArpL3Protocol::Receive(Ptr<NetDevice> de
|
Link Here
|
|---|
|
| 190 |
arp.GetDestinationIpv4Address () << " -- drop"); |
192 |
arp.GetDestinationIpv4Address () << " -- drop"); |
| 191 |
} |
193 |
} |
| 192 |
} |
194 |
} |
|
|
195 |
|
| 196 |
void |
| 197 |
ArpL3Protocol::HandleWaitTimeout (Ptr<ArpCache> cache, Ipv4Address destination) |
| 198 |
{ |
| 199 |
NS_LOG_FUNCTION_NOARGS (); |
| 200 |
ArpCache::Entry *entry = cache->Lookup (destination); |
| 201 |
if (entry != 0 && entry->IsWaitReply ()) |
| 202 |
{ |
| 203 |
if (entry->GetRetries () < cache->GetMaxRetries () ) |
| 204 |
{ |
| 205 |
NS_LOG_LOGIC ("node="<<m_node->GetId ()<< |
| 206 |
", ArpWaitTimeout for " << destination << " expired -- send arp request since retries = " << entry->GetRetries ()); |
| 207 |
SendArpRequest (cache, destination); |
| 208 |
entry->GetWaitTimer ()->Schedule (); |
| 209 |
entry->IncrementRetries (); |
| 210 |
} |
| 211 |
else |
| 212 |
{ |
| 213 |
NS_LOG_LOGIC ("node="<<m_node->GetId ()<< |
| 214 |
", wait reply for " << destination << " expired -- drop since max retries exceeded: " << entry->GetRetries ()); |
| 215 |
entry->MarkDead (); |
| 216 |
Ptr<Packet> pending = entry->DequeuePending(); |
| 217 |
while (pending != 0) |
| 218 |
{ |
| 219 |
m_dropTrace (pending); |
| 220 |
pending = entry->DequeuePending(); |
| 221 |
} |
| 222 |
} |
| 223 |
} |
| 224 |
} |
| 225 |
|
| 193 |
bool |
226 |
bool |
| 194 |
ArpL3Protocol::Lookup (Ptr<Packet> packet, Ipv4Address destination, |
227 |
ArpL3Protocol::Lookup (Ptr<Packet> packet, Ipv4Address destination, |
| 195 |
Ptr<NetDevice> device, |
228 |
Ptr<NetDevice> device, |
|
Lines 208-213
ArpL3Protocol::Lookup (Ptr<Packet> packe
|
Link Here
|
|---|
|
| 208 |
", dead entry for " << destination << " expired -- send arp request"); |
241 |
", dead entry for " << destination << " expired -- send arp request"); |
| 209 |
entry->MarkWaitReply (packet); |
242 |
entry->MarkWaitReply (packet); |
| 210 |
SendArpRequest (cache, destination); |
243 |
SendArpRequest (cache, destination); |
|
|
244 |
// Timer already seeded, so just reschedule |
| 245 |
entry->GetWaitTimer ()->Schedule (); |
| 211 |
} |
246 |
} |
| 212 |
else if (entry->IsAlive ()) |
247 |
else if (entry->IsAlive ()) |
| 213 |
{ |
248 |
{ |
|
Lines 215-223
ArpL3Protocol::Lookup (Ptr<Packet> packe
|
Link Here
|
|---|
|
| 215 |
", alive entry for " << destination << " expired -- send arp request"); |
250 |
", alive entry for " << destination << " expired -- send arp request"); |
| 216 |
entry->MarkWaitReply (packet); |
251 |
entry->MarkWaitReply (packet); |
| 217 |
SendArpRequest (cache, destination); |
252 |
SendArpRequest (cache, destination); |
|
|
253 |
// Timer already seeded, so just reschedule |
| 254 |
entry->GetWaitTimer ()->Schedule (); |
| 218 |
} |
255 |
} |
| 219 |
else if (entry->IsWaitReply ()) |
256 |
else if (entry->IsWaitReply ()) |
| 220 |
{ |
257 |
{ |
|
|
258 |
// Is this dead code branch? |
| 259 |
NS_ASSERT (false); |
| 221 |
NS_LOG_LOGIC ("node="<<m_node->GetId ()<< |
260 |
NS_LOG_LOGIC ("node="<<m_node->GetId ()<< |
| 222 |
", wait reply for " << destination << " expired -- drop"); |
261 |
", wait reply for " << destination << " expired -- drop"); |
| 223 |
entry->MarkDead (); |
262 |
entry->MarkDead (); |
|
Lines 264-269
ArpL3Protocol::Lookup (Ptr<Packet> packe
|
Link Here
|
|---|
|
| 264 |
entry = cache->Add (destination); |
303 |
entry = cache->Add (destination); |
| 265 |
entry->MarkWaitReply (packet); |
304 |
entry->MarkWaitReply (packet); |
| 266 |
SendArpRequest (cache, destination); |
305 |
SendArpRequest (cache, destination); |
|
|
306 |
// Set up the wait timer to handle possible retransmissions |
| 307 |
entry->GetWaitTimer ()->SetFunction (&ns3::ArpL3Protocol::HandleWaitTimeout, this); |
| 308 |
entry->GetWaitTimer ()->SetArguments (cache, destination); |
| 309 |
entry->GetWaitTimer ()->SetDelay (cache->GetWaitReplyTimeout ()); |
| 310 |
entry->GetWaitTimer ()->Schedule (); |
| 267 |
} |
311 |
} |
| 268 |
return false; |
312 |
return false; |
| 269 |
} |
313 |
} |