37#include "ns3/double.h"
40#include "ns3/pointer.h"
41#include "ns3/simulator.h"
42#include "ns3/singleton.h"
43#include "ns3/uinteger.h"
49NS_LOG_COMPONENT_DEFINE(
"SatOrbiterUserPhy");
60 TypeId(
"ns3::SatOrbiterUserPhy")
62 .AddConstructor<SatOrbiterUserPhy>()
63 .AddAttribute(
"PhyRx",
64 "The PhyRx layer attached to this phy.",
67 MakePointerChecker<SatPhyRx>())
68 .AddAttribute(
"PhyTx",
69 "The PhyTx layer attached to this phy.",
72 MakePointerChecker<SatPhyTx>())
73 .AddAttribute(
"RxTemperatureDbk",
74 "RX noise temperature in orbiter User in dBK.",
78 MakeDoubleChecker<double>())
81 "Maximum RX antenna gain in Db",
84 MakeDoubleChecker<double_t>())
87 "Maximum TX gain in dB",
90 MakeDoubleChecker<double_t>())
91 .AddAttribute(
"TxMaxPowerDbw",
92 "Maximum TX power in dB",
95 MakeDoubleChecker<double>())
98 "TX Output loss in dB",
101 MakeDoubleChecker<double>())
104 "TX Pointing loss in dB",
107 MakeDoubleChecker<double>())
108 .AddAttribute(
"TxOboLossDb",
112 MakeDoubleChecker<double>())
115 "TX Antenna loss in dB",
118 MakeDoubleChecker<double>())
121 "RX Antenna loss in dB",
124 MakeDoubleChecker<double>())
125 .AddAttribute(
"DefaultFadingValue",
126 "Default value for fading",
129 MakeDoubleChecker<double_t>())
130 .AddAttribute(
"OtherSysIfCOverIDb",
131 "Other system interference, C over I in dB.",
134 MakeDoubleChecker<double>())
135 .AddAttribute(
"AciIfCOverIDb",
136 "Adjacent channel interference, C over I in dB.",
139 MakeDoubleChecker<double>())
140 .AddAttribute(
"QueueSize",
141 "Maximum size of FIFO m_queue in bytes.",
142 UintegerValue(100000),
144 MakeUintegerChecker<uint32_t>())
145 .AddTraceSource(
"QueueSizeBytes",
146 "Send number of bytes in FIFO return feeder queue",
148 "ns3::SatStatsRtnFeederQueueHelper::QueueSizeCallback")
149 .AddTraceSource(
"QueueSizePackets",
150 "Send number of packets in FIFO return feeder queue",
152 "ns3::SatStatsRtnFeederQueueHelper::QueueSizeCallback");
164 NS_LOG_FUNCTION(
this);
165 NS_FATAL_ERROR(
"SatOrbiterUserPhy default constructor is not allowed to use");
169 Ptr<SatLinkResults> linkResults,
170 SatPhyRxCarrierConf::RxCarrierCreateParams_s parameters,
171 Ptr<SatSuperframeConf> superFrameConf)
179 NS_LOG_FUNCTION(
this << linkResults << superFrameConf);
189 m_queue = std::queue<std::tuple<Ptr<SatSignalParameters>, uint32_t, uint32_t>>();
205 NS_LOG_FUNCTION(
this);
226 Ptr<SatPhyRxCarrierConf> carrierConf = CreateObject<SatPhyRxCarrierConf>(
m_parameters);
233 carrierConf->SetAdditionalInterferenceCb(
241 NS_LOG_FUNCTION(
this);
247 NS_LOG_FUNCTION(
this);
254 NS_LOG_FUNCTION(
this);
255 Object::DoInitialize();
261 NS_LOG_FUNCTION(
this << txParams);
262 NS_LOG_INFO(
this <<
" sending a packet with carrierId: " << txParams->m_carrierId
263 <<
" duration: " << txParams->m_duration);
281 uint32_t nbBytes = 0;
282 for (Ptr<Packet> pkt : txParams->m_packetsInBurst)
284 nbBytes += pkt->GetSize();
286 uint32_t nbPackets = txParams->m_packetsInBurst.size();
290 m_queue.push(std::make_tuple(txParams, nbBytes, nbPackets));
307 NS_LOG_INFO(
"Packet dropped because REGENERATION_PHY queue is full");
332 NS_FATAL_ERROR(
"Trying to deque an empty queue");
336 std::tuple<Ptr<SatSignalParameters>, uint32_t, uint32_t> element =
m_queue.front();
339 Ptr<SatSignalParameters> txParams = std::get<0>(element);
375 NS_LOG_FUNCTION(
this);
379 SatSignalParameters::PacketsInBurst_t::iterator it1;
380 for (it1 = packets.begin(); it1 != packets.end(); ++it1)
383 bool isTaggedWithAddress =
false;
384 ByteTagIterator it2 = (*it1)->GetByteTagIterator();
386 while (!isTaggedWithAddress && it2.HasNext())
388 ByteTagIterator::Item item = it2.Next();
392 NS_LOG_DEBUG(
this <<
" contains a SatAddressTag tag:" <<
" start="
393 << item.GetStart() <<
" end=" << item.GetEnd());
395 item.GetTag(addrTag);
397 isTaggedWithAddress =
true;
404 if ((*it1)->RemovePacketTag(linkTimeTag))
406 NS_LOG_DEBUG(
this <<
" contains a SatPhyLinkTimeTag tag");
425 NS_LOG_FUNCTION(
this << rxParams);
442 NS_LOG_INFO(
this <<
" dropped " << rxParams->m_packetsInBurst.size()
443 <<
" packets because of PHY error.");
453 if (rxParams->m_txInfo.waveformId == 2)
455 SatSignalParameters::PacketsInBurst_t::iterator it;
456 for (it = rxParams->m_packetsInBurst.begin();
457 it != rxParams->m_packetsInBurst.end();
461 (*it)->RemovePacketTag(satUplinkInfoTag);
463 (*it)->AddPacketTag(satUplinkInfoTag);
469 if (rxParams->m_txInfo.waveformId == 2)
472 Ptr<SatCmtMessage> cmtMessage = CreateObject<SatCmtMessage>();
480 SatSignalParameters::PacketsInBurst_t::iterator it;
481 for (it = rxParams->m_packetsInBurst.begin(); it != rxParams->m_packetsInBurst.end();
485 (*it)->RemovePacketTag(satUplinkInfoTag);
486 satUplinkInfoTag.
SetSatId(rxParams->m_satId);
487 satUplinkInfoTag.
SetBeamId(rxParams->m_beamId);
489 (*it)->AddPacketTag(satUplinkInfoTag);
492 RxTraces(rxParams->m_packetsInBurst);
499 NS_FATAL_ERROR(
"Unknown regeneration mode");
509 NS_LOG_FUNCTION(
this);
529 SatSignalParameters::PacketsInBurst_t::iterator it1;
530 for (it1 = packets.begin(); it1 != packets.end(); ++it1)
534 if ((*it1)->PeekPacketTag(satAddressE2ETag))
539 return Mac48Address();
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.
@ PACKET_TYPE_DEDICATED_ACCESS
The SatOrbiterUserPhy models the user link physical layer of the satellite node.
TracedCallback< uint32_t, const Address & > m_queueSizePacketsTrace
Traced callback to monitor RTN feeder queue size in packets.
void SetSendControlMsgToFeederCallback(SendControlMsgToFeederCallback cb)
Set SendControlMsgToFeederCallback.
SatOrbiterUserPhy::SendControlMsgToFeederCallback m_txCtrlFeederCallback
Callback to send ctrl packet on orbiter feeder.
double m_otherSysInterferenceCOverI
Other system interference in linear.
uint32_t m_queueSizeBytes
Size of FIFO queue in bytes.
Ptr< SatSuperframeConf > m_superFrameConf
Super frame cofiguration.
virtual void SendPduWithParams(Ptr< SatSignalParameters > rxParams)
Send Pdu to the PHY tx module (for satellite switch packet forwarding).
virtual void DoInitialize(void)
Initialization of SatPhy.
uint32_t m_queueSizeMax
Maximum size of FIFO m_queue in bytes.
Address GetE2EDestinationAddress(SatPhy::PacketContainer_t packets)
Get destination address of packets.
virtual void DoDispose(void)
Dispose of this class instance.
virtual void NotifyConstructionCompleted() override
Notifier called once the ObjectBase is fully constructed.
virtual double GetAdditionalInterference()
Get additional interference, used to compute final SINR at RX.
Callback< bool, Ptr< SatControlMessage >, const Address &, Ptr< SatSignalParameters > > SendControlMsgToFeederCallback
SatOrbiterUserPhy(void)
Default constructor.
SatEnums::RegenerationMode_t m_forwardLinkRegenerationMode
Regeneration mode on forward link.
virtual void RxTraces(SatPhy::PacketContainer_t packets)
Invoke the Rx trace source for each received packet.
bool m_isSending
Indicates if a packet is already being sent.
double m_otherSysInterferenceCOverIDb
Configured other system interference in dB.
double m_aciInterferenceCOverIDb
Configured Adjacent Channel Interference (ACI) in dB.
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 SatEnums::SatLinkDir_t GetSatLinkRxDir()
Get the link RX direction.
static TypeId GetTypeId(void)
inherited from Object
Ptr< SatLinkResults > m_linkResults
Link results used for this physical layer.
SatEnums::RegenerationMode_t m_returnLinkRegenerationMode
Regeneration mode on return link.
virtual SatEnums::SatLinkDir_t GetSatLinkTxDir()
Get the link TX direction.
TracedCallback< uint32_t, const Address & > m_queueSizeBytesTrace
Traced callback to monitor RTN feeder queue size in bytes.
void SendFromQueue()
Send a packet from the queue.
virtual ~SatOrbiterUserPhy()
Destructor for SatOrbiterUserPhy.
virtual void Receive(Ptr< SatSignalParameters > rxParams, bool phyError)
Receives packets from lower layer.
SatPhyRxCarrierConf::RxCarrierCreateParams_s m_parameters
RX carrier configuration parameters.
void EndTx()
Notify a packet has finished being sent.
uint32_t m_queueSizePackets
Size of FIFO queue in packets.
double m_aciInterferenceCOverI
Adjacent Channel Interference (ACI) in linear.
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.
Time tag used to identify the time when packet is enqueued at PHY on current link level.
Time GetSenderLinkTimestamp(void) const
Get sender time stamp of this tag.
Tag to store uplink phy info that need to be forwarded to the downlink.
void SetBeamId(uint32_t beamId)
Set the UT beam ID.
void SetSatelliteReceptionTime(Time satelliteReceptionTime)
Set satellite reception time of packet.
void SetSatId(uint32_t satId)
Set the UT sat ID.
void SetIsControl(bool isControl)
Set if packet is a control packet.
SatUtils class is for general conversions used in satellite module.
static T DbToLinear(T db)
Converts decibels to linear.
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.