A Discrete-Event Network Simulator
API
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
wifi-phy.h
Go to the documentation of this file.
1 /* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
2 /*
3  * Copyright (c) 2005,2006 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 WIFI_PHY_H
22 #define WIFI_PHY_H
23 
24 #include <stdint.h>
25 #include "ns3/callback.h"
26 #include "ns3/packet.h"
27 #include "ns3/object.h"
28 #include "ns3/nstime.h"
29 #include "ns3/ptr.h"
30 #include "wifi-mode.h"
31 #include "wifi-preamble.h"
32 #include "wifi-phy-standard.h"
33 #include "ns3/traced-callback.h"
34 #include "wifi-tx-vector.h"
35 
36 namespace ns3 {
37 
38 class WifiChannel;
39 class NetDevice;
40 
45 {
46 public:
47  virtual ~WifiPhyListener ();
48 
61  virtual void NotifyRxStart (Time duration) = 0;
67  virtual void NotifyRxEndOk (void) = 0;
73  virtual void NotifyRxEndError (void) = 0;
83  virtual void NotifyTxStart (Time duration) = 0;
84 
100  virtual void NotifyMaybeCcaBusyStart (Time duration) = 0;
108  virtual void NotifySwitchingStart (Time duration) = 0;
109 };
110 
111 
117 class WifiPhy : public Object
118 {
119 public:
123  enum State
124  {
136  TX,
140  RX,
145  };
146 
159 
160  static TypeId GetTypeId (void);
161 
162  WifiPhy ();
163  virtual ~WifiPhy ();
164 
165  virtual double GetTxPowerStart (void) const = 0;
166  virtual double GetTxPowerEnd (void) const = 0;
170  virtual uint32_t GetNTxPower (void) const = 0;
171 
176  virtual void SetReceiveOkCallback (RxOkCallback callback) = 0;
181  virtual void SetReceiveErrorCallback (RxErrorCallback callback) = 0;
182 
190  virtual void SendPacket (Ptr<const Packet> packet, WifiMode mode, enum WifiPreamble preamble, WifiTxVector txvector) = 0;
191 
198  virtual void RegisterListener (WifiPhyListener *listener) = 0;
199 
203  virtual bool IsStateIdle (void) = 0;
207  virtual bool IsStateCcaBusy (void) = 0;
211  virtual bool IsStateBusy (void) = 0;
215  virtual bool IsStateRx (void) = 0;
219  virtual bool IsStateTx (void) = 0;
223  virtual bool IsStateSwitching (void) = 0;
227  virtual Time GetStateDuration (void) = 0;
234  virtual Time GetDelayUntilIdle (void) = 0;
235 
236  virtual Time GetLastRxStartTime (void) const = 0;
237 
245  static Time CalculateTxDuration (uint32_t size, WifiTxVector txvector, enum WifiPreamble preamble);
246 
254  static uint32_t GetPlcpHtTrainingSymbolDurationMicroSeconds (WifiMode payloadMode, WifiPreamble preamble, WifiTxVector txvector);
261  static WifiMode GetMFPlcpHeaderMode (WifiMode payloadMode, WifiPreamble preamble);
268  static uint32_t GetPlcpHtSigHeaderDurationMicroSeconds (WifiMode payloadMode, WifiPreamble preamble);
269 
270 
277  static WifiMode GetPlcpHeaderMode (WifiMode payloadMode, WifiPreamble preamble);
278 
285  static uint32_t GetPlcpHeaderDurationMicroSeconds (WifiMode payloadMode, WifiPreamble preamble);
286 
293  static uint32_t GetPlcpPreambleDurationMicroSeconds (WifiMode payloadMode, WifiPreamble preamble);
294 
301  static double GetPayloadDurationMicroSeconds (uint32_t size, WifiTxVector txvector);
302 
320  virtual uint32_t GetNModes (void) const = 0;
339  virtual WifiMode GetMode (uint32_t mode) const = 0;
346  virtual double CalculateSnr (WifiMode txMode, double ber) const = 0;
361  virtual uint32_t GetNBssMembershipSelectors (void) const=0;
362 
363  virtual uint32_t GetBssMembershipSelector (uint32_t selector) const=0;
378  virtual WifiModeList GetMembershipSelectorModes(uint32_t selector)=0;
393  virtual uint8_t GetNMcs (void) const=0;
394  virtual uint8_t GetMcs (uint8_t mcs) const=0;
395 
396  /* Converts from DataRate to MCS index and vice versa */
397  virtual uint32_t WifiModeToMcs (WifiMode mode)=0;
398  virtual WifiMode McsToWifiMode (uint8_t mcs)=0;
399 
400 
409  virtual void SetChannelNumber (uint16_t id) = 0;
411  virtual uint16_t GetChannelNumber () const = 0;
412 
413  virtual void ConfigureStandard (enum WifiPhyStandard standard) = 0;
414 
415  virtual Ptr<WifiChannel> GetChannel (void) const = 0;
416 
417  static WifiMode GetDsssRate1Mbps ();
418  static WifiMode GetDsssRate2Mbps ();
419  static WifiMode GetDsssRate5_5Mbps ();
420  static WifiMode GetDsssRate11Mbps ();
421  static WifiMode GetErpOfdmRate6Mbps ();
422  static WifiMode GetErpOfdmRate9Mbps ();
423  static WifiMode GetErpOfdmRate12Mbps ();
424  static WifiMode GetErpOfdmRate18Mbps ();
425  static WifiMode GetErpOfdmRate24Mbps ();
426  static WifiMode GetErpOfdmRate36Mbps ();
427  static WifiMode GetErpOfdmRate48Mbps ();
428  static WifiMode GetErpOfdmRate54Mbps ();
429  static WifiMode GetOfdmRate6Mbps ();
430  static WifiMode GetOfdmRate9Mbps ();
431  static WifiMode GetOfdmRate12Mbps ();
432  static WifiMode GetOfdmRate18Mbps ();
433  static WifiMode GetOfdmRate24Mbps ();
434  static WifiMode GetOfdmRate36Mbps ();
435  static WifiMode GetOfdmRate48Mbps ();
436  static WifiMode GetOfdmRate54Mbps ();
469  //Rates for clause 20 with short guard interval
486 
487 
492  void NotifyTxBegin (Ptr<const Packet> packet);
493 
498  void NotifyTxEnd (Ptr<const Packet> packet);
499 
504  void NotifyTxDrop (Ptr<const Packet> packet);
505 
510  void NotifyRxBegin (Ptr<const Packet> packet);
511 
516  void NotifyRxEnd (Ptr<const Packet> packet);
517 
522  void NotifyRxDrop (Ptr<const Packet> packet);
523 
544  void NotifyMonitorSniffRx (Ptr<const Packet> packet, uint16_t channelFreqMhz, uint16_t channelNumber, uint32_t rate, bool isShortPreamble,
545  double signalDbm, double noiseDbm);
546 
560  void NotifyMonitorSniffTx (Ptr<const Packet> packet, uint16_t channelFreqMhz, uint16_t channelNumber, uint32_t rate, bool isShortPreamble, uint8_t txPower);
561 
570  virtual int64_t AssignStreams (int64_t stream) = 0;
571 
575  virtual void SetFrequency (uint32_t freq)=0;
576  virtual uint32_t GetFrequency (void) const=0;
580  virtual void SetNumberOfTransmitAntennas (uint32_t tx)=0;
581 
582  virtual uint32_t GetNumberOfTransmitAntennas (void) const=0;
586  virtual void SetNumberOfReceiveAntennas (uint32_t rx)=0 ;
590  virtual uint32_t GetNumberOfReceiveAntennas (void) const=0;
594  virtual void SetGuardInterval (bool GuardInterval)=0;
598  virtual bool GetGuardInterval (void) const = 0;
602  virtual void SetLdpc (bool Ldpc)=0;
606  virtual bool GetLdpc (void) const=0;
610  virtual void SetStbc (bool stbc)=0;
614  virtual bool GetStbc (void) const=0;
615 
619  virtual void SetGreenfield (bool greenfield)=0;
623  virtual bool GetGreenfield (void) const=0;
627  virtual bool GetChannelBonding (void) const = 0;
631  virtual void SetChannelBonding (bool channelbonding) = 0 ;
632 
633 private:
641 
649 
657 
665 
673 
680 
691  TracedCallback<Ptr<const Packet>, uint16_t, uint16_t, uint32_t, bool, double, double> m_phyMonitorSniffRxTrace;
692 
703  TracedCallback<Ptr<const Packet>, uint16_t, uint16_t, uint32_t, bool,uint8_t> m_phyMonitorSniffTxTrace;
704 
705 };
706 
711 std::ostream& operator<< (std::ostream& os, enum WifiPhy::State state);
712 
713 } // namespace ns3
714 
715 #endif /* WIFI_PHY_H */