27 #include <ns3/address.h>
28 #include <ns3/boolean.h>
30 #include <ns3/simulator.h>
37 NS_LOG_COMPONENT_DEFINE(
"SatPhyRxCarrierPerSlot");
42 NS_OBJECT_ENSURE_REGISTERED(SatPhyRxCarrierPerSlot);
45 Ptr<SatPhyRxCarrierConf> carrierConf,
46 Ptr<SatWaveformConf> waveformConf,
47 bool randomAccessEnabled)
48 :
SatPhyRxCarrier(carrierId, carrierConf, waveformConf, randomAccessEnabled),
49 m_randomAccessBitsInFrame(0),
50 m_randomAccessAllocationChannelId(0),
52 m_randomAccessConstantErrorRate(0.0),
53 m_randomAccessAverageNormalizedOfferedLoadMeasurementWindowSize(0),
54 m_enableRandomAccessDynamicLoadControl(false),
55 m_disableErrorHighTransmissionTime(false)
57 if (randomAccessEnabled)
62 carrierConf->GetRandomAccessAverageNormalizedOfferedLoadMeasurementWindowSize();
64 carrierConf->IsRandomAccessDynamicLoadControlEnabled();
66 NS_LOG_INFO(
"RA interference model: "
67 << carrierConf->GetInterferenceModel(
true)
69 <<
", RA avg. normalized offered load measurement window size: "
76 NS_LOG_FUNCTION(
this);
88 TypeId(
"ns3::SatPhyRxCarrierPerSlot")
91 "DisableErrorHighTransmissionTime",
92 "Disable fatal error when transmission time is higher than propagation time, but "
93 "computations are less precise.",
98 "SlottedAlohaRxCollision",
99 "Received a packet burst through Random Access Slotted ALOHA",
101 "ns3::SatPhyRxCarrierPacketProbe::RxStatusCallback")
103 "SlottedAlohaRxError",
104 "Received a packet burst through Random Access Slotted ALOHA",
106 "ns3::SatPhyRxCarrierPacketProbe::RxStatusCallback");
113 NS_LOG_FUNCTION(
this);
119 Ptr<SatInterference::InterferenceChangeEvent>
122 NS_LOG_FUNCTION(
this << rxParams << senderAddress);
128 rxParams->m_rxPower_W,
152 if (!rxParams->HasSinrComputed())
156 NS_LOG_WARN(
"SatPhyRx::StartRx - too long transmission time: packet started to "
157 "be received in a ground entity while not being fully received on "
158 "the satellite: interferences could not be properly computed.");
159 rxPower = rxParams->m_rxPower_W;
164 "SatPhyRx::StartRx - too long transmission time: packet started to be "
165 "received in a ground entity while not being fully received on the "
166 "satellite: interferences could not be properly computed.");
171 rxPower = rxParams->m_rxPower_W * (1 + 1 / rxParams->GetSinr());
181 rxParams->m_rxPower_W,
185 NS_FATAL_ERROR(
"SatSatellitePhyRxCarrier::CreateInterference - Invalid channel type!");
192 NS_LOG_FUNCTION(
this);
193 NS_LOG_INFO(
this <<
" state: " <<
GetState());
199 const uint32_t nPackets = packetRxParams.
rxParams->m_packetsInBurst.size();
207 NS_ASSERT(packetRxParams.
rxParams->HasSinrComputed());
210 packetRxParams.
rxParams->SetInterferencePower(
225 Ptr<SatSignalParameters> rxParams,
226 Ptr<SatInterference::InterferenceChangeEvent> interferenceEvent)
228 NS_LOG_FUNCTION(
this);
230 bool phyError =
false;
238 NS_LOG_INFO(
"Strict collision mode, phyError: " << phyError);
244 NS_LOG_INFO(
"Composite SINR mode, phyError: " << phyError);
253 NS_LOG_INFO(
"Constant collision probability mode, phyError: " << phyError);
257 NS_FATAL_ERROR(
"SatPhyRxCarrier::ProcessSlottedAlohaCollisions - Random access collision "
258 "model not defined");
266 const uint32_t nPackets)
268 NS_LOG_FUNCTION(
this << &packetRxParams << nPackets);
273 packetRxParams.
rxParams->GetInterferencePower(),
280 packetRxParams.
rxParams->m_packetsInBurst[0]->PeekPacketTag(addressE2ETag);
294 NS_FATAL_ERROR(
"Incorrect channel for satPhyRxCarrierPerSlot: "
300 bool phyError(
false);
315 NS_FATAL_ERROR(
"Incorrect regeneration mode for satPhyRxCarrierPerSlot");
342 packetRxParams.
rxParams->m_txInfo.waveformId));
345 NS_FATAL_ERROR(
"Unsupported node type for a NORMAL Rx model!");
350 packetRxParams.
rxParams->m_packetsInBurst[0]->PeekPacketTag(addressE2ETag);
363 packetRxParams.
rxParams->m_packetsInBurst;
364 SatSignalParameters::PacketsInBurst_t::const_iterator i;
365 for (i = packets.begin(); i != packets.end(); i++)
368 if (!(*i)->PeekPacketTag(satUplinkInfoTag))
370 NS_FATAL_ERROR(
"SatUplinkInfoTag not found !");
378 double downlinkCno = sinr;
392 NS_FATAL_ERROR(
"Unsupported node type for a NORMAL Rx model!");
398 (*i)->PeekPacketTag(addressE2ETag);
401 (*i)->PeekPacketTag(satMacTag);
420 NS_FATAL_ERROR(
"Incorrect regeneration mode for SatPhyRxCarrierPerSlot");
435 NS_LOG_INFO(
"Slotted ALOHA packet received");
448 const bool hasCollision =
484 NS_FATAL_ERROR(
"Channel unknown !");
500 SatSignalParameters::PacketsInBurst_t::const_iterator i;
501 for (i = packets.begin(); i != packets.end(); i++)
504 (*i)->RemovePacketTag(satUplinkInfoTag);
506 (*i)->AddPacketTag(satUplinkInfoTag);
511 NS_FATAL_ERROR(
"Incorrect regeneration mode for SatPhyRxCarrierPerSlot");
518 packetRxParams.
rxParams->GetInterferencePower(),
530 NS_LOG_FUNCTION(
this);
544 NS_LOG_FUNCTION(
this);
547 double averageNormalizedOfferedLoad = 0.0;
548 std::deque<double>::iterator it;
559 averageNormalizedOfferedLoad =
563 NS_LOG_INFO(
"Average normalized offered load: " << averageNormalizedOfferedLoad);
565 return averageNormalizedOfferedLoad;
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.
ChannelType_t
Types of channel.
static std::string GetChannelTypeName(ChannelType_t channelType)
@ PACKET_TYPE_SLOTTED_ALOHA
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.
Information of beam users liken UTs and their users.
@ RA_CONSTANT_COLLISION_PROBABILITY
@ RA_COLLISION_CHECK_AGAINST_SINR
@ RA_COLLISION_ALWAYS_DROP_ALL_COLLIDING_PACKETS
Base class for all SatPhyRxCarriers.
Ptr< SatInterference > GetInterferenceModel()
Get pointer to the current interference model.
void DoCompositeSinrOutputTrace(double cSinr)
Function for composite SINR output tracing.
void RemoveStoredRxParams(uint32_t key)
Remove stored rxParams under a key.
double m_rxExtNoisePowerW
External noise power system RX noise.
TracedCallback< double, const Address & > m_linkSinrTrace
A callback for link specific SINR in dB.
TracedCallback< uint32_t, const Address & > m_daRxCarrierIdTrace
TracedCallback< Ptr< SatSignalParameters >, Mac48Address, Mac48Address, double, double > m_linkBudgetTrace
The trace source on packet receptiong.
Ptr< SatNodeInfo > GetNodeInfo()
Get the satellite node info.
SatPhyRxCarrierConf::AdditionalInterferenceCallback m_additionalInterferenceCallback
Callback to get additional interference.
uint32_t GetCarrierId() const
Get the ID of the carrier.
void DecreaseNumOfRxState(SatEnums::PacketType_t packetType)
Function for decreasing the number of ongoing transmissions.
virtual SatEnums::RegenerationMode_t GetLinkRegenerationMode()
Get the link regeneration mode.
virtual SatEnums::ChannelType_t GetChannelType()
Get the channel type.
bool IsCompositeSinrOutputTraceEnabled() const
Check if composite SINR output trace is enabled.
uint32_t GetBeamId()
Get ID the ID of the beam this carrier is attached to.
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.
TracedCallback< double, const Address & > m_sinrTrace
A callback for transmission composite SINR at UT (BBFrame) or GW (time slot).
rxParams_s GetStoredRxParams(uint32_t key)
Get stored rxParams under a key.
Ptr< SatChannelEstimationErrorContainer > GetChannelEstimationErrorContainer()
Get a pointer to the channel estimation error container of the carrier.
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.
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.
virtual void DoDispose()
Dispose.
double GetUniformRandomValue(double min, double max)
A helper method for getting values form a uniform random variable in child classes.
double m_rxNoisePowerW
RX noise.
uint32_t GetSatId()
Get ID the ID of the satellite this carrier is attached to.
double m_rxBandwidthHz
RX Bandwidth in Hz.
State GetState()
Get the state of the carrier.
Mac48Address GetOwnAddress()
Get the MAC address of the carrier.
TracedCallback< uint32_t, const Address &, bool > m_slottedAlohaRxCollisionTrace
SlottedAlohaRxCollision trace source.
SatPhyRxCarrierPerSlot(uint32_t carrierId, Ptr< SatPhyRxCarrierConf > carrierConf, Ptr< SatWaveformConf > waveformConf, bool randomAccessEnabled)
Constructor.
static TypeId GetTypeId(void)
Get the TypeId of the class.
virtual void EndRxData(uint32_t key)
Function for ending the packet reception from the SatChannel.
bool ProcessSlottedAlohaCollisions(double cSinr, Ptr< SatSignalParameters > rxParams, Ptr< SatInterference::InterferenceChangeEvent > interferenceEvent)
Function for processing the Slotted ALOHA collisions.
TracedCallback< uint32_t, const Address &, bool > m_slottedAlohaRxErrorTrace
SlottedAlohaRxError trace source.
virtual ~SatPhyRxCarrierPerSlot()
Destructor.
bool m_enableRandomAccessDynamicLoadControl
bool m_disableErrorHighTransmissionTime
virtual void ReceiveSlot(SatPhyRxCarrier::rxParams_s packetRxParams, const uint32_t nPackets)
Receive a slot.
virtual void DoDispose()
Dispose implementation.
void SaveMeasuredRandomAccessLoad(double measuredRandomAccessLoad)
Function for saving the measured random access load.
double m_randomAccessConstantErrorRate
SatPhyRxCarrierConf::RandomAccessCollisionModel m_randomAccessCollisionModel
virtual Ptr< SatInterference::InterferenceChangeEvent > CreateInterference(Ptr< SatSignalParameters > rxParams, Address rxAddress)
Create an interference event based on Rx parameters and address.
uint32_t m_randomAccessBitsInFrame
The number of random access bits in current frame.
std::deque< double > m_randomAccessDynamicLoadControlNormalizedOfferedLoad
double CalculateAverageNormalizedOfferedRandomAccessLoad()
Function for calculating the average normalized offered random access load.
virtual void BeginEndScheduling()
Function for initializing the frame/window end scheduling.
uint32_t m_randomAccessAverageNormalizedOfferedLoadMeasurementWindowSize
std::vector< Ptr< Packet > > PacketsInBurst_t
Buffer for transmissions.
Tag to store uplink phy info that need to be forwarded to the downlink.
void SetSinr(double sinr, double additionalInterference)
Set uplink SINR.
uint32_t GetBeamId(void) const
Get the UT beam ID.
double GetSinr(void) const
Get uplink SINR.
uint32_t GetSatId(void) const
Get the UT sat ID.
static T DbToLinear(T db)
Converts decibels to linear.
static T LinearToDb(T linear)
Converts linear to decibels.
constexpr uint32_t BITS_PER_BYTE
Number of bits in a byte.
SatArqSequenceNumber is handling the sequence numbers for the ARQ process.
Struct for storing the packet specific Rx parameters.
Ptr< SatSignalParameters > rxParams
Mac48Address sourceAddress
Ptr< SatInterference::InterferenceChangeEvent > interferenceEvent