20 #include "ns3/packet.h"
21 #include "ns3/simulator.h"
22 #include "ns3/mobility-model.h"
23 #include "ns3/net-device.h"
26 #include "ns3/pointer.h"
27 #include "ns3/object-factory.h"
28 #include "yans-wifi-channel.h"
29 #include "yans-wifi-phy.h"
30 #include "ns3/propagation-loss-model.h"
31 #include "ns3/propagation-delay-model.h"
37 NS_OBJECT_ENSURE_REGISTERED (YansWifiChannel);
40 YansWifiChannel::GetTypeId (
void)
42 static TypeId tid = TypeId (
"ns3::YansWifiChannel")
43 .SetParent<WifiChannel> ()
44 .AddConstructor<YansWifiChannel> ()
45 .AddAttribute (
"PropagationLossModel",
"A pointer to the propagation loss model attached to this channel.",
47 MakePointerAccessor (&YansWifiChannel::m_loss),
48 MakePointerChecker<PropagationLossModel> ())
49 .AddAttribute (
"PropagationDelayModel",
"A pointer to the propagation delay model attached to this channel.",
51 MakePointerAccessor (&YansWifiChannel::m_delay),
52 MakePointerChecker<PropagationDelayModel> ())
57 YansWifiChannel::YansWifiChannel ()
60 YansWifiChannel::~YansWifiChannel ()
84 for (PhyList::const_iterator i = m_phyList.begin (); i != m_phyList.end (); i++, j++)
95 Time delay = m_delay->GetDelay (senderMobility, receiverMobility);
96 double rxPowerDbm = m_loss->
CalcRxPower (txPowerDbm, senderMobility, receiverMobility);
97 NS_LOG_DEBUG (
"propagation: txPower=" << txPowerDbm <<
"dbm, rxPower=" << rxPowerDbm <<
"dbm, " <<
98 "distance=" << senderMobility->
GetDistanceFrom (receiverMobility) <<
"m, delay=" << delay);
100 Ptr<Object> dstNetDevice = m_phyList[j]->GetDevice ();
102 if (dstNetDevice == 0)
104 dstNode = 0xffffffff;
111 delay, &YansWifiChannel::Receive,
this,
112 j, copy, rxPowerDbm, wifiMode, preamble);
118 YansWifiChannel::Receive (uint32_t i,
Ptr<Packet> packet,
double rxPowerDbm,
121 m_phyList[i]->StartReceivePacket (packet, rxPowerDbm, txMode, preamble);
127 return m_phyList.size ();
132 return m_phyList[i]->GetDevice ()->GetObject<
NetDevice> ();
138 m_phyList.push_back (phy);
144 int64_t currentStream = stream;
146 return (currentStream - stream);
double GetDistanceFrom(Ptr< const MobilityModel > position) const
int64_t AssignStreams(int64_t stream)
void SetPropagationLossModel(Ptr< PropagationLossModel > loss)
void SetPropagationDelayModel(Ptr< PropagationDelayModel > delay)
#define NS_ASSERT(condition)
#define NS_LOG_COMPONENT_DEFINE(name)
uint16_t GetChannelNumber() const
Return current channel number, see SetChannelNumber()
#define NS_LOG_FUNCTION_NOARGS()
represent a single transmission modeA WifiMode is implemented by a single integer which is used to lo...
Keep track of the current position and velocity of an object.
virtual Ptr< NetDevice > GetDevice(uint32_t i) const
virtual uint32_t GetNDevices(void) const
double CalcRxPower(double txPowerDbm, Ptr< MobilityModel > a, Ptr< MobilityModel > b) const
static void ScheduleWithContext(uint32_t context, Time const &time, MEM mem_ptr, OBJ obj)
Ptr< Packet > Copy(void) const
Network layer to device interface.
#define NS_LOG_DEBUG(msg)
Ptr< T > GetObject(void) const
void Send(Ptr< YansWifiPhy > sender, Ptr< const Packet > packet, double txPowerDbm, WifiMode wifiMode, WifiPreamble preamble) const
int64_t AssignStreams(int64_t stream)