A Discrete-Event Network Simulator
API
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Groups Pages
dca-txop.h
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 <list>
26 #include "ns3/callback.h"
27 #include "ns3/packet.h"
28 #include "ns3/nstime.h"
29 #include "ns3/object.h"
30 #include "ns3/wifi-phy.h"
31 #include "ns3/wifi-mac-header.h"
32 #include "ns3/wifi-mode.h"
33 #include "ns3/wifi-remote-station-manager.h"
34 #include "ns3/dcf.h"
35 #include "ns3/cognitive-packet-tags.h"
36 
37 namespace ns3 {
38 
39 class DcfState;
40 class DcfManager;
41 class WifiMacQueue;
42 class MacLow;
43 class WifiMacParameters;
44 class MacTxMiddle;
45 class RandomStream;
46 class MacStation;
47 class MacStations;
48 
70 class DcaTxop : public Dcf
71 {
72 public:
73  static TypeId GetTypeId (void);
74 
77 
78  DcaTxop ();
79  ~DcaTxop ();
80 
81  void SetLow (Ptr<MacLow> low);
82  void SetManager (DcfManager *manager);
83  void SetWifiRemoteStationManager (Ptr<WifiRemoteStationManager> remoteManager);
84 
89  void SetTxOkCallback (TxOk callback);
94  void SetTxFailedCallback (TxFailed callback);
95 
96  Ptr<WifiMacQueue > GetQueue () const;
97  virtual void SetMinCw (uint32_t minCw);
98  virtual void SetMaxCw (uint32_t maxCw);
99  virtual void SetAifsn (uint32_t aifsn);
100  virtual uint32_t GetMinCw (void) const;
101  virtual uint32_t GetMaxCw (void) const;
102  virtual uint32_t GetAifsn (void) const;
103 
111  void Queue (Ptr<const Packet> packet, const WifiMacHeader &hdr);
112 
121  int64_t AssignStreams (int64_t stream);
122 
127  void RestartAccessIfNeeded (void);
128 
129 private:
130  class TransmissionListener;
131  class NavListener;
132  class PhyListener;
133  class Dcf;
134  friend class Dcf;
135  friend class TransmissionListener;
136  struct ActiveChannels;
137 
138  DcaTxop &operator = (const DcaTxop &);
139  DcaTxop (const DcaTxop &o);
140 
141  // Inherited from ns3::Object
142  Ptr<MacLow> Low (void);
143  void DoInitialize ();
144  /* dcf notifications forwarded here */
145  bool NeedsAccess (void) const;
146  void NotifyAccessGranted (void);
147  void NotifyInternalCollision (void);
148  void NotifyCollision (void);
152  void NotifyChannelSwitching (Time duration, uint16_t toChannel);
153  void NotifyChannelSensing (void);
154  /* event handlers */
155  void GotCts (double snr, WifiMode txMode);
156  void MissedCts (void);
157  void GotAck (double snr, WifiMode txMode);
158  void MissedAck (void);
159  void StartNext (void);
160  void Cancel (void);
161  void EndTxNoAck (void);
162  void UpdateActiveChannels (uint16_t channel);
163  uint16_t GetNextActiveChannel (void);
164 
165  void StartAccessIfNeeded (void);
166  bool NeedRts (Ptr<const Packet> packet, const WifiMacHeader *header);
167  bool NeedRtsRetransmission (void);
168  bool NeedDataRetransmission (void);
169  bool NeedFragmentation (void);
170  uint32_t GetNextFragmentSize (void);
171  uint32_t GetFragmentSize (void);
172  uint32_t GetFragmentOffset (void);
173  bool IsLastFragment (void);
174  void NextFragment (void);
175  Ptr<Packet> GetFragmentPacket (WifiMacHeader *hdr);
176  virtual void DoDispose (void);
177  void SwitchQueueHandler (void);
178 
179  Dcf *m_dcf;
180  DcfManager *m_manager;
181  TxOk m_txOkCallback;
182  TxFailed m_txFailedCallback;
183  Ptr<WifiMacQueue> m_queue;
184  MacTxMiddle *m_txMiddle;
185  Ptr <MacLow> m_low;
186  Ptr<WifiRemoteStationManager> m_stationManager;
187  TransmissionListener *m_transmissionListener;
188  RandomStream *m_rng;
189  typedef std::list<struct ActiveChannels> ListActiveChannels;
190  typedef std::list<struct ActiveChannels>::iterator ListActiveChannelsI;
191 
192  bool m_accessOngoing;
193  Ptr<const Packet> m_currentPacket;
194  WifiMacHeader m_currentHdr;
195  uint8_t m_fragmentNumber;
196  uint16_t m_currentChannel;
197  ListActiveChannels m_activeChannels;
198  EventId m_switchQueueTimer;
199  Time m_activeChannelTimeout;
200  Time m_queueUtilizationTime;
201 
203  {
204  ActiveChannels(uint16_t channel, Time lastActive);
205  uint16_t channel;
206  Time lastActive;
207  };
208 };
209 
210 } // namespace ns3
211 
212 
213 
214 #endif /* DCA_TXOP_H */
keep track of time unit.
Definition: nstime.h:149
smart pointer class similar to boost::intrusive_ptr
Definition: ptr.h:59
void SetTxFailedCallback(TxFailed callback)
Definition: dca-txop.cc:216
int64_t AssignStreams(int64_t stream)
Definition: dca-txop.cc:388
represent a single transmission modeA WifiMode is implemented by a single integer which is used to lo...
Definition: wifi-mode.h:88
void SetTxOkCallback(TxOk callback)
Definition: dca-txop.cc:210
void Queue(Ptr< const Packet > packet, const WifiMacHeader &hdr)
Definition: dca-txop.cc:267
void Cancel(void)
Definition: dca-txop.cc:753
Manage a set of ns3::DcfStateHandle a set of independent ns3::DcfState, each of which represents a si...
Definition: dcf-manager.h:175
void NotifyChannelSwitching(Time duration, uint16_t toChannel)
Definition: dca-txop.cc:632
void DoInitialize()
Definition: dca-txop.cc:436
an identifier for simulation events.
Definition: event-id.h:46
virtual void DoDispose(void)
Definition: dca-txop.cc:173
void RestartAccessIfNeeded(void)
Definition: dca-txop.cc:396
handle packet fragmentation and retransmissions.This class implements the packet fragmentation and re...
Definition: dca-txop.h:70
a unique identifier for an interface.
Definition: type-id.h:44