author | Pavel Boyko <boyko@iitp.ru> |
Tue, 16 Jun 2009 17:58:16 +0400 | |
changeset 5074 | 355de6af8ea9 |
parent 4461 | ab9b58d664d7 |
child 4609 | 6ec902d6af68 |
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" |
|
4212
a21c19c4cd81
bug 487: add association/disassociation hooks in Nqsta.
Francesco Malandrino <francesco.malandrino@gmail.com>
parents:
4209
diff
changeset
|
30 |
#include "ns3/traced-callback.h" |
1948 | 31 |
|
2524
db72c0e7743e
port wifi model to Attributes
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2350
diff
changeset
|
32 |
#include "wifi-mac.h" |
1948 | 33 |
#include "supported-rates.h" |
34 |
||
35 |
namespace ns3 { |
|
36 |
||
37 |
class WifiMacHeader; |
|
38 |
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
|
39 |
class WifiPhy; |
2524
db72c0e7743e
port wifi model to Attributes
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2350
diff
changeset
|
40 |
class DcfManager; |
db72c0e7743e
port wifi model to Attributes
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2350
diff
changeset
|
41 |
class MacLow; |
db72c0e7743e
port wifi model to Attributes
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2350
diff
changeset
|
42 |
class MacRxMiddle; |
1948 | 43 |
|
2285 | 44 |
/** |
45 |
* \brief a non-QoS STA state machine |
|
46 |
* |
|
47 |
* This state machine handles association, disassociation, |
|
48 |
* authentication and beacon monitoring. It does not perform |
|
49 |
* channel scanning. |
|
50 |
* If the station detects a certain number of missed beacons |
|
51 |
* while associated, it automatically attempts a new association |
|
52 |
* sequence. |
|
53 |
*/ |
|
2524
db72c0e7743e
port wifi model to Attributes
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2350
diff
changeset
|
54 |
class NqstaWifiMac : public WifiMac |
db72c0e7743e
port wifi model to Attributes
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2350
diff
changeset
|
55 |
{ |
1948 | 56 |
public: |
2524
db72c0e7743e
port wifi model to Attributes
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2350
diff
changeset
|
57 |
static TypeId GetTypeId (void); |
db72c0e7743e
port wifi model to Attributes
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2350
diff
changeset
|
58 |
|
db72c0e7743e
port wifi model to Attributes
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2350
diff
changeset
|
59 |
NqstaWifiMac (); |
db72c0e7743e
port wifi model to Attributes
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2350
diff
changeset
|
60 |
~NqstaWifiMac (); |
1948 | 61 |
|
2684
68c643329c2b
improve doxygen
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2617
diff
changeset
|
62 |
// inherited from WifiMac. |
2528
a527ec47b756
avoid crashing AP wifi sample
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2524
diff
changeset
|
63 |
virtual void SetSlot (Time slotTime); |
a527ec47b756
avoid crashing AP wifi sample
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2524
diff
changeset
|
64 |
virtual void SetSifs (Time sifs); |
a527ec47b756
avoid crashing AP wifi sample
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2524
diff
changeset
|
65 |
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
|
66 |
virtual void SetAckTimeout (Time ackTimeout); |
3597
fe35e5be4b78
move cts timeout down to MacLow
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
3596
diff
changeset
|
67 |
virtual void SetCtsTimeout (Time ctsTimeout); |
3599
721bd46c15f8
move slot and pifs down to MacLow
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
3598
diff
changeset
|
68 |
virtual void SetPifs (Time pifs); |
2686 | 69 |
virtual Time GetSlot (void) const; |
70 |
virtual Time GetSifs (void) const; |
|
71 |
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
|
72 |
virtual Time GetAckTimeout (void) const; |
3597
fe35e5be4b78
move cts timeout down to MacLow
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
3596
diff
changeset
|
73 |
virtual Time GetCtsTimeout (void) const; |
3599
721bd46c15f8
move slot and pifs down to MacLow
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
3598
diff
changeset
|
74 |
virtual Time GetPifs (void) const; |
2524
db72c0e7743e
port wifi model to Attributes
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2350
diff
changeset
|
75 |
virtual void SetWifiPhy (Ptr<WifiPhy> phy); |
db72c0e7743e
port wifi model to Attributes
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2350
diff
changeset
|
76 |
virtual void SetWifiRemoteStationManager (Ptr<WifiRemoteStationManager> stationManager); |
3517
5ba130a7f519
implement WifiNetDevice::SendFrom
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2686
diff
changeset
|
77 |
virtual void Enqueue (Ptr<const Packet> packet, Mac48Address to, Mac48Address from); |
3602
e8e41feee205
implement SendFrom correctly
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
3600
diff
changeset
|
78 |
virtual void Enqueue (Ptr<const Packet> packet, Mac48Address to); |
3603
da21b3e410b6
implement SupportsSendFrom
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
3602
diff
changeset
|
79 |
virtual bool SupportsSendFrom (void) const; |
3604
a84d99890289
implement promisc mode
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
3603
diff
changeset
|
80 |
virtual void SetForwardUpCallback (Callback<void,Ptr<Packet>, Mac48Address, Mac48Address> upCallback); |
2524
db72c0e7743e
port wifi model to Attributes
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2350
diff
changeset
|
81 |
virtual void SetLinkUpCallback (Callback<void> linkUp); |
db72c0e7743e
port wifi model to Attributes
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2350
diff
changeset
|
82 |
virtual void SetLinkDownCallback (Callback<void> linkDown); |
db72c0e7743e
port wifi model to Attributes
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2350
diff
changeset
|
83 |
virtual Mac48Address GetAddress (void) const; |
db72c0e7743e
port wifi model to Attributes
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2350
diff
changeset
|
84 |
virtual Ssid GetSsid (void) const; |
db72c0e7743e
port wifi model to Attributes
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2350
diff
changeset
|
85 |
virtual void SetAddress (Mac48Address address); |
db72c0e7743e
port wifi model to Attributes
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2350
diff
changeset
|
86 |
virtual void SetSsid (Ssid ssid); |
3736
9819ffe46a68
bug 361: make GetBssid public.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
3725
diff
changeset
|
87 |
virtual Mac48Address GetBssid (void) const; |
1948 | 88 |
|
2285 | 89 |
/** |
90 |
* \param missed the number of beacons which must be missed |
|
91 |
* before a new association sequence is started. |
|
92 |
*/ |
|
1948 | 93 |
void SetMaxMissedBeacons (uint32_t missed); |
2285 | 94 |
/** |
95 |
* \param timeout |
|
96 |
* |
|
97 |
* If no probe response is received within the specified |
|
98 |
* timeout, the station sends a new probe request. |
|
99 |
*/ |
|
1948 | 100 |
void SetProbeRequestTimeout (Time timeout); |
2285 | 101 |
/** |
102 |
* \param timeout |
|
103 |
* |
|
104 |
* If no association response is received within the specified |
|
105 |
* timeout, the station sends a new association request. |
|
106 |
*/ |
|
1948 | 107 |
void SetAssocRequestTimeout (Time timeout); |
108 |
||
2285 | 109 |
/** |
110 |
* Start an active association sequence immediately. |
|
111 |
*/ |
|
1948 | 112 |
void StartActiveAssociation (void); |
113 |
||
114 |
private: |
|
4212
a21c19c4cd81
bug 487: add association/disassociation hooks in Nqsta.
Francesco Malandrino <francesco.malandrino@gmail.com>
parents:
4209
diff
changeset
|
115 |
enum MacState{ |
a21c19c4cd81
bug 487: add association/disassociation hooks in Nqsta.
Francesco Malandrino <francesco.malandrino@gmail.com>
parents:
4209
diff
changeset
|
116 |
ASSOCIATED, |
a21c19c4cd81
bug 487: add association/disassociation hooks in Nqsta.
Francesco Malandrino <francesco.malandrino@gmail.com>
parents:
4209
diff
changeset
|
117 |
WAIT_PROBE_RESP, |
a21c19c4cd81
bug 487: add association/disassociation hooks in Nqsta.
Francesco Malandrino <francesco.malandrino@gmail.com>
parents:
4209
diff
changeset
|
118 |
WAIT_ASSOC_RESP, |
a21c19c4cd81
bug 487: add association/disassociation hooks in Nqsta.
Francesco Malandrino <francesco.malandrino@gmail.com>
parents:
4209
diff
changeset
|
119 |
BEACON_MISSED, |
a21c19c4cd81
bug 487: add association/disassociation hooks in Nqsta.
Francesco Malandrino <francesco.malandrino@gmail.com>
parents:
4209
diff
changeset
|
120 |
REFUSED |
a21c19c4cd81
bug 487: add association/disassociation hooks in Nqsta.
Francesco Malandrino <francesco.malandrino@gmail.com>
parents:
4209
diff
changeset
|
121 |
}; |
1948 | 122 |
void SetBssid (Mac48Address bssid); |
2528
a527ec47b756
avoid crashing AP wifi sample
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2524
diff
changeset
|
123 |
void SetActiveProbing (bool enable); |
a527ec47b756
avoid crashing AP wifi sample
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2524
diff
changeset
|
124 |
bool GetActiveProbing (void) const; |
3604
a84d99890289
implement promisc mode
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
3603
diff
changeset
|
125 |
void ForwardUp (Ptr<Packet> packet, Mac48Address from, Mac48Address to); |
2524
db72c0e7743e
port wifi model to Attributes
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2350
diff
changeset
|
126 |
void Receive (Ptr<Packet> packet, WifiMacHeader const *hdr); |
1948 | 127 |
Mac48Address GetBroadcastBssid (void); |
128 |
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
|
129 |
void SendAssociationRequest (void); |
1948 | 130 |
void TryToEnsureAssociated (void); |
131 |
void AssocRequestTimeout (void); |
|
132 |
void ProbeRequestTimeout (void); |
|
133 |
bool IsAssociated (void); |
|
134 |
void MissedBeacons (void); |
|
1952
2ad2630756e3
do not use the Watchdog class
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
1948
diff
changeset
|
135 |
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
|
136 |
SupportedRates GetSupportedRates (void) const; |
2524
db72c0e7743e
port wifi model to Attributes
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2350
diff
changeset
|
137 |
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
|
138 |
NqstaWifiMac (const NqstaWifiMac & ctor_arg); |
3725
c27c944e2ec4
add private operator = to disable it
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
3606
diff
changeset
|
139 |
NqstaWifiMac &operator = (const NqstaWifiMac & ctor_arg); |
4406 | 140 |
Ptr<DcaTxop> GetDcaTxop(void) const; |
141 |
void SetDcaTxop (Ptr<DcaTxop> dcaTxop); |
|
4212
a21c19c4cd81
bug 487: add association/disassociation hooks in Nqsta.
Francesco Malandrino <francesco.malandrino@gmail.com>
parents:
4209
diff
changeset
|
142 |
void SetState (enum MacState value); |
2524
db72c0e7743e
port wifi model to Attributes
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2350
diff
changeset
|
143 |
|
4212
a21c19c4cd81
bug 487: add association/disassociation hooks in Nqsta.
Francesco Malandrino <francesco.malandrino@gmail.com>
parents:
4209
diff
changeset
|
144 |
enum MacState m_state; |
1948 | 145 |
Time m_probeRequestTimeout; |
146 |
Time m_assocRequestTimeout; |
|
147 |
EventId m_probeRequestEvent; |
|
148 |
EventId m_assocRequestEvent; |
|
3604
a84d99890289
implement promisc mode
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
3603
diff
changeset
|
149 |
Callback<void, Ptr<Packet>, Mac48Address, Mac48Address> m_forwardUp; |
2524
db72c0e7743e
port wifi model to Attributes
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2350
diff
changeset
|
150 |
Callback<void> m_linkUp; |
db72c0e7743e
port wifi model to Attributes
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2350
diff
changeset
|
151 |
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
|
152 |
Ptr<DcaTxop> m_dca; |
1952
2ad2630756e3
do not use the Watchdog class
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
1948
diff
changeset
|
153 |
EventId m_beaconWatchdog; |
2ad2630756e3
do not use the Watchdog class
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
1948
diff
changeset
|
154 |
Time m_beaconWatchdogEnd; |
1948 | 155 |
uint32_t m_maxMissedBeacons; |
2524
db72c0e7743e
port wifi model to Attributes
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2350
diff
changeset
|
156 |
|
2054
ba8e810bae4c
derive WifiPhy from Object and manage it with a Ptr<>
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2009
diff
changeset
|
157 |
Ptr<WifiPhy> m_phy; |
2524
db72c0e7743e
port wifi model to Attributes
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2350
diff
changeset
|
158 |
Ptr<WifiRemoteStationManager> m_stationManager; |
db72c0e7743e
port wifi model to Attributes
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2350
diff
changeset
|
159 |
DcfManager *m_dcfManager; |
db72c0e7743e
port wifi model to Attributes
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2350
diff
changeset
|
160 |
MacRxMiddle *m_rxMiddle; |
2617
0ecb3a9422e4
avoid double-frees.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2528
diff
changeset
|
161 |
Ptr<MacLow> m_low; |
2524
db72c0e7743e
port wifi model to Attributes
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2350
diff
changeset
|
162 |
Ssid m_ssid; |
4212
a21c19c4cd81
bug 487: add association/disassociation hooks in Nqsta.
Francesco Malandrino <francesco.malandrino@gmail.com>
parents:
4209
diff
changeset
|
163 |
|
a21c19c4cd81
bug 487: add association/disassociation hooks in Nqsta.
Francesco Malandrino <francesco.malandrino@gmail.com>
parents:
4209
diff
changeset
|
164 |
TracedCallback<Mac48Address> m_assocLogger; |
a21c19c4cd81
bug 487: add association/disassociation hooks in Nqsta.
Francesco Malandrino <francesco.malandrino@gmail.com>
parents:
4209
diff
changeset
|
165 |
TracedCallback<Mac48Address> m_deAssocLogger; |
1948 | 166 |
}; |
167 |
||
168 |
} // namespace ns3 |
|
169 |
||
170 |
||
2524
db72c0e7743e
port wifi model to Attributes
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2350
diff
changeset
|
171 |
#endif /* NQSTA_WIFI_MAC_H */ |