|
1 /* -*- Mode: C++; c-file-style: "gnu"; indent-tabs-mode:nil; -*- */ |
|
2 /* |
|
3 * Copyright (c) 2006, 2009 INRIA |
|
4 * Copyright (c) 2009 MIRKO BANCHI |
|
5 * |
|
6 * This program is free software; you can redistribute it and/or modify |
|
7 * it under the terms of the GNU General Public License version 2 as |
|
8 * published by the Free Software Foundation; |
|
9 * |
|
10 * This program is distributed in the hope that it will be useful, |
|
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of |
|
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|
13 * GNU General Public License for more details. |
|
14 * |
|
15 * You should have received a copy of the GNU General Public License |
|
16 * along with this program; if not, write to the Free Software |
|
17 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA |
|
18 * |
|
19 * Author: Mathieu Lacage <mathieu.lacage@sophia.inria.fr> |
|
20 * Author: Mirko Banchi <mk.banchi@gmail.com> |
|
21 */ |
|
22 #ifndef EDCA_TXOP_N_H |
|
23 #define EDCA_TXOP_N_H |
|
24 |
|
25 #include "ns3/object.h" |
|
26 #include "ns3/mac48-address.h" |
|
27 #include "ns3/packet.h" |
|
28 |
|
29 #include "wifi-mode.h" |
|
30 #include "wifi-mac.h" |
|
31 #include "wifi-mac-header.h" |
|
32 #include "qos-utils.h" |
|
33 |
|
34 #include <map> |
|
35 #include <list> |
|
36 |
|
37 namespace ns3 { |
|
38 |
|
39 class DcfState; |
|
40 class DcfManager; |
|
41 class MacLow; |
|
42 class MacTxMiddle; |
|
43 class WifiMacParameters; |
|
44 class WifiMacQueue; |
|
45 class RandomStream; |
|
46 class MsduAggregator; |
|
47 |
|
48 /* This queue contains packets for a particular access class. |
|
49 * possibles access classes are: |
|
50 * |
|
51 * -AC_VO : voice, tid = 6,7 ^ |
|
52 * -AC_VI : video, tid = 4,5 | |
|
53 * -AC_BE : best-effort, tid = 0,3 | priority |
|
54 * -AC_BK : background, tid = 1,2 | |
|
55 * |
|
56 * For more details see section 9.1.3.1 in 802.11 standard. |
|
57 */ |
|
58 enum TypeOfStation |
|
59 { |
|
60 STA, |
|
61 AP, |
|
62 ADHOC_STA |
|
63 }; |
|
64 |
|
65 class EdcaTxopN : public Object |
|
66 { |
|
67 public: |
|
68 |
|
69 typedef Callback <void, WifiMacHeader const&> TxOk; |
|
70 typedef Callback <void, WifiMacHeader const&> TxFailed; |
|
71 |
|
72 static TypeId GetTypeId (void); |
|
73 EdcaTxopN (); |
|
74 virtual ~EdcaTxopN (); |
|
75 void DoDispose (); |
|
76 |
|
77 void SetLow (Ptr<MacLow> low); |
|
78 void SetTxMiddle (MacTxMiddle *txMiddle); |
|
79 void SetManager (DcfManager *manager); |
|
80 void SetTxOkCallback (TxOk callback); |
|
81 void SetTxFailedCallback (TxFailed callback); |
|
82 void SetWifiRemoteStationManager (Ptr<WifiRemoteStationManager> remoteManager); |
|
83 void SetTypeOfStation (enum TypeOfStation type); |
|
84 enum TypeOfStation GetTypeOfStation (void) const; |
|
85 |
|
86 void SetMaxQueueSize (uint32_t size); |
|
87 void SetMaxQueueDelay (Time delay); |
|
88 void SetMinCw (uint32_t minCw); |
|
89 void SetMaxCw (uint32_t maxCw); |
|
90 void SetAifsn (uint32_t aifsn); |
|
91 uint32_t GetMinCw (void) const; |
|
92 uint32_t GetMaxCw (void) const; |
|
93 uint32_t GetAifsn (void) const; |
|
94 |
|
95 Ptr<MacLow> Low (void); |
|
96 Ptr<MsduAggregator> GetMsduAggregator (void) const; |
|
97 |
|
98 /* dcf notifications forwarded here */ |
|
99 bool NeedsAccess (void) const; |
|
100 void NotifyAccessGranted (void); |
|
101 void NotifyInternalCollision (void); |
|
102 void NotifyCollision (void); |
|
103 |
|
104 /*event handlers*/ |
|
105 void GotCts (double snr, WifiMode txMode); |
|
106 void MissedCts (void); |
|
107 void GotAck (double snr, WifiMode txMode); |
|
108 void MissedAck (void); |
|
109 void StartNext (void); |
|
110 void Cancel (void); |
|
111 |
|
112 void RestartAccessIfNeeded (void); |
|
113 void StartAccessIfNeeded (void); |
|
114 bool NeedRts (void); |
|
115 bool NeedRtsRetransmission (void); |
|
116 bool NeedDataRetransmission (void); |
|
117 bool NeedFragmentation (void) const; |
|
118 uint32_t GetNextFragmentSize (void); |
|
119 uint32_t GetFragmentSize (void); |
|
120 uint32_t GetFragmentOffset (void); |
|
121 WifiRemoteStation *GetStation (Mac48Address to) const; |
|
122 bool IsLastFragment (void) const; |
|
123 void NextFragment (void); |
|
124 Ptr<Packet> GetFragmentPacket (WifiMacHeader *hdr); |
|
125 |
|
126 void Queue (Ptr<const Packet> packet, WifiMacHeader const &hdr); |
|
127 void SetMsduAggregator (Ptr<MsduAggregator> aggr); |
|
128 |
|
129 private: |
|
130 /** |
|
131 * This functions are used only to correctly set addresses in a-msdu subframe. |
|
132 * If aggregating sta is a STA (in an infrastructured network): |
|
133 * SA = Address2 |
|
134 * DA = Address3 |
|
135 * If aggregating sta is an AP |
|
136 * SA = Address3 |
|
137 * DA = Address1 |
|
138 */ |
|
139 Mac48Address MapSrcAddressForAggregation (WifiMacHeader const &hdr); |
|
140 Mac48Address MapDestAddressForAggregation (WifiMacHeader const &hdr); |
|
141 |
|
142 class Dcf; |
|
143 class TransmissionListener; |
|
144 friend class Dcf; |
|
145 friend class TransmissionListener; |
|
146 Dcf *m_dcf; |
|
147 DcfManager *m_manager; |
|
148 Ptr<WifiMacQueue> m_queue; |
|
149 TxOk m_txOkCallback; |
|
150 TxFailed m_txFailedCallback; |
|
151 Ptr<MacLow> m_low; |
|
152 MacTxMiddle *m_txMiddle; |
|
153 TransmissionListener *m_transmissionListener; |
|
154 RandomStream *m_rng; |
|
155 Ptr<WifiRemoteStationManager> m_stationManager; |
|
156 uint8_t m_fragmentNumber; |
|
157 |
|
158 /* current packet could be a simple MSDU or, if an aggregator for this queue is |
|
159 present, could be an A-MSDU. |
|
160 */ |
|
161 Ptr<const Packet> m_currentPacket; |
|
162 |
|
163 WifiMacHeader m_currentHdr; |
|
164 Ptr<MsduAggregator> m_aggregator; |
|
165 TypeOfStation m_typeOfStation; |
|
166 }; |
|
167 |
|
168 } //namespace ns3 |
|
169 |
|
170 #endif /* EDCA_TXOP_N_H */ |