00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022 #ifndef NS2EXT_WIFI_PHY_H
00023 #define NS2EXT_WIFI_PHY_H
00024
00025 #include <stdint.h>
00026 #include "ns3/callback.h"
00027 #include "ns3/event-id.h"
00028 #include "ns3/packet.h"
00029 #include "ns3/object.h"
00030 #include "ns3/traced-callback.h"
00031 #include "ns3/nstime.h"
00032 #include "ns3/ptr.h"
00033 #include "ns3/random-variable.h"
00034 #include "wifi-phy.h"
00035 #include "wifi-mode.h"
00036 #include "wifi-preamble.h"
00037 #include "wifi-phy-standard.h"
00038 #include "interference-helper.h"
00039
00040
00041 namespace ns3 {
00042
00043 class RandomUniform;
00044 class RxEvent;
00045 class Ns2ExtWifiChannel;
00046 class Ns2ExtWifiPhyStateHelper;
00047
00048
00049
00050
00051
00052
00053
00054
00055
00056
00057
00058
00059
00060
00061
00062
00063 class Ns2ExtWifiPhy : public WifiPhy
00064 {
00065 public:
00066
00067 static TypeId GetTypeId (void);
00068
00069 Ns2ExtWifiPhy ();
00070 virtual ~Ns2ExtWifiPhy ();
00071
00072 void SetChannel (Ptr<Ns2ExtWifiChannel> channel);
00073 void StartReceivePacket (Ptr<Packet> packet,
00074 double rxPowerDbm,
00075 WifiMode mode,
00076 WifiPreamble preamble);
00077
00078 void SetStandard (enum WifiPhyStandard standard);
00079
00080 void SetRxNoise (double ratio);
00081 double GetRxNoise (void) const;
00082
00083 void SetUseConstantNoiseFloor (bool value);
00084 bool GetUseConstantNoiseFloor () const;
00085
00086 void SetConstantNoiseFloor (double dbm);
00087 double GetConstantNoiseFloor () const;
00088
00089 void SetTxPowerStart (double start);
00090 void SetTxPowerEnd (double end);
00091 void SetNTxPower (uint32_t n);
00092 void SetTxGain (double gain);
00093 void SetRxGain (double gain);
00094 void SetDevice (Ptr<Object> device);
00095 void SetMobility (Ptr<Object> mobility);
00096 double GetTxGain (void) const;
00097 double GetRxGain (void) const;
00098 Ptr<Object> GetDevice (void) const;
00099 Ptr<Object> GetMobility (void);
00100
00101
00102
00103
00104
00105 void SetCarrierSenseThreshold (double dbm);
00106
00107
00108
00109
00110 double GetCarrierSenseThreshold () const;
00111
00112 virtual double GetTxPowerStart (void) const;
00113 virtual double GetTxPowerEnd (void) const;
00114 virtual uint32_t GetNTxPower (void) const;
00115 virtual void SetReceiveOkCallback (WifiPhy::RxOkCallback callback);
00116 virtual void SetReceiveErrorCallback (WifiPhy::RxErrorCallback callback);
00117 virtual void SendPacket (Ptr<const Packet> packet, WifiMode mode, enum WifiPreamble preamble, uint8_t txPowerLevel);
00118 virtual void RegisterListener (WifiPhyListener *listener);
00119 virtual bool IsStateCcaBusy (void);
00120 virtual bool IsStateIdle (void);
00121 virtual bool IsStateBusy (void);
00122 virtual bool IsStateSyncing (void);
00123 virtual bool IsStateRx (void);
00124 virtual bool IsStateTx (void);
00125 virtual Time GetStateDuration (void);
00126 virtual Time GetDelayUntilIdle (void);
00127 virtual Time GetLastRxStartTime (void) const;
00128 virtual Time CalculateTxDuration (uint32_t size, WifiMode payloadMode, enum WifiPreamble preamble) const;
00129 virtual uint32_t GetNModes (void) const;
00130 virtual WifiMode GetMode (uint32_t mode) const;
00131 virtual double CalculateSnr (WifiMode txMode, double ber) const;
00132 virtual Ptr<WifiChannel> GetChannel (void) const;
00133
00134 private:
00135 typedef std::vector<WifiMode> Modes;
00136
00137 private:
00138 Ns2ExtWifiPhy (const Ns2ExtWifiPhy &o);
00139 virtual void DoDispose (void);
00140 void Configure80211a (void);
00141 void ConfigureHolland (void);
00142 double DbmToW (double dbm) const;
00143 double DbToRatio (double db) const;
00144 double WToDbm (double w) const;
00145 double RatioToDb (double ratio) const;
00146 double GetPowerDbm (uint8_t power) const;
00147 void EndReceivePacket (Ptr<Packet> packet, Ptr<InterferenceHelper::Event> event);
00148
00149 private:
00150 double m_txGainDb;
00151 double m_rxGainDb;
00152 double m_txPowerBaseDbm;
00153 double m_txPowerEndDbm;
00154 uint32_t m_nTxPower;
00155 double m_carrierSenseThresholdW;
00156 double m_sinrReceive;
00157
00158 Ptr<Ns2ExtWifiChannel> m_channel;
00159 Ptr<Object> m_device;
00160 Ptr<Object> m_mobility;
00161 Modes m_modes;
00162 EventId m_endRxEvent;
00163 WifiPhyStandard m_standard;
00164 Ptr<Ns2ExtWifiPhyStateHelper> m_state;
00165 InterferenceHelper m_interference;
00166 };
00167
00168 }
00169
00170
00171 #endif