Loading...
Searching...
No Matches
satellite-orbiter-feeder-phy.cc
Go to the documentation of this file.
1/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
2/*
3 * Copyright (c) 2013 Magister Solutions Ltd.
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: Sami Rantanen <sami.rantanen@magister.fi>
19 * Bastien Tauran <bastien.tauran@viveris.fr>
20 */
21
23
26#include "satellite-channel.h"
27#include "satellite-mac.h"
28#include "satellite-phy-rx.h"
29#include "satellite-phy-tx.h"
31#include "satellite-time-tag.h"
32#include "satellite-topology.h"
34#include "satellite-utils.h"
35
36#include "ns3/double.h"
37#include "ns3/enum.h"
38#include "ns3/log.h"
39#include "ns3/pointer.h"
40#include "ns3/simulator.h"
41#include "ns3/singleton.h"
42#include "ns3/uinteger.h"
43
44#include <limits>
45#include <queue>
46#include <tuple>
47
48NS_LOG_COMPONENT_DEFINE("SatOrbiterFeederPhy");
49
50namespace ns3
51{
52
53NS_OBJECT_ENSURE_REGISTERED(SatOrbiterFeederPhy);
54
55TypeId
57{
58 static TypeId tid =
59 TypeId("ns3::SatOrbiterFeederPhy")
60 .SetParent<SatPhy>()
61 .AddConstructor<SatOrbiterFeederPhy>()
62 .AddAttribute("PhyRx",
63 "The PhyRx layer attached to this phy.",
64 PointerValue(),
65 MakePointerAccessor(&SatPhy::GetPhyRx, &SatPhy::SetPhyRx),
66 MakePointerChecker<SatPhyRx>())
67 .AddAttribute("PhyTx",
68 "The PhyTx layer attached to this phy.",
69 PointerValue(),
70 MakePointerAccessor(&SatPhy::GetPhyTx, &SatPhy::SetPhyTx),
71 MakePointerChecker<SatPhyTx>())
72 .AddAttribute("RxTemperatureDbk",
73 "RX noise temperature in orbiter Feeder in dBK.",
74 DoubleValue(28.4),
75 MakeDoubleAccessor(&SatPhy::GetRxNoiseTemperatureDbk,
77 MakeDoubleChecker<double>())
78 .AddAttribute(
79 "RxMaxAntennaGainDb",
80 "Maximum RX gain in dB",
81 DoubleValue(54.00),
83 MakeDoubleChecker<double_t>())
84 .AddAttribute(
85 "TxMaxAntennaGainDb",
86 "Maximum TX gain in dB",
87 DoubleValue(54.00),
89 MakeDoubleChecker<double_t>())
90 .AddAttribute("TxMaxPowerDbw",
91 "Maximum TX power in dB",
92 DoubleValue(-4.38),
94 MakeDoubleChecker<double>())
95 .AddAttribute(
96 "TxOutputLossDb",
97 "TX Output loss in dB",
98 DoubleValue(1.75),
100 MakeDoubleChecker<double>())
101 .AddAttribute(
102 "TxPointingLossDb",
103 "TX Pointing loss in dB",
104 DoubleValue(0.00),
106 MakeDoubleChecker<double>())
107 .AddAttribute("TxOboLossDb",
108 "TX OBO loss in dB",
109 DoubleValue(4.00),
110 MakeDoubleAccessor(&SatPhy::GetTxOboLossDb, &SatPhy::SetTxOboLossDb),
111 MakeDoubleChecker<double>())
112 .AddAttribute(
113 "TxAntennaLossDb",
114 "TX Antenna loss in dB",
115 DoubleValue(1.00),
117 MakeDoubleChecker<double>())
118 .AddAttribute(
119 "RxAntennaLossDb",
120 "RX Antenna loss in dB",
121 DoubleValue(1.00),
123 MakeDoubleChecker<double>())
124 .AddAttribute("DefaultFadingValue",
125 "Default value for fading",
126 DoubleValue(1.00),
128 MakeDoubleChecker<double_t>())
129 .AddAttribute("ExtNoisePowerDensityDbwhz",
130 "Other system interference, C over I in dB.",
131 DoubleValue(-207.0),
133 MakeDoubleChecker<double>())
134 .AddAttribute("ImIfCOverIDb",
135 "Adjacent channel interference, C over I in dB.",
136 DoubleValue(27.0),
138 MakeDoubleChecker<double>())
139 .AddAttribute("FixedAmplificationGainDb",
140 "Fixed amplification gain used in RTN link at the satellite.",
141 DoubleValue(82.0),
143 MakeDoubleChecker<double>())
144 .AddAttribute("QueueSize",
145 "Maximum size of FIFO m_queue in bytes.",
146 UintegerValue(100000),
147 MakeUintegerAccessor(&SatOrbiterFeederPhy::m_queueSizeMax),
148 MakeUintegerChecker<uint32_t>())
149 .AddTraceSource("QueueSizeBytes",
150 "Send number of bytes in FIFO return feeder queue",
151 MakeTraceSourceAccessor(&SatOrbiterFeederPhy::m_queueSizeBytesTrace),
152 "ns3::SatStatsRtnFeederQueueHelper::QueueSizeCallback")
153 .AddTraceSource("QueueSizePackets",
154 "Send number of packets in FIFO return feeder queue",
155 MakeTraceSourceAccessor(&SatOrbiterFeederPhy::m_queueSizePacketsTrace),
156 "ns3::SatStatsRtnFeederQueueHelper::QueueSizeCallback");
157 return tid;
158}
159
167{
168 NS_LOG_FUNCTION(this);
169 NS_FATAL_ERROR("SatOrbiterFeederPhy default constructor is not allowed to use");
170}
171
173 Ptr<SatLinkResults> linkResults,
174 SatPhyRxCarrierConf::RxCarrierCreateParams_s parameters,
175 Ptr<SatSuperframeConf> superFrameConf)
176 : SatPhy(params),
177 m_linkResults(linkResults),
178 m_parameters(parameters),
179 m_superFrameConf(superFrameConf)
180{
181 NS_LOG_FUNCTION(this << linkResults << superFrameConf);
182
183 m_forwardLinkRegenerationMode = Singleton<SatTopology>::Get()->GetForwardLinkRegenerationMode();
184 m_returnLinkRegenerationMode = Singleton<SatTopology>::Get()->GetReturnLinkRegenerationMode();
185 m_isSending = false;
188
190 {
191 m_queue = std::queue<std::tuple<Ptr<SatSignalParameters>, uint32_t, uint32_t>>();
192 }
193
195 {
196 SatPhy::GetPhyTx()->SetAttribute("TxMode", EnumValue(SatPhyTx::TRANSPARENT));
197 }
198 else
199 {
200 SatPhy::GetPhyTx()->SetAttribute("TxMode", EnumValue(SatPhyTx::NORMAL));
201 }
202}
203
204void
206{
207 NS_LOG_FUNCTION(this);
208
210
212
213 // Configure the SatPhyRxCarrier instances
214 // Note, that in satellite, there is no need for error modeling.
215
218 m_parameters.m_aciIfWrtNoiseFactor = 0.0;
220 {
222 }
223 else
224 {
226 }
227 m_parameters.m_linkRegenerationMode = m_forwardLinkRegenerationMode;
229
230 Ptr<SatPhyRxCarrierConf> carrierConf = CreateObject<SatPhyRxCarrierConf>(m_parameters);
231
232 if (m_linkResults)
233 {
234 carrierConf->SetLinkResults(m_linkResults);
235 }
236
237 carrierConf->SetAdditionalInterferenceCb(
239
241}
242
244{
245 NS_LOG_FUNCTION(this);
246}
247
248void
250{
251 NS_LOG_FUNCTION(this);
252 Object::DoDispose();
253}
254
255void
257{
258 NS_LOG_FUNCTION(this);
259 Object::DoInitialize();
260}
261
262void
263SatOrbiterFeederPhy::SendPduWithParams(Ptr<SatSignalParameters> txParams)
264{
265 NS_LOG_FUNCTION(this << txParams);
266 NS_LOG_INFO(this << " sending a packet with carrierId: " << txParams->m_carrierId
267 << " duration: " << txParams->m_duration);
268
270 {
271 SetTimeTag(txParams->m_packetsInBurst);
272 }
273
274 // copy as sender own PhyTx object (at satellite) to ensure right distance calculation
275 // and antenna gain getting at receiver (UT or GW)
276 // copy on tx power too.
277
278 txParams->m_phyTx = m_phyTx;
279
287
289 {
290 txParams->m_txPower_W =
291 txParams->m_rxPower_W * SatUtils::DbToLinear(m_fixedAmplificationGainDb);
292 }
293 else
294 {
295 txParams->m_txPower_W = m_eirpWoGainW;
296 }
297
298 NS_LOG_INFO("Amplified Tx power: " << SatUtils::LinearToDb(txParams->m_txPower_W));
299 NS_LOG_INFO("Statically configured tx power: " << SatUtils::LinearToDb(m_eirpWoGainW));
300
302
304 {
305 uint32_t nbBytes = 0;
306 for (Ptr<Packet> pkt : txParams->m_packetsInBurst)
307 {
308 nbBytes += pkt->GetSize();
309 }
310 uint32_t nbPackets = txParams->m_packetsInBurst.size();
311 if (m_queueSizeBytes + nbBytes < m_queueSizeMax)
312 {
314 m_queue.push(std::make_tuple(txParams, nbBytes, nbPackets));
315 m_queueSizeBytes += nbBytes;
316 m_queueSizePackets += nbPackets;
317
319 GetE2ESourceAddress(txParams->m_packetsInBurst));
321 GetE2ESourceAddress(txParams->m_packetsInBurst));
322
323 if (m_isSending == false)
324 {
326 }
327 }
328 else
329 {
330 event = SatEnums::PACKET_DROP;
331 NS_LOG_INFO("Packet dropped because REGENERATION_PHY queue is full");
332 }
333 }
334 else
335 {
336 event = SatEnums::PACKET_SENT;
337 m_phyTx->StartTx(txParams);
338 }
339
340 // Add packet trace entry:
341 m_packetTrace(Simulator::Now(),
342 event,
343 m_nodeInfo->GetNodeType(),
344 m_nodeInfo->GetNodeId(),
345 m_nodeInfo->GetMacAddress(),
348 SatUtils::GetPacketInfo(txParams->m_packetsInBurst));
349}
350
351void
353{
354 if (m_queue.empty())
355 {
356 NS_FATAL_ERROR("Trying to deque an empty queue");
357 }
358 m_isSending = true;
359 std::tuple<Ptr<SatSignalParameters>, uint32_t, uint32_t> element = m_queue.front();
360 m_queue.pop();
361
362 Ptr<SatSignalParameters> txParams = std::get<0>(element);
363 m_queueSizeBytes -= std::get<1>(element);
364 m_queueSizePackets -= std::get<2>(element);
365
366 m_queueSizeBytesTrace(m_queueSizeBytes, GetE2ESourceAddress(txParams->m_packetsInBurst));
368
369 // Add sent packet trace entry:
370 m_packetTrace(Simulator::Now(),
372 m_nodeInfo->GetNodeType(),
373 m_nodeInfo->GetNodeId(),
374 m_nodeInfo->GetMacAddress(),
377 SatUtils::GetPacketInfo(txParams->m_packetsInBurst));
378
379 Simulator::Schedule(txParams->m_duration + NanoSeconds(1), &SatOrbiterFeederPhy::EndTx, this);
380
381 m_phyTx->StartTx(txParams);
382}
383
384void
386{
387 m_isSending = false;
388 if (!m_queue.empty())
389 {
390 this->SendFromQueue();
391 }
392}
393
394void
396{
397 NS_LOG_FUNCTION(this);
398
400 {
401 SatSignalParameters::PacketsInBurst_t::iterator it1;
402 for (it1 = packets.begin(); it1 != packets.end(); ++it1)
403 {
404 Address addr; // invalid address.
405
406 SatAddressE2ETag addressE2ETag;
407 if ((*it1)->PeekPacketTag(addressE2ETag))
408 {
409 NS_LOG_DEBUG(this << " contains a SatMac tag");
410 addr = addressE2ETag.GetE2EDestAddress();
411 }
412
413 m_rxTrace(*it1, addr);
414
415 SatPhyLinkTimeTag linkTimeTag;
416 if ((*it1)->RemovePacketTag(linkTimeTag))
417 {
418 NS_LOG_DEBUG(this << " contains a SatPhyLinkTimeTag tag");
419 Time delay = Simulator::Now() - linkTimeTag.GetSenderLinkTimestamp();
420 m_rxLinkDelayTrace(delay, addr);
421 if (m_lastLinkDelay.IsZero() == false)
422 {
423 Time jitter = Abs(delay - m_lastLinkDelay);
424 m_rxLinkJitterTrace(jitter, addr);
425 }
426 m_lastLinkDelay = delay;
427 }
428
429 } // end of `for (it1 = rxParams->m_packetsInBurst)`
430
431 } // end of `if (m_isStatisticsTagsEnabled)`
432}
433
434void
435SatOrbiterFeederPhy::Receive(Ptr<SatSignalParameters> rxParams, bool phyError)
436{
437 NS_LOG_FUNCTION(this << rxParams);
438
440
441 // Add packet trace entry:
442 m_packetTrace(Simulator::Now(),
443 event,
444 m_nodeInfo->GetNodeType(),
445 m_nodeInfo->GetNodeId(),
446 m_nodeInfo->GetMacAddress(),
449 SatUtils::GetPacketInfo(rxParams->m_packetsInBurst));
450
451 if (phyError)
452 {
453 // If there was a PHY error, the packet is dropped here.
454 NS_LOG_INFO(this << " dropped " << rxParams->m_packetsInBurst.size()
455 << " packets because of PHY error.");
456 }
457 else
458 {
460 {
462 break;
465 rxParams->m_txInfo.packetType = SatEnums::PACKET_TYPE_DEDICATED_ACCESS;
466
467 SatSignalParameters::PacketsInBurst_t::iterator it;
468 for (it = rxParams->m_packetsInBurst.begin(); it != rxParams->m_packetsInBurst.end();
469 it++)
470 {
471 SatUplinkInfoTag satUplinkInfoTag;
472 (*it)->RemovePacketTag(satUplinkInfoTag);
473 satUplinkInfoTag.SetSatId(rxParams->m_satId);
474 satUplinkInfoTag.SetBeamId(rxParams->m_beamId);
475 (*it)->AddPacketTag(satUplinkInfoTag);
476 }
477
478 RxTraces(rxParams->m_packetsInBurst);
479
480 ModcodTrace(rxParams);
481
482 break;
483 }
484 default:
485 NS_FATAL_ERROR("Unknown regeneration mode");
486 }
487
488 m_rxCallback(rxParams->m_packetsInBurst, rxParams);
489 }
490}
491
492double
494{
495 NS_LOG_FUNCTION(this);
496
498}
499
505
511
512Address
514{
515 SatSignalParameters::PacketsInBurst_t::iterator it1;
516 for (it1 = packets.begin(); it1 != packets.end(); ++it1)
517 {
518 Address addr; // invalid address.
519 ByteTagIterator it2 = (*it1)->GetByteTagIterator();
520
521 while (it2.HasNext())
522 {
523 ByteTagIterator::Item item = it2.Next();
524
525 if (item.GetTypeId() == SatAddressTag::GetTypeId())
526 {
527 SatAddressTag addrTag;
528 item.GetTag(addrTag);
529 return addrTag.GetSourceAddress();
530 }
531 }
532 }
533 return Mac48Address();
534}
535
536} // namespace ns3
This class implements a tag that carries the satellite MAC of GW and UT.
Mac48Address GetE2EDestAddress(void) const
Get E2E destination MAC address.
This class implements a tag that carries the MAC address of the sender of the packet.
static TypeId GetTypeId()
Inherited from ObjectBase base class.
Address GetSourceAddress() const
Get the source address.
SatLinkDir_t
Link direction used for packet tracing.
SatPacketEvent_t
Packet event used for packet tracing.
The SatOrbiterFeederPhy models the feeder link physical layer of the satellite node.
virtual void DoInitialize(void)
Initialization of SatPhy.
virtual double GetAdditionalInterference()
Get additional interference, used to compute final SINR at RX.
std::queue< std::tuple< Ptr< SatSignalParameters >, uint32_t, uint32_t > > m_queue
Simple FIFO queue to avoid collisions on TX in case of REGENERATION_PHY.
virtual ~SatOrbiterFeederPhy()
Destructor for SatOrbiterFeederPhy.
virtual void RxTraces(SatPhy::PacketContainer_t packets)
Invoke the Rx trace source for each received packet.
Ptr< SatLinkResults > m_linkResults
Link results used for this physical layer.
virtual SatEnums::SatLinkDir_t GetSatLinkTxDir()
Get the link TX direction.
double m_extNoisePowerDensityDbwHz
Configured external noise power.
static TypeId GetTypeId(void)
inherited from Object
double m_fixedAmplificationGainDb
Fixed amplification gain used in RTN link at the satellite.
virtual SatEnums::SatLinkDir_t GetSatLinkRxDir()
Get the link RX direction.
double m_imInterferenceCOverI
Intermodulation interference in linear.
Ptr< SatSuperframeConf > m_superFrameConf
Super frame cofiguration.
TracedCallback< uint32_t, const Address & > m_queueSizeBytesTrace
Traced callback to monitor RTN feeder queue size in bytes.
TracedCallback< uint32_t, const Address & > m_queueSizePacketsTrace
Traced callback to monitor RTN feeder queue size in packets.
Address GetE2ESourceAddress(SatPhy::PacketContainer_t packets)
Get source address of packets.
bool m_isSending
Indicates if a packet is already being sent.
void SendFromQueue()
Send a packet from the queue.
virtual void Receive(Ptr< SatSignalParameters > rxParams, bool phyError)
Receives packets from lower layer.
uint32_t m_queueSizeBytes
Size of FIFO queue in bytes.
virtual void SendPduWithParams(Ptr< SatSignalParameters > rxParams)
Send Pdu to the PHY tx module (for satellite switch packet forwarding).
SatEnums::RegenerationMode_t m_forwardLinkRegenerationMode
Regeneration mode on forward link.
SatPhyRxCarrierConf::RxCarrierCreateParams_s m_parameters
RX carrier configuration parameters.
double m_imInterferenceCOverIDb
Configured Intermodulation interference in dB.
uint32_t m_queueSizePackets
Size of FIFO queue in packets.
uint32_t m_queueSizeMax
Maximum size of FIFO m_queue in bytes.
virtual void DoDispose(void)
Dispose of this class instance.
SatEnums::RegenerationMode_t m_returnLinkRegenerationMode
Regeneration mode on return link.
SatOrbiterFeederPhy(void)
Default constructor.
void EndTx()
Notify a packet has finished being sent.
virtual void NotifyConstructionCompleted() override
Notifier called once the ObjectBase is fully constructed.
void SetTxPointingLossDb(double lossDb)
Set the pointing loss of the transmitter in dB.
TracedCallback< Time, SatEnums::SatPacketEvent_t, SatEnums::SatNodeType_t, uint32_t, Mac48Address, SatEnums::SatLogLevel_t, SatEnums::SatLinkDir_t, std::string > m_packetTrace
Trace callback used for packet tracing:
void SetTimeTag(SatPhy::PacketContainer_t packets)
Set SatPhyTimeTag of packets.
void SetRxAntennaGainDb(double gainDb)
Set the maximum antenna gain of the receiver in dB.
void ConfigureRxCarriers(Ptr< SatPhyRxCarrierConf > carrierConf, Ptr< SatSuperframeConf > superFrameConf)
Configure Rx carriers.
virtual Ptr< SatPhyTx > GetPhyTx() const
Get the SatPhyTx pointer.
void SetTxOboLossDb(double lossDb)
Set the OBO loss of the transmitter in dB.
TracedCallback< const Time &, const Address & > m_rxLinkDelayTrace
Traced callback for all received packets, including link delay information and the address of the sen...
void SetDefaultFading(double fading)
Set the default fading of the PHY.
double GetTxOutputLossDb() const
Get the output loss of the transmitter in dB.
double GetTxAntennaGainDb() const
Get the maximum antenna gain of the transmitter in dB.
virtual Ptr< SatPhyRx > GetPhyRx() const
Get the SatPhyRx pointer.
void SetTxOutputLossDb(double lossDb)
Set the output loss of the transmitter in dB.
double GetTxPointingLossDb() const
Get the pointing loss of the transmitter in dB.
Ptr< SatNodeInfo > m_nodeInfo
Node info containing node related information, such as node type, node id and MAC address (of the Sat...
double GetDefaultFading() const
Get the default fading of the PHY.
double GetTxMaxPowerDbw() const
Get the maximum transmit power of the transmitter in dB.
virtual void NotifyConstructionCompleted() override
Notifier called once the ObjectBase is fully constructed.
double GetTxOboLossDb() const
Get the OBO loss of the transmitter in dB.
void SetTxMaxPowerDbw(double powerDb)
Set the maximum transmit power of the transmitter in dB.
TracedCallback< Ptr< const Packet >, const Address & > m_rxTrace
Traced callback for all received packets, including the address of the senders.
double GetRxAntennaGainDb() const
Get the maximum antenna gain of the receiver in dB.
SatPhy(void)
Default constructor.
double m_eirpWoGainW
Calculated EIRP without gain in W.
virtual void SetPhyTx(Ptr< SatPhyTx > phyTx)
Set the SatPhyTx module.
void SetRxAntennaLossDb(double lossDb)
Set the antenna loss of the receiver in dB.
void SetRxNoiseTemperatureDbk(double temperatureDbk)
Set the noise temperature of the receiver in dbK.
double GetRxNoiseTemperatureDbk() const
Get the noise temperature of the receiver in dbK.
double GetRxAntennaLossDb() const
Get the antenna loss of the receiver in dB.
Ptr< SatPhyTx > m_phyTx
Pointer to internal SatPhyTx instance.
void ModcodTrace(Ptr< SatSignalParameters > rxParams)
Invoke the RxLinkModcod trace source for each received packet.
void SetTxAntennaGainDb(double gainDb)
Set the maximum antenna gain of the transmitter in dB.
bool m_isStatisticsTagsEnabled
EnableStatisticsTags attribute.
Time m_lastLinkDelay
Last delay measurement for link.
SatSignalParameters::PacketsInBurst_t PacketContainer_t
Define PacketContainer in SatPhy.
void SetTxAntennaLossDb(double lossDb)
Set the antenna loss of the transmitter in dB.
virtual void SetPhyRx(Ptr< SatPhyRx > phyRx)
Set the SatPhyRx module.
SatPhy::ReceiveCallback m_rxCallback
The upper layer package receive callback.
TracedCallback< const Time &, const Address & > m_rxLinkJitterTrace
Traced callback for all received packets, including link jitter information and the address of the se...
double GetTxAntennaLossDb() const
Get the antenna loss of the transmitter in dB.
SatUtils class is for general conversions used in satellite module.
static T DbToLinear(T db)
Converts decibels to linear.
static T LinearToDb(T linear)
Converts linear to decibels.
static std::string GetPacketInfo(const Ptr< const Packet > p)
Get packet information in std::string for printing purposes.
SatArqSequenceNumber is handling the sequence numbers for the ARQ process.
Creation parameters for base PHY object.