A Discrete-Event Network Simulator
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
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
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  */
21 #ifndef DCA_TXOP_H
22 #define DCA_TXOP_H
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"
34 namespace ns3 {
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;
67 class DcaTxop : public Dcf
68 {
69 public:
70  static TypeId GetTypeId (void);
83  DcaTxop ();
84  ~DcaTxop ();
91  void SetLow (Ptr<MacLow> low);
97  void SetManager (DcfManager *manager);
109  void SetTxMiddle (MacTxMiddle *txMiddle);
115  void SetTxOkCallback (TxOk callback);
120  void SetTxFailedCallback (TxFailed callback);
127  Ptr<WifiMacQueue > GetQueue () const;
128  virtual void SetMinCw (uint32_t minCw);
129  virtual void SetMaxCw (uint32_t maxCw);
130  virtual void SetAifsn (uint32_t aifsn);
131  virtual uint32_t GetMinCw (void) const;
132  virtual uint32_t GetMaxCw (void) const;
133  virtual uint32_t GetAifsn (void) const;
142  void Queue (Ptr<const Packet> packet, const WifiMacHeader &hdr);
152  int64_t AssignStreams (int64_t stream);
154 private:
155  class TransmissionListener;
156  class NavListener;
157  class PhyListener;
158  class Dcf;
159  friend class Dcf;
160  friend class TransmissionListener;
162  DcaTxop &operator = (const DcaTxop &);
163  DcaTxop (const DcaTxop &o);
165  // Inherited from ns3::Object
171  Ptr<MacLow> Low (void);
172  void DoInitialize ();
173  /* dcf notifications forwarded here */
180  bool NeedsAccess (void) const;
184  void NotifyAccessGranted (void);
188  void NotifyInternalCollision (void);
192  void NotifyCollision (void);
196  void NotifyChannelSwitching (void);
198  /* Event handlers */
205  void GotCts (double snr, WifiMode txMode);
209  void MissedCts (void);
216  void GotAck (double snr, WifiMode txMode);
220  void MissedAck (void);
225  void StartNext (void);
229  void Cancel (void);
234  void EndTxNoAck (void);
239  void RestartAccessIfNeeded (void);
243  void StartAccessIfNeeded (void);
251  bool NeedRts (Ptr<const Packet> packet, const WifiMacHeader *header);
257  bool NeedRtsRetransmission (void);
263  bool NeedDataRetransmission (void);
270  bool NeedFragmentation (void);
276  uint32_t GetNextFragmentSize (void);
282  uint32_t GetFragmentSize (void);
288  uint32_t GetFragmentOffset (void);
295  bool IsLastFragment (void);
301  void NextFragment (void);
310  virtual void DoDispose (void);
327 };
329 } // namespace ns3
333 #endif /* DCA_TXOP_H */
void NotifyInternalCollision(void)
Notify the DCF that internal collision has occurred.
Definition: dca-txop.cc:494
DcaTxop & operator=(const DcaTxop &)
virtual uint32_t GetMaxCw(void) const
Return the maximum congestion window size.
Definition: dca-txop.cc:241
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:60
uint32_t GetFragmentOffset(void)
Calculate the offset for the current fragment.
Definition: dca-txop.cc:375
uint8_t m_fragmentNumber
Definition: dca-txop.h:326
bool m_accessOngoing
Definition: dca-txop.h:323
void SetTxFailedCallback(TxFailed callback)
Definition: dca-txop.cc:203
virtual void SetMaxCw(uint32_t maxCw)
Set the maximum congestion window size.
Definition: dca-txop.cc:223
void StartNext(void)
Start transmission for the next fragment.
Definition: dca-txop.cc:599
Ptr< MacLow > m_low
Definition: dca-txop.h:318
Ptr< MacLow > Low(void)
Return the MacLow associated with this DcaTxop.
Definition: dca-txop.cc:299
TxOk m_txOkCallback
Definition: dca-txop.h:314
virtual uint32_t GetAifsn(void) const
Return the number of slots that make up an AIFS.
Definition: dca-txop.cc:247
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:266
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:126
void SetTxOkCallback(TxOk callback)
Definition: dca-txop.cc:197
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:383
void Queue(Ptr< const Packet > packet, const WifiMacHeader &hdr)
Definition: dca-txop.cc:254
void SetLow(Ptr< MacLow > low)
Set MacLow associated with this DcaTxop.
Definition: dca-txop.cc:185
bool NeedFragmentation(void)
Check if the current packet should be fragmented.
Definition: dca-txop.cc:337
Ptr< WifiMacQueue > m_queue
Definition: dca-txop.h:316
void Cancel(void)
Cancel the transmission.
Definition: dca-txop.cc:623
void GotCts(double snr, WifiMode txMode)
Event handler when a CTS is received.
Definition: dca-txop.cc:517
void NotifyChannelSwitching(void)
When a channel switching occurs, enqueued packets are removed.
Definition: dca-txop.cc:509
void MissedCts(void)
Event handler when a CTS timeout has occurred.
Definition: dca-txop.cc:523
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:359
Listener for PHY events.
Definition: dcf-manager.cc:215
Ptr< WifiRemoteStationManager > m_stationManager
Definition: dca-txop.h:319
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:306
virtual void SetAifsn(uint32_t aifsn)
Definition: dca-txop.cc:229
void SetWifiRemoteStationManager(Ptr< WifiRemoteStationManager > remoteManager)
Set WifiRemoteStationsManager this DcaTxop is associated to.
Definition: dca-txop.cc:191
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:314
bool NeedsAccess(void) const
Check if the DCF requires access.
Definition: dca-txop.cc:404
WifiMacHeader m_currentHdr
Definition: dca-txop.h:325
Ptr< WifiMacQueue > GetQueue() const
Return the packet queue associated with this DcaTxop.
Definition: dca-txop.cc:210
bool NeedRtsRetransmission(void)
Check if RTS should be re-transmitted if CTS was missed.
Definition: dca-txop.cc:322
Ptr< const Packet > m_currentPacket
Definition: dca-txop.h:324
Listener for MacLow events.
Definition: dca-txop.cc:75
MacTxMiddle * m_txMiddle
Definition: dca-txop.h:317
DcfManager * m_manager
Definition: dca-txop.h:313
virtual void SetMinCw(uint32_t minCw)
Set the minimum congestion window size.
Definition: dca-txop.cc:217
void GotAck(double snr, WifiMode txMode)
Event handler when an ACK is received.
Definition: dca-txop.cc:547
void SetManager(DcfManager *manager)
Set DcfManager this DcaTxop is associated to.
Definition: dca-txop.cc:172
uint32_t GetNextFragmentSize(void)
Calculate the size of the next fragment.
Definition: dca-txop.cc:367
virtual void DoDispose(void)
This method is called by Object::Dispose or by the object's destructor, whichever comes first...
Definition: dca-txop.cc:156
void NotifyCollision(void)
Notify the DCF that collision has occurred.
Definition: dca-txop.cc:500
void StartAccessIfNeeded(void)
Request access from DCF manager if needed.
Definition: dca-txop.cc:286
void NextFragment(void)
Continue to the next fragment.
Definition: dca-txop.cc:345
TransmissionListener * m_transmissionListener
Definition: dca-txop.h:320
void RestartAccessIfNeeded(void)
Restart access request if needed.
Definition: dca-txop.cc:274
void SetTxMiddle(MacTxMiddle *txMiddle)
Set MacTxMiddle this DcaTxop is associated to.
Definition: dca-txop.cc:179
void MissedAck(void)
Event handler when an ACK is received.
Definition: dca-txop.cc:573
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:330
virtual uint32_t GetMinCw(void) const
Return the minimum congestion window size.
Definition: dca-txop.cc:235
Dcf * m_dcf
Definition: dca-txop.h:312
uint32_t GetFragmentSize(void)
Calculate the size of the current fragment.
Definition: dca-txop.cc:352
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:410
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:655
RandomStream * m_rng
Definition: dca-txop.h:321
TxFailed m_txFailedCallback
Definition: dca-txop.h:315