Loading...
Searching...
No Matches
satellite-phy-tx.cc
Go to the documentation of this file.
1/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
2/*
3 * Copyright (c) 2014 Magister Solutions Ltd.
4 * Copyright (c) 2018 CNES
5 *
6 * This program is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License version 2 as
8 * published by the Free Software Foundation;
9 *
10 * This program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
14 *
15 * You should have received a copy of the GNU General Public License
16 * along with this program; if not, write to the Free Software
17 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
18 *
19 * Author: Jani Puttonen <jani.puttonen@magister.fi>
20 * Author: Mathias Ettinger <mettinger@toulouse.viveris.com>
21 */
22
23#include "satellite-phy-tx.h"
24
26#include "satellite-channel.h"
27#include "satellite-phy.h"
29#include "satellite-utils.h"
30
31#include "ns3/boolean.h"
32#include "ns3/double.h"
33#include "ns3/enum.h"
34#include "ns3/log.h"
35#include "ns3/object-factory.h"
36#include "ns3/simulator.h"
37
38#include <cmath>
39#include <ostream>
40
41NS_LOG_COMPONENT_DEFINE("SatPhyTx");
42
43namespace ns3
44{
45
46NS_OBJECT_ENSURE_REGISTERED(SatPhyTx);
47
51 m_beamId(),
52 m_txMode(),
54{
55 NS_LOG_FUNCTION(this);
56}
57
59{
60 NS_LOG_FUNCTION(this);
61}
62
63void
65{
66 NS_LOG_FUNCTION(this);
67 m_channel = 0;
68 m_mobility = 0;
70 Object::DoDispose();
71}
72
73std::ostream&
74operator<<(std::ostream& os, SatPhyTx::State s)
75{
76 switch (s)
77 {
78 case SatPhyTx::IDLE:
79 os << "IDLE";
80 break;
81 case SatPhyTx::TX:
82 os << "TX";
83 break;
85 os << "RECONFIGURING";
86 break;
87 default:
88 os << "UNKNOWN";
89 break;
90 }
91 return os;
92}
93
94TypeId
96{
97 static TypeId tid =
98 TypeId("ns3::SatPhyTx")
99 .SetParent<Object>()
100 .AddAttribute("TxMode",
101 "Tx mode of this Phy Tx.",
102 EnumValue(SatPhyTx::NORMAL),
103 MakeEnumAccessor<SatPhyTx::SatPhyTxMode_t>(&SatPhyTx::m_txMode),
104 MakeEnumChecker(SatPhyTx::NORMAL,
105 "Normal Tx mode",
107 "Transparent Tx mode"));
108 return tid;
109}
110
111void
113{
114 NS_LOG_FUNCTION(this << gain_db);
115
117}
118
119double
120SatPhyTx::GetAntennaGain(Ptr<MobilityModel> mobility)
121{
122 NS_LOG_FUNCTION(this);
123
124 double gain_W(m_maxAntennaGain);
125
126 // Get the transmit antenna gain at the receiver position.
127 // E.g. Satellite transmits to the UT receiver.
129 {
130 Ptr<SatMobilityModel> m = DynamicCast<SatMobilityModel>(mobility);
131 gain_W = m_antennaGainPattern->GetAntennaGain_lin(m->GetGeoPosition(), m_satMobility);
132 }
133
138
139 return gain_W;
140}
141
142void
144{
145 NS_LOG_FUNCTION(this << fadingValue);
146
147 m_defaultFadingValue = fadingValue;
148}
149
150double
151SatPhyTx::GetFadingValue(Address macAddress, SatEnums::ChannelType_t channelType)
152{
153 NS_LOG_FUNCTION(this << macAddress << channelType);
154
155 double fadingValue = m_defaultFadingValue;
156
158 {
159 fadingValue = m_fadingContainer->GetFading(macAddress, channelType);
160 }
161 // Returns value 1 if fading is not set, as fading value is used as multiplier
162 return fadingValue;
163}
164
165void
166SatPhyTx::SetFadingContainer(Ptr<SatBaseFading> fadingContainer)
167{
168 NS_LOG_FUNCTION(this);
169 NS_ASSERT(m_fadingContainer == nullptr);
170
171 m_fadingContainer = fadingContainer;
172}
173
174Ptr<MobilityModel>
176{
177 NS_LOG_FUNCTION(this);
178 NS_ASSERT(m_mobility != nullptr);
179
180 return m_mobility;
181}
182
183void
184SatPhyTx::SetMobility(Ptr<MobilityModel> m)
185{
186 NS_LOG_FUNCTION(this << m);
187 NS_ASSERT(m_mobility == nullptr);
188
189 m_mobility = m;
190}
191
192void
193SatPhyTx::SetAntennaGainPattern(Ptr<SatAntennaGainPattern> agp, Ptr<SatMobilityModel> mobility)
194{
195 NS_LOG_FUNCTION(this);
196 NS_ASSERT(m_antennaGainPattern == nullptr);
197
199 m_satMobility = mobility;
200}
201
202void
203SatPhyTx::SetChannel(Ptr<SatChannel> c)
204{
205 NS_LOG_FUNCTION(this << c);
206 NS_ASSERT(m_channel == nullptr);
207
208 m_channel = c;
210}
211
212void
214{
215 NS_LOG_FUNCTION(this);
216 NS_ASSERT(m_channel != nullptr);
217
218 m_channel = nullptr;
220}
221
222Ptr<SatChannel>
224{
225 NS_LOG_FUNCTION(this);
226 NS_ASSERT(m_channel != nullptr);
227
228 return m_channel;
229}
230
231void
233{
234 NS_LOG_FUNCTION(this << newState);
235 NS_LOG_INFO(this << " state: " << m_state << " -> " << newState);
236 m_state = newState;
237}
238
239void
240SatPhyTx::StartTx(Ptr<SatSignalParameters> txParams)
241{
242 NS_LOG_FUNCTION(this << txParams);
243 NS_LOG_INFO("State: " << m_state);
244
245 switch (m_state)
246 {
247 case TX:
248 NS_FATAL_ERROR("cannot TX while already TX: the MAC should avoid this");
249 break;
250
251 case IDLE: {
252 NS_ASSERT(m_channel);
254 m_channel->StartTx(txParams);
255
265 if (m_txMode == TRANSPARENT)
266 {
267 EndTx();
268 }
269 else
270 {
271 Simulator::Schedule(txParams->m_duration, &SatPhyTx::EndTx, this);
272 }
273 }
274 break;
275
276 case RECONFIGURING:
277 break;
278
279 default:
280 NS_FATAL_ERROR("unknown state");
281 break;
282 }
283}
284
285void
287{
288 NS_LOG_FUNCTION(this);
289 NS_LOG_INFO(this << " state: " << m_state);
290
291 if (m_state != TX)
292 {
293 NS_FATAL_ERROR("SatPhyTx::EndTx - unexpected state!");
294 }
295
297}
298
299void
300SatPhyTx::SetSatId(uint32_t satId)
301{
302 NS_LOG_FUNCTION(this << satId);
303 m_satId = satId;
304}
305
306void
307SatPhyTx::SetBeamId(uint32_t beamId)
308{
309 NS_LOG_FUNCTION(this << beamId);
310 m_beamId = beamId;
311}
312
313bool
315{
316 NS_LOG_FUNCTION(this);
317
318 return m_state == TX;
319}
320
321bool
323{
324 NS_LOG_FUNCTION(this);
325 return m_state != RECONFIGURING;
326}
327
328} // namespace ns3
ChannelType_t
Types of channel.
The SatellitePhyTx models the physical layer transmitter of satellite system.
void SetDefaultFadingValue(double fadingValue)
Function for setting the default fading value.
void SetSatId(uint32_t satId)
Set the satellite id for all the transmissions from this SatPhyTx.
bool CanTransmit(void) const
Tell whether or not this channel can transmit data.
Ptr< SatAntennaGainPattern > m_antennaGainPattern
void SetChannel(Ptr< SatChannel > c)
double m_maxAntennaGain
Configured maximum antenna gain in linear.
double GetFadingValue(Address macAddress, SatEnums::ChannelType_t channelType)
Get fading value.
Ptr< MobilityModel > m_mobility
Ptr< MobilityModel > GetMobility()
SatPhyTxMode_t m_txMode
void SetAntennaGainPattern(Ptr< SatAntennaGainPattern > agp, Ptr< SatMobilityModel > mobility)
bool IsTransmitting(void) const
Tell whether or not this channel is transmitting data.
virtual void EndTx()
void SetBeamId(uint32_t beamId)
Set the beam id for all the transmissions from this SatPhyTx.
double m_defaultFadingValue
Default fading value.
void ChangeState(State newState)
virtual void StartTx(Ptr< SatSignalParameters > txParams)
Start packet transmission to the channel.
void SetMobility(Ptr< MobilityModel > m)
Ptr< SatMobilityModel > m_satMobility
SatPhyTx()
Default constructor.
Ptr< SatBaseFading > m_fadingContainer
Fading container for fading model.
Ptr< SatChannel > GetChannel()
double GetAntennaGain(Ptr< MobilityModel > mobility)
Get antenna gain based on position or in case that antenna pattern is not configured,...
Ptr< SatChannel > m_channel
virtual ~SatPhyTx()
Destructor for SatPhyTx.
virtual void DoDispose()
Dispose of this class instance.
void SetMaxAntennaGain_Db(double gain_db)
Set the maximum Antenna gain in Db.
void SetFadingContainer(Ptr< SatBaseFading > fadingContainer)
Set fading container.
static TypeId GetTypeId(void)
inherited from Object
static T DbToLinear(T db)
Converts decibels to linear.
SatArqSequenceNumber is handling the sequence numbers for the ARQ process.
std::ostream & operator<<(std::ostream &os, const GeoCoordinate &coordinate)