author | Mathieu Lacage <mathieu.lacage@sophia.inria.fr> |
Tue, 02 Sep 2008 12:00:11 -0700 | |
changeset 3596 | 6c39b712a535 |
parent 3543 | 04315a10b9c1 |
child 3597 | fe35e5be4b78 |
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 |
*/ |
|
2524
db72c0e7743e
port wifi model to Attributes
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2350
diff
changeset
|
20 |
#ifndef NQSTA_WIFI_MAC_H |
db72c0e7743e
port wifi model to Attributes
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2350
diff
changeset
|
21 |
#define NQSTA_WIFI_MAC_H |
1948 | 22 |
|
23 |
#include <stdint.h> |
|
24 |
||
25 |
#include "ns3/mac48-address.h" |
|
26 |
#include "ns3/callback.h" |
|
27 |
#include "ns3/event-id.h" |
|
28 |
#include "ns3/packet.h" |
|
29 |
#include "ns3/nstime.h" |
|
30 |
||
2524
db72c0e7743e
port wifi model to Attributes
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2350
diff
changeset
|
31 |
#include "wifi-mac.h" |
1948 | 32 |
#include "supported-rates.h" |
33 |
||
34 |
namespace ns3 { |
|
35 |
||
36 |
class WifiMacHeader; |
|
37 |
class DcaTxop; |
|
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
|
38 |
class WifiPhy; |
2524
db72c0e7743e
port wifi model to Attributes
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2350
diff
changeset
|
39 |
class DcfManager; |
db72c0e7743e
port wifi model to Attributes
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2350
diff
changeset
|
40 |
class MacLow; |
db72c0e7743e
port wifi model to Attributes
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2350
diff
changeset
|
41 |
class MacRxMiddle; |
1948 | 42 |
|
2285 | 43 |
/** |
44 |
* \brief a non-QoS STA state machine |
|
45 |
* |
|
46 |
* This state machine handles association, disassociation, |
|
47 |
* authentication and beacon monitoring. It does not perform |
|
48 |
* channel scanning. |
|
49 |
* If the station detects a certain number of missed beacons |
|
50 |
* while associated, it automatically attempts a new association |
|
51 |
* sequence. |
|
52 |
*/ |
|
2524
db72c0e7743e
port wifi model to Attributes
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2350
diff
changeset
|
53 |
class NqstaWifiMac : public WifiMac |
db72c0e7743e
port wifi model to Attributes
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2350
diff
changeset
|
54 |
{ |
1948 | 55 |
public: |
2524
db72c0e7743e
port wifi model to Attributes
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2350
diff
changeset
|
56 |
static TypeId GetTypeId (void); |
db72c0e7743e
port wifi model to Attributes
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2350
diff
changeset
|
57 |
|
db72c0e7743e
port wifi model to Attributes
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2350
diff
changeset
|
58 |
NqstaWifiMac (); |
db72c0e7743e
port wifi model to Attributes
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2350
diff
changeset
|
59 |
~NqstaWifiMac (); |
1948 | 60 |
|
2684
68c643329c2b
improve doxygen
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2617
diff
changeset
|
61 |
// inherited from WifiMac. |
2528
a527ec47b756
avoid crashing AP wifi sample
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2524
diff
changeset
|
62 |
virtual void SetSlot (Time slotTime); |
a527ec47b756
avoid crashing AP wifi sample
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2524
diff
changeset
|
63 |
virtual void SetSifs (Time sifs); |
a527ec47b756
avoid crashing AP wifi sample
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2524
diff
changeset
|
64 |
virtual void SetEifsNoDifs (Time eifsNoDifs); |
3596
6c39b712a535
move Address and ack timeout down to MacLow
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
3543
diff
changeset
|
65 |
virtual void SetAckTimeout (Time ackTimeout); |
2686 | 66 |
virtual Time GetSlot (void) const; |
67 |
virtual Time GetSifs (void) const; |
|
68 |
virtual Time GetEifsNoDifs (void) const; |
|
3596
6c39b712a535
move Address and ack timeout down to MacLow
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
3543
diff
changeset
|
69 |
virtual Time GetAckTimeout (void) const; |
2524
db72c0e7743e
port wifi model to Attributes
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2350
diff
changeset
|
70 |
virtual void SetWifiPhy (Ptr<WifiPhy> phy); |
db72c0e7743e
port wifi model to Attributes
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2350
diff
changeset
|
71 |
virtual void SetWifiRemoteStationManager (Ptr<WifiRemoteStationManager> stationManager); |
3517
5ba130a7f519
implement WifiNetDevice::SendFrom
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2686
diff
changeset
|
72 |
virtual void Enqueue (Ptr<const Packet> packet, Mac48Address to, Mac48Address from); |
2524
db72c0e7743e
port wifi model to Attributes
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2350
diff
changeset
|
73 |
virtual void 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
|
74 |
virtual void SetLinkUpCallback (Callback<void> linkUp); |
db72c0e7743e
port wifi model to Attributes
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2350
diff
changeset
|
75 |
virtual void SetLinkDownCallback (Callback<void> linkDown); |
db72c0e7743e
port wifi model to Attributes
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2350
diff
changeset
|
76 |
virtual Mac48Address GetAddress (void) const; |
db72c0e7743e
port wifi model to Attributes
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2350
diff
changeset
|
77 |
virtual Ssid GetSsid (void) const; |
db72c0e7743e
port wifi model to Attributes
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2350
diff
changeset
|
78 |
virtual Mac48Address GetBssid (void) const; |
db72c0e7743e
port wifi model to Attributes
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2350
diff
changeset
|
79 |
virtual void SetAddress (Mac48Address address); |
db72c0e7743e
port wifi model to Attributes
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2350
diff
changeset
|
80 |
virtual void SetSsid (Ssid ssid); |
1948 | 81 |
|
82 |
||
2285 | 83 |
/** |
84 |
* \param missed the number of beacons which must be missed |
|
85 |
* before a new association sequence is started. |
|
86 |
*/ |
|
1948 | 87 |
void SetMaxMissedBeacons (uint32_t missed); |
2285 | 88 |
/** |
89 |
* \param timeout |
|
90 |
* |
|
91 |
* If no probe response is received within the specified |
|
92 |
* timeout, the station sends a new probe request. |
|
93 |
*/ |
|
1948 | 94 |
void SetProbeRequestTimeout (Time timeout); |
2285 | 95 |
/** |
96 |
* \param timeout |
|
97 |
* |
|
98 |
* If no association response is received within the specified |
|
99 |
* timeout, the station sends a new association request. |
|
100 |
*/ |
|
1948 | 101 |
void SetAssocRequestTimeout (Time timeout); |
102 |
||
2285 | 103 |
/** |
104 |
* Start an active association sequence immediately. |
|
105 |
*/ |
|
1948 | 106 |
void StartActiveAssociation (void); |
107 |
||
108 |
private: |
|
109 |
void SetBssid (Mac48Address bssid); |
|
2528
a527ec47b756
avoid crashing AP wifi sample
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2524
diff
changeset
|
110 |
void SetActiveProbing (bool enable); |
a527ec47b756
avoid crashing AP wifi sample
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2524
diff
changeset
|
111 |
bool GetActiveProbing (void) const; |
2524
db72c0e7743e
port wifi model to Attributes
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2350
diff
changeset
|
112 |
void ForwardUp (Ptr<Packet> packet, const Mac48Address &address); |
db72c0e7743e
port wifi model to Attributes
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2350
diff
changeset
|
113 |
void Receive (Ptr<Packet> packet, WifiMacHeader const *hdr); |
1948 | 114 |
Mac48Address GetBroadcastBssid (void); |
115 |
void SendProbeRequest (void); |
|
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
|
116 |
void SendAssociationRequest (void); |
1948 | 117 |
void TryToEnsureAssociated (void); |
118 |
void AssocRequestTimeout (void); |
|
119 |
void ProbeRequestTimeout (void); |
|
120 |
bool IsAssociated (void); |
|
121 |
void MissedBeacons (void); |
|
1952
2ad2630756e3
do not use the Watchdog class
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
1948
diff
changeset
|
122 |
void RestartBeaconWatchdog (Time delay); |
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
|
123 |
SupportedRates GetSupportedRates (void) const; |
2524
db72c0e7743e
port wifi model to Attributes
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2350
diff
changeset
|
124 |
virtual void DoDispose (void); |
3543
04315a10b9c1
Make copy constructors of some wifi classes private so that pybindgen won't use them (they are not usable)
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
3517
diff
changeset
|
125 |
NqstaWifiMac (const NqstaWifiMac & ctor_arg); |
2524
db72c0e7743e
port wifi model to Attributes
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2350
diff
changeset
|
126 |
|
1948 | 127 |
enum { |
128 |
ASSOCIATED, |
|
129 |
WAIT_PROBE_RESP, |
|
130 |
WAIT_ASSOC_RESP, |
|
131 |
BEACON_MISSED, |
|
132 |
REFUSED |
|
133 |
} m_state; |
|
134 |
Time m_probeRequestTimeout; |
|
135 |
Time m_assocRequestTimeout; |
|
136 |
EventId m_probeRequestEvent; |
|
137 |
EventId m_assocRequestEvent; |
|
2524
db72c0e7743e
port wifi model to Attributes
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2350
diff
changeset
|
138 |
Callback<void, Ptr<Packet>,const Mac48Address &> m_forwardUp; |
db72c0e7743e
port wifi model to Attributes
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2350
diff
changeset
|
139 |
Callback<void> m_linkUp; |
db72c0e7743e
port wifi model to Attributes
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2350
diff
changeset
|
140 |
Callback<void> m_linkDown; |
2350
0b54480c4fd1
Hook trace sources into the trace system. Add WifiTrace to give a 'simple' API to tracing wifi-specific sources.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2285
diff
changeset
|
141 |
Ptr<DcaTxop> m_dca; |
1952
2ad2630756e3
do not use the Watchdog class
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
1948
diff
changeset
|
142 |
EventId m_beaconWatchdog; |
2ad2630756e3
do not use the Watchdog class
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
1948
diff
changeset
|
143 |
Time m_beaconWatchdogEnd; |
1948 | 144 |
Mac48Address m_bssid; |
145 |
uint32_t m_maxMissedBeacons; |
|
2524
db72c0e7743e
port wifi model to Attributes
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2350
diff
changeset
|
146 |
|
2054
ba8e810bae4c
derive WifiPhy from Object and manage it with a Ptr<>
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2009
diff
changeset
|
147 |
Ptr<WifiPhy> m_phy; |
2524
db72c0e7743e
port wifi model to Attributes
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2350
diff
changeset
|
148 |
Ptr<WifiRemoteStationManager> m_stationManager; |
db72c0e7743e
port wifi model to Attributes
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2350
diff
changeset
|
149 |
DcfManager *m_dcfManager; |
db72c0e7743e
port wifi model to Attributes
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2350
diff
changeset
|
150 |
MacRxMiddle *m_rxMiddle; |
2617
0ecb3a9422e4
avoid double-frees.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2528
diff
changeset
|
151 |
Ptr<MacLow> m_low; |
2524
db72c0e7743e
port wifi model to Attributes
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2350
diff
changeset
|
152 |
Mac48Address m_address; |
db72c0e7743e
port wifi model to Attributes
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2350
diff
changeset
|
153 |
Ssid m_ssid; |
2686 | 154 |
Time m_slot; |
155 |
Time m_sifs; |
|
156 |
Time m_eifsNoDifs; |
|
1948 | 157 |
}; |
158 |
||
159 |
} // namespace ns3 |
|
160 |
||
161 |
||
2524
db72c0e7743e
port wifi model to Attributes
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2350
diff
changeset
|
162 |
#endif /* NQSTA_WIFI_MAC_H */ |