A Discrete-Event Network Simulator
API
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
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);
104 
109  void SetTxOkCallback (TxOk callback);
114  void SetTxFailedCallback (TxFailed callback);
115 
121  Ptr<WifiMacQueue > GetQueue () const;
122  virtual void SetMinCw (uint32_t minCw);
123  virtual void SetMaxCw (uint32_t maxCw);
124  virtual void SetAifsn (uint32_t aifsn);
125  virtual uint32_t GetMinCw (void) const;
126  virtual uint32_t GetMaxCw (void) const;
127  virtual uint32_t GetAifsn (void) const;
128 
136  void Queue (Ptr<const Packet> packet, const WifiMacHeader &hdr);
137 
146  int64_t AssignStreams (int64_t stream);
147 
148 private:
149  class TransmissionListener;
150  class NavListener;
151  class PhyListener;
152  class Dcf;
153  friend class Dcf;
154  friend class TransmissionListener;
155 
156  DcaTxop &operator = (const DcaTxop &);
157  DcaTxop (const DcaTxop &o);
158 
159  // Inherited from ns3::Object
165  Ptr<MacLow> Low (void);
166  void DoInitialize ();
167  /* dcf notifications forwarded here */
174  bool NeedsAccess (void) const;
178  void NotifyAccessGranted (void);
182  void NotifyInternalCollision (void);
186  void NotifyCollision (void);
190  void NotifyChannelSwitching (void);
191 
192  /* Event handlers */
199  void GotCts (double snr, WifiMode txMode);
203  void MissedCts (void);
210  void GotAck (double snr, WifiMode txMode);
214  void MissedAck (void);
219  void StartNext (void);
223  void Cancel (void);
228  void EndTxNoAck (void);
229 
233  void RestartAccessIfNeeded (void);
237  void StartAccessIfNeeded (void);
245  bool NeedRts (Ptr<const Packet> packet, const WifiMacHeader *header);
251  bool NeedRtsRetransmission (void);
257  bool NeedDataRetransmission (void);
264  bool NeedFragmentation (void);
270  uint32_t GetNextFragmentSize (void);
276  uint32_t GetFragmentSize (void);
282  uint32_t GetFragmentOffset (void);
289  bool IsLastFragment (void);
295  void NextFragment (void);
304  virtual void DoDispose (void);
305 
316 
321 };
322 
323 } // namespace ns3
324 
325 
326 
327 #endif /* DCA_TXOP_H */
void NotifyInternalCollision(void)
Notify the DCF that internal collision has occurred.
Definition: dca-txop.cc:492
DcaTxop & operator=(const DcaTxop &)
virtual uint32_t GetMaxCw(void) const
Return the maximum congestion window size.
Definition: dca-txop.cc:239
Callback< void, const WifiMacHeader & > TxFailed
typedef for a callback to invoke when a packet transmission was failed.
Definition: dca-txop.h:81
smart pointer class similar to boost::intrusive_ptr
Definition: ptr.h:59
uint32_t GetFragmentOffset(void)
Calculate the offset for the current fragment.
Definition: dca-txop.cc:373
uint8_t m_fragmentNumber
Definition: dca-txop.h:320
bool m_accessOngoing
Definition: dca-txop.h:317
void SetTxFailedCallback(TxFailed callback)
Definition: dca-txop.cc:201
virtual void SetMaxCw(uint32_t maxCw)
Set the maximum congestion window size.
Definition: dca-txop.cc:221
void StartNext(void)
Start transmission for the next fragment.
Definition: dca-txop.cc:597
Ptr< MacLow > m_low
Definition: dca-txop.h:312
Ptr< MacLow > Low(void)
Return the MacLow associated with this DcaTxop.
Definition: dca-txop.cc:297
TxOk m_txOkCallback
Definition: dca-txop.h:308
virtual uint32_t GetAifsn(void) const
Return the number of slots that make up an AIFS.
Definition: dca-txop.cc:245
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:264
represent a single transmission modeA WifiMode is implemented by a single integer which is used to lo...
Definition: wifi-mode.h:91
static TypeId GetTypeId(void)
Definition: dca-txop.cc:127
void SetTxOkCallback(TxOk callback)
Definition: dca-txop.cc:195
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:381
void Queue(Ptr< const Packet > packet, const WifiMacHeader &hdr)
Definition: dca-txop.cc:252
void SetLow(Ptr< MacLow > low)
Set MacLow associated with this DcaTxop.
Definition: dca-txop.cc:183
bool NeedFragmentation(void)
Check if the current packet should be fragmented.
Definition: dca-txop.cc:335
Ptr< WifiMacQueue > m_queue
Definition: dca-txop.h:310
void Cancel(void)
Cancel the transmission.
Definition: dca-txop.cc:621
void GotCts(double snr, WifiMode txMode)
Event handler when a CTS is received.
Definition: dca-txop.cc:515
void NotifyChannelSwitching(void)
When a channel switching occurs, enqueued packets are removed.
Definition: dca-txop.cc:507
void MissedCts(void)
Event handler when a CTS timeout has occurred.
Definition: dca-txop.cc:521
Manage a set of ns3::DcfStateHandle a set of independent ns3::DcfState, each of which represents a si...
Definition: dcf-manager.h:229
A simple wrapper around RngStream to make testing of the code easier.
Definition: random-stream.h:33
bool IsLastFragment(void)
Check if the curren fragment is the last fragment.
Definition: dca-txop.cc:357
Listener for PHY events.
Definition: dcf-manager.cc:215
Ptr< WifiRemoteStationManager > m_stationManager
Definition: dca-txop.h:313
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:304
virtual void SetAifsn(uint32_t aifsn)
Definition: dca-txop.cc:227
void SetWifiRemoteStationManager(Ptr< WifiRemoteStationManager > remoteManager)
Set WifiRemoteStationsManager this DcaTxop is associated to.
Definition: dca-txop.cc:189
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()
This method is called only once by Object::Initialize.
Definition: dca-txop.cc:312
bool NeedsAccess(void) const
Check if the DCF requires access.
Definition: dca-txop.cc:402
WifiMacHeader m_currentHdr
Definition: dca-txop.h:319
Ptr< WifiMacQueue > GetQueue() const
Return the packet queue associated with this DcaTxop.
Definition: dca-txop.cc:208
bool NeedRtsRetransmission(void)
Check if RTS should be re-transmitted if CTS was missed.
Definition: dca-txop.cc:320
Ptr< const Packet > m_currentPacket
Definition: dca-txop.h:318
Listener for MacLow events.
Definition: dca-txop.cc:75
MacTxMiddle * m_txMiddle
Definition: dca-txop.h:311
DcfManager * m_manager
Definition: dca-txop.h:307
virtual void SetMinCw(uint32_t minCw)
Set the minimum congestion window size.
Definition: dca-txop.cc:215
void GotAck(double snr, WifiMode txMode)
Event handler when an ACK is received.
Definition: dca-txop.cc:545
void SetManager(DcfManager *manager)
Set DcfManager this DcaTxop is associated to.
Definition: dca-txop.cc:175
uint32_t GetNextFragmentSize(void)
Calculate the size of the next fragment.
Definition: dca-txop.cc:365
virtual void DoDispose(void)
This method is called by Object::Dispose or by the object's destructor, whichever comes first...
Definition: dca-txop.cc:158
void NotifyCollision(void)
Notify the DCF that collision has occurred.
Definition: dca-txop.cc:498
void StartAccessIfNeeded(void)
Request access from DCF manager if needed.
Definition: dca-txop.cc:284
void NextFragment(void)
Continue to the next fragment.
Definition: dca-txop.cc:343
TransmissionListener * m_transmissionListener
Definition: dca-txop.h:314
void RestartAccessIfNeeded(void)
Restart access request if needed.
Definition: dca-txop.cc:272
void MissedAck(void)
Event handler when an ACK is received.
Definition: dca-txop.cc:571
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:328
virtual uint32_t GetMinCw(void) const
Return the minimum congestion window size.
Definition: dca-txop.cc:233
Dcf * m_dcf
Definition: dca-txop.h:306
uint32_t GetFragmentSize(void)
Calculate the size of the current fragment.
Definition: dca-txop.cc:350
a unique identifier for an interface.
Definition: type-id.h:49
void NotifyAccessGranted(void)
Notify the DCF that access has been granted.
Definition: dca-txop.cc:408
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:653
RandomStream * m_rng
Definition: dca-txop.h:315
TxFailed m_txFailedCallback
Definition: dca-txop.h:309