36 #include <ns3/double.h>
39 #include <ns3/pointer.h>
40 #include <ns3/simulator.h>
41 #include <ns3/uinteger.h>
45 NS_LOG_COMPONENT_DEFINE(
"SatGeoUserPhy");
50 NS_OBJECT_ENSURE_REGISTERED(SatGeoUserPhy);
56 TypeId(
"ns3::SatGeoUserPhy")
58 .AddConstructor<SatGeoUserPhy>()
59 .AddAttribute(
"PhyRx",
60 "The PhyRx layer attached to this phy.",
63 MakePointerChecker<SatPhyRx>())
64 .AddAttribute(
"PhyTx",
65 "The PhyTx layer attached to this phy.",
68 MakePointerChecker<SatPhyTx>())
69 .AddAttribute(
"RxTemperatureDbk",
70 "RX noise temperature in Geo User in dBK.",
74 MakeDoubleChecker<double>())
77 "Maximum RX antenna gain in Db",
80 MakeDoubleChecker<double_t>())
83 "Maximum TX gain in dB",
86 MakeDoubleChecker<double_t>())
87 .AddAttribute(
"TxMaxPowerDbw",
88 "Maximum TX power in dB",
91 MakeDoubleChecker<double>())
94 "TX Output loss in dB",
97 MakeDoubleChecker<double>())
100 "TX Pointing loss in dB",
103 MakeDoubleChecker<double>())
104 .AddAttribute(
"TxOboLossDb",
108 MakeDoubleChecker<double>())
111 "TX Antenna loss in dB",
114 MakeDoubleChecker<double>())
117 "RX Antenna loss in dB",
120 MakeDoubleChecker<double>())
121 .AddAttribute(
"DefaultFadingValue",
122 "Default value for fading",
125 MakeDoubleChecker<double_t>())
126 .AddAttribute(
"OtherSysIfCOverIDb",
127 "Other system interference, C over I in dB.",
130 MakeDoubleChecker<double>())
131 .AddAttribute(
"AciIfCOverIDb",
132 "Adjacent channel interference, C over I in dB.",
135 MakeDoubleChecker<double>())
136 .AddAttribute(
"QueueSize",
137 "Maximum size of FIFO m_queue in bytes.",
138 UintegerValue(100000),
140 MakeUintegerChecker<uint32_t>())
141 .AddTraceSource(
"QueueSizeBytes",
142 "Send number of bytes in FIFO return feeder queue",
144 "ns3::SatStatsRtnFeederQueueHelper::QueueSizeCallback")
145 .AddTraceSource(
"QueueSizePackets",
146 "Send number of packets in FIFO return feeder queue",
148 "ns3::SatStatsRtnFeederQueueHelper::QueueSizeCallback");
155 NS_LOG_FUNCTION(
this);
161 : m_aciInterferenceCOverIDb(17.0),
162 m_otherSysInterferenceCOverIDb(27.5),
163 m_aciInterferenceCOverI(
SatUtils::DbToLinear(m_aciInterferenceCOverIDb)),
164 m_otherSysInterferenceCOverI(
SatUtils::DbToLinear(m_otherSysInterferenceCOverIDb)),
166 m_queueSizePackets(0)
168 NS_LOG_FUNCTION(
this);
169 NS_FATAL_ERROR(
"SatGeoUserPhy default constructor is not allowed to use");
173 Ptr<SatLinkResults> linkResults,
174 SatPhyRxCarrierConf::RxCarrierCreateParams_s parameters,
175 Ptr<SatSuperframeConf> superFrameConf,
180 m_queueSizePackets(0)
182 NS_LOG_FUNCTION(
this);
192 m_queue = std::queue<std::tuple<Ptr<SatSignalParameters>, uint32_t, uint32_t>>();
204 ObjectBase::ConstructSelf(AttributeConstructionList());
210 parameters.m_aciIfWrtNoiseFactor = 0.0;
211 parameters.m_extNoiseDensityWhz = 0.0;
220 parameters.m_linkRegenerationMode = returnLinkRegenerationMode;
223 Ptr<SatPhyRxCarrierConf> carrierConf = CreateObject<SatPhyRxCarrierConf>(parameters);
227 carrierConf->SetLinkResults(linkResults);
230 carrierConf->SetAdditionalInterferenceCb(
238 NS_LOG_FUNCTION(
this);
244 NS_LOG_FUNCTION(
this);
251 NS_LOG_FUNCTION(
this);
252 Object::DoInitialize();
258 NS_LOG_FUNCTION(
this << txParams);
259 NS_LOG_INFO(
this <<
" sending a packet with carrierId: " << txParams->m_carrierId
260 <<
" duration: " << txParams->m_duration);
278 uint32_t nbBytes = 0;
279 for (Ptr<Packet> pkt : txParams->m_packetsInBurst)
281 nbBytes += pkt->GetSize();
283 uint32_t nbPackets = txParams->m_packetsInBurst.size();
287 m_queue.push(std::make_tuple(txParams, nbBytes, nbPackets));
304 NS_LOG_INFO(
"Packet dropped because REGENERATION_PHY queue is full");
329 NS_FATAL_ERROR(
"Trying to deque an empty queue");
333 std::tuple<Ptr<SatSignalParameters>, uint32_t, uint32_t> element =
m_queue.front();
336 Ptr<SatSignalParameters> txParams = std::get<0>(element);
372 NS_LOG_FUNCTION(
this);
376 SatSignalParameters::PacketsInBurst_t::iterator it1;
377 for (it1 = packets.begin(); it1 != packets.end(); ++it1)
380 bool isTaggedWithAddress =
false;
381 ByteTagIterator it2 = (*it1)->GetByteTagIterator();
383 while (!isTaggedWithAddress && it2.HasNext())
385 ByteTagIterator::Item item = it2.Next();
389 NS_LOG_DEBUG(
this <<
" contains a SatAddressTag tag:"
390 <<
" start=" << item.GetStart() <<
" end=" << item.GetEnd());
392 item.GetTag(addrTag);
394 isTaggedWithAddress =
true;
401 if ((*it1)->RemovePacketTag(linkTimeTag))
403 NS_LOG_DEBUG(
this <<
" contains a SatPhyLinkTimeTag tag");
422 NS_LOG_FUNCTION(
this << rxParams);
439 NS_LOG_INFO(
this <<
" dropped " << rxParams->m_packetsInBurst.size()
440 <<
" packets because of PHY error.");
450 if (rxParams->m_txInfo.waveformId == 2)
452 SatSignalParameters::PacketsInBurst_t::iterator it;
453 for (it = rxParams->m_packetsInBurst.begin();
454 it != rxParams->m_packetsInBurst.end();
458 (*it)->RemovePacketTag(satUplinkInfoTag);
460 (*it)->AddPacketTag(satUplinkInfoTag);
466 if (rxParams->m_txInfo.waveformId == 2)
469 Ptr<SatCmtMessage> cmtMessage = CreateObject<SatCmtMessage>();
477 SatSignalParameters::PacketsInBurst_t::iterator it;
478 for (it = rxParams->m_packetsInBurst.begin(); it != rxParams->m_packetsInBurst.end();
482 (*it)->RemovePacketTag(satUplinkInfoTag);
483 satUplinkInfoTag.
SetSatId(rxParams->m_satId);
484 satUplinkInfoTag.
SetBeamId(rxParams->m_beamId);
486 (*it)->AddPacketTag(satUplinkInfoTag);
489 RxTraces(rxParams->m_packetsInBurst);
496 NS_FATAL_ERROR(
"Unknown regeneration mode");
506 NS_LOG_FUNCTION(
this);
526 SatSignalParameters::PacketsInBurst_t::iterator it1;
527 for (it1 = packets.begin(); it1 != packets.end(); ++it1)
531 if ((*it1)->PeekPacketTag(satAddressE2ETag))
536 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
RegenerationMode_t
The regeneration mode used in satellites.
uint32_t m_queueSizeMax
Maximum size of FIFO m_queue in bytes.
uint32_t m_queueSizeBytes
Size of FIFO queue in bytes.
virtual void SendPduWithParams(Ptr< SatSignalParameters > rxParams)
Send Pdu to the PHY tx module (for GEO satellite switch packet forwarding)
Address GetE2EDestinationAddress(SatPhy::PacketContainer_t packets)
Get destination address of packets.
void EndTx()
Notify a packet has finished being sent.
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 double GetAdditionalInterference()
Get additional interference, used to compute final SINR at RX.
virtual void DoDispose(void)
Dispose of this class instance.
double m_aciInterferenceCOverIDb
Configured Adjacent Channel Interference (ACI) in dB.
TypeId GetInstanceTypeId(void) const
uint32_t m_queueSizePackets
Size of FIFO queue in packets.
void SetSendControlMsgToFeederCallback(SendControlMsgToFeederCallback cb)
Set SendControlMsgToFeederCallback.
virtual SatEnums::SatLinkDir_t GetSatLinkTxDir()
Get the link TX direction.
bool m_isSending
Indicates if a packet is already being sent.
Callback< bool, Ptr< SatControlMessage >, const Address &, Ptr< SatSignalParameters > > SendControlMsgToFeederCallback
virtual void Receive(Ptr< SatSignalParameters > rxParams, bool phyError)
Receives packets from lower layer.
TracedCallback< uint32_t, const Address & > m_queueSizeBytesTrace
Traced callback to monitor RTN feeder queue size in bytes.
virtual SatEnums::SatLinkDir_t GetSatLinkRxDir()
Get the link RX direction.
double m_otherSysInterferenceCOverIDb
Configured other system interference in dB.
TracedCallback< uint32_t, const Address & > m_queueSizePacketsTrace
Traced callback to monitor RTN feeder queue size in packets.
double m_aciInterferenceCOverI
Adjacent Channel Interference (ACI) in linear.
double m_otherSysInterferenceCOverI
Other system interference in linear.
static TypeId GetTypeId(void)
inherited from Object
virtual void RxTraces(SatPhy::PacketContainer_t packets)
Invoke the Rx trace source for each received packet.
SatGeoUserPhy(void)
Default constructor.
virtual ~SatGeoUserPhy()
Destructor for SatGeoUserPhy.
SatEnums::RegenerationMode_t m_forwardLinkRegenerationMode
Regeneration mode on forward link.
SatEnums::RegenerationMode_t m_returnLinkRegenerationMode
Regeneration mode on return link.
virtual void DoInitialize(void)
Initialization of SatPhy.
SatGeoUserPhy::SendControlMsgToFeederCallback m_txCtrlFeederCallback
Callback to send ctrl packet on geo feeder.
void SendFromQueue()
Send a packet from the queue.
The SatPhy models the basic physical layer of the satellite system.
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.
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.
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.