OLD | NEW |
1 /* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */ | 1 /* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */ |
2 /* | 2 /* |
3 * Copyright (c) 2006 INRIA | 3 * Copyright (c) 2006 INRIA |
4 * | 4 * |
5 * This program is free software; you can redistribute it and/or modify | 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 | 6 * it under the terms of the GNU General Public License version 2 as |
7 * published by the Free Software Foundation; | 7 * published by the Free Software Foundation; |
8 * | 8 * |
9 * This program is distributed in the hope that it will be useful, | 9 * This program is distributed in the hope that it will be useful, |
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of | 10 * but WITHOUT ANY WARRANTY; without even the implied warranty of |
(...skipping 203 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
214 arp.GetSourceIpv4Address () << " -- send reply"); | 214 arp.GetSourceIpv4Address () << " -- send reply"); |
215 SendArpReply (cache, arp.GetDestinationIpv4Address (), arp.GetSourceIp
v4Address (), | 215 SendArpReply (cache, arp.GetDestinationIpv4Address (), arp.GetSourceIp
v4Address (), |
216 arp.GetSourceHardwareAddress ()); | 216 arp.GetSourceHardwareAddress ()); |
217 break; | 217 break; |
218 }· | 218 }· |
219 else if (arp.IsReply () &&· | 219 else if (arp.IsReply () &&· |
220 arp.GetDestinationIpv4Address ().IsEqual (cache->GetInterface ()-
>GetAddress (i).GetLocal ()) && | 220 arp.GetDestinationIpv4Address ().IsEqual (cache->GetInterface ()-
>GetAddress (i).GetLocal ()) && |
221 arp.GetDestinationHardwareAddress () == device->GetAddress ()) | 221 arp.GetDestinationHardwareAddress () == device->GetAddress ()) |
222 { | 222 { |
223 found = true; | 223 found = true; |
224 Ipv4Address from = arp.GetSourceIpv4Address (); | 224 Ipv4Address from1 = arp.GetSourceIpv4Address (); |
225 ArpCache::Entry *entry = cache->Lookup (from); | 225 ArpCache::Entry *entry = cache->Lookup (from1); |
226 if (entry != 0) | 226 if (entry != 0) |
227 { | 227 { |
228 if (entry->IsWaitReply ())· | 228 if (entry->IsWaitReply ())· |
229 { | 229 { |
230 NS_LOG_LOGIC ("node="<< m_node->GetId () <<· | 230 NS_LOG_LOGIC ("node="<< m_node->GetId () <<· |
231 ", got reply from " << arp.GetSourceIpv4Address
() | 231 ", got reply from " << arp.GetSourceIpv4Address
() |
232 << " for waiting entry -- flush"); | 232 << " for waiting entry -- flush"); |
233 Address from_mac = arp.GetSourceHardwareAddress (); | 233 Address from_mac = arp.GetSourceHardwareAddress (); |
234 entry->MarkAlive (from_mac); | 234 entry->MarkAlive (from_mac); |
235 ArpCache::Ipv4PayloadHeaderPair pending = entry->DequeuePendin
g (); | 235 ArpCache::Ipv4PayloadHeaderPair pending = entry->DequeuePendin
g (); |
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
276 ArpCache::Entry *entry = cache->Lookup (destination); | 276 ArpCache::Entry *entry = cache->Lookup (destination); |
277 if (entry != 0) | 277 if (entry != 0) |
278 { | 278 { |
279 if (entry->IsExpired ())· | 279 if (entry->IsExpired ())· |
280 { | 280 { |
281 if (entry->IsDead ())· | 281 if (entry->IsDead ())· |
282 { | 282 { |
283 NS_LOG_LOGIC ("node="<<m_node->GetId ()<< | 283 NS_LOG_LOGIC ("node="<<m_node->GetId ()<< |
284 ", dead entry for " << destination << " expired -- s
end arp request"); | 284 ", dead entry for " << destination << " expired -- s
end arp request"); |
285 entry->MarkWaitReply (ArpCache::Ipv4PayloadHeaderPair (packet, ipH
eader)); | 285 entry->MarkWaitReply (ArpCache::Ipv4PayloadHeaderPair (packet, ipH
eader)); |
286 Simulator::Schedule (Time (MilliSeconds (m_requestJitter->GetValue
())), &ArpL3Protocol::SendArpRequest, this, cache, destination); | 286 Simulator::Schedule (Time (MilliSeconds (static_cast<uint64_t> (m_
requestJitter->GetValue ()))), &ArpL3Protocol::SendArpRequest, this, cache, dest
ination); |
287 }· | 287 }· |
288 else if (entry->IsAlive ())· | 288 else if (entry->IsAlive ())· |
289 { | 289 { |
290 NS_LOG_LOGIC ("node="<<m_node->GetId ()<< | 290 NS_LOG_LOGIC ("node="<<m_node->GetId ()<< |
291 ", alive entry for " << destination << " expired --
send arp request"); | 291 ", alive entry for " << destination << " expired --
send arp request"); |
292 entry->MarkWaitReply (ArpCache::Ipv4PayloadHeaderPair (packet, ipH
eader)); | 292 entry->MarkWaitReply (ArpCache::Ipv4PayloadHeaderPair (packet, ipH
eader)); |
293 Simulator::Schedule (Time (MilliSeconds (m_requestJitter->GetValue
())), &ArpL3Protocol::SendArpRequest, this, cache, destination); | 293 Simulator::Schedule (Time (MilliSeconds (static_cast<uint64_t> (m_
requestJitter->GetValue ()))), &ArpL3Protocol::SendArpRequest, this, cache, dest
ination); |
294 }· | 294 }· |
295 else | 295 else |
296 { | 296 { |
297 NS_FATAL_ERROR ("Test for possibly unreachable code-- please file
a bug report, with a test case, if this is ever hit"); | 297 NS_FATAL_ERROR ("Test for possibly unreachable code-- please file
a bug report, with a test case, if this is ever hit"); |
298 } | 298 } |
299 }· | 299 }· |
300 else· | 300 else· |
301 { | 301 { |
302 if (entry->IsDead ())· | 302 if (entry->IsDead ())· |
303 { | 303 { |
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
338 } | 338 } |
339 } | 339 } |
340 } | 340 } |
341 else | 341 else |
342 { | 342 { |
343 // This is our first attempt to transmit data to this destination. | 343 // This is our first attempt to transmit data to this destination. |
344 NS_LOG_LOGIC ("node="<<m_node->GetId ()<< | 344 NS_LOG_LOGIC ("node="<<m_node->GetId ()<< |
345 ", no entry for " << destination << " -- send arp request"); | 345 ", no entry for " << destination << " -- send arp request"); |
346 entry = cache->Add (destination); | 346 entry = cache->Add (destination); |
347 entry->MarkWaitReply (ArpCache::Ipv4PayloadHeaderPair (packet, ipHeader)); | 347 entry->MarkWaitReply (ArpCache::Ipv4PayloadHeaderPair (packet, ipHeader)); |
348 Simulator::Schedule (Time (MilliSeconds (m_requestJitter->GetValue ())), &
ArpL3Protocol::SendArpRequest, this, cache, destination); | 348 Simulator::Schedule (Time (MilliSeconds (static_cast<uint64_t> (m_requestJ
itter->GetValue ()))), &ArpL3Protocol::SendArpRequest, this, cache, destination)
; |
349 } | 349 } |
350 return false; | 350 return false; |
351 } | 351 } |
352 | 352 |
353 void | 353 void |
354 ArpL3Protocol::SendArpRequest (Ptr<const ArpCache> cache, Ipv4Address to) | 354 ArpL3Protocol::SendArpRequest (Ptr<const ArpCache> cache, Ipv4Address to) |
355 { | 355 { |
356 NS_LOG_FUNCTION (this << cache << to); | 356 NS_LOG_FUNCTION (this << cache << to); |
357 ArpHeader arp; | 357 ArpHeader arp; |
358 // need to pick a source address; use routing implementation to select | 358 // need to pick a source address; use routing implementation to select |
(...skipping 21 matching lines...) Expand all Loading... |
380 "|| src: " << cache->GetDevice ()->GetAddress () << | 380 "|| src: " << cache->GetDevice ()->GetAddress () << |
381 " / " << myIp << | 381 " / " << myIp << |
382 " || dst: " << toMac << " / " << toIp); | 382 " || dst: " << toMac << " / " << toIp); |
383 arp.SetReply (cache->GetDevice ()->GetAddress (), myIp, toMac, toIp); | 383 arp.SetReply (cache->GetDevice ()->GetAddress (), myIp, toMac, toIp); |
384 Ptr<Packet> packet = Create<Packet> (); | 384 Ptr<Packet> packet = Create<Packet> (); |
385 packet->AddHeader (arp); | 385 packet->AddHeader (arp); |
386 cache->GetDevice ()->Send (packet, toMac, PROT_NUMBER); | 386 cache->GetDevice ()->Send (packet, toMac, PROT_NUMBER); |
387 } | 387 } |
388 | 388 |
389 } // namespace ns3 | 389 } // namespace ns3 |
OLD | NEW |