A Discrete-Event Network Simulator
API
half-duplex-ideal-phy.h
Go to the documentation of this file.
1 /* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
2 /*
3  * Copyright (c) 2009 CTTC
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: Nicola Baldo <nbaldo@cttc.es>
19  */
20 
21 #ifndef HALF_DUPLEX_IDEAL_PHY_H
22 #define HALF_DUPLEX_IDEAL_PHY_H
23 
24 
25 #include <ns3/spectrum-value.h>
26 #include <ns3/mobility-model.h>
27 #include <ns3/packet.h>
28 #include <ns3/nstime.h>
29 #include <ns3/net-device.h>
30 #include <ns3/spectrum-phy.h>
31 #include <ns3/spectrum-channel.h>
32 #include <ns3/spectrum-interference.h>
33 #include <ns3/data-rate.h>
34 #include <ns3/generic-phy.h>
35 #include <ns3/event-id.h>
36 #include <ns3/spectrum-signal-parameters.h>
37 
38 namespace ns3 {
39 
79 {
80 
81 public:
83  virtual ~HalfDuplexIdealPhy ();
84 
88  enum State
89  {
90  IDLE,
91  TX,
92  RX
93  };
94 
99  static TypeId GetTypeId (void);
100 
101  // inherited from SpectrumPhy
104  void SetDevice (Ptr<NetDevice> d);
106  Ptr<NetDevice> GetDevice () const;
110 
111 
119 
126 
127 
137  bool StartTx (Ptr<Packet> p);
138 
144  void SetRate (DataRate rate);
145 
151  DataRate GetRate () const;
152 
160 
168 
176 
184 
190  void SetAntenna (Ptr<AntennaModel> a);
191 
192 private:
193  virtual void DoDispose (void);
194 
199  void ChangeState (State newState);
203  void EndTx ();
207  void AbortRx ();
211  void EndRx ();
212 
214 
219 
224 
227 
234 
239 
241 
242 };
243 
244 }
245 
246 
247 #endif /* HALF_DUPLEX_IDEAL_PHY_H */
void SetRate(DataRate rate)
Set the PHY rate to be used by this PHY.
void SetGenericPhyTxEndCallback(GenericPhyTxEndCallback c)
Set the callback for the end of a TX, as part of the interconnections between the PHY and the MAC...
Smart pointer class similar to boost::intrusive_ptr.
Definition: ptr.h:73
Ptr< MobilityModel > m_mobility
Mobility model.
Abstract base class for Spectrum-aware PHY layers.
Definition: spectrum-phy.h:45
bool StartTx(Ptr< Packet > p)
Start a transmission.
Forward calls to a chain of Callback.
EventId m_endRxEventId
End Rx event.
void SetGenericPhyRxStartCallback(GenericPhyRxStartCallback c)
Set the callback for the start of RX, as part of the interconnections between the PHY and the MAC...
SpectrumInterference m_interference
Received interference.
GenericPhyRxEndErrorCallback m_phyMacRxEndErrorCallback
Callback - Rx error.
Ptr< MobilityModel > GetMobility()
Get the associated MobilityModel instance.
Ptr< const SpectrumValue > m_rxPsd
Rx power spectral density.
TracedCallback< Ptr< const Packet > > m_phyTxEndTrace
Trace - Tx end.
void StartRx(Ptr< SpectrumSignalParameters > params)
Notify the SpectrumPhy instance of an incoming signal.
TracedCallback< Ptr< const Packet > > m_phyRxStartTrace
Trace - Rx start.
TracedCallback< Ptr< const Packet > > m_phyRxAbortTrace
Trace - Rx abort.
Ptr< NetDevice > GetDevice() const
Get the associated NetDevice instance.
Class for representing data rates.
Definition: data-rate.h:88
TracedCallback< Ptr< const Packet > > m_phyTxStartTrace
Trace - Tx start.
void SetDevice(Ptr< NetDevice > d)
Set the associated NetDevice instance.
void SetAntenna(Ptr< AntennaModel > a)
set the AntennaModel to be used
Ptr< SpectrumValue > m_txPsd
Tx power spectral density.
void SetGenericPhyRxEndOkCallback(GenericPhyRxEndOkCallback c)
set the callback for the successful end of a RX, as part of the interconnections between the PHY and ...
void AbortRx()
About current Rx.
GenericPhyRxEndOkCallback m_phyMacRxEndOkCallback
Callback - Rx end.
virtual void DoDispose(void)
Destructor implementation.
Ptr< AntennaModel > GetRxAntenna()
Get the AntennaModel used by the NetDevice for reception.
Ptr< SpectrumChannel > m_channel
Channel.
This PHY layer implementation realizes an ideal OFDM PHY which transmits half-duplex (i...
DataRate GetRate() const
Get the PHY rate to be used by this PHY.
void SetNoisePowerSpectralDensity(Ptr< const SpectrumValue > noisePsd)
Set the Noise Power Spectral Density in power units (Watt, Pascal...) per Hz.
void EndRx()
End current Rx.
Every class exported by the ns3 library is enclosed in the ns3 namespace.
void ChangeState(State newState)
Change the PHY state.
This class implements a gaussian interference model, i.e., all incoming signals are added to the tota...
Ptr< NetDevice > m_netDevice
NetDevice connected to theis phy.
Ptr< Packet > m_rxPacket
Rx packet.
void SetGenericPhyRxEndErrorCallback(GenericPhyRxEndErrorCallback c)
set the callback for the end of a RX in error, as part of the interconnections between the PHY and th...
Ptr< AntennaModel > m_antenna
Antenna model.
An identifier for simulation events.
Definition: event-id.h:53
TracedCallback< Ptr< const Packet > > m_phyRxEndErrorTrace
Trace - Rx end (error)
GenericPhyRxStartCallback m_phyMacRxStartCallback
Callback - Rx start.
static TypeId GetTypeId(void)
Get the type ID.
Ptr< Packet > m_txPacket
Tx packet.
void SetChannel(Ptr< SpectrumChannel > c)
Set the channel attached to this device.
void EndTx()
End the current Tx.
TracedCallback< Ptr< const Packet > > m_phyRxEndOkTrace
Trace - Tx end (ok)
void SetMobility(Ptr< MobilityModel > m)
Set the mobility model associated with this device.
Ptr< const SpectrumModel > GetRxSpectrumModel() const
GenericPhyTxEndCallback m_phyMacTxEndCallback
Callback - Tx end.
void SetTxPowerSpectralDensity(Ptr< SpectrumValue > txPsd)
Set the Power Spectral Density of outgoing signals in power units (Watt, Pascal...) per Hz.
a unique identifier for an interface.
Definition: type-id.h:58