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 void SetTxopLimit (Time txopLimit);
133  virtual uint32_t GetMinCw (void) const;
134  virtual uint32_t GetMaxCw (void) const;
135  virtual uint32_t GetAifsn (void) const;
136  virtual Time GetTxopLimit (void) const;
137 
145  void Queue (Ptr<const Packet> packet, const WifiMacHeader &hdr);
146 
156  int64_t AssignStreams (int64_t stream);
157 
158 
159 private:
160  class TransmissionListener;
161  class NavListener;
162  class PhyListener;
163  class Dcf;
164  friend class Dcf;
165  friend class TransmissionListener;
166 
167  DcaTxop &operator = (const DcaTxop &);
168  DcaTxop (const DcaTxop &o);
169 
170  //Inherited from ns3::Object
176  Ptr<MacLow> Low (void);
177  void DoInitialize ();
178  /* dcf notifications forwarded here */
185  bool NeedsAccess (void) const;
186 
190  void NotifyAccessGranted (void);
194  void NotifyInternalCollision (void);
198  void NotifyCollision (void);
202  void NotifyChannelSwitching (void);
207  void NotifySleep (void);
211  void NotifyWakeUp (void);
212 
213  /* Event handlers */
220  void GotCts (double snr, WifiMode txMode);
224  void MissedCts (void);
231  void GotAck (double snr, WifiMode txMode);
235  void MissedAck (void);
240  void StartNextFragment (void);
244  void Cancel (void);
249  void EndTxNoAck (void);
250 
254  void RestartAccessIfNeeded (void);
258  void StartAccessIfNeeded (void);
259 
266  bool NeedRtsRetransmission (void);
273  bool NeedDataRetransmission (void);
280  bool NeedFragmentation (void);
286  uint32_t GetNextFragmentSize (void);
292  uint32_t GetFragmentSize (void);
298  uint32_t GetFragmentOffset (void);
305  bool IsLastFragment (void);
311  void NextFragment (void);
321 
322  virtual void DoDispose (void);
323 
334 
339 };
340 
341 } //namespace ns3
342 
343 #endif /* DCA_TXOP_H */
void NotifyInternalCollision(void)
Notify the DCF that internal collision has occurred.
Definition: dca-txop.cc:511
DcaTxop & operator=(const DcaTxop &)
virtual uint32_t GetMaxCw(void) const
Return the maximum contention window size.
Definition: dca-txop.cc:275
Simulation virtual time values and global simulation resolution.
Definition: nstime.h:102
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:409
uint8_t m_fragmentNumber
Definition: dca-txop.h:338
bool m_accessOngoing
Definition: dca-txop.h:335
void SetTxFailedCallback(TxFailed callback)
Definition: dca-txop.cc:226
virtual void SetMaxCw(uint32_t maxCw)
Set the maximum contention window size.
Definition: dca-txop.cc:247
Ptr< MacLow > m_low
Definition: dca-txop.h:330
void StartNextFragment(void)
Start transmission for the next fragment.
Definition: dca-txop.cc:638
Ptr< MacLow > Low(void)
Return the MacLow associated with this DcaTxop.
Definition: dca-txop.cc:338
TxOk m_txOkCallback
Definition: dca-txop.h:326
virtual uint32_t GetAifsn(void) const
Return the number of slots that make up an AIFS.
Definition: dca-txop.cc:282
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:306
represent a single transmission modeA WifiMode is implemented by a single integer which is used to lo...
Definition: wifi-mode.h:99
static TypeId GetTypeId(void)
Definition: dca-txop.cc:145
void SetTxOkCallback(TxOk callback)
Definition: dca-txop.cc:219
void NotifySleep(void)
When sleep operation occurs, if there is a pending packet transmission, it will be reinserted to the ...
Definition: dca-txop.cc:534
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:417
void Queue(Ptr< const Packet > packet, const WifiMacHeader &hdr)
Definition: dca-txop.cc:296
virtual Time GetTxopLimit(void) const
Return the TXOP limit.
Definition: dca-txop.cc:289
void SetLow(Ptr< MacLow > low)
Set MacLow associated with this DcaTxop.
Definition: dca-txop.cc:205
bool NeedFragmentation(void)
Check if the current packet should be fragmented.
Definition: dca-txop.cc:370
Ptr< WifiMacQueue > m_queue
Definition: dca-txop.h:328
void Cancel(void)
Cancel the transmission.
Definition: dca-txop.cc:662
void GotCts(double snr, WifiMode txMode)
Event handler when a CTS is received.
Definition: dca-txop.cc:552
void NotifyChannelSwitching(void)
When a channel switching occurs, enqueued packets are removed.
Definition: dca-txop.cc:526
void MissedCts(void)
Event handler when a CTS timeout has occurred.
Definition: dca-txop.cc:559
Manage a set of ns3::DcfStateHandle a set of independent ns3::DcfState, each of which represents a si...
Definition: dcf-manager.h:279
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:393
Listener for PHY events.
Definition: dcf-manager.cc:269
Ptr< WifiRemoteStationManager > m_stationManager
Definition: dca-txop.h:331
virtual void SetAifsn(uint32_t aifsn)
Definition: dca-txop.cc:254
void SetWifiRemoteStationManager(Ptr< WifiRemoteStationManager > remoteManager)
Set WifiRemoteStationsManager this DcaTxop is associated to.
Definition: dca-txop.cc:212
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:345
bool NeedsAccess(void) const
Check if the DCF requires access.
Definition: dca-txop.cc:438
WifiMacHeader m_currentHdr
Definition: dca-txop.h:337
Ptr< WifiMacQueue > GetQueue() const
Return the packet queue associated with this DcaTxop.
Definition: dca-txop.cc:233
bool NeedRtsRetransmission(void)
Check if RTS should be re-transmitted if CTS was missed.
Definition: dca-txop.cc:354
void NotifyWakeUp(void)
When wake up operation occurs, channel access will be restarted.
Definition: dca-txop.cc:545
Ptr< const Packet > m_currentPacket
Definition: dca-txop.h:336
Listener for MacLow events.
Definition: dca-txop.cc:88
MacTxMiddle * m_txMiddle
Definition: dca-txop.h:329
DcfManager * m_manager
Definition: dca-txop.h:325
virtual void SetMinCw(uint32_t minCw)
Set the minimum contention window size.
Definition: dca-txop.cc:240
void GotAck(double snr, WifiMode txMode)
Event handler when an ACK is received.
Definition: dca-txop.cc:584
virtual void SetTxopLimit(Time txopLimit)
Definition: dca-txop.cc:261
void SetManager(DcfManager *manager)
Set DcfManager this DcaTxop is associated to.
Definition: dca-txop.cc:192
uint32_t GetNextFragmentSize(void)
Calculate the size of the next fragment.
Definition: dca-txop.cc:401
virtual void DoDispose(void)
Destructor implementation.
Definition: dca-txop.cc:176
void NotifyCollision(void)
Notify the DCF that collision has occurred.
Definition: dca-txop.cc:518
void StartAccessIfNeeded(void)
Request access from DCF manager if needed.
Definition: dca-txop.cc:326
void NextFragment(void)
Continue to the next fragment.
Definition: dca-txop.cc:378
TransmissionListener * m_transmissionListener
Definition: dca-txop.h:332
void RestartAccessIfNeeded(void)
Restart access request if needed.
Definition: dca-txop.cc:314
void SetTxMiddle(MacTxMiddle *txMiddle)
Set MacTxMiddle this DcaTxop is associated to.
Definition: dca-txop.cc:199
void MissedAck(void)
Event handler when an ACK is missed.
Definition: dca-txop.cc:611
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:362
virtual uint32_t GetMinCw(void) const
Return the minimum contention window size.
Definition: dca-txop.cc:268
Dcf * m_dcf
Definition: dca-txop.h:324
uint32_t GetFragmentSize(void)
Calculate the size of the current fragment.
Definition: dca-txop.cc:385
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:444
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:694
RandomStream * m_rng
Definition: dca-txop.h:333
TxFailed m_txFailedCallback
Definition: dca-txop.h:327