View | Details | Raw Unified | Return to bug 2073
Collapse All | Expand All

(-)a/src/internet/model/icmpv6-l4-protocol.cc (-10 / +4 lines)
 Lines 379-388    Link Here 
379
      std::list<Ptr<Packet> > waiting;
379
      std::list<Ptr<Packet> > waiting;
380
      if (entry->IsIncomplete ())
380
      if (entry->IsIncomplete ())
381
        {
381
        {
382
          entry->StopRetransmitTimer ();
382
          entry->StopNudTimer ();
383
          // mark it to reachable
383
          // mark it to reachable
384
          waiting = entry->MarkReachable (lla.GetAddress ());
384
          waiting = entry->MarkReachable (lla.GetAddress ());
385
          entry->StopReachableTimer ();
386
          entry->StartReachableTimer ();
385
          entry->StartReachableTimer ();
387
          // send out waiting packet
386
          // send out waiting packet
388
          for (std::list<Ptr<Packet> >::const_iterator it = waiting.begin (); it != waiting.end (); it++)
387
          for (std::list<Ptr<Packet> >::const_iterator it = waiting.begin (); it != waiting.end (); it++)
 Lines 403-410    Link Here 
403
            {
402
            {
404
              if (!entry->IsReachable ())
403
              if (!entry->IsReachable ())
405
                {
404
                {
406
                  entry->StopProbeTimer ();
405
                  entry->StopNudTimer ();
407
                  entry->StopDelayTimer ();
408
                  waiting = entry->MarkReachable (lla.GetAddress ());
406
                  waiting = entry->MarkReachable (lla.GetAddress ());
409
                  if (entry->IsProbe ())
407
                  if (entry->IsProbe ())
410
                    {
408
                    {
 Lines 413-419    Link Here 
413
                          cache->GetInterface ()->Send (*it, src);
411
                          cache->GetInterface ()->Send (*it, src);
414
                        }
412
                        }
415
                    }
413
                    }
416
                  entry->StopReachableTimer ();
417
                  entry->StartReachableTimer ();
414
                  entry->StartReachableTimer ();
418
                }
415
                }
419
            }
416
            }
 Lines 664-676    Link Here 
664
  if (entry->IsIncomplete ())
661
  if (entry->IsIncomplete ())
665
    {
662
    {
666
      /* we receive a NA so stop the retransmission timer */
663
      /* we receive a NA so stop the retransmission timer */
667
      entry->StopRetransmitTimer ();
664
      entry->StopNudTimer ();
668
665
669
      if (naHeader.GetFlagS ())
666
      if (naHeader.GetFlagS ())
670
        {
667
        {
671
          /* mark it to reachable */
668
          /* mark it to reachable */
672
          waiting = entry->MarkReachable (lla.GetAddress ());
669
          waiting = entry->MarkReachable (lla.GetAddress ());
673
          entry->StopReachableTimer ();
674
          entry->StartReachableTimer ();
670
          entry->StartReachableTimer ();
675
          /* send out waiting packet */
671
          /* send out waiting packet */
676
          for (std::list<Ptr<Packet> >::const_iterator it = waiting.begin (); it != waiting.end (); it++)
672
          for (std::list<Ptr<Packet> >::const_iterator it = waiting.begin (); it != waiting.end (); it++)
 Lines 692-699    Link Here 
692
  else
688
  else
693
    {
689
    {
694
      /* we receive a NA so stop the probe timer or delay timer if any */
690
      /* we receive a NA so stop the probe timer or delay timer if any */
695
      entry->StopProbeTimer ();
691
      entry->StopNudTimer ();
696
      entry->StopDelayTimer ();
697
692
698
      /* if the Flag O is clear and mac address differs from the cache */
693
      /* if the Flag O is clear and mac address differs from the cache */
699
      if (!naHeader.GetFlagO () && lla.GetAddress () != entry->GetMacAddress ())
694
      if (!naHeader.GetFlagO () && lla.GetAddress () != entry->GetMacAddress ())
 Lines 728-734    Link Here 
728
                          entry->MarkReachable (lla.GetAddress ());
723
                          entry->MarkReachable (lla.GetAddress ());
729
                        }
724
                        }
730
                    }
725
                    }
731
                  entry->StopReachableTimer ();
732
                  entry->StartReachableTimer ();
726
                  entry->StartReachableTimer ();
733
                }
727
                }
734
              else if (lla.GetAddress () != entry->GetMacAddress ())
728
              else if (lla.GetAddress () != entry->GetMacAddress ())
(-)a/src/internet/model/ndisc-cache.cc (-72 / +31 lines)
 Lines 197-206    Link Here 
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
{
 Lines 268-276    Link Here 
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 */
 Lines 323-330    Link Here 
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
 Lines 334-341    Link Here 
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 ())
 Lines 358-364    Link Here 
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);
 Lines 379-402    Link Here 
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 ();
 Lines 411-487    Link Here 
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)
 Lines 573-579    Link Here 
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
(-)a/src/internet/model/ndisc-cache.h (-50 / +4 lines)
 Lines 250-271    Link Here 
250
    void SetRouter (bool router);
250
    void SetRouter (bool router);
251
251
252
    /**
252
    /**
253
     * \brief Get the number of NS retransmit.
254
     * \return number of NS that have been retransmit
255
     */
256
    uint8_t GetNSRetransmit () const;
257
258
    /**
259
     * \brief Increment NS retransmit.
260
     */
261
    void IncNSRetransmit ();
262
263
    /**
264
     * \brief Reset NS retransmit (=0).
265
     */
266
    void ResetNSRetransmit ();
267
268
    /**
269
     * \brief Get the time of last reachability confirmation.
253
     * \brief Get the time of last reachability confirmation.
270
     * \return time
254
     * \return time
271
     */
255
     */
 Lines 282-320    Link Here 
282
    void StartReachableTimer ();
266
    void StartReachableTimer ();
283
267
284
    /**
268
    /**
285
     * \brief Stop the reachable timer.
286
     */
287
    void StopReachableTimer ();
288
289
    /**
290
     * \brief Start retransmit timer.
269
     * \brief Start retransmit timer.
291
     */
270
     */
292
    void StartRetransmitTimer ();
271
    void StartRetransmitTimer ();
293
272
294
    /**
273
    /**
295
     * \brief Stop retransmit timer.
296
     */
297
    void StopRetransmitTimer ();
298
299
    /**
300
     * \brief Start probe timer.
274
     * \brief Start probe timer.
301
     */
275
     */
302
    void StartProbeTimer ();
276
    void StartProbeTimer ();
303
277
304
    /**
278
    /**
305
     * \brief Stop probe timer.
306
     */
307
    void StopProbeTimer ();
308
309
    /**
310
     * \brief Start delay timer.
279
     * \brief Start delay timer.
311
     */
280
     */
312
    void StartDelayTimer ();
281
    void StartDelayTimer ();
313
282
314
    /**
283
    /**
315
     * \brief Stop delay timer.
284
     * \brief Stop NUD timer and reset the NUD retransmission counter
316
     */
285
     */
317
    void StopDelayTimer ();
286
    void StopNudTimer ();
318
287
319
    /**
288
    /**
320
     * \brief Function called when reachable timer timeout.
289
     * \brief Function called when reachable timer timeout.
 Lines 388-411    Link Here 
388
    bool m_router;
357
    bool m_router;
389
358
390
    /**
359
    /**
391
     * \brief Reachable timer (used for NUD in REACHABLE state).
360
     * \brief Timer (used for NUD).
392
     */
361
     */
393
    Timer m_reachableTimer;
362
    Timer m_nudTimer;
394
395
    /**
396
     * \brief Retransmission timer (used for NUD in INCOMPLETE state).
397
     */
398
    Timer m_retransTimer;
399
400
    /**
401
     * \brief Probe timer (used for NUD in PROBE state).
402
     */
403
    Timer m_probeTimer;
404
405
    /**
406
     * \brief Delay timer (used for NUD when in DELAY state).
407
     */
408
    Timer m_delayTimer;
409
363
410
    /**
364
    /**
411
     * \brief Last time we see a reachability confirmation.
365
     * \brief Last time we see a reachability confirmation.

Return to bug 2073