21 #include "ns3/object.h"
22 #include "ns3/packet.h"
23 #include "ns3/simulator.h"
24 #include "ns3/mobility-model.h"
25 #include "ns3/net-device.h"
28 #include "ns3/pointer.h"
31 #include "uan-channel.h"
33 #include "uan-prop-model.h"
34 #include "uan-tx-mode.h"
35 #include "uan-net-device.h"
36 #include "uan-transducer.h"
37 #include "uan-noise-model-default.h"
38 #include "uan-prop-model-ideal.h"
43 NS_OBJECT_ENSURE_REGISTERED (UanChannel);
46 UanChannel::GetTypeId ()
48 static TypeId tid = TypeId (
"ns3::UanChannel")
49 .SetParent<Channel> ()
50 .AddConstructor<UanChannel> ()
51 .AddAttribute (
"PropagationModel",
52 "A pointer to the propagation model.",
53 PointerValue (CreateObject<UanPropModelIdeal> ()),
54 MakePointerAccessor (&UanChannel::m_prop),
55 MakePointerChecker<UanPropModel> ())
56 .AddAttribute (
"NoiseModel",
57 "A pointer to the model of the channel ambient noise.",
58 PointerValue (CreateObject<UanNoiseModelDefault> ()),
59 MakePointerAccessor (&UanChannel::m_noise),
60 MakePointerChecker<UanNoiseModel> ())
66 UanChannel::UanChannel ()
73 UanChannel::~UanChannel ()
85 UanDeviceList::iterator it = m_devList.begin ();
86 for (; it != m_devList.end (); it++)
129 return m_devList.size ();
135 return m_devList[i].first;
141 NS_LOG_DEBUG (
"Adding dev/trans pair number " << m_devList.size ());
142 m_devList.push_back (std::make_pair (dev, trans));
152 for (UanDeviceList::const_iterator i = m_devList.begin (); i
153 != m_devList.end (); i++)
156 if (src == i->second)
164 UanDeviceList::const_iterator i = m_devList.begin ();
165 for (; i != m_devList.end (); i++)
167 if (src != i->second)
169 NS_LOG_DEBUG (
"Scheduling " << i->first->GetMac ()->GetAddress ());
171 Time delay = m_prop->GetDelay (senderMobility, rcvrMobility, txMode);
172 UanPdp pdp = m_prop->GetPdp (senderMobility, rcvrMobility, txMode);
173 double rxPowerDb = txPowerDb - m_prop->GetPathLossDb (senderMobility,
177 NS_LOG_DEBUG (
"txPowerDb=" << txPowerDb <<
"dB, rxPowerDb="
178 << rxPowerDb <<
"dB, distance="
180 <<
"m, delay=" << delay);
182 uint32_t dstNodeId = i->first->GetNode ()->GetId ();
204 UanChannel::SendUp (uint32_t i,
Ptr<Packet> packet,
double rxPowerDb,
208 m_devList[i].second->Receive (packet, rxPowerDb, txMode, pdp);
215 double noise = m_noise->GetNoiseDbHz (fKhz);
smart pointer class similar to boost::intrusive_ptr
double GetDistanceFrom(Ptr< const MobilityModel > position) const
#define NS_ASSERT(condition)
#define NS_LOG_COMPONENT_DEFINE(name)
double GetNoiseDbHz(double fKhz)
virtual void DoDispose(void)
void SetNoiseModel(Ptr< UanNoiseModel > noise)
void TxPacket(Ptr< UanTransducer > src, Ptr< Packet > packet, double txPowerDb, UanTxMode txmode)
Keep track of the current position and velocity of an object.
void AddDevice(Ptr< UanNetDevice > dev, Ptr< UanTransducer > trans)
Abstraction of packet modulation information.
virtual uint32_t GetNDevices(void) const
static void ScheduleWithContext(uint32_t context, Time const &time, MEM mem_ptr, OBJ obj)
Ptr< Packet > Copy(void) const
virtual Ptr< NetDevice > GetDevice(uint32_t i) const
#define NS_LOG_DEBUG(msg)
void SetPropagationModel(Ptr< UanPropModel > prop)
Ptr< T > GetObject(void) const