|
1 /* -*- Mode: C++; c-file-style: "gnu"; indent-tabs-mode:nil; -*- */ |
|
2 /* |
|
3 * Copyright (c) 2005,2006,2007 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 #ifndef WIFI_REMOTE_STATION_MANAGER_H |
|
21 #define WIFI_REMOTE_STATION_MANAGER_H |
|
22 |
|
23 #include <vector> |
|
24 #include <utility> |
|
25 #include "ns3/mac48-address.h" |
|
26 #include "ns3/packet.h" |
|
27 #include "ns3/object.h" |
|
28 #include "wifi-mode.h" |
|
29 |
|
30 namespace ns3 { |
|
31 |
|
32 class WifiRemoteStation; |
|
33 class NonUnicastWifiRemoteStation; |
|
34 class WifiPhy; |
|
35 |
|
36 class WifiRemoteStationManager : public Object |
|
37 { |
|
38 private: |
|
39 typedef std::vector<WifiMode> BasicModes; |
|
40 public: |
|
41 typedef BasicModes::const_iterator BasicModesIterator; |
|
42 |
|
43 static TypeId GetTypeId (void); |
|
44 |
|
45 WifiRemoteStationManager (); |
|
46 virtual ~WifiRemoteStationManager (); |
|
47 |
|
48 virtual void SetupPhy (Ptr<WifiPhy> phy); |
|
49 |
|
50 uint32_t GetMaxSsrc (void) const; |
|
51 uint32_t GetMaxSlrc (void) const; |
|
52 uint32_t GetRtsCtsThreshold (void) const; |
|
53 uint32_t GetFragmentationThreshold (void) const; |
|
54 void SetMaxSsrc (uint32_t maxSsrc); |
|
55 void SetMaxSlrc (uint32_t maxSlrc); |
|
56 void SetRtsCtsThreshold (uint32_t threshold); |
|
57 void SetFragmentationThreshold (uint32_t threshold); |
|
58 |
|
59 // Invoked in a STA upon dis-association |
|
60 // or in an AP upon reboot |
|
61 void Reset (void); |
|
62 // Invoked in a STA upon association to store |
|
63 // the set of rates which belong to the |
|
64 // BSSBasicRateSet of the associated AP |
|
65 // and which are supported locally. |
|
66 // Invoked in an AP to configure the BSSBasicRateSet |
|
67 void AddBasicMode (WifiMode mode); |
|
68 |
|
69 WifiMode GetDefaultMode (void) const; |
|
70 uint32_t GetNBasicModes (void) const; |
|
71 WifiMode GetBasicMode (uint32_t i) const; |
|
72 BasicModesIterator BeginBasicModes (void) const; |
|
73 BasicModesIterator EndBasicModes (void) const; |
|
74 |
|
75 bool IsLowLatency (void) const; |
|
76 |
|
77 WifiRemoteStation *Lookup (Mac48Address address); |
|
78 WifiRemoteStation *LookupNonUnicast (void); |
|
79 private: |
|
80 typedef std::vector <std::pair<Mac48Address, WifiRemoteStation *> > Stations; |
|
81 virtual class WifiRemoteStation *CreateStation (void) = 0; |
|
82 Stations m_stations; |
|
83 WifiMode m_defaultTxMode; |
|
84 NonUnicastWifiRemoteStation *m_nonUnicast; |
|
85 BasicModes m_basicModes; |
|
86 bool m_isLowLatency; |
|
87 uint32_t m_maxSsrc; |
|
88 uint32_t m_maxSlrc; |
|
89 uint32_t m_rtsCtsThreshold; |
|
90 uint32_t m_fragmentationThreshold; |
|
91 }; |
|
92 |
|
93 } // namespace ns3 |
|
94 |
|
95 namespace ns3 { |
|
96 |
|
97 class WifiRemoteStation { |
|
98 public: |
|
99 WifiRemoteStation (); |
|
100 virtual ~WifiRemoteStation (); |
|
101 |
|
102 // Invoked in an AP upon disassociation of a |
|
103 // specific STA. |
|
104 void Reset (void); |
|
105 // Invoked in a STA or AP to store the set of |
|
106 // modes supported by a destination which is |
|
107 // also supported locally. |
|
108 // The set of supported modes includes |
|
109 // the BSSBasicRateSet. |
|
110 void AddSupportedMode (WifiMode mode); |
|
111 |
|
112 bool IsBrandNew (void) const; |
|
113 bool IsAssociated (void) const; |
|
114 bool IsWaitAssocTxOk (void) const; |
|
115 void RecordWaitAssocTxOk (void); |
|
116 void RecordGotAssocTxOk (void); |
|
117 void RecordGotAssocTxFailed (void); |
|
118 void RecordDisassociated (void); |
|
119 |
|
120 void PrepareForQueue (Ptr<const Packet> packet, uint32_t fullPacketSize); |
|
121 WifiMode GetDataMode (Ptr<const Packet> packet, uint32_t fullPacketSize); |
|
122 WifiMode GetRtsMode (Ptr<const Packet> packet); |
|
123 |
|
124 // reception-related method |
|
125 virtual void ReportRxOk (double rxSnr, WifiMode txMode) = 0; |
|
126 |
|
127 // transmission-related methods |
|
128 virtual void ReportRtsFailed (void) = 0; |
|
129 virtual void ReportDataFailed (void) = 0; |
|
130 virtual void ReportRtsOk (double ctsSnr, WifiMode ctsMode, double rtsSnr) = 0; |
|
131 virtual void ReportDataOk (double ackSnr, WifiMode ackMode, double dataSnr) = 0; |
|
132 virtual void ReportFinalRtsFailed (void) = 0; |
|
133 virtual void ReportFinalDataFailed (void) = 0; |
|
134 virtual bool NeedRts (Ptr<const Packet> packet); |
|
135 virtual uint32_t GetMaxSsrc (Ptr<const Packet> packet); |
|
136 virtual uint32_t GetMaxSlrc (Ptr<const Packet> packet); |
|
137 virtual bool NeedFragmentation (Ptr<const Packet> packet); |
|
138 virtual uint32_t GetNFragments (Ptr<const Packet> packet); |
|
139 virtual uint32_t GetFragmentSize (Ptr<const Packet> packet, uint32_t fragmentNumber); |
|
140 virtual bool IsLastFragment (Ptr<const Packet> packet, uint32_t fragmentNumber); |
|
141 |
|
142 WifiMode GetCtsMode (WifiMode rtsMode); |
|
143 WifiMode GetAckMode (WifiMode dataMode); |
|
144 |
|
145 private: |
|
146 typedef std::vector<WifiMode> SupportedModes; |
|
147 virtual Ptr<WifiRemoteStationManager> GetManager (void) const = 0; |
|
148 virtual WifiMode DoGetDataMode (uint32_t size) = 0; |
|
149 virtual WifiMode DoGetRtsMode (void) = 0; |
|
150 protected: |
|
151 uint32_t GetNSupportedModes (void) const; |
|
152 WifiMode GetSupportedMode (uint32_t i) const; |
|
153 private: |
|
154 bool IsIn (WifiMode mode) const; |
|
155 WifiMode GetControlAnswerMode (WifiMode reqMode); |
|
156 enum { |
|
157 BRAND_NEW, |
|
158 DISASSOC, |
|
159 WAIT_ASSOC_TX_OK, |
|
160 GOT_ASSOC_TX_OK |
|
161 } m_state; |
|
162 SupportedModes m_modes; |
|
163 }; |
|
164 |
|
165 } // namespace ns3 |
|
166 |
|
167 #endif /* MAC_STATIONS_H */ |