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

(-)original/sta-wifi-mac.cc (-37 / +113 lines)
 Lines 73-78    Link Here 
73
    .SetParent<RegularWifiMac> ()
73
    .SetParent<RegularWifiMac> ()
74
    .SetGroupName ("Wifi")
74
    .SetGroupName ("Wifi")
75
    .AddConstructor<StaWifiMac> ()
75
    .AddConstructor<StaWifiMac> ()
76
	/* Edited by manish ProbeRequestTimeout is no more in use , can be remove */
76
    .AddAttribute ("ProbeRequestTimeout", "The interval between two consecutive probe request attempts.",
77
    .AddAttribute ("ProbeRequestTimeout", "The interval between two consecutive probe request attempts.",
77
                   TimeValue (Seconds (0.05)),
78
                   TimeValue (Seconds (0.05)),
78
                   MakeTimeAccessor (&StaWifiMac::m_probeRequestTimeout),
79
                   MakeTimeAccessor (&StaWifiMac::m_probeRequestTimeout),
 Lines 81-87    Link Here 
81
                   TimeValue (Seconds (0.5)),
82
                   TimeValue (Seconds (0.5)),
82
                   MakeTimeAccessor (&StaWifiMac::m_assocRequestTimeout),
83
                   MakeTimeAccessor (&StaWifiMac::m_assocRequestTimeout),
83
                   MakeTimeChecker ())
84
                   MakeTimeChecker ())
84
    .AddAttribute ("ScanningTimeout", "The interval to dwell on a channel while scanning",
85
    .AddAttribute ("ScanningTimeout", "The interval to dwell on a channel while scanning during passive probring",
85
                   TimeValue (MilliSeconds (120)),
86
                   TimeValue (MilliSeconds (120)),
86
                   MakeTimeAccessor (&StaWifiMac::m_scanningTimeout),
87
                   MakeTimeAccessor (&StaWifiMac::m_scanningTimeout),
87
                   MakeTimeChecker ())
88
                   MakeTimeChecker ())
 Lines 100-105    Link Here 
100
                   BooleanValue (false),
101
                   BooleanValue (false),
101
                   MakeBooleanAccessor (&StaWifiMac::SetActiveProbing, &StaWifiMac::GetActiveProbing),
102
                   MakeBooleanAccessor (&StaWifiMac::SetActiveProbing, &StaWifiMac::GetActiveProbing),
102
                   MakeBooleanChecker ())
103
                   MakeBooleanChecker ())
104
	/* Edited by manish MinChannelTimeout */
105
	.AddAttribute ("MinChannelTimeout", "The time duration upto which the station have to wait"
106
                   "for probe response (in active probing )if no activity found on channel till the end of this time duration.",
107
                   TimeValue (Seconds (0.010)),
108
                   MakeTimeAccessor (&StaWifiMac::m_minChannelTimeout),
109
                   MakeTimeChecker ())
110
	/* Edited by manish MaxChannelTimeout */
111
	.AddAttribute ("MaxChannelTimeout", "The time duration upto which the station have to wait"
112
                   "for probe response (in active probing )if some activity found on channel till the end of this time duration.",
113
                   TimeValue (Seconds (0.040)),
114
                   MakeTimeAccessor (&StaWifiMac::m_maxChannelTimeout),
115
                   MakeTimeChecker ())
103
    .AddTraceSource ("Assoc", "Associated with an access point.",
116
    .AddTraceSource ("Assoc", "Associated with an access point.",
104
                     MakeTraceSourceAccessor (&StaWifiMac::m_assocLogger),
117
                     MakeTraceSourceAccessor (&StaWifiMac::m_assocLogger),
105
                     "ns3::Mac48Address::TracedCallback")
118
                     "ns3::Mac48Address::TracedCallback")
 Lines 136-142    Link Here 
136
void
149
void
137
StaWifiMac::DoInitialize (void)
150
StaWifiMac::DoInitialize (void)
138
{
151
{
139
  StartScanning ();
152
    StartScanning ();
140
}
153
}
141
154
142
void
155
void
 Lines 223-230    Link Here 
223
    {
236
    {
224
      m_probeRequestEvent.Cancel ();
237
      m_probeRequestEvent.Cancel ();
225
    }
238
    }
226
  m_probeRequestEvent = Simulator::Schedule (m_probeRequestTimeout,
239
	//edited by manish start 
227
                                             &StaWifiMac::ProbeRequestTimeout, this);
240
 // if (m_candidateChannels.size () == 0)
241
   // {
242
	//	//m_probeRequestEvent = Simulator::Schedule (m_probeRequestTimeout,
243
    //                                         &StaWifiMac::ProbeRequestTimeout, this);
244
	//}
245
	//edited by manish end
228
}
246
}
229
247
230
void
248
void
 Lines 293-299    Link Here 
293
      if (m_activeProbing)
311
      if (m_activeProbing)
294
        {
312
        {
295
          SetState (WAIT_PROBE_RESP);
313
          SetState (WAIT_PROBE_RESP);
296
          m_bestBeaconObserved.Clear ();
314
          //m_bestBeaconObserved.Clear ();removed by manish as resulting in clearing of best becon data of channel
297
          SendProbeRequest ();
315
          SendProbeRequest ();
298
        }
316
        }
299
      else
317
      else
 Lines 302-310    Link Here 
302
            {
320
            {
303
              m_waitBeaconEvent.Cancel ();
321
              m_waitBeaconEvent.Cancel ();
304
            }
322
            }
305
          m_bestBeaconObserved.Clear ();
323
          //m_bestBeaconObserved.Clear ();removed by manish as resulting in clearing of best becon data of channel
306
          m_waitBeaconEvent = Simulator::Schedule (m_scanningTimeout,
324
          //m_waitBeaconEvent = Simulator::Schedule (m_scanningTimeout,
307
                                       &StaWifiMac::WaitBeaconTimeout, this);
325
          //                             &StaWifiMac::WaitBeaconTimeout, this);
326
		  //no need to call WaitBeaconTimeout as it is not end of scanning 
308
          SetState (WAIT_BEACON);
327
          SetState (WAIT_BEACON);
309
        }
328
        }
310
      break;
329
      break;
 Lines 409-415    Link Here 
409
      SetBssid (m_bestBeaconObserved.m_bssid);
428
      SetBssid (m_bestBeaconObserved.m_bssid);
410
      Time delay = MicroSeconds (m_bestBeaconObserved.m_probeResp.GetBeaconIntervalUs () * m_maxMissedBeacons);
429
      Time delay = MicroSeconds (m_bestBeaconObserved.m_probeResp.GetBeaconIntervalUs () * m_maxMissedBeacons);
411
      RestartBeaconWatchdog (delay);
430
      RestartBeaconWatchdog (delay);
412
      if (m_probeRequestEvent.IsRunning ())
431
      NS_LOG_DEBUG ("Stopping scanning; best beacon found on channel " << m_bestBeaconObserved.m_channelNumber);//manish 
432
      m_phy->SetChannelNumber (m_bestBeaconObserved.m_channelNumber);//manish
433
	  if (m_probeRequestEvent.IsRunning ())
413
        {
434
        {
414
          m_probeRequestEvent.Cancel ();
435
          m_probeRequestEvent.Cancel ();
415
        }
436
        }
 Lines 419-425    Link Here 
419
  else
440
  else
420
    {
441
    {
421
      NS_LOG_DEBUG ("no probe responses received; resend request");
442
      NS_LOG_DEBUG ("no probe responses received; resend request");
422
      SendProbeRequest ();
443
      StartScanning ();//manish restart scanning process 
423
    }
444
    }
424
}
445
}
425
446
 Lines 432-444    Link Here 
432
      NS_LOG_DEBUG ("Beacon found, selecting " << m_bestBeaconObserved.m_bssid);
453
      NS_LOG_DEBUG ("Beacon found, selecting " << m_bestBeaconObserved.m_bssid);
433
      SetBssid (m_bestBeaconObserved.m_bssid);
454
      SetBssid (m_bestBeaconObserved.m_bssid);
434
      SetState (WAIT_ASSOC_RESP);
455
      SetState (WAIT_ASSOC_RESP);
456
	  m_phy->SetChannelNumber (m_bestBeaconObserved.m_channelNumber);//manish
435
      SendAssociationRequest ();
457
      SendAssociationRequest ();
436
    }
458
    }
437
  else
459
 // edited by manish check allready present in channelScanning Timeout
438
    {
460
 //else
439
      NS_LOG_DEBUG ("no beacons received; restart scanning");
461
   // {
440
      StartScanning ();
462
     // NS_LOG_DEBUG ("no beacons received; restart scanning");
441
    }
463
      //StartScanning ();
464
    //} 
442
}
465
}
443
466
444
void
467
void
 Lines 557-603    Link Here 
557
StaWifiMac::StartScanning (void)
580
StaWifiMac::StartScanning (void)
558
{
581
{
559
  NS_LOG_FUNCTION (this);
582
  NS_LOG_FUNCTION (this);
583
  m_bestBeaconObserved.Clear ();//rev manish moved from TryToEnsureAssociated 
560
  SetState (SCANNING);
584
  SetState (SCANNING);
561
  m_candidateChannels = m_phy->GetOperationalChannelList ();
585
  m_candidateChannels = m_phy->GetOperationalChannelList (); 
562
  if (m_candidateChannels.size () == 1)
586
  if (m_candidateChannels.size () == 1)
563
    {
587
    {
564
      NS_LOG_DEBUG ("No need to scan; only one channel possible");
588
      NS_LOG_DEBUG ("No need to scan; only one channel possible");
589
	  //rev1.0 manish setting channel number and communicating to phy layer
590
	  uint32_t nextChannel = m_candidateChannels.back (); 
591
	  m_phy->SetChannelNumber (nextChannel);
565
      m_candidateChannels.clear ();
592
      m_candidateChannels.clear ();
566
      SetState (UNASSOCIATED);
593
	  SetState (UNASSOCIATED);
567
      TryToEnsureAssociated ();
594
      TryToEnsureAssociated ();
568
      return;
595
      return;
569
    }
596
    }
570
  // Keep track of whether we find any good beacons, so that if we do
597
  // Keep track of whether we find any good beacons, so that if we do
571
  // not, we restart scanning
598
  // not, we restart scanning
572
  m_bestBeaconObserved.Clear ();
599
  //m_bestBeaconObserved.Clear ();rev1.0 manish moved above
573
  uint32_t nextChannel = m_candidateChannels.back ();
600
  uint32_t nextChannel = m_candidateChannels.back ();
574
  m_candidateChannels.pop_back ();
601
  m_candidateChannels.pop_back ();
575
  NS_LOG_DEBUG ("Scanning channel " << nextChannel);
602
  NS_LOG_DEBUG ("Scanning channel " << nextChannel);  
576
  Simulator::Schedule (m_scanningTimeout, &StaWifiMac::ScanningTimeout, this);
603
  m_phy->SetChannelNumber (nextChannel);//rev1.0 manish setting channel number
604
  SetState (UNASSOCIATED);//rev1.0 manish setting state 
605
 
606
 // edited by manish checking whether active probing or passive probing
607
  if (m_activeProbing)
608
     {  
609
         Simulator::Schedule (m_minChannelTimeout, &StaWifiMac::MinScanningTimeout, this);
610
	  }
611
  else
612
  {
613
         Simulator::Schedule (m_scanningTimeout, &StaWifiMac::ChannelScanningTimeout, this);
614
  }
615
  TryToEnsureAssociated ();//rev1.0 manish 	   
616
}
617
//edited by manish adding new function
618
void
619
StaWifiMac::MinScanningTimeout (void) 
620
{
621
 if (! activityDetected)
622
 { Simulator::ScheduleNow ( &StaWifiMac::ChannelScanningTimeout, this);
623
  }
624
 else{Simulator::Schedule (m_maxChannelTimeout - m_minChannelTimeout ), 
625
                             &StaWifiMac::ChannelScanningTimeout, this);
626
	activityDetected = false ;
627
	}
577
}
628
}
578
629
579
void
630
void
580
StaWifiMac::ScanningTimeout (void)
631
StaWifiMac::ChannelScanningTimeout (void)
581
{
632
{
582
  NS_LOG_FUNCTION (this);
633
  NS_LOG_FUNCTION (this);
583
  if (m_candidateChannels.size () == 0)
634
  if (m_candidateChannels.size () == 0)
584
    {
635
    {
585
      if (m_bestBeaconObserved.m_channelNumber == 0)
636
     if (m_bestBeaconObserved.m_channelNumber == 0)
586
        {
637
      {
587
          NS_LOG_DEBUG ("No beacons found when scanning; restart scanning");
638
         NS_LOG_DEBUG ("No beacons/ probe reponse found when scanning; restart scanning");
588
          StartScanning ();
639
         StartScanning ();
589
          return;
640
         return;
590
        }
641
      }
591
      NS_LOG_DEBUG ("Stopping scanning; best beacon found on channel " << m_bestBeaconObserved.m_channelNumber);
642
      NS_LOG_DEBUG ("Stopping scanning; best beacon found on channel " << m_bestBeaconObserved.m_channelNumber);
592
      m_phy->SetChannelNumber (m_bestBeaconObserved.m_channelNumber);
643
      //edited by manish no need of following lines at this place
593
      SetState (UNASSOCIATED);
644
	  // m_phy->SetChannelNumber (m_bestBeaconObserved.m_channelNumber);
594
      TryToEnsureAssociated ();
645
      //SetState (UNASSOCIATED);
646
      //TryToEnsureAssociated ();
647
	  
648
	  // manish checking active /passive probing
649
	 if (m_activeProbing)
650
     {  
651
        m_probeRequestEvent = Simulator::ScheduleNow (&StaWifiMac::ProbeRequestTimeout, this);//manish
652
	  }
653
  else
654
  {
655
         m_waitBeaconEvent = Simulator::Schedule (m_scanningTimeout,&StaWifiMac::WaitBeaconTimeout, this);
656
  } //manish 
657
	   
658
     	  
595
      return;
659
      return;
596
    }
660
    }
597
  uint32_t nextChannel = m_candidateChannels.back ();
661
  uint32_t nextChannel = m_candidateChannels.back ();
598
  m_candidateChannels.pop_back ();
662
  m_candidateChannels.pop_back ();
599
  NS_LOG_DEBUG ("Scanning channel " << nextChannel);
663
  NS_LOG_DEBUG ("Scanning channel " << nextChannel);
600
  Simulator::Schedule (m_scanningTimeout, &StaWifiMac::ScanningTimeout, this);
664
  m_phy->SetChannelNumber (nextChannel);//rev1.0 manish setting channel number
665
  SetState (UNASSOCIATED);//rev1.0 manish setting channel number
666
  // manish checking active /passive probing
667
  if (m_activeProbing)
668
     {  
669
         Simulator::Schedule (m_minChannelTimeout, &StaWifiMac::MinScanningTimeout, this);
670
	  }
671
  else
672
      (
673
         Simulator::Schedule (m_scanningTimeout, &StaWifiMac::ChannelScanningTimeout, this);
674
	   )//manish 
675
  TryToEnsureAssociated ();//rev1.0 manish setting channel number
601
}
676
}
602
677
603
void
678
void
 Lines 605-610    Link Here 
605
{
680
{
606
  NS_LOG_FUNCTION (this << packet << hdr);
681
  NS_LOG_FUNCTION (this << packet << hdr);
607
  NS_ASSERT (!hdr->IsCtl ());
682
  NS_ASSERT (!hdr->IsCtl ());
683
  activityDetected = true ;//new variable to sense channel
608
  if (hdr->GetAddr3 () == GetAddress ())
684
  if (hdr->GetAddr3 () == GetAddress ())
609
    {
685
    {
610
      NS_LOG_LOGIC ("packet sent by us.");
686
      NS_LOG_LOGIC ("packet sent by us.");
 Lines 725-736    Link Here 
725
          m_stationManager->SetShortPreambleEnabled (isShortPreambleEnabled);
801
          m_stationManager->SetShortPreambleEnabled (isShortPreambleEnabled);
726
          m_stationManager->SetShortSlotTimeEnabled (capabilities.IsShortSlotTime ());
802
          m_stationManager->SetShortSlotTimeEnabled (capabilities.IsShortSlotTime ());
727
        }
803
        }
728
      if (goodBeacon && m_state == UNASSOCIATED)
804
     // if (goodBeacon && m_state == UNASSOCIATED)
729
        {
805
       // {
730
          SetState (WAIT_ASSOC_RESP);
806
         // SetState (WAIT_ASSOC_RESP);
731
          SendAssociationRequest ();
807
          //SendAssociationRequest ();
732
        }
808
        //} edited by manish no need to send association request 
733
      if (goodBeacon && (m_state == SCANNING || m_state == WAIT_BEACON))
809
      if (goodBeacon && (m_state == SCANNING || m_state == WAIT_BEACON) && !m_activeProbing)
734
        {
810
        {
735
          NS_LOG_DEBUG ("Beacon received while scanning");
811
          NS_LOG_DEBUG ("Beacon received while scanning");
736
          if (m_bestBeaconObserved.m_snr < tag.Get ())
812
          if (m_bestBeaconObserved.m_snr < tag.Get ())
(-)original/sta-wifi-mac.h (-1 / +9 lines)
 Lines 213-222    Link Here 
213
   * Start the scanning process to find the strongest beacon
213
   * Start the scanning process to find the strongest beacon
214
   */
214
   */
215
  void StartScanning (void);
215
  void StartScanning (void);
216
    /**
217
   * (edited by manish)To check the waiting time (MaxTime Or MinTime) on the channel during Active Probing
218
   */
219
  void MinScanningTimeout (void);
216
  /**
220
  /**
221
   * Edited by Manish old ScanningTimeout is now channel scanning timeout
217
   * Continue scanning process or terminate if no further channels to scan
222
   * Continue scanning process or terminate if no further channels to scan
218
   */
223
   */
219
  void ScanningTimeout (void);
224
  void ChannelScanningTimeout (void);
220
225
221
  virtual void DoInitialize (void);
226
  virtual void DoInitialize (void);
222
227
 Lines 224-229    Link Here 
224
  Time m_probeRequestTimeout;
229
  Time m_probeRequestTimeout;
225
  Time m_assocRequestTimeout;
230
  Time m_assocRequestTimeout;
226
  Time m_scanningTimeout;
231
  Time m_scanningTimeout;
232
  Time m_minChannelTimeout;// edited by manish used when scanning
233
  Time m_maxChannelTimeout;// edited by manish used when scanning
227
  EventId m_probeRequestEvent;
234
  EventId m_probeRequestEvent;
228
  EventId m_assocRequestEvent;
235
  EventId m_assocRequestEvent;
229
  EventId m_beaconWatchdog;
236
  EventId m_beaconWatchdog;
 Lines 231-236    Link Here 
231
  Time m_beaconWatchdogEnd;
238
  Time m_beaconWatchdogEnd;
232
  uint32_t m_maxMissedBeacons;
239
  uint32_t m_maxMissedBeacons;
233
  bool m_activeProbing;
240
  bool m_activeProbing;
241
  bool activityDetected ;// edited by manish used when scanning
234
  std::vector<uint16_t> m_candidateChannels; /// used when scanning
242
  std::vector<uint16_t> m_candidateChannels; /// used when scanning
235
  BeaconInfo m_bestBeaconObserved; /// used when scanning
243
  BeaconInfo m_bestBeaconObserved; /// used when scanning
(-)original/yans-wifi-phy.cc (-2 / +4 lines)
 Lines 515-522    Link Here 
515
    {
515
    {
516
      if (m_operationalChannelList[i] != m_channelNumber)
516
      if (m_operationalChannelList[i] != m_channelNumber)
517
        {
517
        {
518
          channelList.push_back (m_channelNumber);
518
          //edited by Manish Puraswani ver 1.0 as the original one was not updating channel list 
519
        }
519
		  //channelList.push_back (m_channelNumber); (original code)
520
          channelList.push_back (m_operationalChannelList[i]);   
521
		}
520
    }
522
    }
521
  return channelList;
523
  return channelList;
522
}
524
}

Return to bug 2399