A Discrete-Event Network Simulator
API
Loading...
Searching...
No Matches
simple-ofdm-wimax-channel.cc
Go to the documentation of this file.
1/*
2 * Copyright (c) 2007,2008, 2009 INRIA, UDcast
3 *
4 * SPDX-License-Identifier: GPL-2.0-only
5 *
6 * Author: Mohamed Amine Ismail <amine.ismail@sophia.inria.fr>
7 * <amine.ismail@udcast.com>
8 */
9
11
14#include "wimax-phy.h"
15
16#include "ns3/assert.h"
17#include "ns3/callback.h"
18#include "ns3/cost231-propagation-loss-model.h"
19#include "ns3/event-id.h"
20#include "ns3/mobility-model.h"
21#include "ns3/net-device.h"
22#include "ns3/node.h"
23#include "ns3/nstime.h"
24#include "ns3/simulator.h"
25
26namespace ns3
27{
28
29NS_LOG_COMPONENT_DEFINE("simpleOfdmWimaxChannel");
30
31// NS_OBJECT_ENSURE_REGISTERED (simpleOfdmWimaxChannel);
32
37
42
43/* static */
46{
47 static TypeId tid = TypeId("ns3::SimpleOfdmWimaxChannel")
49 .SetGroupName("Wimax")
50 .AddConstructor<SimpleOfdmWimaxChannel>();
51 return tid;
52}
53
77
78void
102
103void
105{
106 Ptr<SimpleOfdmWimaxPhy> o_phy = phy->GetObject<SimpleOfdmWimaxPhy>();
107 m_phyList.push_back(o_phy);
108}
109
110std::size_t
112{
113 return m_phyList.size();
114}
115
118{
119 std::size_t j = 0;
120 for (auto iter = m_phyList.begin(); iter != m_phyList.end(); ++iter)
121 {
122 if (j == index)
123 {
124 return (*iter)->GetDevice();
125 }
126 j++;
127 }
128
129 NS_FATAL_ERROR("Unable to get device");
130 return nullptr;
131}
132
133void
135 uint32_t burstSize,
136 Ptr<WimaxPhy> phy,
137 bool isFirstBlock,
138 bool isLastBlock,
139 uint64_t frequency,
140 WimaxPhy::ModulationType modulationType,
141 uint8_t direction,
142 double txPowerDbm,
143 Ptr<PacketBurst> burst)
144{
145 double rxPowerDbm = 0;
146 Ptr<MobilityModel> senderMobility = nullptr;
147 Ptr<MobilityModel> receiverMobility = nullptr;
148 senderMobility = phy->GetDevice()->GetNode()->GetObject<MobilityModel>();
149 SimpleOfdmSendParam* param;
150 for (auto iter = m_phyList.begin(); iter != m_phyList.end(); ++iter)
151 {
152 Time delay = Seconds(0);
153 if (phy != *iter)
154 {
155 double distance = 0;
156 receiverMobility = (*iter)->GetDevice()->GetNode()->GetObject<MobilityModel>();
157 if (receiverMobility && senderMobility && m_loss)
158 {
159 distance = senderMobility->GetDistanceFrom(receiverMobility);
160 delay = Seconds(distance / 300000000.0);
161 rxPowerDbm = m_loss->CalcRxPower(txPowerDbm, senderMobility, receiverMobility);
162 }
163
164 param = new SimpleOfdmSendParam(burstSize,
165 isFirstBlock,
166 frequency,
167 modulationType,
168 direction,
169 rxPowerDbm,
170 burst);
171 Ptr<Object> dstNetDevice = (*iter)->GetDevice();
172 uint32_t dstNode;
173 if (!dstNetDevice)
174 {
175 dstNode = 0xffffffff;
176 }
177 else
178 {
179 dstNode = dstNetDevice->GetObject<NetDevice>()->GetNode()->GetId();
180 }
182 delay,
184 this,
185 *iter,
186 param);
187 }
188 }
189}
190
191void
193{
194 rxphy->StartReceive(param->GetBurstSize(),
195 param->GetIsFirstBlock(),
196 param->GetFrequency(),
197 param->GetModulationType(),
198 param->GetDirection(),
199 param->GetRxPowerDbm(),
200 param->GetBurst());
201 delete param;
202}
203
204int64_t
206{
207 int64_t currentStream = stream;
208 for (auto i = m_phyList.begin(); i != m_phyList.end(); i++)
209 {
210 Ptr<SimpleOfdmWimaxPhy> simpleOfdm = (*i);
211 currentStream += simpleOfdm->AssignStreams(currentStream);
212 }
213 return (currentStream - stream);
214}
215
216} // namespace ns3
217
218// namespace ns3
Keep track of the current position and velocity of an object.
Network layer to device interface.
Definition net-device.h:87
Smart pointer class similar to boost::intrusive_ptr.
SimpleOfdmSendParam class.
WimaxPhy::ModulationType GetModulationType()
SimpleOfdmWimaxChannel class.
Ptr< PropagationLossModel > m_loss
loss
void SetPropagationModel(PropModel propModel)
sets the propagation model
void DoAttach(Ptr< WimaxPhy > phy) override
Attach function.
std::size_t DoGetNDevices() const override
Get number of devices function.
static TypeId GetTypeId()
Register this type.
std::list< Ptr< SimpleOfdmWimaxPhy > > m_phyList
phy list
void EndSendDummyBlock(Ptr< SimpleOfdmWimaxPhy > rxphy, SimpleOfdmSendParam *param)
End send dummy block function.
Ptr< NetDevice > DoGetDevice(std::size_t i) const override
Get device function.
void Send(Time BlockTime, uint32_t burstSize, Ptr< WimaxPhy > phy, bool isFirstBlock, bool isLastBlock, uint64_t frequency, WimaxPhy::ModulationType modulationType, uint8_t direction, double txPowerDbm, Ptr< PacketBurst > burst)
Sends a dummy fec block to all connected physical devices.
int64_t AssignStreams(int64_t stream) override
Assign a fixed random variable stream number to the random variables used by this model.
SimpleOfdmWimaxPhy class.
static void ScheduleWithContext(uint32_t context, const Time &delay, FUNC f, Ts &&... args)
Schedule an event with the given context.
Definition simulator.h:577
Simulation virtual time values and global simulation resolution.
Definition nstime.h:94
a unique identifier for an interface.
Definition type-id.h:48
TypeId SetParent(TypeId tid)
Set the parent TypeId.
Definition type-id.cc:1001
The channel object to attach Wimax NetDevices.
ModulationType
ModulationType enumeration.
Definition wimax-phy.h:43
#define NS_FATAL_ERROR(msg)
Report a fatal error with a message and terminate.
#define NS_LOG_COMPONENT_DEFINE(name)
Define a Log component with a specific name.
Definition log.h:191
Ptr< T > CreateObject(Args &&... args)
Create an object by type, with varying number of constructor parameters.
Definition object.h:619
Time Seconds(double value)
Construct a Time in the indicated unit.
Definition nstime.h:1308
Every class exported by the ns3 library is enclosed in the ns3 namespace.