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<SatPhyRx>();
112 m_phyTx = CreateObject<SatLoraPhyTx>();
113 m_phyRx = CreateObject<SatLoraPhyRx>();
117 m_phyTx = CreateObject<SatLoraPhyTx>();
118 m_phyRx = CreateObject<SatPhyRx>();
122 NS_FATAL_ERROR(
"Standard not implemented yet: " << params.
m_standard);
131 m_phyTx->SetMobility(mobility);
132 m_phyRx->SetMobility(mobility);
139 TypeId(
"ns3::SatPhy")
141 .AddAttribute(
"ReceiveCb",
142 "The receive callback for this phy.",
145 MakeCallbackChecker())
146 .AddAttribute(
"CnoCb",
147 "The C/N0 info callback for this phy.",
150 MakeCallbackChecker())
151 .AddAttribute(
"AverageNormalizedOfferedLoadCallback",
152 "The average offered random access load callback for this phy.",
155 MakeCallbackChecker())
156 .AddAttribute(
"EnableStatisticsTags",
157 "If true, some tags will be added to each transmitted packet to assist "
158 "with statistics computation",
161 MakeBooleanChecker())
162 .AddTraceSource(
"PacketTrace",
163 "Packet event trace",
165 "ns3::SatTypedefs::PacketTraceCallback")
166 .AddTraceSource(
"Rx",
169 "ns3::SatTypedefs::PacketSourceAddressCallback")
170 .AddTraceSource(
"RxDelay",
171 "A packet is received with delay information",
173 "ns3::SatTypedefs::PacketDelayAddressCallback")
174 .AddTraceSource(
"RxLinkDelay",
175 "A packet is received with link delay information",
177 "ns3::SatTypedefs::PacketDelayAddressCallback")
178 .AddTraceSource(
"RxJitter",
179 "A packet is received with jitter information",
181 "ns3::SatTypedefs::PacketJitterAddressCallback")
182 .AddTraceSource(
"RxLinkJitter",
183 "A packet is received with link jitter information",
185 "ns3::SatTypedefs::PacketJitterAddressCallback")
186 .AddTraceSource(
"RxLinkModcod",
187 "A packet is received with link MODCOD information",
189 "ns3::SatTypedefs::PacketModcodAddressCallback");
196 NS_LOG_FUNCTION(
this);
203 NS_LOG_FUNCTION(
this);
204 Object::DoInitialize();
210 NS_LOG_FUNCTION(
this);
213 double eirpWoGainDbw =
233 m_phyRx->SetAverageNormalizedOfferedLoadCallback(
248 NS_LOG_FUNCTION(
this);
254 NS_LOG_FUNCTION(
this);
266 NS_LOG_FUNCTION(
this << sinr << otherInterference);
270 NS_FATAL_ERROR(
"Calculated own SINR is expected to be greater than zero!!!");
273 if (otherInterference <= 0)
275 NS_FATAL_ERROR(
"Interference is expected to be greater than zero!!!");
278 double finalSinr = 1 / ((1 / sinr) + (1 / otherInterference));
285 Ptr<SatMobilityModel> satelliteMobility)
287 NS_LOG_FUNCTION(
this);
288 m_phyTx->SetAntennaGainPattern(agp, satelliteMobility);
293 Ptr<SatMobilityModel> satelliteMobility)
295 NS_LOG_FUNCTION(
this);
296 m_phyRx->SetAntennaGainPattern(agp, satelliteMobility);
301 Ptr<SatSuperframeConf> superFrameConf)
303 NS_LOG_FUNCTION(
this);
304 m_phyRx->ConfigurePhyRxCarriers(carrierConf, superFrameConf);
310 NS_LOG_FUNCTION(
this);
312 m_phyRx->SetFadingContainer(fadingContainer);
318 NS_LOG_FUNCTION(
this);
320 m_phyTx->SetFadingContainer(fadingContainer);
326 NS_LOG_FUNCTION(
this << nodeInfo);
328 m_phyRx->SetNodeInfo(nodeInfo);
334 NS_LOG_FUNCTION(
this);
341 NS_LOG_FUNCTION(
this);
348 NS_LOG_FUNCTION(
this);
355 NS_LOG_FUNCTION(
this << phyTx);
362 NS_LOG_FUNCTION(
this << phyRx);
369 NS_LOG_FUNCTION(
this);
381 NS_LOG_FUNCTION(
this << carrierId << duration);
382 NS_LOG_INFO(
"Sending a packet with carrierId: " << carrierId <<
" duration: " << duration);
400 Ptr<SatSignalParameters> txParams = Create<SatSignalParameters>();
401 txParams->m_duration = duration;
403 txParams->m_packetsInBurst = p;
406 txParams->m_carrierId = carrierId;
408 txParams->m_txInfo.modCod = txInfo.
modCod;
409 txParams->m_txInfo.sliceId = txInfo.
sliceId;
411 txParams->m_txInfo.frameType = txInfo.
frameType;
412 txParams->m_txInfo.waveformId = txInfo.
waveformId;
413 txParams->m_txInfo.packetType = txInfo.
packetType;
422 NS_LOG_FUNCTION(
this << txParams);
434 NS_LOG_FUNCTION(
this << satId);
443 NS_LOG_FUNCTION(
this << beamId);
445 bool connect =
m_beamId == 0 && beamId != 0;
446 bool disconnect =
m_beamId != 0 && beamId == 0;
452 return connect || disconnect;
460 for (PacketContainer_t::const_iterator it = packets.begin(); it != packets.end(); ++it)
463 if (!(*it)->PeekPacketTag(timeTag))
488 NS_LOG_FUNCTION(
this);
492 SatSignalParameters::PacketsInBurst_t::iterator it1;
493 for (it1 = packets.begin(); it1 != packets.end(); ++it1)
496 bool isTaggedWithAddress =
false;
497 ByteTagIterator it2 = (*it1)->GetByteTagIterator();
499 while (!isTaggedWithAddress && it2.HasNext())
501 ByteTagIterator::Item item = it2.Next();
505 NS_LOG_DEBUG(
this <<
" contains a SatAddressTag tag:"
506 <<
" start=" << item.GetStart() <<
" end=" << item.GetEnd());
508 item.GetTag(addrTag);
510 isTaggedWithAddress =
true;
517 if ((*it1)->RemovePacketTag(linkTimeTag))
519 NS_LOG_DEBUG(
this <<
" contains a SatPhyLinkTimeTag tag");
531 if ((*it1)->RemovePacketTag(timeTag))
533 NS_LOG_DEBUG(
this <<
" contains a SatPhyTimeTag tag");
552 NS_LOG_FUNCTION(
this);
561 SatSignalParameters::PacketsInBurst_t::iterator it1;
562 for (it1 = rxParams->m_packetsInBurst.begin(); it1 != rxParams->m_packetsInBurst.end();
565 if (!(*it1)->PeekPacketTag(satAddressE2ETag))
567 NS_FATAL_ERROR(
"SatUplinkInfoTag not found");
575 SatSignalParameters::PacketsInBurst_t::iterator it1;
576 for (it1 = rxParams->m_packetsInBurst.begin(); it1 != rxParams->m_packetsInBurst.end();
579 if (!(*it1)->PeekPacketTag(satAddressE2ETag))
581 NS_FATAL_ERROR(
"SatUplinkInfoTag not found");
589 NS_FATAL_ERROR(
"Incorrect satellite RX link direction");
597 NS_LOG_FUNCTION(
this << rxParams << phyError);
616 NS_LOG_INFO(
this <<
" dropped " << rxParams->m_packetsInBurst.size()
617 <<
" packets because of PHY error.");
622 RxTraces(rxParams->m_packetsInBurst);
640 NS_LOG_FUNCTION(
this << beamId << source << cno << isSatelliteMac);
641 m_cnoCallback(satId, beamId, source, dest, cno, isSatelliteMac);
648 uint8_t allocationChannelId,
649 double averageNormalizedOfferedLoad)
651 NS_LOG_FUNCTION(
this << satId << beamId << carrierId << allocationChannelId
652 << averageNormalizedOfferedLoad);
657 averageNormalizedOfferedLoad);
663 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.
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 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...
bool SetBeamId(uint32_t beamId)
Set the beamId this PHY is connected with.
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