27 #include <ns3/address.h>
28 #include <ns3/boolean.h>
30 #include <ns3/simulator.h>
38 NS_LOG_COMPONENT_DEFINE(
"SatPhyRxCarrierPerSlot");
43 NS_OBJECT_ENSURE_REGISTERED(SatPhyRxCarrierPerSlot);
46 Ptr<SatPhyRxCarrierConf> carrierConf,
47 Ptr<SatWaveformConf> waveformConf,
48 bool randomAccessEnabled)
49 :
SatPhyRxCarrier(carrierId, carrierConf, waveformConf, randomAccessEnabled),
50 m_randomAccessBitsInFrame(0),
51 m_randomAccessAllocationChannelId(0),
53 m_randomAccessConstantErrorRate(0.0),
54 m_randomAccessAverageNormalizedOfferedLoadMeasurementWindowSize(0),
55 m_enableRandomAccessDynamicLoadControl(false),
56 m_disableErrorHighTransmissionTime(false)
58 if (randomAccessEnabled)
63 carrierConf->GetRandomAccessAverageNormalizedOfferedLoadMeasurementWindowSize();
65 carrierConf->IsRandomAccessDynamicLoadControlEnabled();
67 NS_LOG_INFO(
"RA interference model: "
68 << carrierConf->GetInterferenceModel(
true)
70 <<
", RA avg. normalized offered load measurement window size: "
77 NS_LOG_FUNCTION(
this);
89 TypeId(
"ns3::SatPhyRxCarrierPerSlot")
92 "DisableErrorHighTransmissionTime",
93 "Disable fatal error when transmission time is higher than propagation time, but "
94 "computations are less precise.",
99 "SlottedAlohaRxCollision",
100 "Received a packet burst through Random Access Slotted ALOHA",
102 "ns3::SatPhyRxCarrierPacketProbe::RxStatusCallback")
104 "SlottedAlohaRxError",
105 "Received a packet burst through Random Access Slotted ALOHA",
107 "ns3::SatPhyRxCarrierPacketProbe::RxStatusCallback");
114 NS_LOG_FUNCTION(
this);
120 Ptr<SatInterference::InterferenceChangeEvent>
123 NS_LOG_FUNCTION(
this << rxParams << senderAddress);
129 rxParams->m_rxPower_W,
153 if (!rxParams->HasSinrComputed())
157 NS_LOG_WARN(
"SatPhyRx::StartRx - too long transmission time: packet started to "
158 "be received in a ground entity while not being fully received on "
159 "the satellite: interferences could not be properly computed.");
160 rxPower = rxParams->m_rxPower_W;
165 "SatPhyRx::StartRx - too long transmission time: packet started to be "
166 "received in a ground entity while not being fully received on the "
167 "satellite: interferences could not be properly computed.");
172 rxPower = rxParams->m_rxPower_W * (1 + 1 / rxParams->GetSinr());
182 rxParams->m_rxPower_W,
186 NS_FATAL_ERROR(
"SatSatellitePhyRxCarrier::CreateInterference - Invalid channel type!");
193 NS_LOG_FUNCTION(
this << key);
195 NS_LOG_INFO(
this <<
" state: " <<
GetState());
201 const uint32_t nPackets = packetRxParams.
rxParams->m_packetsInBurst.size();
209 NS_ASSERT(packetRxParams.
rxParams->HasSinrComputed());
212 packetRxParams.
rxParams->SetInterferencePower(
227 Ptr<SatSignalParameters> rxParams,
228 Ptr<SatInterference::InterferenceChangeEvent> interferenceEvent)
230 NS_LOG_FUNCTION(
this);
232 bool phyError =
false;
240 NS_LOG_INFO(
"Strict collision mode, phyError: " << phyError);
246 NS_LOG_INFO(
"Composite SINR mode, phyError: " << phyError);
255 NS_LOG_INFO(
"Constant collision probability mode, phyError: " << phyError);
259 NS_FATAL_ERROR(
"SatPhyRxCarrier::ProcessSlottedAlohaCollisions - Random access collision "
260 "model not defined");
268 const uint32_t nPackets)
270 NS_LOG_FUNCTION(
this << &packetRxParams << nPackets);
275 packetRxParams.
rxParams->GetInterferencePower(),
282 packetRxParams.
rxParams->m_packetsInBurst[0]->PeekPacketTag(addressE2ETag);
296 NS_FATAL_ERROR(
"Incorrect channel for satPhyRxCarrierPerSlot: "
302 bool phyError(
false);
317 NS_FATAL_ERROR(
"Incorrect regeneration mode for satPhyRxCarrierPerSlot");
344 packetRxParams.
rxParams->m_txInfo.waveformId));
347 NS_FATAL_ERROR(
"Unsupported node type for a NORMAL Rx model!");
352 packetRxParams.
rxParams->m_packetsInBurst[0]->PeekPacketTag(addressE2ETag);
365 packetRxParams.
rxParams->m_packetsInBurst;
366 SatSignalParameters::PacketsInBurst_t::const_iterator i;
367 for (i = packets.begin(); i != packets.end(); i++)
370 if (!(*i)->PeekPacketTag(satUplinkInfoTag))
372 NS_FATAL_ERROR(
"SatUplinkInfoTag not found !");
380 double downlinkCno = sinr;
394 NS_FATAL_ERROR(
"Unsupported node type for a NORMAL Rx model!");
400 (*i)->PeekPacketTag(addressE2ETag);
403 (*i)->PeekPacketTag(satMacTag);
422 NS_FATAL_ERROR(
"Incorrect regeneration mode for SatPhyRxCarrierPerSlot");
437 NS_LOG_INFO(
"Slotted ALOHA packet received");
450 const bool hasCollision =
486 NS_FATAL_ERROR(
"Channel unknown !");
502 SatSignalParameters::PacketsInBurst_t::const_iterator i;
503 for (i = packets.begin(); i != packets.end(); i++)
506 (*i)->RemovePacketTag(satUplinkInfoTag);
508 (*i)->AddPacketTag(satUplinkInfoTag);
513 NS_FATAL_ERROR(
"Incorrect regeneration mode for SatPhyRxCarrierPerSlot");
520 packetRxParams.
rxParams->GetInterferencePower(),
532 NS_LOG_FUNCTION(
this);
546 NS_LOG_FUNCTION(
this);
549 double averageNormalizedOfferedLoad = 0.0;
550 std::deque<double>::iterator it;
561 averageNormalizedOfferedLoad =
565 NS_LOG_INFO(
"Average normalized offered load: " << averageNormalizedOfferedLoad);
567 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