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>
53 NS_LOG_COMPONENT_DEFINE(
"SatPhyRxCarrier");
58 NS_OBJECT_ENSURE_REGISTERED(SatPhyRxCarrier);
61 Ptr<SatPhyRxCarrierConf> carrierConf,
62 Ptr<SatWaveformConf> waveformConf,
63 bool isRandomAccessEnabled)
64 : m_randomAccessEnabled(isRandomAccessEnabled),
68 m_carrierId(carrierId),
69 m_receivingDedicatedAccess(false),
71 m_satInterferenceElimination(),
72 m_enableCompositeSinrOutputTrace(false),
75 m_waveformConf(waveformConf)
77 NS_LOG_FUNCTION(
this << carrierId);
97 NS_LOG_INFO(
this <<
" link results in use in carrier: " << carrierId);
123 NS_LOG_INFO(
"Carrier ID: " <<
m_carrierId <<
", channel type: "
130 double rxBandwidthHz)
135 NS_LOG_INFO(
this <<
" Constant interference model created for carrier: " << carrierId);
140 NS_LOG_INFO(
this <<
" Per packet interference model created for carrier: " << carrierId);
141 if (carrierConf->IsIntfOutputTraceEnabled())
144 CreateObject<SatPerPacketInterference>(
GetChannelType(), rxBandwidthHz);
153 NS_LOG_INFO(
this <<
" Per fragment interference model created for carrier: " << carrierId);
154 if (carrierConf->IsIntfOutputTraceEnabled())
157 CreateObject<SatPerFragmentInterference>(
GetChannelType(), rxBandwidthHz);
166 NS_LOG_INFO(
this <<
" Traced interference model created for carrier: " << carrierId);
171 NS_LOG_ERROR(
this <<
" Not a valid interference model!");
180 Ptr<SatWaveformConf> waveformConf)
185 NS_LOG_INFO(
this <<
" Perfect interference elimination model created for carrier: "
191 NS_LOG_INFO(
this <<
" Residual interference elimination model created for carrier: "
194 CreateObject<SatResidualInterferenceElimination>(waveformConf);
198 NS_LOG_ERROR(
this <<
" Not a valid interference elimination model!");
206 NS_LOG_FUNCTION(
this);
218 TypeId(
"ns3::SatPhyRxCarrier")
220 .AddAttribute(
"EnableCompositeSinrOutputTrace",
221 "Enable composite SINR output trace.",
224 MakeBooleanChecker())
225 .AddTraceSource(
"LinkBudgetTrace",
226 "The trace for link budget related quantities",
228 "ns3::SatPhyRxCarrier::LinkBudgetTraceCallback")
229 .AddTraceSource(
"RxPowerTrace",
230 "The trace for received signal power in dBW",
232 "ns3::SatPhyRxCarrier::RxPowerTraceCallback")
233 .AddTraceSource(
"Sinr",
234 "The trace for composite SINR in dB",
236 "ns3::SatPhyRxCarrier::SinrTraceCallback")
237 .AddTraceSource(
"LinkSinr",
238 "The trace for link specific SINR in dB",
240 "ns3::SatPhyRxCarrier::LinkSinrTraceCallback")
241 .AddTraceSource(
"DaRx",
242 "Received a packet burst through Dedicated Channel",
244 "ns3::SatPhyRxCarrierPacketProbe::RxStatusCallback")
245 .AddTraceSource(
"DaRxCarrierId",
246 "Received a packet burst though DAMA",
248 "ns3::SatTypedefs::DataSenderAddressCallback");
255 NS_LOG_FUNCTION(
this);
289 NS_LOG_FUNCTION(
this);
296 NS_LOG_FUNCTION(
this);
303 NS_LOG_FUNCTION(
this << newState);
304 NS_LOG_INFO(
this <<
" state: " <<
m_state <<
" -> " << newState);
308 std::pair<bool, SatPhyRxCarrier::rxParams_s>
315 bool ownAddressFound =
false;
322 if (!rxParams->m_packetsInBurst.empty())
325 rxParams->m_packetsInBurst[0]->PeekPacketTag(mTag);
327 rxParams->m_packetsInBurst[0]->PeekPacketTag(addressE2ETag);
334 receivePacket =
true;
338 for (SatSignalParameters::PacketsInBurst_t::const_iterator i =
339 rxParams->m_packetsInBurst.begin();
340 ((i != rxParams->m_packetsInBurst.end()) && (ownAddressFound ==
false));
344 (*i)->PeekPacketTag(mTag);
346 (*i)->PeekPacketTag(addressE2ETag);
355 NS_LOG_INFO(
"Packet intended for this specific receiver: " << params.
destAddress);
357 receivePacket =
true;
358 ownAddressFound =
true;
362 NS_LOG_INFO(
"Destination is broadcast address: " << params.
destAddress);
363 receivePacket =
true;
367 NS_LOG_INFO(
"Destination is multicast address: " << params.
destAddress);
368 receivePacket =
true;
372 return std::make_pair(receivePacket, params);
378 NS_LOG_FUNCTION(
this << rxParams);
379 NS_LOG_INFO(
"State: " <<
m_state);
384 NS_LOG_INFO(
"Node: " <<
m_nodeInfo->GetMacAddress()
385 <<
" starts receiving packet at: " << Simulator::Now().GetSeconds()
386 <<
" in carrier: " << rxParams->m_carrierId);
387 NS_LOG_INFO(
"Sender: " << rxParams->m_phyTx);
393 std::pair<bool, SatPhyRxCarrier::rxParams_s> receiveParamTuple =
GetReceiveParams(rxParams);
395 bool receivePacket = receiveParamTuple.first;
396 rxParams_s rxParamsStruct = receiveParamTuple.second;
406 bool isGoodBeam = (rxParams->m_beamId ==
GetBeamId());
414 if (receivePacket && isGoodBeam)
419 NS_LOG_WARN(
"Starting reception of a packet when receiving DA transmission! "
420 "This may be due to a clock drift in UTs too important, or an "
421 "update period for SGP4 too important.");
432 NS_LOG_INFO(
this <<
" scheduling EndRx with delay " << rxParams->m_duration.GetSeconds()
450 NS_FATAL_ERROR(
"Incorrect channel for satPhyRxCarrierUplink: "
463 NS_FATAL_ERROR(
"SatPhyRxCarrier::StartRx - Unknown state");
474 NS_LOG_FUNCTION(
this);
476 std::vector<double> tempVector;
477 tempVector.push_back(Now().GetSeconds());
478 tempVector.push_back(cSinr);
480 Singleton<SatCompositeSinrOutputTraceContainer>::Get()->AddToContainer(
488 NS_LOG_FUNCTION(
this);
512 NS_FATAL_ERROR(
"SatPhyRxCarrier::EndRxData - Error model not defined");
521 Ptr<SatSignalParameters> rxParams)
546 ->GetBler(rxParams->m_txInfo.modCod,
547 rxParams->m_txInfo.frameType,
558 <<
" ber: " << ber <<
" error: " << error);
589 ->GetBler(rxParams->m_txInfo.modCod,
590 rxParams->m_txInfo.frameType,
605 NS_LOG_INFO(
"RETURN cSinr (dB): "
608 <<
" rand: " << r <<
" ber: " << ber <<
" error: " << error);
614 "SatPhyRxCarrier::CheckAgainstLinkResultsErrorModelAvi - Invalid channel type!");
624 NS_LOG_FUNCTION(
this << nodeInfo);
633 double rxNoisePowerW,
634 double rxAciIfPowerW,
635 double rxExtNoisePowerW,
636 double additionalInterference)
638 NS_LOG_FUNCTION(
this << rxPowerW << ifPowerW);
640 if (rxNoisePowerW <= 0.0)
642 NS_FATAL_ERROR(
"Noise power must be greater than zero!!! Current value is "
649 double sinr = rxPowerW / (ifPowerW + rxNoisePowerW + rxAciIfPowerW + rxExtNoisePowerW);
652 double finalSinr = (1 / (1 / sinr + 1 / additionalInterference));
660 NS_LOG_FUNCTION(
this << sinr << otherInterference);
664 NS_FATAL_ERROR(
"Calculated own SINR is expected to be greater than zero!!!");
667 if (otherInterference <= 0)
669 NS_FATAL_ERROR(
"Interference is expected to be greater than zero!!!");
672 double finalSinr = 1 / ((1 / sinr) + (1 / otherInterference));
680 NS_LOG_FUNCTION(
this << sinr1 << sinr2);
684 NS_FATAL_ERROR(
"SINR 1 must be greater than zero!!!");
689 NS_FATAL_ERROR(
"SINR 2 must be greater than zero!!!");
692 return 1.0 / ((1.0 / sinr1) + (1.0 / sinr2));
698 NS_LOG_FUNCTION(
this << sinr1 << sinr2);
702 NS_FATAL_ERROR(
"SINR 1 must be greater than zero!!! Current value is " << sinr1);
707 NS_FATAL_ERROR(
"SINR 2 must be greater than zero!!! Current value is " << sinr2);
710 return std::min(sinr1, sinr2);
716 NS_LOG_FUNCTION(
this);
732 NS_LOG_FUNCTION(
this);
755 NS_LOG_FUNCTION(
this);
759 NS_FATAL_ERROR(
"SatPhyRxCarrier::CheckStateSanity - State mismatch");
764 NS_FATAL_ERROR(
"SatPhyRxCarrier::CheckStateSanity - State mismatch");
772 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