author | Mathieu Lacage <mathieu.lacage@sophia.inria.fr> |
Thu, 17 Apr 2008 13:42:25 -0700 | |
changeset 2965 | 4b28e9740e3b |
parent 2686 | e8cdac3c936f |
child 2989 | b7eb3929096c |
permissions | -rw-r--r-- |
1948 | 1 |
/* -*- Mode: C++; c-file-style: "gnu"; indent-tabs-mode:nil; -*- */ |
2 |
/* |
|
3 |
* Copyright (c) 2005,2006 INRIA |
|
4 |
* |
|
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 |
|
7 |
* published by the Free Software Foundation; |
|
8 |
* |
|
9 |
* This program is distributed in the hope that it will be useful, |
|
10 |
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
|
11 |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|
12 |
* GNU General Public License for more details. |
|
13 |
* |
|
14 |
* You should have received a copy of the GNU General Public License |
|
15 |
* along with this program; if not, write to the Free Software |
|
16 |
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA |
|
17 |
* |
|
18 |
* Author: Mathieu Lacage <mathieu.lacage@sophia.inria.fr> |
|
19 |
*/ |
|
20 |
||
21 |
#include "ns3/packet.h" |
|
22 |
#include "ns3/simulator.h" |
|
23 |
#include "ns3/assert.h" |
|
2012
54dd9789c670
enable logging
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2009
diff
changeset
|
24 |
#include "ns3/log.h" |
2156
754a843db672
improve log output
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2090
diff
changeset
|
25 |
#include "ns3/node.h" |
2524
db72c0e7743e
port wifi model to Attributes
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2350
diff
changeset
|
26 |
#include "ns3/uinteger.h" |
1948 | 27 |
|
2524
db72c0e7743e
port wifi model to Attributes
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2350
diff
changeset
|
28 |
#include "nqsta-wifi-mac.h" |
1948 | 29 |
#include "wifi-mac-header.h" |
30 |
#include "mgt-headers.h" |
|
31 |
#include "wifi-phy.h" |
|
32 |
#include "dca-txop.h" |
|
2524
db72c0e7743e
port wifi model to Attributes
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2350
diff
changeset
|
33 |
#include "mac-low.h" |
db72c0e7743e
port wifi model to Attributes
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2350
diff
changeset
|
34 |
#include "dcf-manager.h" |
db72c0e7743e
port wifi model to Attributes
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2350
diff
changeset
|
35 |
#include "mac-rx-middle.h" |
1948 | 36 |
|
2524
db72c0e7743e
port wifi model to Attributes
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2350
diff
changeset
|
37 |
NS_LOG_COMPONENT_DEFINE ("NqstaWifiMac"); |
1948 | 38 |
|
2012
54dd9789c670
enable logging
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2009
diff
changeset
|
39 |
#define TRACE(x) \ |
2524
db72c0e7743e
port wifi model to Attributes
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2350
diff
changeset
|
40 |
NS_LOG_DEBUG (Simulator::Now () << " " << GetAddress () << " " << x); |
1948 | 41 |
|
42 |
/* |
|
43 |
* The state machine for this NQSTA is: |
|
44 |
-------------- ----------- |
|
45 |
| Associated | <-------------------- -------> | Refused | |
|
46 |
-------------- \ / ----------- |
|
47 |
\ \ / |
|
48 |
\ ----------------- ----------------------------- |
|
49 |
\-> | Beacon Missed | --> | Wait Association Response | |
|
50 |
----------------- ----------------------------- |
|
51 |
\ ^ |
|
52 |
\ | |
|
53 |
\ ----------------------- |
|
54 |
\-> | Wait Probe Response | |
|
55 |
----------------------- |
|
56 |
*/ |
|
57 |
||
58 |
namespace ns3 { |
|
59 |
||
2524
db72c0e7743e
port wifi model to Attributes
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2350
diff
changeset
|
60 |
NS_OBJECT_ENSURE_REGISTERED (NqstaWifiMac); |
db72c0e7743e
port wifi model to Attributes
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2350
diff
changeset
|
61 |
|
db72c0e7743e
port wifi model to Attributes
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2350
diff
changeset
|
62 |
TypeId |
db72c0e7743e
port wifi model to Attributes
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2350
diff
changeset
|
63 |
NqstaWifiMac::GetTypeId (void) |
db72c0e7743e
port wifi model to Attributes
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2350
diff
changeset
|
64 |
{ |
2602
d9262bff6df2
add back support for introspected doxygen.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2528
diff
changeset
|
65 |
static TypeId tid = TypeId ("ns3::NqstaWifiMac") |
2524
db72c0e7743e
port wifi model to Attributes
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2350
diff
changeset
|
66 |
.SetParent<WifiMac> () |
db72c0e7743e
port wifi model to Attributes
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2350
diff
changeset
|
67 |
.AddConstructor<NqstaWifiMac> () |
db72c0e7743e
port wifi model to Attributes
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2350
diff
changeset
|
68 |
.AddAttribute ("ProbeRequestTimeout", "XXX", |
2965
4b28e9740e3b
get rid of Attribute class. Use AttributeValue subclasses directly.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2686
diff
changeset
|
69 |
TimeValue (Seconds (0.5)), |
2524
db72c0e7743e
port wifi model to Attributes
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2350
diff
changeset
|
70 |
MakeTimeAccessor (&NqstaWifiMac::m_probeRequestTimeout), |
db72c0e7743e
port wifi model to Attributes
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2350
diff
changeset
|
71 |
MakeTimeChecker ()) |
db72c0e7743e
port wifi model to Attributes
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2350
diff
changeset
|
72 |
.AddAttribute ("AssocRequestTimeout", "XXX", |
2965
4b28e9740e3b
get rid of Attribute class. Use AttributeValue subclasses directly.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2686
diff
changeset
|
73 |
TimeValue (Seconds (0.5)), |
2524
db72c0e7743e
port wifi model to Attributes
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2350
diff
changeset
|
74 |
MakeTimeAccessor (&NqstaWifiMac::m_assocRequestTimeout), |
db72c0e7743e
port wifi model to Attributes
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2350
diff
changeset
|
75 |
MakeTimeChecker ()) |
db72c0e7743e
port wifi model to Attributes
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2350
diff
changeset
|
76 |
.AddAttribute ("MaxMissedBeacons", |
db72c0e7743e
port wifi model to Attributes
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2350
diff
changeset
|
77 |
"Number of beacons which much be consecutively missed before " |
db72c0e7743e
port wifi model to Attributes
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2350
diff
changeset
|
78 |
"we attempt to restart association.", |
2965
4b28e9740e3b
get rid of Attribute class. Use AttributeValue subclasses directly.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2686
diff
changeset
|
79 |
UintegerValue (10), |
2524
db72c0e7743e
port wifi model to Attributes
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2350
diff
changeset
|
80 |
MakeUintegerAccessor (&NqstaWifiMac::m_maxMissedBeacons), |
db72c0e7743e
port wifi model to Attributes
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2350
diff
changeset
|
81 |
MakeUintegerChecker<uint32_t> ()) |
2528
a527ec47b756
avoid crashing AP wifi sample
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2524
diff
changeset
|
82 |
.AddAttribute ("ActiveProbing", "XXX", |
2965
4b28e9740e3b
get rid of Attribute class. Use AttributeValue subclasses directly.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2686
diff
changeset
|
83 |
BooleanValue (false), |
2528
a527ec47b756
avoid crashing AP wifi sample
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2524
diff
changeset
|
84 |
MakeBooleanAccessor (&NqstaWifiMac::SetActiveProbing), |
a527ec47b756
avoid crashing AP wifi sample
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2524
diff
changeset
|
85 |
MakeBooleanChecker ()) |
2524
db72c0e7743e
port wifi model to Attributes
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2350
diff
changeset
|
86 |
; |
db72c0e7743e
port wifi model to Attributes
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2350
diff
changeset
|
87 |
return tid; |
db72c0e7743e
port wifi model to Attributes
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2350
diff
changeset
|
88 |
} |
db72c0e7743e
port wifi model to Attributes
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2350
diff
changeset
|
89 |
|
db72c0e7743e
port wifi model to Attributes
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2350
diff
changeset
|
90 |
|
db72c0e7743e
port wifi model to Attributes
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2350
diff
changeset
|
91 |
NqstaWifiMac::NqstaWifiMac () |
1948 | 92 |
: m_state (BEACON_MISSED), |
93 |
m_probeRequestEvent (), |
|
94 |
m_assocRequestEvent (), |
|
1952
2ad2630756e3
do not use the Watchdog class
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
1951
diff
changeset
|
95 |
m_beaconWatchdogEnd (Seconds (0.0)) |
1948 | 96 |
{ |
2524
db72c0e7743e
port wifi model to Attributes
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2350
diff
changeset
|
97 |
m_rxMiddle = new MacRxMiddle (); |
db72c0e7743e
port wifi model to Attributes
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2350
diff
changeset
|
98 |
m_rxMiddle->SetForwardCallback (MakeCallback (&NqstaWifiMac::Receive, this)); |
db72c0e7743e
port wifi model to Attributes
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2350
diff
changeset
|
99 |
|
2617
0ecb3a9422e4
avoid double-frees.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2602
diff
changeset
|
100 |
m_low = CreateObject<MacLow> (); |
2524
db72c0e7743e
port wifi model to Attributes
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2350
diff
changeset
|
101 |
m_low->SetRxCallback (MakeCallback (&MacRxMiddle::Receive, m_rxMiddle)); |
2528
a527ec47b756
avoid crashing AP wifi sample
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2524
diff
changeset
|
102 |
m_low->SetMac (this); |
2524
db72c0e7743e
port wifi model to Attributes
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2350
diff
changeset
|
103 |
|
2617
0ecb3a9422e4
avoid double-frees.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2602
diff
changeset
|
104 |
m_dcfManager = new DcfManager (); |
0ecb3a9422e4
avoid double-frees.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2602
diff
changeset
|
105 |
m_dcfManager->SetupLowListener (m_low); |
0ecb3a9422e4
avoid double-frees.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2602
diff
changeset
|
106 |
|
2524
db72c0e7743e
port wifi model to Attributes
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2350
diff
changeset
|
107 |
m_dca = CreateObject<DcaTxop> (); |
db72c0e7743e
port wifi model to Attributes
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2350
diff
changeset
|
108 |
m_dca->SetLow (m_low); |
db72c0e7743e
port wifi model to Attributes
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2350
diff
changeset
|
109 |
m_dca->SetManager (m_dcfManager); |
1948 | 110 |
} |
111 |
||
2524
db72c0e7743e
port wifi model to Attributes
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2350
diff
changeset
|
112 |
NqstaWifiMac::~NqstaWifiMac () |
db72c0e7743e
port wifi model to Attributes
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2350
diff
changeset
|
113 |
{} |
db72c0e7743e
port wifi model to Attributes
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2350
diff
changeset
|
114 |
|
db72c0e7743e
port wifi model to Attributes
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2350
diff
changeset
|
115 |
void |
db72c0e7743e
port wifi model to Attributes
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2350
diff
changeset
|
116 |
NqstaWifiMac::DoDispose (void) |
2054
ba8e810bae4c
derive WifiPhy from Object and manage it with a Ptr<>
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2012
diff
changeset
|
117 |
{ |
2524
db72c0e7743e
port wifi model to Attributes
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2350
diff
changeset
|
118 |
delete m_rxMiddle; |
2528
a527ec47b756
avoid crashing AP wifi sample
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2524
diff
changeset
|
119 |
delete m_dcfManager; |
2524
db72c0e7743e
port wifi model to Attributes
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2350
diff
changeset
|
120 |
m_rxMiddle = 0; |
db72c0e7743e
port wifi model to Attributes
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2350
diff
changeset
|
121 |
m_low = 0; |
2528
a527ec47b756
avoid crashing AP wifi sample
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2524
diff
changeset
|
122 |
m_dcfManager = 0; |
2054
ba8e810bae4c
derive WifiPhy from Object and manage it with a Ptr<>
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2012
diff
changeset
|
123 |
m_phy = 0; |
2524
db72c0e7743e
port wifi model to Attributes
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2350
diff
changeset
|
124 |
m_dca = 0; |
db72c0e7743e
port wifi model to Attributes
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2350
diff
changeset
|
125 |
WifiMac::DoDispose (); |
2054
ba8e810bae4c
derive WifiPhy from Object and manage it with a Ptr<>
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2012
diff
changeset
|
126 |
} |
1948 | 127 |
|
128 |
void |
|
2528
a527ec47b756
avoid crashing AP wifi sample
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2524
diff
changeset
|
129 |
NqstaWifiMac::SetSlot (Time slotTime) |
a527ec47b756
avoid crashing AP wifi sample
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2524
diff
changeset
|
130 |
{ |
a527ec47b756
avoid crashing AP wifi sample
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2524
diff
changeset
|
131 |
m_dcfManager->SetSlot (slotTime); |
2686 | 132 |
m_slot = slotTime; |
2528
a527ec47b756
avoid crashing AP wifi sample
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2524
diff
changeset
|
133 |
} |
a527ec47b756
avoid crashing AP wifi sample
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2524
diff
changeset
|
134 |
void |
a527ec47b756
avoid crashing AP wifi sample
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2524
diff
changeset
|
135 |
NqstaWifiMac::SetSifs (Time sifs) |
a527ec47b756
avoid crashing AP wifi sample
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2524
diff
changeset
|
136 |
{ |
a527ec47b756
avoid crashing AP wifi sample
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2524
diff
changeset
|
137 |
m_dcfManager->SetSifs (sifs); |
2686 | 138 |
m_sifs = sifs; |
2528
a527ec47b756
avoid crashing AP wifi sample
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2524
diff
changeset
|
139 |
} |
a527ec47b756
avoid crashing AP wifi sample
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2524
diff
changeset
|
140 |
void |
a527ec47b756
avoid crashing AP wifi sample
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2524
diff
changeset
|
141 |
NqstaWifiMac::SetEifsNoDifs (Time eifsNoDifs) |
a527ec47b756
avoid crashing AP wifi sample
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2524
diff
changeset
|
142 |
{ |
a527ec47b756
avoid crashing AP wifi sample
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2524
diff
changeset
|
143 |
m_dcfManager->SetEifsNoDifs (eifsNoDifs); |
2686 | 144 |
m_eifsNoDifs = eifsNoDifs; |
145 |
} |
|
146 |
Time |
|
147 |
NqstaWifiMac::GetSlot (void) const |
|
148 |
{ |
|
149 |
return m_slot; |
|
150 |
} |
|
151 |
Time |
|
152 |
NqstaWifiMac::GetSifs (void) const |
|
153 |
{ |
|
154 |
return m_sifs; |
|
155 |
} |
|
156 |
Time |
|
157 |
NqstaWifiMac::GetEifsNoDifs (void) const |
|
158 |
{ |
|
159 |
return m_eifsNoDifs; |
|
2528
a527ec47b756
avoid crashing AP wifi sample
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2524
diff
changeset
|
160 |
} |
a527ec47b756
avoid crashing AP wifi sample
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2524
diff
changeset
|
161 |
|
a527ec47b756
avoid crashing AP wifi sample
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2524
diff
changeset
|
162 |
void |
2524
db72c0e7743e
port wifi model to Attributes
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2350
diff
changeset
|
163 |
NqstaWifiMac::SetWifiPhy (Ptr<WifiPhy> phy) |
2009
afed751cc0b5
dynamically update the list of supported rates based on the ap supported rates
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
1964
diff
changeset
|
164 |
{ |
afed751cc0b5
dynamically update the list of supported rates based on the ap supported rates
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
1964
diff
changeset
|
165 |
m_phy = phy; |
2528
a527ec47b756
avoid crashing AP wifi sample
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2524
diff
changeset
|
166 |
m_dcfManager->SetupPhyListener (phy); |
a527ec47b756
avoid crashing AP wifi sample
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2524
diff
changeset
|
167 |
m_low->SetPhy (phy); |
2009
afed751cc0b5
dynamically update the list of supported rates based on the ap supported rates
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
1964
diff
changeset
|
168 |
} |
afed751cc0b5
dynamically update the list of supported rates based on the ap supported rates
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
1964
diff
changeset
|
169 |
void |
2524
db72c0e7743e
port wifi model to Attributes
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2350
diff
changeset
|
170 |
NqstaWifiMac::SetWifiRemoteStationManager (Ptr<WifiRemoteStationManager> stationManager) |
db72c0e7743e
port wifi model to Attributes
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2350
diff
changeset
|
171 |
{ |
db72c0e7743e
port wifi model to Attributes
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2350
diff
changeset
|
172 |
m_stationManager = stationManager; |
2528
a527ec47b756
avoid crashing AP wifi sample
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2524
diff
changeset
|
173 |
m_dca->SetWifiRemoteStationManager (stationManager); |
a527ec47b756
avoid crashing AP wifi sample
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2524
diff
changeset
|
174 |
m_low->SetWifiRemoteStationManager (stationManager); |
2524
db72c0e7743e
port wifi model to Attributes
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2350
diff
changeset
|
175 |
} |
db72c0e7743e
port wifi model to Attributes
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2350
diff
changeset
|
176 |
void |
db72c0e7743e
port wifi model to Attributes
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2350
diff
changeset
|
177 |
NqstaWifiMac::SetForwardUpCallback (Callback<void,Ptr<Packet>, const Mac48Address &> upCallback) |
db72c0e7743e
port wifi model to Attributes
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2350
diff
changeset
|
178 |
{ |
db72c0e7743e
port wifi model to Attributes
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2350
diff
changeset
|
179 |
m_forwardUp = upCallback; |
db72c0e7743e
port wifi model to Attributes
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2350
diff
changeset
|
180 |
} |
db72c0e7743e
port wifi model to Attributes
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2350
diff
changeset
|
181 |
void |
db72c0e7743e
port wifi model to Attributes
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2350
diff
changeset
|
182 |
NqstaWifiMac::SetLinkUpCallback (Callback<void> linkUp) |
db72c0e7743e
port wifi model to Attributes
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2350
diff
changeset
|
183 |
{ |
db72c0e7743e
port wifi model to Attributes
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2350
diff
changeset
|
184 |
m_linkUp = linkUp; |
db72c0e7743e
port wifi model to Attributes
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2350
diff
changeset
|
185 |
} |
db72c0e7743e
port wifi model to Attributes
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2350
diff
changeset
|
186 |
void |
db72c0e7743e
port wifi model to Attributes
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2350
diff
changeset
|
187 |
NqstaWifiMac::SetLinkDownCallback (Callback<void> linkDown) |
db72c0e7743e
port wifi model to Attributes
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2350
diff
changeset
|
188 |
{ |
db72c0e7743e
port wifi model to Attributes
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2350
diff
changeset
|
189 |
m_linkDown = linkDown; |
db72c0e7743e
port wifi model to Attributes
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2350
diff
changeset
|
190 |
} |
db72c0e7743e
port wifi model to Attributes
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2350
diff
changeset
|
191 |
Mac48Address |
db72c0e7743e
port wifi model to Attributes
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2350
diff
changeset
|
192 |
NqstaWifiMac::GetAddress (void) const |
2009
afed751cc0b5
dynamically update the list of supported rates based on the ap supported rates
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
1964
diff
changeset
|
193 |
{ |
2524
db72c0e7743e
port wifi model to Attributes
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2350
diff
changeset
|
194 |
return m_address; |
db72c0e7743e
port wifi model to Attributes
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2350
diff
changeset
|
195 |
} |
db72c0e7743e
port wifi model to Attributes
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2350
diff
changeset
|
196 |
Ssid |
db72c0e7743e
port wifi model to Attributes
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2350
diff
changeset
|
197 |
NqstaWifiMac::GetSsid (void) const |
db72c0e7743e
port wifi model to Attributes
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2350
diff
changeset
|
198 |
{ |
db72c0e7743e
port wifi model to Attributes
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2350
diff
changeset
|
199 |
return m_ssid; |
db72c0e7743e
port wifi model to Attributes
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2350
diff
changeset
|
200 |
} |
db72c0e7743e
port wifi model to Attributes
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2350
diff
changeset
|
201 |
Mac48Address |
db72c0e7743e
port wifi model to Attributes
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2350
diff
changeset
|
202 |
NqstaWifiMac::GetBssid (void) const |
db72c0e7743e
port wifi model to Attributes
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2350
diff
changeset
|
203 |
{ |
db72c0e7743e
port wifi model to Attributes
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2350
diff
changeset
|
204 |
return m_bssid; |
db72c0e7743e
port wifi model to Attributes
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2350
diff
changeset
|
205 |
} |
db72c0e7743e
port wifi model to Attributes
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2350
diff
changeset
|
206 |
void |
db72c0e7743e
port wifi model to Attributes
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2350
diff
changeset
|
207 |
NqstaWifiMac::SetAddress (Mac48Address address) |
db72c0e7743e
port wifi model to Attributes
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2350
diff
changeset
|
208 |
{ |
db72c0e7743e
port wifi model to Attributes
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2350
diff
changeset
|
209 |
m_address = address; |
db72c0e7743e
port wifi model to Attributes
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2350
diff
changeset
|
210 |
} |
db72c0e7743e
port wifi model to Attributes
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2350
diff
changeset
|
211 |
void |
db72c0e7743e
port wifi model to Attributes
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2350
diff
changeset
|
212 |
NqstaWifiMac::SetSsid (Ssid ssid) |
db72c0e7743e
port wifi model to Attributes
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2350
diff
changeset
|
213 |
{ |
db72c0e7743e
port wifi model to Attributes
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2350
diff
changeset
|
214 |
m_ssid = ssid; |
2009
afed751cc0b5
dynamically update the list of supported rates based on the ap supported rates
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
1964
diff
changeset
|
215 |
} |
afed751cc0b5
dynamically update the list of supported rates based on the ap supported rates
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
1964
diff
changeset
|
216 |
|
afed751cc0b5
dynamically update the list of supported rates based on the ap supported rates
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
1964
diff
changeset
|
217 |
void |
2524
db72c0e7743e
port wifi model to Attributes
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2350
diff
changeset
|
218 |
NqstaWifiMac::SetMaxMissedBeacons (uint32_t missed) |
1948 | 219 |
{ |
220 |
m_maxMissedBeacons = missed; |
|
221 |
} |
|
222 |
void |
|
2524
db72c0e7743e
port wifi model to Attributes
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2350
diff
changeset
|
223 |
NqstaWifiMac::SetProbeRequestTimeout (Time timeout) |
1948 | 224 |
{ |
225 |
m_probeRequestTimeout = timeout; |
|
226 |
} |
|
227 |
void |
|
2524
db72c0e7743e
port wifi model to Attributes
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2350
diff
changeset
|
228 |
NqstaWifiMac::SetAssocRequestTimeout (Time timeout) |
1948 | 229 |
{ |
230 |
m_assocRequestTimeout = timeout; |
|
231 |
} |
|
232 |
||
233 |
void |
|
2524
db72c0e7743e
port wifi model to Attributes
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2350
diff
changeset
|
234 |
NqstaWifiMac::StartActiveAssociation (void) |
1948 | 235 |
{ |
236 |
TryToEnsureAssociated (); |
|
237 |
} |
|
238 |
||
239 |
Mac48Address |
|
2524
db72c0e7743e
port wifi model to Attributes
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2350
diff
changeset
|
240 |
NqstaWifiMac::GetBroadcastBssid (void) |
1948 | 241 |
{ |
242 |
return Mac48Address::GetBroadcast (); |
|
243 |
} |
|
244 |
||
2524
db72c0e7743e
port wifi model to Attributes
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2350
diff
changeset
|
245 |
void |
db72c0e7743e
port wifi model to Attributes
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2350
diff
changeset
|
246 |
NqstaWifiMac::SetBssid (Mac48Address bssid) |
db72c0e7743e
port wifi model to Attributes
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2350
diff
changeset
|
247 |
{ |
db72c0e7743e
port wifi model to Attributes
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2350
diff
changeset
|
248 |
m_bssid = bssid; |
db72c0e7743e
port wifi model to Attributes
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2350
diff
changeset
|
249 |
} |
db72c0e7743e
port wifi model to Attributes
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2350
diff
changeset
|
250 |
void |
2528
a527ec47b756
avoid crashing AP wifi sample
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2524
diff
changeset
|
251 |
NqstaWifiMac::SetActiveProbing (bool enable) |
a527ec47b756
avoid crashing AP wifi sample
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2524
diff
changeset
|
252 |
{ |
a527ec47b756
avoid crashing AP wifi sample
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2524
diff
changeset
|
253 |
if (enable) |
a527ec47b756
avoid crashing AP wifi sample
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2524
diff
changeset
|
254 |
{ |
a527ec47b756
avoid crashing AP wifi sample
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2524
diff
changeset
|
255 |
TryToEnsureAssociated (); |
a527ec47b756
avoid crashing AP wifi sample
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2524
diff
changeset
|
256 |
} |
a527ec47b756
avoid crashing AP wifi sample
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2524
diff
changeset
|
257 |
else |
a527ec47b756
avoid crashing AP wifi sample
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2524
diff
changeset
|
258 |
{ |
a527ec47b756
avoid crashing AP wifi sample
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2524
diff
changeset
|
259 |
m_probeRequestEvent.Cancel (); |
a527ec47b756
avoid crashing AP wifi sample
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2524
diff
changeset
|
260 |
} |
a527ec47b756
avoid crashing AP wifi sample
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2524
diff
changeset
|
261 |
} |
a527ec47b756
avoid crashing AP wifi sample
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2524
diff
changeset
|
262 |
void |
2524
db72c0e7743e
port wifi model to Attributes
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2350
diff
changeset
|
263 |
NqstaWifiMac::ForwardUp (Ptr<Packet> packet, const Mac48Address &address) |
db72c0e7743e
port wifi model to Attributes
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2350
diff
changeset
|
264 |
{ |
db72c0e7743e
port wifi model to Attributes
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2350
diff
changeset
|
265 |
m_forwardUp (packet, address); |
db72c0e7743e
port wifi model to Attributes
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2350
diff
changeset
|
266 |
} |
1948 | 267 |
void |
2524
db72c0e7743e
port wifi model to Attributes
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2350
diff
changeset
|
268 |
NqstaWifiMac::SendProbeRequest (void) |
1948 | 269 |
{ |
270 |
TRACE ("send probe request"); |
|
271 |
WifiMacHeader hdr; |
|
272 |
hdr.SetProbeReq (); |
|
273 |
hdr.SetAddr1 (GetBroadcastBssid ()); |
|
2524
db72c0e7743e
port wifi model to Attributes
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2350
diff
changeset
|
274 |
hdr.SetAddr2 (GetAddress ()); |
1948 | 275 |
hdr.SetAddr3 (GetBroadcastBssid ()); |
276 |
hdr.SetDsNotFrom (); |
|
277 |
hdr.SetDsNotTo (); |
|
2159
20f882e85b4a
port to Ptr<Packet> branch
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2156
diff
changeset
|
278 |
Ptr<Packet> packet = Create<Packet> (); |
1948 | 279 |
MgtProbeRequestHeader probe; |
2524
db72c0e7743e
port wifi model to Attributes
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2350
diff
changeset
|
280 |
probe.SetSsid (GetSsid ()); |
2009
afed751cc0b5
dynamically update the list of supported rates based on the ap supported rates
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
1964
diff
changeset
|
281 |
probe.SetSupportedRates (GetSupportedRates ()); |
2159
20f882e85b4a
port to Ptr<Packet> branch
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2156
diff
changeset
|
282 |
packet->AddHeader (probe); |
1948 | 283 |
|
284 |
m_dca->Queue (packet, hdr); |
|
285 |
||
286 |
m_probeRequestEvent = Simulator::Schedule (m_probeRequestTimeout, |
|
2524
db72c0e7743e
port wifi model to Attributes
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2350
diff
changeset
|
287 |
&NqstaWifiMac::ProbeRequestTimeout, this); |
1948 | 288 |
} |
289 |
||
290 |
void |
|
2524
db72c0e7743e
port wifi model to Attributes
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2350
diff
changeset
|
291 |
NqstaWifiMac::SendAssociationRequest (void) |
1948 | 292 |
{ |
2012
54dd9789c670
enable logging
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2009
diff
changeset
|
293 |
TRACE ("send assoc request to=" << GetBssid ()); |
1948 | 294 |
WifiMacHeader hdr; |
295 |
hdr.SetAssocReq (); |
|
296 |
hdr.SetAddr1 (GetBssid ()); |
|
2524
db72c0e7743e
port wifi model to Attributes
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2350
diff
changeset
|
297 |
hdr.SetAddr2 (GetAddress ()); |
1948 | 298 |
hdr.SetAddr3 (GetBssid ()); |
299 |
hdr.SetDsNotFrom (); |
|
300 |
hdr.SetDsNotTo (); |
|
2159
20f882e85b4a
port to Ptr<Packet> branch
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2156
diff
changeset
|
301 |
Ptr<Packet> packet = Create<Packet> (); |
1948 | 302 |
MgtAssocRequestHeader assoc; |
2524
db72c0e7743e
port wifi model to Attributes
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2350
diff
changeset
|
303 |
assoc.SetSsid (GetSsid ()); |
2009
afed751cc0b5
dynamically update the list of supported rates based on the ap supported rates
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
1964
diff
changeset
|
304 |
assoc.SetSupportedRates (GetSupportedRates ()); |
2159
20f882e85b4a
port to Ptr<Packet> branch
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2156
diff
changeset
|
305 |
packet->AddHeader (assoc); |
1948 | 306 |
|
307 |
m_dca->Queue (packet, hdr); |
|
308 |
||
309 |
m_assocRequestEvent = Simulator::Schedule (m_assocRequestTimeout, |
|
2524
db72c0e7743e
port wifi model to Attributes
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2350
diff
changeset
|
310 |
&NqstaWifiMac::AssocRequestTimeout, this); |
1948 | 311 |
} |
312 |
void |
|
2524
db72c0e7743e
port wifi model to Attributes
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2350
diff
changeset
|
313 |
NqstaWifiMac::TryToEnsureAssociated (void) |
1948 | 314 |
{ |
315 |
switch (m_state) { |
|
316 |
case ASSOCIATED: |
|
317 |
return; |
|
318 |
break; |
|
319 |
case WAIT_PROBE_RESP: |
|
320 |
/* we have sent a probe request earlier so we |
|
321 |
do not need to re-send a probe request immediately. |
|
322 |
We just need to wait until probe-request-timeout |
|
323 |
or until we get a probe response |
|
324 |
*/ |
|
325 |
break; |
|
326 |
case BEACON_MISSED: |
|
327 |
/* we were associated but we missed a bunch of beacons |
|
328 |
* so we should assume we are not associated anymore. |
|
329 |
* We try to initiate a probe request now. |
|
330 |
*/ |
|
2524
db72c0e7743e
port wifi model to Attributes
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2350
diff
changeset
|
331 |
m_linkDown (); |
1948 | 332 |
m_state = WAIT_PROBE_RESP; |
333 |
SendProbeRequest (); |
|
334 |
break; |
|
335 |
case WAIT_ASSOC_RESP: |
|
336 |
/* we have sent an assoc request so we do not need to |
|
337 |
re-send an assoc request right now. We just need to |
|
338 |
wait until either assoc-request-timeout or until |
|
339 |
we get an assoc response. |
|
340 |
*/ |
|
341 |
break; |
|
342 |
case REFUSED: |
|
343 |
/* we have sent an assoc request and received a negative |
|
344 |
assoc resp. We wait until someone restarts an |
|
345 |
association with a given ssid. |
|
346 |
*/ |
|
347 |
break; |
|
348 |
} |
|
349 |
} |
|
350 |
||
351 |
void |
|
2524
db72c0e7743e
port wifi model to Attributes
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2350
diff
changeset
|
352 |
NqstaWifiMac::AssocRequestTimeout (void) |
1948 | 353 |
{ |
354 |
TRACE ("assoc request timeout"); |
|
355 |
m_state = WAIT_ASSOC_RESP; |
|
356 |
SendAssociationRequest (); |
|
357 |
} |
|
358 |
void |
|
2524
db72c0e7743e
port wifi model to Attributes
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2350
diff
changeset
|
359 |
NqstaWifiMac::ProbeRequestTimeout (void) |
1948 | 360 |
{ |
361 |
TRACE ("probe request timeout"); |
|
362 |
m_state = WAIT_PROBE_RESP; |
|
363 |
SendProbeRequest (); |
|
364 |
} |
|
365 |
void |
|
2524
db72c0e7743e
port wifi model to Attributes
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2350
diff
changeset
|
366 |
NqstaWifiMac::MissedBeacons (void) |
1948 | 367 |
{ |
1952
2ad2630756e3
do not use the Watchdog class
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
1951
diff
changeset
|
368 |
if (m_beaconWatchdogEnd > Simulator::Now ()) |
2ad2630756e3
do not use the Watchdog class
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
1951
diff
changeset
|
369 |
{ |
2090
3622fda1717b
calculate the delay, not -delay.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2054
diff
changeset
|
370 |
m_beaconWatchdog = Simulator::Schedule (m_beaconWatchdogEnd - Simulator::Now (), |
2524
db72c0e7743e
port wifi model to Attributes
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2350
diff
changeset
|
371 |
&NqstaWifiMac::MissedBeacons, this); |
1952
2ad2630756e3
do not use the Watchdog class
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
1951
diff
changeset
|
372 |
return; |
2ad2630756e3
do not use the Watchdog class
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
1951
diff
changeset
|
373 |
} |
2156
754a843db672
improve log output
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2090
diff
changeset
|
374 |
TRACE ("beacon missed"); |
1948 | 375 |
m_state = BEACON_MISSED; |
2156
754a843db672
improve log output
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2090
diff
changeset
|
376 |
TryToEnsureAssociated (); |
1948 | 377 |
} |
1952
2ad2630756e3
do not use the Watchdog class
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
1951
diff
changeset
|
378 |
void |
2524
db72c0e7743e
port wifi model to Attributes
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2350
diff
changeset
|
379 |
NqstaWifiMac::RestartBeaconWatchdog (Time delay) |
1952
2ad2630756e3
do not use the Watchdog class
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
1951
diff
changeset
|
380 |
{ |
2ad2630756e3
do not use the Watchdog class
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
1951
diff
changeset
|
381 |
m_beaconWatchdogEnd = std::max (Simulator::Now () + delay, m_beaconWatchdogEnd); |
2ad2630756e3
do not use the Watchdog class
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
1951
diff
changeset
|
382 |
if (Simulator::GetDelayLeft (m_beaconWatchdog) < delay && |
2ad2630756e3
do not use the Watchdog class
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
1951
diff
changeset
|
383 |
m_beaconWatchdog.IsExpired ()) |
2ad2630756e3
do not use the Watchdog class
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
1951
diff
changeset
|
384 |
{ |
2524
db72c0e7743e
port wifi model to Attributes
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2350
diff
changeset
|
385 |
m_beaconWatchdog = Simulator::Schedule (delay, &NqstaWifiMac::MissedBeacons, this); |
1952
2ad2630756e3
do not use the Watchdog class
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
1951
diff
changeset
|
386 |
} |
2ad2630756e3
do not use the Watchdog class
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
1951
diff
changeset
|
387 |
} |
1948 | 388 |
bool |
2524
db72c0e7743e
port wifi model to Attributes
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2350
diff
changeset
|
389 |
NqstaWifiMac::IsAssociated (void) |
1948 | 390 |
{ |
391 |
return (m_state == ASSOCIATED)?true:false; |
|
392 |
} |
|
393 |
||
394 |
void |
|
2524
db72c0e7743e
port wifi model to Attributes
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2350
diff
changeset
|
395 |
NqstaWifiMac::Enqueue (Ptr<const Packet> packet, Mac48Address to) |
1948 | 396 |
{ |
397 |
if (!IsAssociated ()) |
|
398 |
{ |
|
399 |
TryToEnsureAssociated (); |
|
400 |
return; |
|
401 |
} |
|
2159
20f882e85b4a
port to Ptr<Packet> branch
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2156
diff
changeset
|
402 |
//TRACE ("enqueue size="<<packet->GetSize ()<<", to="<<to); |
1948 | 403 |
WifiMacHeader hdr; |
404 |
hdr.SetTypeData (); |
|
405 |
hdr.SetAddr1 (GetBssid ()); |
|
2524
db72c0e7743e
port wifi model to Attributes
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2350
diff
changeset
|
406 |
hdr.SetAddr2 (GetAddress ()); |
1948 | 407 |
hdr.SetAddr3 (to); |
408 |
hdr.SetDsNotFrom (); |
|
409 |
hdr.SetDsTo (); |
|
410 |
m_dca->Queue (packet, hdr); |
|
411 |
} |
|
412 |
||
413 |
void |
|
2524
db72c0e7743e
port wifi model to Attributes
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2350
diff
changeset
|
414 |
NqstaWifiMac::Receive (Ptr<Packet> packet, WifiMacHeader const *hdr) |
1948 | 415 |
{ |
416 |
NS_ASSERT (!hdr->IsCtl ()); |
|
2524
db72c0e7743e
port wifi model to Attributes
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2350
diff
changeset
|
417 |
if (hdr->GetAddr1 () != GetAddress () && |
1948 | 418 |
!hdr->GetAddr1 ().IsBroadcast ()) |
419 |
{ |
|
420 |
// packet is not for us |
|
421 |
} |
|
422 |
else if (hdr->IsData ()) |
|
423 |
{ |
|
2524
db72c0e7743e
port wifi model to Attributes
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2350
diff
changeset
|
424 |
ForwardUp (packet, hdr->GetAddr2 ()); |
1948 | 425 |
} |
426 |
else if (hdr->IsProbeReq () || |
|
427 |
hdr->IsAssocReq ()) |
|
428 |
{ |
|
429 |
/* this is a frame aimed at an AP. |
|
430 |
* so we can safely ignore it. |
|
431 |
*/ |
|
432 |
} |
|
433 |
else if (hdr->IsBeacon ()) |
|
434 |
{ |
|
435 |
MgtBeaconHeader beacon; |
|
2159
20f882e85b4a
port to Ptr<Packet> branch
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2156
diff
changeset
|
436 |
packet->RemoveHeader (beacon); |
1948 | 437 |
bool goodBeacon = false; |
2524
db72c0e7743e
port wifi model to Attributes
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2350
diff
changeset
|
438 |
if (GetSsid ().IsBroadcast () || |
db72c0e7743e
port wifi model to Attributes
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2350
diff
changeset
|
439 |
beacon.GetSsid ().IsEqual (GetSsid ())) |
1948 | 440 |
{ |
441 |
Time delay = MicroSeconds (beacon.GetBeaconIntervalUs () * m_maxMissedBeacons); |
|
1952
2ad2630756e3
do not use the Watchdog class
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
1951
diff
changeset
|
442 |
RestartBeaconWatchdog (delay); |
1948 | 443 |
goodBeacon = true; |
444 |
} |
|
445 |
if (goodBeacon) |
|
446 |
{ |
|
447 |
SetBssid (hdr->GetAddr3 ()); |
|
448 |
} |
|
2009
afed751cc0b5
dynamically update the list of supported rates based on the ap supported rates
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
1964
diff
changeset
|
449 |
if (goodBeacon && m_state == BEACON_MISSED) |
afed751cc0b5
dynamically update the list of supported rates based on the ap supported rates
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
1964
diff
changeset
|
450 |
{ |
afed751cc0b5
dynamically update the list of supported rates based on the ap supported rates
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
1964
diff
changeset
|
451 |
m_state = WAIT_ASSOC_RESP; |
afed751cc0b5
dynamically update the list of supported rates based on the ap supported rates
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
1964
diff
changeset
|
452 |
SendAssociationRequest (); |
afed751cc0b5
dynamically update the list of supported rates based on the ap supported rates
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
1964
diff
changeset
|
453 |
} |
1948 | 454 |
} |
455 |
else if (hdr->IsProbeResp ()) |
|
456 |
{ |
|
457 |
if (m_state == WAIT_PROBE_RESP) |
|
458 |
{ |
|
459 |
MgtProbeResponseHeader probeResp; |
|
2159
20f882e85b4a
port to Ptr<Packet> branch
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2156
diff
changeset
|
460 |
packet->RemoveHeader (probeResp); |
2524
db72c0e7743e
port wifi model to Attributes
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2350
diff
changeset
|
461 |
if (!probeResp.GetSsid ().IsEqual (GetSsid ())) |
1948 | 462 |
{ |
463 |
//not a probe resp for our ssid. |
|
464 |
return; |
|
465 |
} |
|
466 |
SetBssid (hdr->GetAddr3 ()); |
|
467 |
Time delay = MicroSeconds (probeResp.GetBeaconIntervalUs () * m_maxMissedBeacons); |
|
1952
2ad2630756e3
do not use the Watchdog class
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
1951
diff
changeset
|
468 |
RestartBeaconWatchdog (delay); |
1948 | 469 |
if (m_probeRequestEvent.IsRunning ()) |
470 |
{ |
|
471 |
m_probeRequestEvent.Cancel (); |
|
472 |
} |
|
473 |
m_state = WAIT_ASSOC_RESP; |
|
474 |
SendAssociationRequest (); |
|
475 |
} |
|
476 |
} |
|
477 |
else if (hdr->IsAssocResp ()) |
|
478 |
{ |
|
479 |
if (m_state == WAIT_ASSOC_RESP) |
|
480 |
{ |
|
481 |
MgtAssocResponseHeader assocResp; |
|
2159
20f882e85b4a
port to Ptr<Packet> branch
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2156
diff
changeset
|
482 |
packet->RemoveHeader (assocResp); |
1948 | 483 |
if (m_assocRequestEvent.IsRunning ()) |
484 |
{ |
|
485 |
m_assocRequestEvent.Cancel (); |
|
486 |
} |
|
487 |
if (assocResp.GetStatusCode ().IsSuccess ()) |
|
488 |
{ |
|
489 |
m_state = ASSOCIATED; |
|
490 |
TRACE ("assoc completed"); |
|
2009
afed751cc0b5
dynamically update the list of supported rates based on the ap supported rates
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
1964
diff
changeset
|
491 |
SupportedRates rates = assocResp.GetSupportedRates (); |
2524
db72c0e7743e
port wifi model to Attributes
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2350
diff
changeset
|
492 |
WifiRemoteStation *ap = m_stationManager->Lookup (hdr->GetAddr2 ()); |
2009
afed751cc0b5
dynamically update the list of supported rates based on the ap supported rates
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
1964
diff
changeset
|
493 |
for (uint32_t i = 0; i < m_phy->GetNModes (); i++) |
afed751cc0b5
dynamically update the list of supported rates based on the ap supported rates
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
1964
diff
changeset
|
494 |
{ |
afed751cc0b5
dynamically update the list of supported rates based on the ap supported rates
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
1964
diff
changeset
|
495 |
WifiMode mode = m_phy->GetMode (i); |
2164
6e347fdbfa4a
avoid confusion between code and uncoded rates.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2159
diff
changeset
|
496 |
if (rates.IsSupportedRate (mode.GetDataRate ())) |
2009
afed751cc0b5
dynamically update the list of supported rates based on the ap supported rates
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
1964
diff
changeset
|
497 |
{ |
afed751cc0b5
dynamically update the list of supported rates based on the ap supported rates
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
1964
diff
changeset
|
498 |
ap->AddSupportedMode (mode); |
2164
6e347fdbfa4a
avoid confusion between code and uncoded rates.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2159
diff
changeset
|
499 |
if (rates.IsBasicRate (mode.GetDataRate ())) |
2009
afed751cc0b5
dynamically update the list of supported rates based on the ap supported rates
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
1964
diff
changeset
|
500 |
{ |
2524
db72c0e7743e
port wifi model to Attributes
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2350
diff
changeset
|
501 |
m_stationManager->AddBasicMode (mode); |
2009
afed751cc0b5
dynamically update the list of supported rates based on the ap supported rates
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
1964
diff
changeset
|
502 |
} |
afed751cc0b5
dynamically update the list of supported rates based on the ap supported rates
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
1964
diff
changeset
|
503 |
} |
afed751cc0b5
dynamically update the list of supported rates based on the ap supported rates
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
1964
diff
changeset
|
504 |
} |
2528
a527ec47b756
avoid crashing AP wifi sample
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2524
diff
changeset
|
505 |
if (!m_linkUp.IsNull ()) |
a527ec47b756
avoid crashing AP wifi sample
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2524
diff
changeset
|
506 |
{ |
a527ec47b756
avoid crashing AP wifi sample
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2524
diff
changeset
|
507 |
m_linkUp (); |
a527ec47b756
avoid crashing AP wifi sample
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2524
diff
changeset
|
508 |
} |
1948 | 509 |
} |
510 |
else |
|
511 |
{ |
|
512 |
TRACE ("assoc refused"); |
|
513 |
m_state = REFUSED; |
|
514 |
} |
|
515 |
} |
|
516 |
} |
|
517 |
} |
|
518 |
||
2009
afed751cc0b5
dynamically update the list of supported rates based on the ap supported rates
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
1964
diff
changeset
|
519 |
SupportedRates |
2524
db72c0e7743e
port wifi model to Attributes
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2350
diff
changeset
|
520 |
NqstaWifiMac::GetSupportedRates (void) const |
2009
afed751cc0b5
dynamically update the list of supported rates based on the ap supported rates
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
1964
diff
changeset
|
521 |
{ |
afed751cc0b5
dynamically update the list of supported rates based on the ap supported rates
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
1964
diff
changeset
|
522 |
SupportedRates rates; |
afed751cc0b5
dynamically update the list of supported rates based on the ap supported rates
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
1964
diff
changeset
|
523 |
for (uint32_t i = 0; i < m_phy->GetNModes (); i++) |
afed751cc0b5
dynamically update the list of supported rates based on the ap supported rates
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
1964
diff
changeset
|
524 |
{ |
afed751cc0b5
dynamically update the list of supported rates based on the ap supported rates
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
1964
diff
changeset
|
525 |
WifiMode mode = m_phy->GetMode (i); |
2164
6e347fdbfa4a
avoid confusion between code and uncoded rates.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2159
diff
changeset
|
526 |
rates.AddSupportedRate (mode.GetDataRate ()); |
2009
afed751cc0b5
dynamically update the list of supported rates based on the ap supported rates
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
1964
diff
changeset
|
527 |
} |
afed751cc0b5
dynamically update the list of supported rates based on the ap supported rates
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
1964
diff
changeset
|
528 |
return rates; |
afed751cc0b5
dynamically update the list of supported rates based on the ap supported rates
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
1964
diff
changeset
|
529 |
} |
afed751cc0b5
dynamically update the list of supported rates based on the ap supported rates
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
1964
diff
changeset
|
530 |
|
1948 | 531 |
} // namespace ns3 |