A Discrete-Event Network Simulator
API
dca-txop.h
Go to the documentation of this file.
1 /* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
2 /*
3  * Copyright (c) 2005 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 
21 #ifndef DCA_TXOP_H
22 #define DCA_TXOP_H
23 
24 #include <stdint.h>
25 #include "ns3/callback.h"
26 #include "ns3/packet.h"
27 #include "ns3/nstime.h"
28 #include "ns3/object.h"
29 #include "ns3/wifi-mac-header.h"
30 #include "ns3/wifi-mode.h"
31 #include "ns3/wifi-remote-station-manager.h"
32 #include "ns3/dcf.h"
33 
34 namespace ns3 {
35 
36 class DcfState;
37 class DcfManager;
38 class WifiMacQueue;
39 class MacLow;
40 class WifiMacParameters;
41 class MacTxMiddle;
42 class RandomStream;
43 class MacStation;
44 class MacStations;
45 
67 class DcaTxop : public Dcf
68 {
69 public:
70  static TypeId GetTypeId (void);
71 
82 
83  DcaTxop ();
84  ~DcaTxop ();
85 
91  void SetLow (Ptr<MacLow> low);
97  void SetManager (DcfManager *manager);
109  void SetTxMiddle (MacTxMiddle *txMiddle);
110 
115  void SetTxOkCallback (TxOk callback);
120  void SetTxFailedCallback (TxFailed callback);
121 
127  Ptr<WifiMacQueue > GetQueue () const;
128 
129  virtual void SetMinCw (uint32_t minCw);
130  virtual void SetMaxCw (uint32_t maxCw);
131  virtual void SetAifsn (uint32_t aifsn);
132  virtual uint32_t GetMinCw (void) const;
133  virtual uint32_t GetMaxCw (void) const;
134  virtual uint32_t GetAifsn (void) const;
135 
143  void Queue (Ptr<const Packet> packet, const WifiMacHeader &hdr);
144 
154  int64_t AssignStreams (int64_t stream);
155 
156 
157 private:
158  class TransmissionListener;
159  class NavListener;
160  class PhyListener;
161  class Dcf;
162  friend class Dcf;
163  friend class TransmissionListener;
164 
165  DcaTxop &operator = (const DcaTxop &);
166  DcaTxop (const DcaTxop &o);
167 
168  //Inherited from ns3::Object
174  Ptr<MacLow> Low (void);
175  void DoInitialize ();
176  /* dcf notifications forwarded here */
183  bool NeedsAccess (void) const;
184 
188  void NotifyAccessGranted (void);
192  void NotifyInternalCollision (void);
196  void NotifyCollision (void);
200  void NotifyChannelSwitching (void);
205  void NotifySleep (void);
209  void NotifyWakeUp (void);
210 
211  /* Event handlers */
218  void GotCts (double snr, WifiMode txMode);
222  void MissedCts (void);
229  void GotAck (double snr, WifiMode txMode);
233  void MissedAck (void);
238  void StartNext (void);
242  void Cancel (void);
247  void EndTxNoAck (void);
248 
252  void RestartAccessIfNeeded (void);
256  void StartAccessIfNeeded (void);
257 
267  bool NeedRts (Ptr<const Packet> packet, const WifiMacHeader *header);
274  bool NeedRtsRetransmission (void);
281  bool NeedDataRetransmission (void);
288  bool NeedFragmentation (void);
294  uint32_t GetNextFragmentSize (void);
300  uint32_t GetFragmentSize (void);
306  uint32_t GetFragmentOffset (void);
313  bool IsLastFragment (void);
319  void NextFragment (void);
329 
330  virtual void DoDispose (void);
331 
342 
347 };
348 
349 } //namespace ns3
350 
351 #endif /* DCA_TXOP_H */
void NotifyInternalCollision(void)
Notify the DCF that internal collision has occurred.
Definition: dca-txop.cc:519
DcaTxop & operator=(const DcaTxop &)
virtual uint32_t GetMaxCw(void) const
Return the maximum congestion window size.
Definition: dca-txop.cc:262
Callback< void, const WifiMacHeader & > TxFailed
typedef for a callback to invoke when a packet transmission was failed.
Definition: dca-txop.h:81
uint32_t GetFragmentOffset(void)
Calculate the offset for the current fragment.
Definition: dca-txop.cc:399
uint8_t m_fragmentNumber
Definition: dca-txop.h:346
bool m_accessOngoing
Definition: dca-txop.h:343
void SetTxFailedCallback(TxFailed callback)
Definition: dca-txop.cc:220
virtual void SetMaxCw(uint32_t maxCw)
Set the maximum congestion window size.
Definition: dca-txop.cc:241
void StartNext(void)
Start transmission for the next fragment.
Definition: dca-txop.cc:647
Ptr< MacLow > m_low
Definition: dca-txop.h:338
Ptr< MacLow > Low(void)
Return the MacLow associated with this DcaTxop.
Definition: dca-txop.cc:320
TxOk m_txOkCallback
Definition: dca-txop.h:334
virtual uint32_t GetAifsn(void) const
Return the number of slots that make up an AIFS.
Definition: dca-txop.cc:269
int64_t AssignStreams(int64_t stream)
Assign a fixed random variable stream number to the random variables used by this model...
Definition: dca-txop.cc:288
represent a single transmission modeA WifiMode is implemented by a single integer which is used to lo...
Definition: wifi-mode.h:97
static TypeId GetTypeId(void)
Definition: dca-txop.cc:139
void SetTxOkCallback(TxOk callback)
Definition: dca-txop.cc:213
void NotifySleep(void)
When sleep operation occurs, if there is a pending packet transmission, it will be reinserted to the ...
Definition: dca-txop.cc:543
Handles sequence numbering of IEEE 802.11 data frames.
Definition: mac-tx-middle.h:39
Ptr< Packet > GetFragmentPacket(WifiMacHeader *hdr)
Get the next fragment from the packet with appropriate Wifi header for the fragment.
Definition: dca-txop.cc:407
void Queue(Ptr< const Packet > packet, const WifiMacHeader &hdr)
Definition: dca-txop.cc:276
void SetLow(Ptr< MacLow > low)
Set MacLow associated with this DcaTxop.
Definition: dca-txop.cc:199
bool NeedFragmentation(void)
Check if the current packet should be fragmented.
Definition: dca-txop.cc:360
Ptr< WifiMacQueue > m_queue
Definition: dca-txop.h:336
void Cancel(void)
Cancel the transmission.
Definition: dca-txop.cc:671
void GotCts(double snr, WifiMode txMode)
Event handler when a CTS is received.
Definition: dca-txop.cc:561
void NotifyChannelSwitching(void)
When a channel switching occurs, enqueued packets are removed.
Definition: dca-txop.cc:535
void MissedCts(void)
Event handler when a CTS timeout has occurred.
Definition: dca-txop.cc:568
Manage a set of ns3::DcfStateHandle a set of independent ns3::DcfState, each of which represents a si...
Definition: dcf-manager.h:252
A simple wrapper around RngStream to make testing of the code easier.
Definition: random-stream.h:34
bool IsLastFragment(void)
Check if the curren fragment is the last fragment.
Definition: dca-txop.cc:383
Listener for PHY events.
Definition: dcf-manager.cc:242
Ptr< WifiRemoteStationManager > m_stationManager
Definition: dca-txop.h:339
bool NeedRts(Ptr< const Packet > packet, const WifiMacHeader *header)
Check if the current packet should be sent with a RTS protection.
Definition: dca-txop.cc:327
virtual void SetAifsn(uint32_t aifsn)
Definition: dca-txop.cc:248
void SetWifiRemoteStationManager(Ptr< WifiRemoteStationManager > remoteManager)
Set WifiRemoteStationsManager this DcaTxop is associated to.
Definition: dca-txop.cc:206
Every class exported by the ns3 library is enclosed in the ns3 namespace.
Callback< void, const WifiMacHeader & > TxOk
typedef for a callback to invoke when a packet transmission was completed successfully.
Definition: dca-txop.h:76
void DoInitialize()
Initialize() implementation.
Definition: dca-txop.cc:335
bool NeedsAccess(void) const
Check if the DCF requires access.
Definition: dca-txop.cc:428
WifiMacHeader m_currentHdr
Definition: dca-txop.h:345
Ptr< WifiMacQueue > GetQueue() const
Return the packet queue associated with this DcaTxop.
Definition: dca-txop.cc:227
bool NeedRtsRetransmission(void)
Check if RTS should be re-transmitted if CTS was missed.
Definition: dca-txop.cc:344
void NotifyWakeUp(void)
When wake up operation occurs, channel access will be restarted.
Definition: dca-txop.cc:554
Ptr< const Packet > m_currentPacket
Definition: dca-txop.h:344
Listener for MacLow events.
Definition: dca-txop.cc:85
MacTxMiddle * m_txMiddle
Definition: dca-txop.h:337
DcfManager * m_manager
Definition: dca-txop.h:333
virtual void SetMinCw(uint32_t minCw)
Set the minimum congestion window size.
Definition: dca-txop.cc:234
void GotAck(double snr, WifiMode txMode)
Event handler when an ACK is received.
Definition: dca-txop.cc:593
void SetManager(DcfManager *manager)
Set DcfManager this DcaTxop is associated to.
Definition: dca-txop.cc:186
uint32_t GetNextFragmentSize(void)
Calculate the size of the next fragment.
Definition: dca-txop.cc:391
virtual void DoDispose(void)
Destructor implementation.
Definition: dca-txop.cc:170
void NotifyCollision(void)
Notify the DCF that collision has occurred.
Definition: dca-txop.cc:526
void StartAccessIfNeeded(void)
Request access from DCF manager if needed.
Definition: dca-txop.cc:308
void NextFragment(void)
Continue to the next fragment.
Definition: dca-txop.cc:368
TransmissionListener * m_transmissionListener
Definition: dca-txop.h:340
void RestartAccessIfNeeded(void)
Restart access request if needed.
Definition: dca-txop.cc:296
void SetTxMiddle(MacTxMiddle *txMiddle)
Set MacTxMiddle this DcaTxop is associated to.
Definition: dca-txop.cc:193
void MissedAck(void)
Event handler when an ACK is received.
Definition: dca-txop.cc:620
handle packet fragmentation and retransmissions.
Definition: dca-txop.h:67
bool NeedDataRetransmission(void)
Check if DATA should be re-transmitted if ACK was missed.
Definition: dca-txop.cc:352
virtual uint32_t GetMinCw(void) const
Return the minimum congestion window size.
Definition: dca-txop.cc:255
Dcf * m_dcf
Definition: dca-txop.h:332
uint32_t GetFragmentSize(void)
Calculate the size of the current fragment.
Definition: dca-txop.cc:375
a unique identifier for an interface.
Definition: type-id.h:58
void NotifyAccessGranted(void)
Notify the DCF that access has been granted.
Definition: dca-txop.cc:434
Implements the IEEE 802.11 MAC header.
void EndTxNoAck(void)
Event handler when a transmission that does not require an ACK has completed.
Definition: dca-txop.cc:703
RandomStream * m_rng
Definition: dca-txop.h:341
TxFailed m_txFailedCallback
Definition: dca-txop.h:335