37 #include <ns3/boolean.h>
38 #include <ns3/double.h>
41 #include <ns3/pointer.h>
42 #include <ns3/simulator.h>
43 #include <ns3/uinteger.h>
45 NS_LOG_COMPONENT_DEFINE(
"SatPhy");
50 NS_OBJECT_ENSURE_REGISTERED(SatPhy);
56 m_isStatisticsTagsEnabled(false),
59 m_rxNoiseTemperatureDbk(0),
60 m_rxMaxAntennaGainDb(0),
62 m_txMaxAntennaGainDb(0),
65 m_txPointingLossDb(0),
68 m_defaultFadingValue(1.0)
70 NS_LOG_FUNCTION(
this);
71 NS_FATAL_ERROR(
"SatPhy default constructor is not allowed to use");
78 m_isStatisticsTagsEnabled(false),
81 m_rxNoiseTemperatureDbk(0),
82 m_rxMaxAntennaGainDb(0),
84 m_txMaxAntennaGainDb(0),
87 m_txPointingLossDb(0),
90 m_defaultFadingValue(1.0)
93 ObjectBase::ConstructSelf(AttributeConstructionList());
95 Ptr<MobilityModel> mobility = params.
m_device->GetNode()->GetObject<MobilityModel>();
102 m_phyTx = CreateObject<SatPhyTx>();
103 m_phyRx = CreateObject<SatPhyRx>();
107 m_phyTx = CreateObject<SatLoraPhyTx>();
108 m_phyRx = CreateObject<SatLoraPhyRx>();
112 m_phyTx = CreateObject<SatLoraPhyTx>();
113 m_phyRx = CreateObject<SatPhyRx>();
117 NS_FATAL_ERROR(
"Standard not implemented yet: " << params.
m_standard);
126 m_phyTx->SetMobility(mobility);
127 m_phyRx->SetMobility(mobility);
134 TypeId(
"ns3::SatPhy")
136 .AddAttribute(
"ReceiveCb",
137 "The receive callback for this phy.",
140 MakeCallbackChecker())
141 .AddAttribute(
"CnoCb",
142 "The C/N0 info callback for this phy.",
145 MakeCallbackChecker())
146 .AddAttribute(
"AverageNormalizedOfferedLoadCallback",
147 "The average offered random access load callback for this phy.",
150 MakeCallbackChecker())
151 .AddAttribute(
"EnableStatisticsTags",
152 "If true, some tags will be added to each transmitted packet to assist "
153 "with statistics computation",
156 MakeBooleanChecker())
157 .AddTraceSource(
"PacketTrace",
158 "Packet event trace",
160 "ns3::SatTypedefs::PacketTraceCallback")
161 .AddTraceSource(
"Rx",
164 "ns3::SatTypedefs::PacketSourceAddressCallback")
165 .AddTraceSource(
"RxDelay",
166 "A packet is received with delay information",
168 "ns3::SatTypedefs::PacketDelayAddressCallback")
169 .AddTraceSource(
"RxLinkDelay",
170 "A packet is received with link delay information",
172 "ns3::SatTypedefs::PacketDelayAddressCallback")
173 .AddTraceSource(
"RxJitter",
174 "A packet is received with jitter information",
176 "ns3::SatTypedefs::PacketJitterAddressCallback")
177 .AddTraceSource(
"RxLinkJitter",
178 "A packet is received with link jitter information",
180 "ns3::SatTypedefs::PacketJitterAddressCallback")
181 .AddTraceSource(
"RxLinkModcod",
182 "A packet is received with link MODCOD information",
184 "ns3::SatTypedefs::PacketModcodAddressCallback");
191 NS_LOG_FUNCTION(
this);
198 NS_LOG_FUNCTION(
this);
199 Object::DoInitialize();
205 NS_LOG_FUNCTION(
this);
208 double eirpWoGainDbw =
228 m_phyRx->SetAverageNormalizedOfferedLoadCallback(
243 NS_LOG_FUNCTION(
this);
249 NS_LOG_FUNCTION(
this);
261 NS_LOG_FUNCTION(
this << sinr << otherInterference);
265 NS_FATAL_ERROR(
"Calculated own SINR is expected to be greater than zero!!!");
268 if (otherInterference <= 0)
270 NS_FATAL_ERROR(
"Interference is expected to be greater than zero!!!");
273 double finalSinr = 1 / ((1 / sinr) + (1 / otherInterference));
280 Ptr<SatMobilityModel> satelliteMobility)
282 NS_LOG_FUNCTION(
this);
283 m_phyTx->SetAntennaGainPattern(agp, satelliteMobility);
288 Ptr<SatMobilityModel> satelliteMobility)
290 NS_LOG_FUNCTION(
this);
291 m_phyRx->SetAntennaGainPattern(agp, satelliteMobility);
296 Ptr<SatSuperframeConf> superFrameConf)
298 NS_LOG_FUNCTION(
this);
299 m_phyRx->ConfigurePhyRxCarriers(carrierConf, superFrameConf);
305 NS_LOG_FUNCTION(
this);
307 m_phyRx->SetFadingContainer(fadingContainer);
313 NS_LOG_FUNCTION(
this);
315 m_phyTx->SetFadingContainer(fadingContainer);
321 NS_LOG_FUNCTION(
this << nodeInfo);
323 m_phyRx->SetNodeInfo(nodeInfo);
329 NS_LOG_FUNCTION(
this);
336 NS_LOG_FUNCTION(
this);
343 NS_LOG_FUNCTION(
this);
350 NS_LOG_FUNCTION(
this << phyTx);
357 NS_LOG_FUNCTION(
this << phyRx);
364 NS_LOG_FUNCTION(
this);
376 NS_LOG_FUNCTION(
this << carrierId << duration);
377 NS_LOG_INFO(
"Sending a packet with carrierId: " << carrierId <<
" duration: " << duration);
395 Ptr<SatSignalParameters> txParams = Create<SatSignalParameters>();
396 txParams->m_duration = duration;
398 txParams->m_packetsInBurst = p;
401 txParams->m_carrierId = carrierId;
403 txParams->m_txInfo.modCod = txInfo.
modCod;
404 txParams->m_txInfo.sliceId = txInfo.
sliceId;
406 txParams->m_txInfo.frameType = txInfo.
frameType;
407 txParams->m_txInfo.waveformId = txInfo.
waveformId;
408 txParams->m_txInfo.packetType = txInfo.
packetType;
417 NS_LOG_FUNCTION(
this << txParams);
429 NS_LOG_FUNCTION(
this << satId);
438 NS_LOG_FUNCTION(
this << beamId);
449 for (PacketContainer_t::const_iterator it = packets.begin(); it != packets.end(); ++it)
452 if (!(*it)->PeekPacketTag(timeTag))
477 NS_LOG_FUNCTION(
this);
481 SatSignalParameters::PacketsInBurst_t::iterator it1;
482 for (it1 = packets.begin(); it1 != packets.end(); ++it1)
485 bool isTaggedWithAddress =
false;
486 ByteTagIterator it2 = (*it1)->GetByteTagIterator();
488 while (!isTaggedWithAddress && it2.HasNext())
490 ByteTagIterator::Item item = it2.Next();
494 NS_LOG_DEBUG(
this <<
" contains a SatAddressTag tag:"
495 <<
" start=" << item.GetStart() <<
" end=" << item.GetEnd());
497 item.GetTag(addrTag);
499 isTaggedWithAddress =
true;
506 if ((*it1)->RemovePacketTag(linkTimeTag))
508 NS_LOG_DEBUG(
this <<
" contains a SatPhyLinkTimeTag tag");
520 if ((*it1)->RemovePacketTag(timeTag))
522 NS_LOG_DEBUG(
this <<
" contains a SatPhyTimeTag tag");
541 NS_LOG_FUNCTION(
this);
550 SatSignalParameters::PacketsInBurst_t::iterator it1;
551 for (it1 = rxParams->m_packetsInBurst.begin(); it1 != rxParams->m_packetsInBurst.end();
554 if (!(*it1)->PeekPacketTag(satAddressE2ETag))
556 NS_FATAL_ERROR(
"SatUplinkInfoTag not found");
564 SatSignalParameters::PacketsInBurst_t::iterator it1;
565 for (it1 = rxParams->m_packetsInBurst.begin(); it1 != rxParams->m_packetsInBurst.end();
568 if (!(*it1)->PeekPacketTag(satAddressE2ETag))
570 NS_FATAL_ERROR(
"SatUplinkInfoTag not found");
578 NS_FATAL_ERROR(
"Incorrect satellite RX link direction");
586 NS_LOG_FUNCTION(
this << rxParams << phyError);
605 NS_LOG_INFO(
this <<
" dropped " << rxParams->m_packetsInBurst.size()
606 <<
" packets because of PHY error.");
611 RxTraces(rxParams->m_packetsInBurst);
629 NS_LOG_FUNCTION(
this << beamId << source << cno << isSatelliteMac);
630 m_cnoCallback(satId, beamId, source, dest, cno, isSatelliteMac);
637 uint8_t allocationChannelId,
638 double averageNormalizedOfferedLoad)
640 NS_LOG_FUNCTION(
this << satId << beamId << carrierId << allocationChannelId
641 << averageNormalizedOfferedLoad);
646 averageNormalizedOfferedLoad);
652 NS_LOG_FUNCTION(
this << &cb);
This class implements a tag that carries the satellite MAC of GW and UT.
Mac48Address GetE2ESourceAddress(void) const
Get E2E source MAC address.
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.
void SetBeamId(uint32_t beamId)
Set the beamId this PHY is connected with.
virtual void SetTxAntennaGainPattern(Ptr< SatAntennaGainPattern > agp, Ptr< SatMobilityModel > satelliteMobility)
Set the transmit antenna gain pattern.
double m_txMaxAntennaGainDb
Configured maximum transmitter antenna gain in dBi.
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 SetNodeInfo(const Ptr< SatNodeInfo > nodeInfo)
Set the node info class.
void SetTimeTag(SatPhy::PacketContainer_t packets)
Set SatPhyTimeTag of packets.
void ConfigureRxCarriers(Ptr< SatPhyRxCarrierConf > carrierConf, Ptr< SatSuperframeConf > superFrameConf)
Configure Rx carriers.
void Initialize()
Initialize phy.
virtual Ptr< SatPhyTx > GetPhyTx() const
Get the SatPhyTx pointer.
virtual void SetRxAntennaGainPattern(Ptr< SatAntennaGainPattern > agp, Ptr< SatMobilityModel > satelliteMobility)
Set the receive antenna gain pattern.
TracedCallback< const Time &, const Address & > m_rxDelayTrace
Traced callback for all received packets, including delay information and the address of the senders.
TracedCallback< const Time &, const Address & > m_rxJitterTrace
Traced callback for all received packets, including jitter information and the address of the senders...
void CnoInfo(uint32_t satId, uint32_t beamId, Address source, Address destination, double cno, bool isSatelliteMac)
Function for getting the C/NO information.
void SetSatId(uint32_t satId)
Set the satId this PHY is connected with.
TracedCallback< const Time &, const Address & > m_rxLinkDelayTrace
Traced callback for all received packets, including link delay information and the address of the sen...
Ptr< SatPhyRx > m_phyRx
Pointer to internal SatPhyRx instance.
virtual SatEnums::SatLinkDir_t GetSatLinkTxDir()
Get the link TX direction.
virtual SatEnums::SatLinkDir_t GetSatLinkRxDir()
Get the link RX direction.
uint32_t m_satId
Satellite ID.
void BeginEndScheduling()
Begin frame/window end scheduling for processes utilizing frame length as interval.
TypeId GetInstanceTypeId(void) const
Derived from Object.
virtual void SendPduWithParams(Ptr< SatSignalParameters > rxParams)
Send Pdu to the PHY tx module (for GEO satellite switch packet forwarding)
uint32_t m_beamId
Beam ID.
double m_rxAntennaLossDb
Configured receiver antenna loss in Dbs.
double m_defaultFadingValue
Default fading value.
virtual Ptr< SatPhyRx > GetPhyRx() const
Get the SatPhyRx pointer.
static TypeId GetTypeId(void)
Derived from Object.
double m_txMaxPowerDbw
Configured maximum transmitter power in DbWs.
void SetRxFadingContainer(Ptr< SatBaseFading > fadingContainer)
Set fading container.
void AverageNormalizedOfferedRandomAccessLoadInfo(uint32_t satId, uint32_t beamId, uint32_t carrierId, uint8_t allocationChannelId, double averageNormalizedOfferedLoad)
Function for getting the normalized offered load of the specific random access allocation channel.
Ptr< SatChannel > GetTxChannel()
Get the Tx satellite channel.
Ptr< SatNodeInfo > m_nodeInfo
Node info containing node related information, such as node type, node id and MAC address (of the Sat...
TracedCallback< uint32_t, const Address & > m_rxLinkModcodTrace
Traced callback for all received packets, including link MODCOD information and the address of the se...
double m_rxMaxAntennaGainDb
Configured maximum receiver antenna gain in dBi.
virtual void SendPdu(PacketContainer_t, uint32_t carrierId, Time duration, SatSignalParameters::txInfo_s txInfo)
Send Pdu to the PHY tx module (for initial transmissions from either UT or GW)
void SetChannelPairGetterCallback(SatPhy::ChannelPairGetterCallback cb)
Set the channel pair getter callback.
virtual void RxTraces(SatPhy::PacketContainer_t packets)
Invoke the Rx trace source for each received packet.
virtual void Receive(Ptr< SatSignalParameters > rxParams, bool phyError)
Receives packets from lower layer.
double m_txOutputLossDb
Configured transmitter output loss in Dbs.
SatPhy::ChannelPairGetterCallback m_retrieveChannelPair
Callback for retrieving SatChannel pairs by beam.
TracedCallback< Ptr< const Packet >, const Address & > m_rxTrace
Traced callback for all received packets, including the address of the senders.
SatPhy(void)
Default constructor.
SatPhy::AverageNormalizedOfferedLoadCallback m_avgNormalizedOfferedLoadCallback
Average normalized offered load callback.
double m_eirpWoGainW
Calculated EIRP without gain in W.
virtual void SetPhyTx(Ptr< SatPhyTx > phyTx)
Set the SatPhyTx module.
Time m_lastDelay
Last delay measurement.
double m_txPointingLossDb
Configured transmitter pointing loss in Dbs.
Ptr< SatPhyTx > m_phyTx
Pointer to internal SatPhyTx instance.
void ModcodTrace(Ptr< SatSignalParameters > rxParams)
Invoke the RxLinkModcod trace source for each received packet.
double m_txAntennaLossDb
Configured transmitter antenna loss in Dbs.
bool m_isStatisticsTagsEnabled
EnableStatisticsTags attribute.
virtual void DoDispose(void)
Dispose of SatPhy.
virtual ~SatPhy()
Destructor.
Time m_lastLinkDelay
Last delay measurement for link.
void SetTxFadingContainer(Ptr< SatBaseFading > fadingContainer)
Set fading container.
double CalculateSinr(double sinr, double otherInterference)
Calculate final SINR with PHY specific parameters and given calculated SINR.
SatSignalParameters::PacketsInBurst_t PacketContainer_t
Define PacketContainer in SatPhy.
double m_txOboLossDb
Configured transmitter OBO loss in Dbs.
virtual void SetPhyRx(Ptr< SatPhyRx > phyRx)
Set the SatPhyRx module.
SatPhy::CnoCallback m_cnoCallback
The C/N0 info callback.
Callback< SatChannelPair::ChannelPair_t, uint32_t, uint32_t > ChannelPairGetterCallback
Callback for retrieving a pair of SatChannel associated to a beam.
virtual void DoInitialize(void)
Initialization of SatPhy.
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...
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.
Time tag used to identify the time when packet is enqueued at PHY on first link between GW and UT lev...
Time GetSenderTimestamp(void) const
Get sender time stamp of this tag.
static T DbWToW(T dbw)
Converts Decibel Watts to Watts.
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.
Ptr< NetDevice > m_device
SatEnums::SatLoraNodeType_t m_standard
Struct for storing the packet specific Tx information.
SatEnums::PacketType_t packetType
uint32_t crdsaUniquePacketId
SatEnums::SatBbFrameType_t frameType
uint32_t fecBlockSizeInBytes
SatEnums::SatModcod_t modCod