author | Mathieu Lacage <mathieu.lacage@sophia.inria.fr> |
Fri, 14 Aug 2009 12:21:39 +0200 | |
changeset 4720 | 15221757964f |
parent 4421 | 0608881b163f |
child 5189 | 8fcdf87a790a |
permissions | -rw-r--r-- |
4408 | 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" |
|
4720
15221757964f
bug 641: CwMin setting for 802.11b
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
4421
diff
changeset
|
33 |
#include "dcf.h" |
4408 | 34 |
|
35 |
#include <map> |
|
36 |
#include <list> |
|
37 |
||
38 |
namespace ns3 { |
|
39 |
||
40 |
class DcfState; |
|
41 |
class DcfManager; |
|
42 |
class MacLow; |
|
43 |
class MacTxMiddle; |
|
44 |
class WifiMacParameters; |
|
45 |
class WifiMacQueue; |
|
46 |
class RandomStream; |
|
47 |
class MsduAggregator; |
|
48 |
||
49 |
/* This queue contains packets for a particular access class. |
|
50 |
* possibles access classes are: |
|
51 |
* |
|
52 |
* -AC_VO : voice, tid = 6,7 ^ |
|
53 |
* -AC_VI : video, tid = 4,5 | |
|
54 |
* -AC_BE : best-effort, tid = 0,3 | priority |
|
55 |
* -AC_BK : background, tid = 1,2 | |
|
56 |
* |
|
57 |
* For more details see section 9.1.3.1 in 802.11 standard. |
|
58 |
*/ |
|
59 |
enum TypeOfStation |
|
60 |
{ |
|
61 |
STA, |
|
62 |
AP, |
|
63 |
ADHOC_STA |
|
64 |
}; |
|
65 |
||
4720
15221757964f
bug 641: CwMin setting for 802.11b
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
4421
diff
changeset
|
66 |
class EdcaTxopN : public Dcf |
4408 | 67 |
{ |
68 |
public: |
|
69 |
||
70 |
typedef Callback <void, WifiMacHeader const&> TxOk; |
|
71 |
typedef Callback <void, WifiMacHeader const&> TxFailed; |
|
72 |
||
73 |
static TypeId GetTypeId (void); |
|
74 |
EdcaTxopN (); |
|
75 |
virtual ~EdcaTxopN (); |
|
76 |
void DoDispose (); |
|
77 |
||
78 |
void SetLow (Ptr<MacLow> low); |
|
79 |
void SetTxMiddle (MacTxMiddle *txMiddle); |
|
80 |
void SetManager (DcfManager *manager); |
|
81 |
void SetTxOkCallback (TxOk callback); |
|
82 |
void SetTxFailedCallback (TxFailed callback); |
|
83 |
void SetWifiRemoteStationManager (Ptr<WifiRemoteStationManager> remoteManager); |
|
84 |
void SetTypeOfStation (enum TypeOfStation type); |
|
85 |
enum TypeOfStation GetTypeOfStation (void) const; |
|
86 |
||
87 |
void SetMaxQueueSize (uint32_t size); |
|
88 |
void SetMaxQueueDelay (Time delay); |
|
4720
15221757964f
bug 641: CwMin setting for 802.11b
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
4421
diff
changeset
|
89 |
virtual void SetMinCw (uint32_t minCw); |
15221757964f
bug 641: CwMin setting for 802.11b
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
4421
diff
changeset
|
90 |
virtual void SetMaxCw (uint32_t maxCw); |
15221757964f
bug 641: CwMin setting for 802.11b
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
4421
diff
changeset
|
91 |
virtual void SetAifsn (uint32_t aifsn); |
15221757964f
bug 641: CwMin setting for 802.11b
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
4421
diff
changeset
|
92 |
virtual uint32_t GetMinCw (void) const; |
15221757964f
bug 641: CwMin setting for 802.11b
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
4421
diff
changeset
|
93 |
virtual uint32_t GetMaxCw (void) const; |
15221757964f
bug 641: CwMin setting for 802.11b
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
4421
diff
changeset
|
94 |
virtual uint32_t GetAifsn (void) const; |
4408 | 95 |
|
96 |
Ptr<MacLow> Low (void); |
|
97 |
Ptr<MsduAggregator> GetMsduAggregator (void) const; |
|
98 |
||
99 |
/* dcf notifications forwarded here */ |
|
100 |
bool NeedsAccess (void) const; |
|
101 |
void NotifyAccessGranted (void); |
|
102 |
void NotifyInternalCollision (void); |
|
103 |
void NotifyCollision (void); |
|
104 |
||
105 |
/*event handlers*/ |
|
106 |
void GotCts (double snr, WifiMode txMode); |
|
107 |
void MissedCts (void); |
|
108 |
void GotAck (double snr, WifiMode txMode); |
|
109 |
void MissedAck (void); |
|
110 |
void StartNext (void); |
|
111 |
void Cancel (void); |
|
112 |
||
113 |
void RestartAccessIfNeeded (void); |
|
114 |
void StartAccessIfNeeded (void); |
|
115 |
bool NeedRts (void); |
|
116 |
bool NeedRtsRetransmission (void); |
|
117 |
bool NeedDataRetransmission (void); |
|
118 |
bool NeedFragmentation (void) const; |
|
119 |
uint32_t GetNextFragmentSize (void); |
|
120 |
uint32_t GetFragmentSize (void); |
|
121 |
uint32_t GetFragmentOffset (void); |
|
122 |
WifiRemoteStation *GetStation (Mac48Address to) const; |
|
123 |
bool IsLastFragment (void) const; |
|
124 |
void NextFragment (void); |
|
125 |
Ptr<Packet> GetFragmentPacket (WifiMacHeader *hdr); |
|
126 |
||
127 |
void Queue (Ptr<const Packet> packet, WifiMacHeader const &hdr); |
|
128 |
void SetMsduAggregator (Ptr<MsduAggregator> aggr); |
|
129 |
||
130 |
private: |
|
131 |
/** |
|
132 |
* This functions are used only to correctly set addresses in a-msdu subframe. |
|
133 |
* If aggregating sta is a STA (in an infrastructured network): |
|
134 |
* SA = Address2 |
|
135 |
* DA = Address3 |
|
136 |
* If aggregating sta is an AP |
|
137 |
* SA = Address3 |
|
138 |
* DA = Address1 |
|
139 |
*/ |
|
140 |
Mac48Address MapSrcAddressForAggregation (WifiMacHeader const &hdr); |
|
141 |
Mac48Address MapDestAddressForAggregation (WifiMacHeader const &hdr); |
|
4421
0608881b163f
help python bindings
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
4408
diff
changeset
|
142 |
EdcaTxopN &operator = (const EdcaTxopN &); |
0608881b163f
help python bindings
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
4408
diff
changeset
|
143 |
EdcaTxopN (const EdcaTxopN &); |
4408 | 144 |
|
145 |
class Dcf; |
|
146 |
class TransmissionListener; |
|
147 |
friend class Dcf; |
|
148 |
friend class TransmissionListener; |
|
149 |
Dcf *m_dcf; |
|
150 |
DcfManager *m_manager; |
|
151 |
Ptr<WifiMacQueue> m_queue; |
|
152 |
TxOk m_txOkCallback; |
|
153 |
TxFailed m_txFailedCallback; |
|
154 |
Ptr<MacLow> m_low; |
|
155 |
MacTxMiddle *m_txMiddle; |
|
156 |
TransmissionListener *m_transmissionListener; |
|
157 |
RandomStream *m_rng; |
|
158 |
Ptr<WifiRemoteStationManager> m_stationManager; |
|
159 |
uint8_t m_fragmentNumber; |
|
160 |
||
161 |
/* current packet could be a simple MSDU or, if an aggregator for this queue is |
|
162 |
present, could be an A-MSDU. |
|
163 |
*/ |
|
164 |
Ptr<const Packet> m_currentPacket; |
|
165 |
||
166 |
WifiMacHeader m_currentHdr; |
|
167 |
Ptr<MsduAggregator> m_aggregator; |
|
168 |
TypeOfStation m_typeOfStation; |
|
169 |
}; |
|
170 |
||
171 |
} //namespace ns3 |
|
172 |
||
173 |
#endif /* EDCA_TXOP_N_H */ |