|
|
| 197 |
: m_ndCache (nd), |
197 |
: m_ndCache (nd), |
| 198 |
m_waiting (), |
198 |
m_waiting (), |
| 199 |
m_router (false), |
199 |
m_router (false), |
| 200 |
m_reachableTimer (Timer::CANCEL_ON_DESTROY), |
200 |
m_nudTimer (Timer::CANCEL_ON_DESTROY), |
| 201 |
m_retransTimer (Timer::CANCEL_ON_DESTROY), |
|
|
| 202 |
m_probeTimer (Timer::CANCEL_ON_DESTROY), |
| 203 |
m_delayTimer (Timer::CANCEL_ON_DESTROY), |
| 204 |
m_lastReachabilityConfirmation (Seconds (0.0)), |
201 |
m_lastReachabilityConfirmation (Seconds (0.0)), |
| 205 |
m_nsRetransmit (0) |
202 |
m_nsRetransmit (0) |
| 206 |
{ |
203 |
{ |
|
|
| 268 |
} |
265 |
} |
| 269 |
} |
266 |
} |
| 270 |
|
267 |
|
| 271 |
if (GetNSRetransmit () < icmpv6->MAX_MULTICAST_SOLICIT) |
268 |
if (m_nsRetransmit < icmpv6->MAX_MULTICAST_SOLICIT) |
| 272 |
{ |
269 |
{ |
| 273 |
IncNSRetransmit (); |
270 |
m_nsRetransmit++; |
| 274 |
|
271 |
|
| 275 |
icmpv6->SendNS (addr, Ipv6Address::MakeSolicitedAddress (m_ipv6Address), m_ipv6Address, m_ndCache->GetDevice ()->GetAddress ()); |
272 |
icmpv6->SendNS (addr, Ipv6Address::MakeSolicitedAddress (m_ipv6Address), m_ipv6Address, m_ndCache->GetDevice ()->GetAddress ()); |
| 276 |
/* arm the timer again */ |
273 |
/* arm the timer again */ |
|
|
| 323 |
Ptr<Packet> p = icmpv6->ForgeNS (addr, m_ipv6Address, m_ipv6Address, m_ndCache->GetDevice ()->GetAddress ()); |
320 |
Ptr<Packet> p = icmpv6->ForgeNS (addr, m_ipv6Address, m_ipv6Address, m_ndCache->GetDevice ()->GetAddress ()); |
| 324 |
m_ndCache->GetDevice ()->Send (p, this->GetMacAddress (), Ipv6L3Protocol::PROT_NUMBER); |
321 |
m_ndCache->GetDevice ()->Send (p, this->GetMacAddress (), Ipv6L3Protocol::PROT_NUMBER); |
| 325 |
|
322 |
|
| 326 |
ResetNSRetransmit (); |
323 |
m_nsRetransmit = 1; |
| 327 |
IncNSRetransmit (); |
|
|
| 328 |
StartProbeTimer (); |
324 |
StartProbeTimer (); |
| 329 |
} |
325 |
} |
| 330 |
|
326 |
|
|
|
| 334 |
Ptr<Ipv6L3Protocol> ipv6 = m_ndCache->GetDevice ()->GetNode ()->GetObject<Ipv6L3Protocol> (); |
330 |
Ptr<Ipv6L3Protocol> ipv6 = m_ndCache->GetDevice ()->GetNode ()->GetObject<Ipv6L3Protocol> (); |
| 335 |
Ptr<Icmpv6L4Protocol> icmpv6 = ipv6->GetIcmpv6 (); |
331 |
Ptr<Icmpv6L4Protocol> icmpv6 = ipv6->GetIcmpv6 (); |
| 336 |
|
332 |
|
| 337 |
if (GetNSRetransmit () < icmpv6->MAX_UNICAST_SOLICIT) |
333 |
if (m_nsRetransmit < icmpv6->MAX_UNICAST_SOLICIT) |
| 338 |
{ |
334 |
{ |
|
|
335 |
m_nsRetransmit++; |
| 336 |
|
| 339 |
Ipv6Address addr; |
337 |
Ipv6Address addr; |
| 340 |
|
338 |
|
| 341 |
if (m_ipv6Address.IsLinkLocal ()) |
339 |
if (m_ipv6Address.IsLinkLocal ()) |
|
|
| 358 |
return; |
356 |
return; |
| 359 |
} |
357 |
} |
| 360 |
|
358 |
|
| 361 |
IncNSRetransmit (); |
|
|
| 362 |
/* icmpv6->SendNS (m_ndCache->GetInterface ()->GetLinkLocalAddress (), m_ipv6Address, m_ipv6Address, m_ndCache->GetDevice ()->GetAddress ()); */ |
359 |
/* icmpv6->SendNS (m_ndCache->GetInterface ()->GetLinkLocalAddress (), m_ipv6Address, m_ipv6Address, m_ndCache->GetDevice ()->GetAddress ()); */ |
| 363 |
Ptr<Packet> p = icmpv6->ForgeNS (addr, m_ipv6Address, m_ipv6Address, m_ndCache->GetDevice ()->GetAddress ()); |
360 |
Ptr<Packet> p = icmpv6->ForgeNS (addr, m_ipv6Address, m_ipv6Address, m_ndCache->GetDevice ()->GetAddress ()); |
| 364 |
m_ndCache->GetDevice ()->Send (p, this->GetMacAddress (), Ipv6L3Protocol::PROT_NUMBER); |
361 |
m_ndCache->GetDevice ()->Send (p, this->GetMacAddress (), Ipv6L3Protocol::PROT_NUMBER); |
|
|
| 379 |
m_ipv6Address = ipv6Address; |
376 |
m_ipv6Address = ipv6Address; |
| 380 |
} |
377 |
} |
| 381 |
|
378 |
|
| 382 |
uint8_t NdiscCache::Entry::GetNSRetransmit () const |
|
|
| 383 |
{ |
| 384 |
NS_LOG_FUNCTION_NOARGS (); |
| 385 |
return m_nsRetransmit; |
| 386 |
} |
| 387 |
|
| 388 |
void NdiscCache::Entry::IncNSRetransmit () |
| 389 |
{ |
| 390 |
NS_LOG_FUNCTION_NOARGS (); |
| 391 |
m_nsRetransmit++; |
| 392 |
} |
| 393 |
|
| 394 |
void NdiscCache::Entry::ResetNSRetransmit () |
| 395 |
{ |
| 396 |
NS_LOG_FUNCTION_NOARGS (); |
| 397 |
m_nsRetransmit = 0; |
| 398 |
} |
| 399 |
|
| 400 |
Time NdiscCache::Entry::GetLastReachabilityConfirmation () const |
379 |
Time NdiscCache::Entry::GetLastReachabilityConfirmation () const |
| 401 |
{ |
380 |
{ |
| 402 |
NS_LOG_FUNCTION_NOARGS (); |
381 |
NS_LOG_FUNCTION_NOARGS (); |
|
|
| 411 |
void NdiscCache::Entry::StartReachableTimer () |
390 |
void NdiscCache::Entry::StartReachableTimer () |
| 412 |
{ |
391 |
{ |
| 413 |
NS_LOG_FUNCTION_NOARGS (); |
392 |
NS_LOG_FUNCTION_NOARGS (); |
| 414 |
if (m_reachableTimer.IsRunning ()) |
393 |
if (m_nudTimer.IsRunning ()) |
| 415 |
{ |
394 |
{ |
| 416 |
m_reachableTimer.Cancel (); |
395 |
m_nudTimer.Cancel (); |
| 417 |
} |
396 |
} |
| 418 |
m_reachableTimer.SetFunction (&NdiscCache::Entry::FunctionReachableTimeout, this); |
|
|
| 419 |
m_reachableTimer.SetDelay (MilliSeconds (Icmpv6L4Protocol::REACHABLE_TIME)); |
| 420 |
m_reachableTimer.Schedule (); |
| 421 |
} |
| 422 |
|
397 |
|
| 423 |
void NdiscCache::Entry::StopReachableTimer () |
398 |
m_nudTimer.SetFunction (&NdiscCache::Entry::FunctionReachableTimeout, this); |
| 424 |
{ |
399 |
m_nudTimer.SetDelay (MilliSeconds (Icmpv6L4Protocol::REACHABLE_TIME)); |
| 425 |
NS_LOG_FUNCTION_NOARGS (); |
400 |
m_nudTimer.Schedule (); |
| 426 |
m_reachableTimer.Cancel (); |
|
|
| 427 |
} |
401 |
} |
| 428 |
|
402 |
|
| 429 |
void NdiscCache::Entry::StartProbeTimer () |
403 |
void NdiscCache::Entry::StartProbeTimer () |
| 430 |
{ |
404 |
{ |
| 431 |
NS_LOG_FUNCTION_NOARGS (); |
405 |
NS_LOG_FUNCTION_NOARGS (); |
| 432 |
if (m_probeTimer.IsRunning ()) |
406 |
if (m_nudTimer.IsRunning ()) |
| 433 |
{ |
407 |
{ |
| 434 |
m_probeTimer.Cancel (); |
408 |
m_nudTimer.Cancel (); |
| 435 |
} |
409 |
} |
| 436 |
m_probeTimer.SetFunction (&NdiscCache::Entry::FunctionProbeTimeout, this); |
410 |
m_nudTimer.SetFunction (&NdiscCache::Entry::FunctionProbeTimeout, this); |
| 437 |
m_probeTimer.SetDelay (MilliSeconds (Icmpv6L4Protocol::RETRANS_TIMER)); |
411 |
m_nudTimer.SetDelay (MilliSeconds (Icmpv6L4Protocol::RETRANS_TIMER)); |
| 438 |
m_probeTimer.Schedule (); |
412 |
m_nudTimer.Schedule (); |
| 439 |
} |
413 |
} |
| 440 |
|
414 |
|
| 441 |
void NdiscCache::Entry::StopProbeTimer () |
|
|
| 442 |
{ |
| 443 |
NS_LOG_FUNCTION_NOARGS (); |
| 444 |
m_probeTimer.Cancel (); |
| 445 |
ResetNSRetransmit (); |
| 446 |
} |
| 447 |
|
| 448 |
|
| 449 |
void NdiscCache::Entry::StartDelayTimer () |
415 |
void NdiscCache::Entry::StartDelayTimer () |
| 450 |
{ |
416 |
{ |
| 451 |
NS_LOG_FUNCTION_NOARGS (); |
417 |
NS_LOG_FUNCTION_NOARGS (); |
| 452 |
if (m_delayTimer.IsRunning ()) |
418 |
if (m_nudTimer.IsRunning ()) |
| 453 |
{ |
419 |
{ |
| 454 |
m_delayTimer.Cancel (); |
420 |
m_nudTimer.Cancel (); |
| 455 |
} |
421 |
} |
| 456 |
m_delayTimer.SetFunction (&NdiscCache::Entry::FunctionDelayTimeout, this); |
422 |
m_nudTimer.SetFunction (&NdiscCache::Entry::FunctionDelayTimeout, this); |
| 457 |
m_delayTimer.SetDelay (Seconds (Icmpv6L4Protocol::DELAY_FIRST_PROBE_TIME)); |
423 |
m_nudTimer.SetDelay (Seconds (Icmpv6L4Protocol::DELAY_FIRST_PROBE_TIME)); |
| 458 |
m_delayTimer.Schedule (); |
424 |
m_nudTimer.Schedule (); |
| 459 |
} |
|
|
| 460 |
|
| 461 |
void NdiscCache::Entry::StopDelayTimer () |
| 462 |
{ |
| 463 |
NS_LOG_FUNCTION_NOARGS (); |
| 464 |
m_delayTimer.Cancel (); |
| 465 |
ResetNSRetransmit (); |
| 466 |
} |
425 |
} |
| 467 |
|
426 |
|
| 468 |
void NdiscCache::Entry::StartRetransmitTimer () |
427 |
void NdiscCache::Entry::StartRetransmitTimer () |
| 469 |
{ |
428 |
{ |
| 470 |
NS_LOG_FUNCTION_NOARGS (); |
429 |
NS_LOG_FUNCTION_NOARGS (); |
| 471 |
if (m_retransTimer.IsRunning ()) |
430 |
if (m_nudTimer.IsRunning ()) |
| 472 |
{ |
431 |
{ |
| 473 |
m_retransTimer.Cancel (); |
432 |
m_nudTimer.Cancel (); |
| 474 |
} |
433 |
} |
| 475 |
m_retransTimer.SetFunction (&NdiscCache::Entry::FunctionRetransmitTimeout, this); |
434 |
m_nudTimer.SetFunction (&NdiscCache::Entry::FunctionRetransmitTimeout, this); |
| 476 |
m_retransTimer.SetDelay (MilliSeconds (Icmpv6L4Protocol::RETRANS_TIMER)); |
435 |
m_nudTimer.SetDelay (MilliSeconds (Icmpv6L4Protocol::RETRANS_TIMER)); |
| 477 |
m_retransTimer.Schedule (); |
436 |
m_nudTimer.Schedule (); |
| 478 |
} |
437 |
} |
| 479 |
|
438 |
|
| 480 |
void NdiscCache::Entry::StopRetransmitTimer () |
439 |
void NdiscCache::Entry::StopNudTimer () |
| 481 |
{ |
440 |
{ |
| 482 |
NS_LOG_FUNCTION_NOARGS (); |
441 |
NS_LOG_FUNCTION_NOARGS (); |
| 483 |
m_retransTimer.Cancel (); |
442 |
m_nudTimer.Cancel (); |
| 484 |
ResetNSRetransmit (); |
443 |
m_nsRetransmit = 0; |
| 485 |
} |
444 |
} |
| 486 |
|
445 |
|
| 487 |
void NdiscCache::Entry::MarkIncomplete (Ptr<Packet> p) |
446 |
void NdiscCache::Entry::MarkIncomplete (Ptr<Packet> p) |
|
|
| 573 |
|
532 |
|
| 574 |
void NdiscCache::Entry::SetMacAddress (Address mac) |
533 |
void NdiscCache::Entry::SetMacAddress (Address mac) |
| 575 |
{ |
534 |
{ |
| 576 |
NS_LOG_FUNCTION (this << mac); |
535 |
NS_LOG_FUNCTION (this << mac << int(m_state)); |
| 577 |
m_macAddress = mac; |
536 |
m_macAddress = mac; |
| 578 |
} |
537 |
} |
| 579 |
|
538 |
|