25 #include "../stats/satellite-phy-rx-carrier-packet-probe.h"
41 #include <ns3/address.h>
42 #include <ns3/boolean.h>
44 #include <ns3/simulator.h>
45 #include <ns3/singleton.h>
52 NS_LOG_COMPONENT_DEFINE(
"SatPhyRxCarrier");
57 NS_OBJECT_ENSURE_REGISTERED(SatPhyRxCarrier);
60 Ptr<SatPhyRxCarrierConf> carrierConf,
61 Ptr<SatWaveformConf> waveformConf,
62 bool isRandomAccessEnabled)
63 : m_randomAccessEnabled(isRandomAccessEnabled),
67 m_carrierId(carrierId),
68 m_receivingDedicatedAccess(false),
70 m_satInterferenceElimination(),
71 m_enableCompositeSinrOutputTrace(false),
74 m_waveformConf(waveformConf)
76 NS_LOG_FUNCTION(
this << carrierId);
96 NS_LOG_INFO(
this <<
" link results in use in carrier: " << carrierId);
122 NS_LOG_INFO(
"Carrier ID: " <<
m_carrierId <<
", channel type: "
129 double rxBandwidthHz)
134 NS_LOG_INFO(
this <<
" Constant interference model created for carrier: " << carrierId);
139 NS_LOG_INFO(
this <<
" Per packet interference model created for carrier: " << carrierId);
140 if (carrierConf->IsIntfOutputTraceEnabled())
143 CreateObject<SatPerPacketInterference>(
GetChannelType(), rxBandwidthHz);
152 NS_LOG_INFO(
this <<
" Per fragment interference model created for carrier: " << carrierId);
153 if (carrierConf->IsIntfOutputTraceEnabled())
156 CreateObject<SatPerFragmentInterference>(
GetChannelType(), rxBandwidthHz);
165 NS_LOG_INFO(
this <<
" Traced interference model created for carrier: " << carrierId);
170 NS_LOG_ERROR(
this <<
" Not a valid interference model!");
179 Ptr<SatWaveformConf> waveformConf)
184 NS_LOG_INFO(
this <<
" Perfect interference elimination model created for carrier: "
190 NS_LOG_INFO(
this <<
" Residual interference elimination model created for carrier: "
193 CreateObject<SatResidualInterferenceElimination>(waveformConf);
197 NS_LOG_ERROR(
this <<
" Not a valid interference elimination model!");
205 NS_LOG_FUNCTION(
this);
217 TypeId(
"ns3::SatPhyRxCarrier")
219 .AddAttribute(
"EnableCompositeSinrOutputTrace",
220 "Enable composite SINR output trace.",
223 MakeBooleanChecker())
224 .AddTraceSource(
"LinkBudgetTrace",
225 "The trace for link budget related quantities",
227 "ns3::SatPhyRxCarrier::LinkBudgetTraceCallback")
228 .AddTraceSource(
"RxPowerTrace",
229 "The trace for received signal power in dBW",
231 "ns3::SatPhyRxCarrier::RxPowerTraceCallback")
232 .AddTraceSource(
"Sinr",
233 "The trace for composite SINR in dB",
235 "ns3::SatPhyRxCarrier::SinrTraceCallback")
236 .AddTraceSource(
"LinkSinr",
237 "The trace for link specific SINR in dB",
239 "ns3::SatPhyRxCarrier::LinkSinrTraceCallback")
240 .AddTraceSource(
"DaRx",
241 "Received a packet burst through Dedicated Channel",
243 "ns3::SatPhyRxCarrierPacketProbe::RxStatusCallback")
244 .AddTraceSource(
"DaRxCarrierId",
245 "Received a packet burst though DAMA",
247 "ns3::SatTypedefs::DataSenderAddressCallback");
254 NS_LOG_FUNCTION(
this);
288 NS_LOG_FUNCTION(
this);
295 NS_LOG_FUNCTION(
this);
302 NS_LOG_FUNCTION(
this << newState);
303 NS_LOG_INFO(
this <<
" state: " <<
m_state <<
" -> " << newState);
307 std::pair<bool, SatPhyRxCarrier::rxParams_s>
314 bool ownAddressFound =
false;
321 if (!rxParams->m_packetsInBurst.empty())
324 rxParams->m_packetsInBurst[0]->PeekPacketTag(mTag);
326 rxParams->m_packetsInBurst[0]->PeekPacketTag(addressE2ETag);
333 receivePacket =
true;
337 for (SatSignalParameters::PacketsInBurst_t::const_iterator i =
338 rxParams->m_packetsInBurst.begin();
339 ((i != rxParams->m_packetsInBurst.end()) && (ownAddressFound ==
false));
343 (*i)->PeekPacketTag(mTag);
345 (*i)->PeekPacketTag(addressE2ETag);
354 NS_LOG_INFO(
"Packet intended for this specific receiver: " << params.
destAddress);
356 receivePacket =
true;
357 ownAddressFound =
true;
361 NS_LOG_INFO(
"Destination is broadcast address: " << params.
destAddress);
362 receivePacket =
true;
366 NS_LOG_INFO(
"Destination is multicast address: " << params.
destAddress);
367 receivePacket =
true;
371 return std::make_pair(receivePacket, params);
377 NS_LOG_FUNCTION(
this << rxParams);
378 NS_LOG_INFO(
"State: " <<
m_state);
383 NS_LOG_INFO(
"Node: " <<
m_nodeInfo->GetMacAddress()
384 <<
" starts receiving packet at: " << Simulator::Now().GetSeconds()
385 <<
" in carrier: " << rxParams->m_carrierId);
386 NS_LOG_INFO(
"Sender: " << rxParams->m_phyTx);
394 bool receivePacket = receiveParamTuple.first;
395 rxParams_s rxParamsStruct = receiveParamTuple.second;
405 bool isGoodBeam = (rxParams->m_beamId ==
GetBeamId());
413 if (receivePacket && isGoodBeam)
418 NS_FATAL_ERROR(
"Starting reception of a packet when receiving DA transmission! "
419 "This may be due to a clock drift in UTs too important, or an "
420 "update period for SGP4 too important.");
430 NS_LOG_INFO(
this <<
" scheduling EndRx with delay " << rxParams->m_duration.GetSeconds()
448 NS_FATAL_ERROR(
"Incorrect channel for satPhyRxCarrierUplink: "
461 NS_FATAL_ERROR(
"SatPhyRxCarrier::StartRx - Unknown state");
472 NS_LOG_FUNCTION(
this);
474 std::vector<double> tempVector;
475 tempVector.push_back(Now().GetSeconds());
476 tempVector.push_back(cSinr);
478 Singleton<SatCompositeSinrOutputTraceContainer>::Get()->AddToContainer(
486 NS_LOG_FUNCTION(
this);
510 NS_FATAL_ERROR(
"SatPhyRxCarrier::EndRxData - Error model not defined");
519 Ptr<SatSignalParameters> rxParams)
544 ->GetBler(rxParams->m_txInfo.modCod,
545 rxParams->m_txInfo.frameType,
556 <<
" ber: " << ber <<
" error: " << error);
587 ->GetBler(rxParams->m_txInfo.modCod,
588 rxParams->m_txInfo.frameType,
603 NS_LOG_INFO(
"RETURN cSinr (dB): "
606 <<
" rand: " << r <<
" ber: " << ber <<
" error: " << error);
612 "SatPhyRxCarrier::CheckAgainstLinkResultsErrorModelAvi - Invalid channel type!");
622 NS_LOG_FUNCTION(
this << nodeInfo);
631 double rxNoisePowerW,
632 double rxAciIfPowerW,
633 double rxExtNoisePowerW,
634 double additionalInterference)
636 NS_LOG_FUNCTION(
this << rxPowerW << ifPowerW);
638 if (rxNoisePowerW <= 0.0)
640 NS_FATAL_ERROR(
"Noise power must be greater than zero!!! Current value is "
647 double sinr = rxPowerW / (ifPowerW + rxNoisePowerW + rxAciIfPowerW + rxExtNoisePowerW);
650 double finalSinr = (1 / (1 / sinr + 1 / additionalInterference));
658 NS_LOG_FUNCTION(
this << sinr << otherInterference);
662 NS_FATAL_ERROR(
"Calculated own SINR is expected to be greater than zero!!!");
665 if (otherInterference <= 0)
667 NS_FATAL_ERROR(
"Interference is expected to be greater than zero!!!");
670 double finalSinr = 1 / ((1 / sinr) + (1 / otherInterference));
678 NS_LOG_FUNCTION(
this << sinr1 << sinr2);
682 NS_FATAL_ERROR(
"SINR 1 must be greater than zero!!!");
687 NS_FATAL_ERROR(
"SINR 2 must be greater than zero!!!");
690 return 1.0 / ((1.0 / sinr1) + (1.0 / sinr2));
696 NS_LOG_FUNCTION(
this << sinr1 << sinr2);
700 NS_FATAL_ERROR(
"SINR 1 must be greater than zero!!! Current value is " << sinr1);
705 NS_FATAL_ERROR(
"SINR 2 must be greater than zero!!! Current value is " << sinr2);
708 return std::min(sinr1, sinr2);
714 NS_LOG_FUNCTION(
this);
730 NS_LOG_FUNCTION(
this);
753 NS_LOG_FUNCTION(
this);
757 NS_FATAL_ERROR(
"SatPhyRxCarrier::CheckStateSanity - State mismatch");
762 NS_FATAL_ERROR(
"SatPhyRxCarrier::CheckStateSanity - State mismatch");
770 NS_LOG_FUNCTION(
this << &callback);
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.
static std::string GetChannelTypeName(ChannelType_t channelType)
PacketType_t
Packet types.
@ PACKET_TYPE_DEDICATED_ACCESS
Link results for forward link.
Link results for DVB-RCS2.
This class implements a tag that carries the satellite MAC specific information, such as source and d...
Mac48Address GetSourceAddress(void) const
Get source MAC address.
Mac48Address GetDestAddress(void) const
Get destination MAC address.
SatPhy::AverageNormalizedOfferedLoadCallback m_avgNormalizedOfferedLoadCallback
Average normalized offered load callback.
void SetNodeInfo(const Ptr< SatNodeInfo > nodeInfo)
Function for setting the node info class.
Ptr< SatInterference > GetInterferenceModel()
Get pointer to the current interference model.
void DoCompositeSinrOutputTrace(double cSinr)
Function for composite SINR output tracing.
double m_rxExtNoisePowerW
External noise power system RX noise.
Ptr< SatNodeInfo > m_nodeInfo
void SetLinkRegenerationMode(SatEnums::RegenerationMode_t linkRegenerationMode)
Set the link regeneration mode.
void CheckRxStateSanity()
Function for checking the Rx state sanity.
void SetCnoCb(SatPhyRx::CnoCallback cb)
Function for settign the C/NO callback.
TracedCallback< double, const Address & > m_linkSinrTrace
A callback for link specific SINR in dB.
Ptr< SatInterferenceElimination > m_satInterferenceElimination
static TypeId GetTypeId(void)
Function for gettign the NS-3 type ID.
TracedCallback< uint32_t, const Address & > m_daRxCarrierIdTrace
TracedCallback< Ptr< SatSignalParameters >, Mac48Address, Mac48Address, double, double > m_linkBudgetTrace
The trace source on packet receptiong.
void SetAverageNormalizedOfferedLoadCallback(SatPhyRx::AverageNormalizedOfferedLoadCallback callback)
Function for setting the AverageNormalizedOfferedLoadCallback callback.
SatPhyRxCarrierConf::AdditionalInterferenceCallback m_additionalInterferenceCallback
Callback to get additional interference.
TracedCallback< double, const Address & > m_rxPowerTrace
A callback for received signal power in dBW.
void DecreaseNumOfRxState(SatEnums::PacketType_t packetType)
Function for decreasing the number of ongoing transmissions.
virtual Ptr< SatInterference::InterferenceChangeEvent > CreateInterference(Ptr< SatSignalParameters > rxParams, Address rxAddress)=0
Create an interference event based on Rx parameters and address.
Ptr< SatLinkResults > m_linkResults
virtual SatEnums::ChannelType_t GetChannelType()
Get the channel type.
uint32_t GetBeamId()
Get ID the ID of the beam this carrier is attached to.
bool m_receivingDedicatedAccess
Mac48Address m_ownAddress
virtual void DoCreateInterferenceEliminationModel(Ptr< SatPhyRxCarrierConf > carrierConf, uint32_t carrierId, Ptr< SatWaveformConf > waveformConf)
Create an interference cancelation model for this carrier.
double CalculateSinr(double rxPowerW, double ifPowerW, double rxNoisePowerW, double rxAciIfPowerW, double rxExtNoisePowerW, double otherInterference)
Function for calculating the SINR.
SatPhyRx::ReceiveCallback m_rxCallback
The upper layer package receive callback.
TracedCallback< uint32_t, const Address &, bool > m_daRxTrace
DaRx trace source.
double m_rxAciIfPowerW
RX Adjacent channel interference.
virtual bool StartRx(Ptr< SatSignalParameters > rxParams)
Function for starting packet reception from the SatChannel.
bool m_enableCompositeSinrOutputTrace
TracedCallback< double, const Address & > m_sinrTrace
A callback for transmission composite SINR at UT (BBFrame) or GW (time slot).
Ptr< SatChannelEstimationErrorContainer > m_channelEstimationError
Channel estimation error container.
double m_constantErrorRate
bool IsReceivingDedicatedAccess()
Check if the carrier is receiving a dedicated access packet.
void SetReceiveCb(SatPhyRx::ReceiveCallback cb)
Function for setting the receive callback.
bool CheckAgainstLinkResults(double cSinr, Ptr< SatSignalParameters > rxParams)
Function for checking the SINR against the link results.
SatPhy::CnoCallback m_cnoCallback
The upper layer C/N0 receive callback.
bool CheckAgainstLinkResultsErrorModelAvi(double cSinr, Ptr< SatSignalParameters > rxParams)
Function for checking the SINR against the link results.
virtual void DoCreateInterferenceModel(Ptr< SatPhyRxCarrierConf > carrierConf, uint32_t carrierId, double rxBandwidthHz)
Create an interference model for this carrier.
double CalculateCompositeSinr(double sinr1, double sinr2)
Function for calculating the composite SINR.
double GetWorstSinr(double sinr1, double sinr2)
Function for calculating the worst sinr between uplink and downlink.
SatPhyRxCarrierConf::ErrorModel m_errorModel
uint32_t m_numOfOngoingRx
Contains information about how many ongoing Rx events there are.
const bool m_randomAccessEnabled
Is random access enabled for this carrier.
virtual void BeginEndScheduling()
Function for initializing the frame/window end scheduling.
virtual void DoDispose()
Dispose.
double GetUniformRandomValue(double min, double max)
A helper method for getting values form a uniform random variable in child classes.
void ChangeState(State newState)
Function for changing the receiver state.
SatPhyRxCarrier(uint32_t carrierId, Ptr< SatPhyRxCarrierConf > carrierConf, Ptr< SatWaveformConf > waveformConf, bool isRandomAccessEnabled)
Constructor.
void SetChannelType(SatEnums::ChannelType_t channelType)
Set the channel type for the carrier.
Ptr< UniformRandomVariable > m_uniformVariable
Ptr< SatInterference > m_satInterference
State
Enum for PHY states.
double m_rxNoisePowerW
RX noise.
SatEnums::RegenerationMode_t m_linkRegenerationMode
Link regeneration mode.
virtual const bool GetDefaultReceiveMode()
Get the default receive mode for the carrier.
std::pair< bool, SatPhyRxCarrier::rxParams_s > GetReceiveParams(Ptr< SatSignalParameters > rxParams)
Rx parameter storage methods.
Ptr< SatLinkResults > GetLinkResults()
Get pointer to the link results given by the carrier creation configuration.
virtual void EndRxData(uint32_t key)=0
Function for ending the packet reception from the SatChannel.
void IncreaseNumOfRxState(SatEnums::PacketType_t packetType)
Function for increasing the number of ongoing transmissions.
uint32_t m_rxPacketCounter
Running counter for received packets.
virtual ~SatPhyRxCarrier()
Destructor.
double m_rxBandwidthHz
RX Bandwidth in Hz.
void StoreRxParams(uint32_t key, rxParams_s rxParams)
Store rxParams under a key.
Mac48Address GetOwnAddress()
Get the MAC address of the carrier.
double m_rxTemperatureK
RX noise temperature in K.
Callback< void, uint32_t, uint32_t, Address, Address, double, bool > CnoCallback
Callback< void, Ptr< SatSignalParameters >, bool > ReceiveCallback
Callback< void, uint32_t, uint32_t, uint32_t, uint8_t, double > AverageNormalizedOfferedLoadCallback
static T LinearToDb(T linear)
Converts linear to decibels.
static uint32_t GetModulatedBits(SatEnums::SatModcod_t modcod)
Get the modulated bits of a certain MODCOD.
static double GetCodingRate(SatEnums::SatModcod_t modcod)
Gets the coding rate of a certain MODCOD.
constexpr double BOLTZMANN_CONSTANT
Boltzmann Constant.
SatArqSequenceNumber is handling the sequence numbers for the ARQ process.
std::ostream & operator<<(std::ostream &os, const GeoCoordinate &coordinate)
Struct for storing the packet specific Rx parameters.
Mac48Address finalDestAddress
Ptr< SatSignalParameters > rxParams
Mac48Address finalSourceAddress
Mac48Address sourceAddress
Ptr< SatInterference::InterferenceChangeEvent > interferenceEvent