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

(-)a/src/devices/wifi/nqsta-wifi-mac.cc (-8 / +21 lines)
 Lines 24-29    Link Here 
24
#include "ns3/log.h"
24
#include "ns3/log.h"
25
#include "ns3/node.h"
25
#include "ns3/node.h"
26
#include "ns3/uinteger.h"
26
#include "ns3/uinteger.h"
27
#include "ns3/trace-source-accessor.h"
27
28
28
#include "nqsta-wifi-mac.h"
29
#include "nqsta-wifi-mac.h"
29
#include "wifi-mac-header.h"
30
#include "wifi-mac-header.h"
 Lines 83-88    Link Here 
83
                   BooleanValue (false),
84
                   BooleanValue (false),
84
                   MakeBooleanAccessor (&NqstaWifiMac::SetActiveProbing),
85
                   MakeBooleanAccessor (&NqstaWifiMac::SetActiveProbing),
85
                   MakeBooleanChecker ())
86
                   MakeBooleanChecker ())
87
    .AddTraceSource ("Assoc", "Associated with an access point.",
88
                     MakeTraceSourceAccessor (&NqstaWifiMac::m_assocLogger))
89
    .AddTraceSource ("DeAssoc", "Association with an access point lost.",
90
                     MakeTraceSourceAccessor (&NqstaWifiMac::m_deAssocLogger))
86
    ;
91
    ;
87
  return tid;
92
  return tid;
88
}
93
}
 Lines 374-380    Link Here 
374
     * We try to initiate a probe request now.
379
     * We try to initiate a probe request now.
375
     */
380
     */
376
    m_linkDown ();
381
    m_linkDown ();
377
    m_state = WAIT_PROBE_RESP;
382
    SetState(WAIT_PROBE_RESP);
378
    SendProbeRequest ();
383
    SendProbeRequest ();
379
    break;
384
    break;
380
  case WAIT_ASSOC_RESP:
385
  case WAIT_ASSOC_RESP:
 Lines 397-410    Link Here 
397
NqstaWifiMac::AssocRequestTimeout (void)
402
NqstaWifiMac::AssocRequestTimeout (void)
398
{
403
{
399
  NS_LOG_FUNCTION (this);
404
  NS_LOG_FUNCTION (this);
400
  m_state = WAIT_ASSOC_RESP;
405
  SetState(WAIT_ASSOC_RESP);
401
  SendAssociationRequest ();
406
  SendAssociationRequest ();
402
}
407
}
403
void
408
void
404
NqstaWifiMac::ProbeRequestTimeout (void)
409
NqstaWifiMac::ProbeRequestTimeout (void)
405
{
410
{
406
  NS_LOG_FUNCTION (this);
411
  NS_LOG_FUNCTION (this);
407
  m_state = WAIT_PROBE_RESP;
412
  SetState(WAIT_PROBE_RESP);
408
  SendProbeRequest ();
413
  SendProbeRequest ();
409
}
414
}
410
void 
415
void 
 Lines 418-424    Link Here 
418
      return;
423
      return;
419
    }
424
    }
420
  NS_LOG_DEBUG ("beacon missed");
425
  NS_LOG_DEBUG ("beacon missed");
421
  m_state = BEACON_MISSED;
426
  SetState(BEACON_MISSED);
422
  TryToEnsureAssociated ();
427
  TryToEnsureAssociated ();
423
}
428
}
424
void 
429
void 
 Lines 532-538    Link Here 
532
        }
537
        }
533
      if (goodBeacon && m_state == BEACON_MISSED) 
538
      if (goodBeacon && m_state == BEACON_MISSED) 
534
        {
539
        {
535
          m_state = WAIT_ASSOC_RESP;
540
          SetState(WAIT_ASSOC_RESP);
536
          SendAssociationRequest ();
541
          SendAssociationRequest ();
537
        }
542
        }
538
  } 
543
  } 
 Lines 554-560    Link Here 
554
            {
559
            {
555
              m_probeRequestEvent.Cancel ();
560
              m_probeRequestEvent.Cancel ();
556
            }
561
            }
557
          m_state = WAIT_ASSOC_RESP;
562
          SetState(WAIT_ASSOC_RESP);
558
          SendAssociationRequest ();
563
          SendAssociationRequest ();
559
        }
564
        }
560
    } 
565
    } 
 Lines 570-576    Link Here 
570
            }
575
            }
571
          if (assocResp.GetStatusCode ().IsSuccess ()) 
576
          if (assocResp.GetStatusCode ().IsSuccess ()) 
572
            {
577
            {
573
              m_state = ASSOCIATED;
578
              SetState(ASSOCIATED);
574
              NS_LOG_DEBUG ("assoc completed"); 
579
              NS_LOG_DEBUG ("assoc completed"); 
575
              SupportedRates rates = assocResp.GetSupportedRates ();
580
              SupportedRates rates = assocResp.GetSupportedRates ();
576
              WifiRemoteStation *ap = m_stationManager->Lookup (hdr->GetAddr2 ());
581
              WifiRemoteStation *ap = m_stationManager->Lookup (hdr->GetAddr2 ());
 Lines 594-600    Link Here 
594
          else 
599
          else 
595
            {
600
            {
596
              NS_LOG_DEBUG ("assoc refused");
601
              NS_LOG_DEBUG ("assoc refused");
597
              m_state = REFUSED;
602
              SetState(REFUSED);
598
            }
603
            }
599
        }
604
        }
600
    }
605
    }
 Lines 612-615    Link Here 
612
  return rates;
617
  return rates;
613
}
618
}
614
619
620
void
621
NqstaWifiMac::SetState(MacState value)
622
{
623
  if(value==ASSOCIATED && m_state!=ASSOCIATED) m_assocLogger(GetBssid());
624
  else if(value!=ASSOCIATED && m_state==ASSOCIATED) m_deAssocLogger(GetBssid());
625
  m_state=value;
626
}
627
615
} // namespace ns3
628
} // namespace ns3
(-)a/src/devices/wifi/nqsta-wifi-mac.h (-2 / +8 lines)
 Lines 27-32    Link Here 
27
#include "ns3/event-id.h"
27
#include "ns3/event-id.h"
28
#include "ns3/packet.h"
28
#include "ns3/packet.h"
29
#include "ns3/nstime.h"
29
#include "ns3/nstime.h"
30
#include "ns3/traced-callback.h"
30
31
31
#include "wifi-mac.h"
32
#include "wifi-mac.h"
32
#include "supported-rates.h"
33
#include "supported-rates.h"
 Lines 130-142    Link Here 
130
  NqstaWifiMac (const NqstaWifiMac & ctor_arg);
131
  NqstaWifiMac (const NqstaWifiMac & ctor_arg);
131
  NqstaWifiMac &operator = (const NqstaWifiMac & ctor_arg);
132
  NqstaWifiMac &operator = (const NqstaWifiMac & ctor_arg);
132
133
133
  enum {
134
  enum MacState{
134
    ASSOCIATED,
135
    ASSOCIATED,
135
    WAIT_PROBE_RESP,
136
    WAIT_PROBE_RESP,
136
    WAIT_ASSOC_RESP,
137
    WAIT_ASSOC_RESP,
137
    BEACON_MISSED,
138
    BEACON_MISSED,
138
    REFUSED
139
    REFUSED
139
  } m_state;
140
  };
141
  MacState m_state;
142
  void SetState(MacState value);
140
  Time m_probeRequestTimeout;
143
  Time m_probeRequestTimeout;
141
  Time m_assocRequestTimeout;
144
  Time m_assocRequestTimeout;
142
  EventId m_probeRequestEvent;
145
  EventId m_probeRequestEvent;
 Lines 156-161    Link Here 
156
  Ptr<MacLow> m_low;
159
  Ptr<MacLow> m_low;
157
  Ssid m_ssid;
160
  Ssid m_ssid;
158
  Time m_eifsNoDifs;
161
  Time m_eifsNoDifs;
162
163
  TracedCallback<Mac48Address> m_assocLogger;
164
  TracedCallback<Mac48Address> m_deAssocLogger;
159
};
165
};
160
166
161
} // namespace ns3
167
} // namespace ns3

Return to bug 487