Left: | ||
Right: |
LEFT | RIGHT |
---|---|
1 /* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */ | 1 /* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */ |
2 /* | 2 /* |
3 * Copyright (c) 2009 IITP RAS | 3 * Copyright (c) 2009 IITP RAS |
4 * | 4 * |
5 * This program is free software; you can redistribute it and/or modify | 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 | 6 * it under the terms of the GNU General Public License version 2 as |
7 * published by the Free Software Foundation; | 7 * published by the Free Software Foundation; |
8 * | 8 * |
9 * This program is distributed in the hope that it will be useful, | 9 * This program is distributed in the hope that it will be useful, |
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of | 10 * but WITHOUT ANY WARRANTY; without even the implied warranty of |
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | 11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
12 * GNU General Public License for more details. | 12 * GNU General Public License for more details. |
13 * | 13 * |
14 * You should have received a copy of the GNU General Public License | 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 | 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 | 16 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA |
17 * | 17 * |
18 * Authors: Kirill Andreev <andreev@iitp.ru> | 18 * Authors: Kirill Andreev <andreev@iitp.ru> |
19 * Pavel Boyko <boyko@iitp.ru> | 19 * Pavel Boyko <boyko@iitp.ru> |
20 */ | 20 */ |
21 | 21 |
22 #ifndef MESHWIFIINTERFACEMAC_H_ | 22 #ifndef MESHWIFIINTERFACEMAC_H_ |
23 #define MESHWIFIINTERFACEMAC_H_ | 23 #define MESHWIFIINTERFACEMAC_H_ |
24 | 24 |
25 #include <stdint.h> | 25 #include <stdint.h> |
26 #include <map> | 26 #include <map> |
27 #include "ns3/mac48-address.h" | 27 #include "ns3/mac48-address.h" |
28 #include "ns3/mgt-headers.h" | 28 #include "ns3/mgt-headers.h" |
29 #include "ns3/callback.h" | 29 #include "ns3/callback.h" |
30 #include "ns3/packet.h" | 30 #include "ns3/packet.h" |
31 #include "ns3/nstime.h" | 31 #include "ns3/nstime.h" |
32 #include "ns3/wifi-remote-station-manager.h" | 32 #include "ns3/wifi-remote-station-manager.h" |
33 #include "ns3/wifi-mac.h" | 33 #include "ns3/wifi-mac.h" |
34 #include "ns3/mesh-wifi-interface-mac-plugin.h" | 34 #include "ns3/mesh-wifi-interface-mac-plugin.h" |
35 #include "ns3/event-id.h" | 35 #include "ns3/event-id.h" |
36 | 36 #include "qos-utils.h" |
37 namespace ns3 { | 37 namespace ns3 { |
38 | 38 |
39 class WifiMacHeader; | 39 class WifiMacHeader; |
40 class DcaTxop; | 40 class DcaTxop; |
41 class WifiPhy; | 41 class WifiPhy; |
42 class DcfManager; | 42 class DcfManager; |
43 class MacRxMiddle; | 43 class MacRxMiddle; |
44 class MacLow; | 44 class MacLow; |
45 /** | 45 /** |
46 * \ingroup mesh | 46 * \ingroup mesh |
47 * | 47 * |
48 * \brief Basic MAC of mesh point Wi-Fi interface. Its function is extendable th rough plugins mechanism. | 48 * \brief Basic MAC of mesh point Wi-Fi interface. Its function is extendable th rough plugins mechanism. |
49 * | 49 * |
50 * Now only three output queues are used: | 50 * Now only three output queues are used: |
51 * - beacons (PIFS and no backoff), | 51 * - beacons (PIFS and no backoff), |
52 * - background traffic, | 52 * - background traffic, |
53 * - management and priority traffic. | 53 * - management and priority traffic. |
54 * | 54 * |
55 */ | 55 */ |
56 class MeshWifiInterfaceMac : public WifiMac | 56 class MeshWifiInterfaceMac : public WifiMac |
57 { | 57 { |
58 public: | 58 public: |
59 /// Never forget to support typeid | 59 /// Never forget to support typeid |
60 static TypeId GetTypeId (); | 60 static TypeId GetTypeId (); |
61 /// C-tor | 61 /// C-tor |
62 MeshWifiInterfaceMac (); | 62 MeshWifiInterfaceMac (); |
63 /// D-tor | 63 /// D-tor |
64 virtual ~MeshWifiInterfaceMac (); | 64 virtual ~MeshWifiInterfaceMac (); |
65 | 65 |
66 ///\name Inherited from WifiMac | 66 ///\name Inherited from WifiMac |
67 //\{ | 67 //\{ |
68 virtual void SetSlot (Time slotTime); | 68 virtual void SetSlot (Time slotTime); |
69 virtual void SetSifs (Time sifs); | 69 virtual void SetSifs (Time sifs); |
70 virtual void SetPifs (Time pifs); | 70 virtual void SetPifs (Time pifs); |
71 virtual void SetCtsTimeout (Time ctsTimeout); | 71 virtual void SetCtsTimeout (Time ctsTimeout); |
72 virtual void SetAckTimeout (Time ackTimeout); | 72 virtual void SetAckTimeout (Time ackTimeout); |
73 virtual void SetEifsNoDifs (Time eifsNoDifs); | 73 virtual void SetEifsNoDifs (Time eifsNoDifs); |
74 virtual Time GetSlot () const; | 74 virtual Time GetSlot () const; |
75 virtual Time GetSifs () const; | 75 virtual Time GetSifs () const; |
76 virtual Time GetPifs () const; | 76 virtual Time GetPifs () const; |
77 virtual Time GetCtsTimeout () const; | 77 virtual Time GetCtsTimeout () const; |
78 virtual Time GetAckTimeout () const; | 78 virtual Time GetAckTimeout () const; |
79 virtual Time GetEifsNoDifs () const; | 79 virtual Time GetEifsNoDifs () const; |
80 virtual void SetWifiPhy (Ptr<WifiPhy> phy); | 80 virtual void SetWifiPhy (Ptr<WifiPhy> phy); |
81 virtual void SetWifiRemoteStationManager (Ptr<WifiRemoteStationManager> stati onManager); | 81 virtual void SetWifiRemoteStationManager (Ptr<WifiRemoteStationManager> stati onManager); |
82 virtual void Enqueue (Ptr<const Packet> packet, Mac48Address to, Mac48Address from); | 82 virtual void Enqueue (Ptr<const Packet> packet, Mac48Address to, Mac48Address from); |
83 virtual void Enqueue (Ptr<const Packet> packet, Mac48Address to); | 83 virtual void Enqueue (Ptr<const Packet> packet, Mac48Address to); |
84 virtual bool SupportsSendFrom () const; | 84 virtual bool SupportsSendFrom () const; |
85 virtual void SetForwardUpCallback (Callback<void,Ptr<Packet>, Mac48Address, M ac48Address> upCallback); | 85 virtual void SetForwardUpCallback (Callback<void,Ptr<Packet>, Mac48Address, M ac48Address> upCallback); |
86 virtual void SetLinkUpCallback (Callback<void> linkUp); | 86 virtual void SetLinkUpCallback (Callback<void> linkUp); |
87 virtual void SetLinkDownCallback (Callback<void> linkDown); | 87 virtual void SetLinkDownCallback (Callback<void> linkDown); |
88 virtual Mac48Address GetAddress () const; | 88 virtual Mac48Address GetAddress () const; |
89 virtual Mac48Address GetBssid () const; | 89 virtual Mac48Address GetBssid () const; |
90 virtual Ssid GetSsid () const; | 90 virtual Ssid GetSsid () const; |
91 virtual void SetAddress (Mac48Address address); | 91 virtual void SetAddress (Mac48Address address); |
92 virtual void SetSsid (Ssid ssid); | 92 virtual void SetSsid (Ssid ssid); |
93 //\} | 93 //\} |
94 | 94 |
95 ///\name Each mesh point interfaces must know the mesh point address | 95 ///\name Each mesh point interfaces must know the mesh point address |
96 //\{ | 96 //\{ |
97 void SetMeshPointAddress (Mac48Address); | 97 void SetMeshPointAddress (Mac48Address); |
98 Mac48Address GetMeshPointAddress () const; | 98 Mac48Address GetMeshPointAddress () const; |
99 //\} | 99 //\} |
100 ///\name Beacons | 100 ///\name Beacons |
101 //\{ | 101 //\{ |
102 /// Set maximum initial random delay before first beacon | 102 /// Set maximum initial random delay before first beacon |
103 void SetRandomStartDelay (Time interval); | 103 void SetRandomStartDelay (Time interval); |
104 /// Set interval between two successive beacons | 104 /// Set interval between two successive beacons |
105 void SetBeaconInterval (Time interval); | 105 void SetBeaconInterval (Time interval); |
106 /// \return interval between two beacons | 106 /// \return interval between two beacons |
107 Time GetBeaconInterval () const; | 107 Time GetBeaconInterval () const; |
108 /** | 108 /** |
109 * \brief Next beacon frame time | 109 * \brief Next beacon frame time |
110 * | 110 * |
111 * This is supposed to be used by any entity managing beacon collision avoidan ce (e.g. Peer management protocol in 802.11s) | 111 * This is supposed to be used by any entity managing beacon collision avoidan ce (e.g. Peer management protocol in 802.11s) |
112 */ | 112 */ |
113 Time GetTbtt () const; | 113 Time GetTbtt () const; |
114 /** | 114 /** |
115 * \brief Shift TBTT. | 115 * \brief Shift TBTT. |
116 * | 116 * |
117 * This is supposed to be used by any entity managing beacon collision avoidan ce (e.g. Peer management protocol in 802.11s) | 117 * This is supposed to be used by any entity managing beacon collision avoidan ce (e.g. Peer management protocol in 802.11s) |
118 * | 118 * |
119 * \attention User of ShiftTbtt () must take care to not shift it to the past. | 119 * \attention User of ShiftTbtt () must take care to not shift it to the past. |
120 */ | 120 */ |
121 void ShiftTbtt (Time shift); | 121 void ShiftTbtt (Time shift); |
122 //\} | 122 //\} |
123 | 123 |
124 ///\name Plugins | 124 ///\name Plugins |
125 //\{ | 125 //\{ |
126 /// Install plugin. TODO return unique ID to allow unregister plugins | 126 /// Install plugin. TODO return unique ID to allow unregister plugins |
127 void InstallPlugin (Ptr<MeshWifiInterfaceMacPlugin> plugin); | 127 void InstallPlugin (Ptr<MeshWifiInterfaceMacPlugin> plugin); |
128 //\} | 128 //\} |
129 | 129 |
130 /** \name Channel switching | 130 /** \name Channel switching |
131 * | 131 * |
132 * Channel center frequency = Channel starting frequency + 5 * channel_id (MHz ), | 132 * Channel center frequency = Channel starting frequency + 5 * channel_id (MHz ), |
133 * where Starting channel frequency is standard-dependent as defined in IEEE 8 02.11-2007 17.3.8.3.2. | 133 * where Starting channel frequency is standard-dependent as defined in IEEE 8 02.11-2007 17.3.8.3.2. |
134 * | 134 * |
135 * Number of channels to use must be limited elsewhere. | 135 * Number of channels to use must be limited elsewhere. |
136 */ | 136 */ |
137 //\{ | 137 //\{ |
138 /// Return true if PHY layer can switch channels | |
139 bool CanSwitchChannel () const; | |
140 /// Current channel Id | 138 /// Current channel Id |
141 uint16_t GetFrequencyChannel () const; | 139 uint16_t GetFrequencyChannel () const; |
142 /// Switch channel | 140 /// Switch channel |
143 void SwitchFrequencyChannel (uint16_t new_id); | 141 void SwitchFrequencyChannel (uint16_t new_id); |
144 //\} | 142 //\} |
145 | 143 |
146 /// To be used by plugins sending management frames. | 144 /// To be used by plugins sending management frames. |
147 void SendManagementFrame(Ptr<Packet> frame, const WifiMacHeader& hdr); | 145 void SendManagementFrame (Ptr<Packet> frame, const WifiMacHeader& hdr); |
148 /// \return true if rates are supported | 146 /// \return true if rates are supported |
149 bool CheckSupportedRates(SupportedRates rates) const; | 147 bool CheckSupportedRates (SupportedRates rates) const; |
150 /// \return list of supported bitrates | 148 /// \return list of supported bitrates |
151 SupportedRates GetSupportedRates () const; | 149 SupportedRates GetSupportedRates () const; |
152 ///\ name Metric Calculation routines: | 150 ///\ name Metric Calculation routines: |
153 ///\{ | 151 ///\{ |
154 void SetLinkMetricCallback(Callback<uint32_t, Mac48Address, Ptr<MeshWifiInterf aceMac> > cb); | 152 void SetLinkMetricCallback (Callback<uint32_t, Mac48Address, Ptr<MeshWifiInter faceMac> > cb); |
155 uint32_t GetLinkMetric(Mac48Address peerAddress); | 153 uint32_t GetLinkMetric (Mac48Address peerAddress); |
156 Ptr<WifiRemoteStationManager> GetStationManager (); | 154 Ptr<WifiRemoteStationManager> GetStationManager (); |
157 ///\} | 155 ///\} |
158 ///\brief Statistics: | 156 ///\brief Statistics: |
159 void Report (std::ostream &) const; | 157 void Report (std::ostream &) const; |
160 void ResetStats (); | 158 void ResetStats (); |
161 /// Enable/disable beacons | 159 /// Enable/disable beacons |
162 void SetBeaconGeneration (bool enable); | 160 void SetBeaconGeneration (bool enable); |
161 void SetQueue (AccessClass ac); | |
162 virtual void FinishConfigureStandard (enum WifiPhyStandard standard); | |
163 private: | 163 private: |
164 Ptr<DcaTxop> GetBE(void) const; | |
165 void SetBE (Ptr<DcaTxop> dcaTxop); | |
166 Ptr<DcaTxop> GetVO(void) const; | |
167 void SetVO (Ptr<DcaTxop> dcaTxop); | |
168 /// Frame receive handler | 164 /// Frame receive handler |
169 void Receive (Ptr<Packet> packet, WifiMacHeader const *hdr); | 165 void Receive (Ptr<Packet> packet, WifiMacHeader const *hdr); |
170 /// Forward frame to mesh point | 166 /// Forward frame to mesh point |
171 virtual void ForwardUp (Ptr<Packet> packet, Mac48Address src, Mac48Address dst ); | 167 virtual void ForwardUp (Ptr<Packet> packet, Mac48Address src, Mac48Address dst ); |
172 /// Send frame. Frame is supposed to be tagged by routing information. TODO: c larify this point | 168 /// Send frame. Frame is supposed to be tagged by routing information. TODO: c larify this point |
173 void ForwardDown (Ptr<const Packet> packet, Mac48Address from, Mac48Address t o); | 169 void ForwardDown (Ptr<const Packet> packet, Mac48Address from, Mac48Address t o); |
170 // Notify about tx OK/Error frames: | |
171 void TxOk (WifiMacHeader const &hdr); | |
172 void TxFailed (WifiMacHeader const &hdr); | |
174 /// Send beacon | 173 /// Send beacon |
175 void SendBeacon (); | 174 void SendBeacon (); |
176 /// Schedule next beacon | 175 /// Schedule next beacon |
177 void ScheduleNextBeacon (); | 176 void ScheduleNextBeacon (); |
178 /// Get current beaconing status | 177 /// Get current beaconing status |
179 bool GetBeaconGeneration () const; | 178 bool GetBeaconGeneration () const; |
180 /// Real d-tor | 179 /// Real d-tor |
181 virtual void DoDispose (); | 180 virtual void DoDispose (); |
182 | 181 |
183 private: | 182 private: |
183 typedef std::map<AccessClass, Ptr<DcaTxop> > Queues; | |
184 typedef std::vector<Ptr<MeshWifiInterfaceMacPlugin> > PluginList; | |
184 ///\name Wifi MAC internals | 185 ///\name Wifi MAC internals |
185 //\{ | 186 //\{ |
186 Ptr<DcaTxop> m_BE; | 187 Queues m_queues; |
187 Ptr<DcaTxop> m_BK; | 188 Ptr<DcaTxop> m_beaconDca; |
188 Ptr<DcaTxop> m_VI; | |
189 Ptr<DcaTxop> m_VO; | |
190 Ptr<DcaTxop> m_beaconDca; | |
191 Ptr<WifiRemoteStationManager> m_stationManager; | 189 Ptr<WifiRemoteStationManager> m_stationManager; |
192 Ptr<WifiPhy> m_phy; | 190 Ptr<WifiPhy> m_phy; |
193 Callback<void, Ptr<Packet>, Mac48Address, Mac48Address> m_upCallback; | 191 Callback<void, Ptr<Packet> , Mac48Address, Mac48Address> m_upCallback; |
194 //\} | 192 //\} |
195 | 193 |
196 ///\name Wifi timing intervals | 194 ///\name Wifi timing intervals |
197 //\{ | 195 //\{ |
198 Time m_slot; | 196 Time m_slot; |
199 Time m_sifs; | 197 Time m_sifs; |
200 Time m_pifs; | 198 Time m_pifs; |
201 Time m_ackTimeout; | 199 Time m_ackTimeout; |
202 Time m_ctsTimeout; | 200 Time m_ctsTimeout; |
203 Time m_eifsNoDifs; | 201 Time m_eifsNoDifs; |
204 //\} | 202 //\} |
205 | 203 |
206 ///\name Mesh timing intervals | 204 ///\name Mesh timing intervals |
207 //\{ | 205 //\{ |
208 /// Beaconing interval. | 206 /// Beaconing interval. |
209 Time m_beaconInterval; | 207 Time m_beaconInterval; |
210 /// Maximum delay before first beacon | 208 /// Maximum delay before first beacon |
211 Time m_randomStart; | 209 Time m_randomStart; |
212 /// Time for the next frame | 210 /// Time for the next frame |
213 Time m_tbtt; | 211 Time m_tbtt; |
214 //\} | 212 //\} |
215 | 213 |
216 /// DCF implementation | 214 /// DCF implementation |
217 DcfManager* m_dcfManager; | 215 DcfManager* m_dcfManager; |
218 /// Middle MAC sublayer | 216 /// Middle MAC sublayer |
219 MacRxMiddle* m_rxMiddle; | 217 MacRxMiddle* m_rxMiddle; |
220 /// Low MAC sublayer | 218 /// Low MAC sublayer |
221 Ptr<MacLow> m_low; | 219 Ptr<MacLow> m_low; |
222 /// My address | 220 /// My address |
223 Mac48Address m_address; | 221 Mac48Address m_address; |
224 /// Mesh point address | 222 /// Mesh point address |
225 Mac48Address m_mpAddress; | 223 Mac48Address m_mpAddress; |
226 /// SSID | 224 /// SSID |
227 Ssid m_meshId; | 225 Ssid m_meshId; |
228 | 226 |
229 /// "Timer" for the next beacon | 227 /// "Timer" for the next beacon |
230 EventId m_beaconSendEvent; | 228 EventId m_beaconSendEvent; |
231 ·· | |
232 typedef std::vector< Ptr<MeshWifiInterfaceMacPlugin> > PluginList;· | |
233 /// List of all installed plugins | 229 /// List of all installed plugins |
234 PluginList m_plugins; | 230 PluginList m_plugins; |
235 Callback<uint32_t, Mac48Address, Ptr<MeshWifiInterfaceMac> > m_linkMetricCallb ack; | 231 Callback<uint32_t, Mac48Address, Ptr<MeshWifiInterfaceMac> > m_linkMetricCallb ack; |
236 ///\name Statistics: | 232 ///\name Statistics: |
237 ///\{ | 233 ///\{ |
238 struct Statistics | 234 struct Statistics |
239 { | 235 { |
240 uint16_t recvBeacons; | 236 uint16_t recvBeacons; |
241 uint32_t sentFrames; | 237 uint32_t sentFrames; |
242 uint32_t sentBytes; | 238 uint32_t sentBytes; |
243 uint32_t recvFrames; | 239 uint32_t recvFrames; |
244 uint32_t recvBytes; | 240 uint32_t recvBytes; |
245 void Print (std::ostream & os) const; | 241 void |
246 Statistics () : | 242 Print (std::ostream & os) const; |
Mathieu Lacage
2009/07/16 11:39:05
generally, even for trivial constructors, we put n
and.kirill
2009/07/21 09:14:48
Done.
| |
247 recvBeacons (0), | 243 Statistics (); |
248 sentFrames (0), | |
249 sentBytes (0), | |
250 recvFrames (0), | |
251 recvBytes (0) | |
252 {} | |
253 }; | 244 }; |
254 Statistics m_stats; | 245 Statistics m_stats; |
255 ///\} | 246 ///\} |
247 TracedCallback<WifiMacHeader const &> m_txOkCallback; | |
248 TracedCallback<WifiMacHeader const &> m_txErrCallback; | |
256 | 249 |
257 }; | 250 }; |
258 | 251 |
259 } // namespace ns3 | 252 } // namespace ns3 |
260 | 253 |
261 #endif /* MESHWIFIINTERFACEMAC_H_ */ | 254 #endif /* MESHWIFIINTERFACEMAC_H_ */ |
LEFT | RIGHT |