A Discrete-Event Network Simulator
API
uan-transducer.h
Go to the documentation of this file.
1 /* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
2 /*
3  * Copyright (c) 2009 University of Washington
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: Leonard Tracy <lentracy@gmail.com>
19  */
20 
21 #ifndef UAN_TRANSDUCER_H
22 #define UAN_TRANSDUCER_H
23 
24 #include "ns3/object.h"
25 #include "ns3/packet.h"
26 #include "uan-tx-mode.h"
27 #include "ns3/uan-prop-model.h"
28 
29 #include <list>
30 
31 namespace ns3 {
32 
33 class UanPhy;
34 class UanChannel;
35 
36 
43 {
44 public:
45 
48  {
49  }
50 
60  UanPacketArrival (Ptr<Packet> packet, double rxPowerDb, UanTxMode txMode, UanPdp pdp, Time arrTime)
61  : m_packet (packet),
62  m_rxPowerDb (rxPowerDb),
63  m_txMode (txMode),
64  m_pdp (pdp),
65  m_arrTime (arrTime)
66  {
67  }
68 
71  {
72  m_packet = 0;
73  }
74 
80  inline Ptr<Packet> GetPacket (void) const
81  {
82  return m_packet;
83  }
89  inline double GetRxPowerDb (void) const
90  {
91  return m_rxPowerDb;
92  }
98  inline const UanTxMode &GetTxMode (void) const
99  {
100  return m_txMode;
101  }
107  inline Time GetArrivalTime (void) const
108  {
109  return m_arrTime;
110  }
116  inline UanPdp GetPdp (void) const
117  {
118  return m_pdp;
119  }
120 private:
122  double m_rxPowerDb;
126 
127 }; // class UanPacketArrival
128 
138 class UanTransducer : public Object
139 {
140 public:
145  static TypeId GetTypeId (void);
146 
148  enum State {
149  TX,
150  RX
151  };
152 
154  typedef std::list<UanPacketArrival> ArrivalList;
156  typedef std::list<Ptr<UanPhy> > UanPhyList;
157 
163  virtual State GetState (void) const = 0;
164 
171  virtual bool IsRx (void) const = 0;
177  virtual bool IsTx (void) const = 0;
183  virtual const ArrivalList &GetArrivalList (void) const = 0;
189  virtual void SetRxGainDb (double gainDb) = 0;
195  virtual double GetRxGainDb (void) = 0;
203  virtual double ApplyRxGainDb (double rxPowerDb, UanTxMode mode) = 0;
212  virtual void Receive (Ptr<Packet> packet, double rxPowerDb, UanTxMode txMode, UanPdp pdp) = 0;
221  virtual void Transmit (Ptr<UanPhy> src, Ptr<Packet> packet, double txPowerDb, UanTxMode txMode) = 0;
227  virtual void SetChannel (Ptr<UanChannel> chan) = 0;
233  virtual Ptr<UanChannel> GetChannel (void) const = 0;
241  virtual void AddPhy (Ptr<UanPhy> phy) = 0;
247  virtual const UanPhyList &GetPhyList (void) const = 0;
251  virtual void Clear (void) = 0;
252 
253 }; // class UanTransducer
254 
255 } // namespace ns3
256 
257 #endif /* UAN_TRANSDUCER_H */
double m_rxPowerDb
The received power, in dB.
Simulation virtual time values and global simulation resolution.
Definition: nstime.h:102
virtual const UanPhyList & GetPhyList(void) const =0
Get the list of physical layer above this transducer.
Time GetArrivalTime(void) const
Get the packet arrival time.
double GetRxPowerDb(void) const
Get the received signal strength.
virtual bool IsRx(void) const =0
Is the state receiving (or available for reception)?
std::list< Ptr< UanPhy > > UanPhyList
List of UanPhy objects.
virtual const ArrivalList & GetArrivalList(void) const =0
Get the list of overlapped (in time) packets at this transducer.
UanPacketArrival(Ptr< Packet > packet, double rxPowerDb, UanTxMode txMode, UanPdp pdp, Time arrTime)
Constructor.
virtual void Receive(Ptr< Packet > packet, double rxPowerDb, UanTxMode txMode, UanPdp pdp)=0
Notify this object that a new packet has arrived at this nodes location.
~UanPacketArrival()
Destructor.
UanPdp GetPdp(void) const
Get the propagation delay profile.
virtual void AddPhy(Ptr< UanPhy > phy)=0
Attach a physical network layer above this transducer.
phy
Definition: third.py:86
virtual State GetState(void) const =0
Get the transducer state.
UanTxMode m_txMode
The transmission mode.
virtual void SetChannel(Ptr< UanChannel > chan)=0
Attach this transducer to a channel.
virtual void Clear(void)=0
Clears all pointer references.
The power delay profile returned by propagation models.
Abstraction of packet modulation information.
Definition: uan-tx-mode.h:41
UanPdp m_pdp
The propagation delay profile.
Virtual base for Transducer objects.
std::list< UanPacketArrival > ArrivalList
List of arriving packets overlapping in time.
Ptr< Packet > GetPacket(void) const
Get the arriving packet.
UanPacketArrival()
Default constructor.
virtual Ptr< UanChannel > GetChannel(void) const =0
Get the attached channel.
virtual void SetRxGainDb(double gainDb)=0
Set the receiver gain.
Time m_arrTime
The arrival time.
Ptr< Packet > m_packet
The arrived packet.
Every class exported by the ns3 library is enclosed in the ns3 namespace.
virtual bool IsTx(void) const =0
Is the state transmitting?
virtual double ApplyRxGainDb(double rxPowerDb, UanTxMode mode)=0
Apply receiver gain in dB to the received power.
virtual double GetRxGainDb(void)=0
Get the receiver gain added to signal at receiver in dB.
virtual void Transmit(Ptr< UanPhy > src, Ptr< Packet > packet, double txPowerDb, UanTxMode txMode)=0
Transmit a packet from this transducer.
const UanTxMode & GetTxMode(void) const
Get the transmission mode of the packet.
State
Transducer state.
A base class which provides memory management and object aggregation.
Definition: object.h:87
a unique identifier for an interface.
Definition: type-id.h:58
Class consisting of packet arrival information (Time, RxPower, mode, PDP).
static TypeId GetTypeId(void)
Register this type.