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 "mac-low.h"
25 #include "wifi-mac-header.h"
27 
28 namespace ns3 {
29 
30 class DcfState;
31 class DcfManager;
32 class MacTxMiddle;
33 class UniformRandomVariable;
34 class CtrlBAckResponseHeader;
35 
58 class DcaTxop : public Object
59 {
60 public:
62  friend class DcfListener;
65 
66  DcaTxop ();
67  virtual ~DcaTxop ();
68 
73  static TypeId GetTypeId (void);
74 
90 
96  virtual bool IsEdca ();
97 
103  void SetLow (const Ptr<MacLow> low);
109  void SetManager (const Ptr<DcfManager> manager);
115  virtual void SetWifiRemoteStationManager (const Ptr<WifiRemoteStationManager> remoteManager);
121  void SetTxMiddle (const Ptr<MacTxMiddle> txMiddle);
122 
127  void SetTxOkCallback (TxOk callback);
132  void SetTxFailedCallback (TxFailed callback);
137  void SetTxDroppedCallback (TxDropped callback);
138 
144  Ptr<MacLow> GetLow (void) const;
145 
151  Ptr<WifiMacQueue > GetQueue () const;
152 
158  void SetMinCw (uint32_t minCw);
164  void SetMaxCw (uint32_t maxCw);
170  void SetAifsn (uint32_t aifsn);
177  void SetTxopLimit (Time txopLimit);
183  uint32_t GetMinCw (void) const;
189  uint32_t GetMaxCw (void) const;
195  uint32_t GetAifsn (void) const;
201  Time GetTxopLimit (void) const;
202 
206  virtual void NotifyChannelSwitching (void);
211  virtual void NotifySleep (void);
215  virtual void NotifyWakeUp (void);
216 
217  /* Event handlers */
225  virtual void Queue (Ptr<const Packet> packet, const WifiMacHeader &hdr);
226 
227  /* Event handlers */
231  virtual void MissedCts (void);
235  virtual void GotAck (void);
239  virtual void MissedAck (void);
249  virtual void GotBlockAck (const CtrlBAckResponseHeader *blockAck, Mac48Address recipient, double rxSnr, WifiMode txMode, double dataSnr);
254  virtual void MissedBlockAck (uint8_t nMpdus);
255 
260  virtual void StartNextFragment (void);
264  virtual void Cancel (void);
268  virtual void StartNextPacket (void);
273  virtual void EndTxNoAck (void);
274 
281  virtual bool HasTxop (void) const;
282 
292  int64_t AssignStreams (int64_t stream);
293 
294 
295 protected:
297  friend class DcfState;
298 
299  virtual void DoDispose (void);
300  virtual void DoInitialize (void);
301 
302  /* dcf notifications forwarded here */
309  virtual bool NeedsAccess (void) const;
310 
314  virtual void NotifyAccessGranted (void);
318  virtual void NotifyInternalCollision (void);
322  virtual void NotifyCollision (void);
323 
327  virtual void RestartAccessIfNeeded (void);
331  virtual void StartAccessIfNeeded (void);
332 
341  bool NeedRtsRetransmission (Ptr<const Packet> packet, const WifiMacHeader &hdr);
350  bool NeedDataRetransmission (Ptr<const Packet> packet, const WifiMacHeader &hdr);
357  virtual bool NeedFragmentation (void) const;
358 
364  void NextFragment (void);
379  virtual uint32_t GetNextFragmentSize (void) const;
385  virtual uint32_t GetFragmentSize (void) const;
391  virtual uint32_t GetFragmentOffset (void) const;
398  virtual bool IsLastFragment (void) const;
407 
418 
423 };
424 
425 } //namespace ns3
426 
427 #endif /* DCA_TXOP_H */
virtual uint32_t GetFragmentSize(void) const
Calculate the size of the current fragment.
Definition: dca-txop.cc:304
MacLowTransmissionParameters m_currentParams
current transmission parameters
Definition: dca-txop.h:421
virtual void NotifyInternalCollision(void)
Notify the DCF that internal collision has occurred.
Definition: dca-txop.cc:428
uint32_t GetMaxCw(void) const
Return the maximum contention window size.
Definition: dca-txop.cc:201
bool NeedRtsRetransmission(Ptr< const Packet > packet, const WifiMacHeader &hdr)
Check if RTS should be re-transmitted if CTS was missed.
Definition: dca-txop.cc:275
Simulation virtual time values and global simulation resolution.
Definition: nstime.h:102
Ptr< DcfState > m_dcf
the DCF state
Definition: dca-txop.h:408
Callback< void, const WifiMacHeader & > TxFailed
typedef for a callback to invoke when a packet transmission was failed.
Definition: dca-txop.h:84
void SetTxDroppedCallback(TxDropped callback)
Definition: dca-txop.cc:143
uint8_t m_fragmentNumber
the fragment number
Definition: dca-txop.h:422
void SetTxFailedCallback(TxFailed callback)
Definition: dca-txop.cc:136
void SetMaxCw(uint32_t maxCw)
Set the maximum contention window size.
Definition: dca-txop.cc:174
virtual uint32_t GetNextFragmentSize(void) const
Calculate the size of the next fragment.
Definition: dca-txop.cc:320
Ptr< MacLow > m_low
the MacLow
Definition: dca-txop.h:415
virtual void StartNextFragment(void)
Start transmission for the next fragment.
Definition: dca-txop.cc:548
TxOk m_txOkCallback
the transmit OK callback
Definition: dca-txop.h:410
bool NeedDataRetransmission(Ptr< const Packet > packet, const WifiMacHeader &hdr)
Check if DATA should be re-transmitted if ACK was missed.
Definition: dca-txop.cc:282
uint32_t GetAifsn(void) const
Return the number of slots that make up an AIFS.
Definition: dca-txop.cc:207
void SetManager(const Ptr< DcfManager > manager)
Set DcfManager this DcaTxop is associated to.
Definition: dca-txop.cc:101
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:228
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)
Get the type ID.
Definition: dca-txop.cc:39
control how a packet is transmitted.
Definition: mac-low.h:54
void SetTxOkCallback(TxOk callback)
Definition: dca-txop.cc:129
virtual void NotifySleep(void)
When sleep operation occurs, if there is a pending packet transmission, it will be reinserted to the ...
Definition: dca-txop.cc:451
virtual Ptr< Packet > GetFragmentPacket(WifiMacHeader *hdr)
Get the next fragment from the packet with appropriate Wifi header for the fragment.
Definition: dca-txop.cc:336
friend class MacLowTransmissionListener
allow MacLowTransmissionListener class access
Definition: dca-txop.h:64
Callback< void, Ptr< const Packet > > TxDropped
typedef for a callback to invoke when a packet is dropped.
Definition: dca-txop.h:89
virtual void Queue(Ptr< const Packet > packet, const WifiMacHeader &hdr)
Definition: dca-txop.cc:219
Time GetTxopLimit(void) const
Return the TXOP limit.
Definition: dca-txop.cc:213
TxDropped m_txDroppedCallback
the packet dropped callback
Definition: dca-txop.h:412
virtual bool IsEdca()
Check for EDCA.
Definition: dca-txop.cc:589
Ptr< WifiMacQueue > m_queue
the wifi MAC queue
Definition: dca-txop.h:413
virtual void Cancel(void)
Cancel the transmission.
Definition: dca-txop.cc:571
virtual bool NeedFragmentation(void) const
Check if the current packet should be fragmented.
Definition: dca-txop.cc:289
virtual void DoInitialize(void)
Initialize() implementation.
Definition: dca-txop.cc:267
virtual void NotifyChannelSwitching(void)
When a channel switching occurs, enqueued packets are removed.
Definition: dca-txop.cc:443
virtual void MissedCts(void)
Event handler when a CTS timeout has occurred.
Definition: dca-txop.cc:469
virtual ~DcaTxop()
Definition: dca-txop.cc:83
keep track of the state needed for a single DCF function.
Definition: dcf-state.h:41
Headers for Block ack response.
Definition: ctrl-headers.h:190
virtual void GotAck(void)
Event handler when an ACK is received.
Definition: dca-txop.cc:494
Ptr< WifiRemoteStationManager > m_stationManager
the wifi remote station manager
Definition: dca-txop.h:416
void SetAifsn(uint32_t aifsn)
Set the number of slots that make up an AIFS.
Definition: dca-txop.cc:181
Ptr< UniformRandomVariable > m_rng
the random stream
Definition: dca-txop.h:417
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:79
virtual bool NeedsAccess(void) const
Check if the DCF requires access.
Definition: dca-txop.cc:357
WifiMacHeader m_currentHdr
the current header
Definition: dca-txop.h:420
Ptr< WifiMacQueue > GetQueue() const
Return the packet queue associated with this DcaTxop.
Definition: dca-txop.cc:160
an EUI-48 address
Definition: mac48-address.h:43
virtual void NotifyWakeUp(void)
When wake up operation occurs, channel access will be restarted.
Definition: dca-txop.cc:462
Ptr< const Packet > m_currentPacket
the current packet
Definition: dca-txop.h:419
friend class DcfListener
allow DcfListener class access
Definition: dca-txop.h:62
Ptr< MacLow > GetLow(void) const
Return the MacLow associated with this DcaTxop.
Definition: dca-txop.cc:260
virtual void StartNextPacket(void)
Start transmission for the next packet if allowed by the TxopLimit.
Definition: dca-txop.cc:595
void SetLow(const Ptr< MacLow > low)
Set MacLow associated with this DcaTxop.
Definition: dca-txop.cc:115
void SetTxMiddle(const Ptr< MacTxMiddle > txMiddle)
Set MacTxMiddle this DcaTxop is associated to.
Definition: dca-txop.cc:108
void SetMinCw(uint32_t minCw)
Set the minimum contention window size.
Definition: dca-txop.cc:167
virtual bool IsLastFragment(void) const
Check if the current fragment is the last fragment.
Definition: dca-txop.cc:312
Ptr< MacTxMiddle > m_txMiddle
the MacTxMiddle
Definition: dca-txop.h:414
virtual void GotBlockAck(const CtrlBAckResponseHeader *blockAck, Mac48Address recipient, double rxSnr, WifiMode txMode, double dataSnr)
Event handler when a Block ACK is received.
Definition: dca-txop.cc:601
void SetTxopLimit(Time txopLimit)
Set the TXOP limit.
Definition: dca-txop.cc:188
void TxDroppedPacket(Ptr< const WifiMacQueueItem > item)
Pass the packet included in the wifi MAC queue item to the packet dropped callback.
Definition: dca-txop.cc:151
virtual void DoDispose(void)
Destructor implementation.
Definition: dca-txop.cc:89
virtual void NotifyCollision(void)
Notify the DCF that collision has occurred.
Definition: dca-txop.cc:435
virtual void StartAccessIfNeeded(void)
Request access from DCF manager if needed.
Definition: dca-txop.cc:248
void NextFragment(void)
Continue to the next fragment.
Definition: dca-txop.cc:297
virtual bool HasTxop(void) const
Check if the station has TXOP granted for the next MPDU.
Definition: dca-txop.cc:613
virtual void RestartAccessIfNeeded(void)
Restart access request if needed.
Definition: dca-txop.cc:236
A base class which provides memory management and object aggregation.
Definition: object.h:87
virtual void MissedAck(void)
Event handler when an ACK is missed.
Definition: dca-txop.cc:521
handle packet fragmentation and retransmissions.
Definition: dca-txop.h:58
uint32_t GetMinCw(void) const
Return the minimum contention window size.
Definition: dca-txop.cc:195
a unique identifier for an interface.
Definition: type-id.h:58
virtual void NotifyAccessGranted(void)
Notify the DCF that access has been granted.
Definition: dca-txop.cc:364
Implements the IEEE 802.11 MAC header.
virtual void EndTxNoAck(void)
Event handler when a transmission that does not require an ACK has completed.
Definition: dca-txop.cc:578
virtual void SetWifiRemoteStationManager(const Ptr< WifiRemoteStationManager > remoteManager)
Set WifiRemoteStationsManager this DcaTxop is associated to.
Definition: dca-txop.cc:122
virtual void MissedBlockAck(uint8_t nMpdus)
Event handler when a Block ACK timeout has occurred.
Definition: dca-txop.cc:607
virtual uint32_t GetFragmentOffset(void) const
Calculate the offset for the current fragment.
Definition: dca-txop.cc:328
TxFailed m_txFailedCallback
the transmit failed callback
Definition: dca-txop.h:411
Ptr< DcfManager > m_manager
the DCF manager
Definition: dca-txop.h:409