25 #include <ns3/boolean.h>
27 #include <ns3/simulator.h>
33 NS_LOG_COMPONENT_DEFINE(
"SatPhyRxCarrierMarsala");
38 NS_OBJECT_ENSURE_REGISTERED(SatPhyRxCarrierMarsala);
41 Ptr<SatPhyRxCarrierConf> carrierConf,
42 Ptr<SatWaveformConf> waveformConf,
43 bool randomAccessEnabled)
46 NS_LOG_FUNCTION(
this);
51 NS_LOG_FUNCTION(
this);
58 TypeId(
"ns3::SatPhyRxCarrierMarsala")
61 "MarsalaCorrelationRx",
62 "Correlate a CRDSA packet replica through Random Access",
64 "ns3::SatPhyRxCarrierPacketProbe::RxStatusCallback");
70 std::vector<SatPhyRxCarrierPerFrame::crdsaPacketRxParams_s>& combinedPacketsForFrame)
72 NS_LOG_FUNCTION(
this);
85 const std::list<SatPhyRxCarrierPerFrame::crdsaPacketRxParams_s>& slotContent,
88 bool replicaFound =
false;
97 NS_FATAL_ERROR(
"Found more than one replica in the same slot!");
100 replica = currentPacket;
106 NS_FATAL_ERROR(
"Could not find a replica of a packet in the given slot!");
114 std::vector<SatPhyRxCarrierPerFrame::crdsaPacketRxParams_s>& combinedPacketsForFrame)
116 NS_LOG_FUNCTION(
this);
119 NS_LOG_INFO(
"Number of slots: " << nbSlots);
121 std::map<uint32_t, std::list<SatPhyRxCarrierPerFrame::crdsaPacketRxParams_s>>::iterator iter;
124 NS_LOG_INFO(
"Iterating slot: " << iter->first);
126 std::list<SatPhyRxCarrierPerFrame::crdsaPacketRxParams_s>& slotContent = iter->second;
127 if (slotContent.size() < 1)
129 NS_FATAL_ERROR(
"No packet in slot! This should not happen");
132 std::list<SatPhyRxCarrierPerFrame::crdsaPacketRxParams_s>::iterator currentPacket;
133 for (currentPacket = slotContent.begin(); currentPacket != slotContent.end();
136 NS_LOG_INFO(
"Iterating packet in slot: " << currentPacket->ownSlotId);
139 uint32_t otherReplicasCount = currentPacket->slotIdsForOtherReplicas.size();
140 uint32_t replicasCount = 1 + otherReplicasCount;
141 uint32_t replicasCountSquared = replicasCount * replicasCount;
142 uint32_t packetsInSlotsCount = slotContent.size();
144 double replicasIfPower = currentPacket->rxParams->GetInterferencePower();
149 double replicasIfPowerInSatellite =
150 currentPacket->rxParams->GetInterferencePowerInSatellite();
151 double replicasNoisePowerInSatellite =
152 currentPacket->rxParams->GetRxNoisePowerInSatellite();
153 double replicasAciIfPowerInSatellite =
154 currentPacket->rxParams->GetRxAciIfPowerInSatellite();
155 double replicasExtNoisePowerInSatellite =
156 currentPacket->rxParams->GetRxExtNoisePowerInSatellite();
159 for (uint16_t& replicaSlotId : currentPacket->slotIdsForOtherReplicas)
161 NS_LOG_INFO(
"Processing replica in slot: " << replicaSlotId);
164 std::list<SatPhyRxCarrierPerFrame::crdsaPacketRxParams_s>>::iterator
169 NS_FATAL_ERROR(
"Slot " << replicaSlotId <<
" not found in frame!");
171 packetsInSlotsCount += replicaSlot->second.size();
175 replicasIfPower += replica.
rxParams->GetInterferencePower();
176 replicasIfPowerInSatellite += replica.
rxParams->GetInterferencePowerInSatellite();
177 replicasNoisePowerInSatellite += replica.
rxParams->GetRxNoisePowerInSatellite();
178 replicasAciIfPowerInSatellite += replica.
rxParams->GetRxAciIfPowerInSatellite();
179 replicasExtNoisePowerInSatellite +=
180 replica.
rxParams->GetRxExtNoisePowerInSatellite();
183 double sinr =
CalculateSinr(replicasCountSquared * currentPacket->rxParams->m_rxPower_W,
187 replicasExtNoisePower,
195 replicasCountSquared * currentPacket->rxParams->GetRxPowerInSatellite(),
196 replicasIfPowerInSatellite,
197 replicasNoisePowerInSatellite,
198 replicasAciIfPowerInSatellite,
199 replicasExtNoisePowerInSatellite,
200 currentPacket->rxParams->GetAdditionalInterference());
209 currentPacket->rxParams->m_packetsInBurst;
210 SatSignalParameters::PacketsInBurst_t::const_iterator i;
211 for (i = packets.begin(); i != packets.end(); i++)
214 (*i)->RemovePacketTag(satUplinkInfoTag);
216 (*i)->AddPacketTag(satUplinkInfoTag);
226 NS_LOG_INFO(
"MARSALA correlation computation, Replicas: "
227 << replicasCount <<
" Interferents: "
228 << (packetsInSlotsCount - replicasCount) <<
" Correlated SINR: " << cSinr);
232 uint32_t correlations = 1;
233 for (uint32_t i = nbSlots - otherReplicasCount; i < nbSlots; ++i)
238 currentPacket->sourceAddress,
239 currentPacket->phyError);
241 NS_LOG_INFO(
"Packet error: " << currentPacket->phyError);
243 if (!currentPacket->phyError)
247 NS_LOG_INFO(
"Packet successfully received, removing its interference and "
248 "processing the replicas");
250 slotContent.erase(currentPacket);
253 combinedPacketsForFrame.push_back(processedPacket);
double m_rxExtNoisePowerW
External noise power system RX noise.
TracedCallback< double, const Address & > m_linkSinrTrace
A callback for link specific SINR in dB.
SatPhyRxCarrierConf::AdditionalInterferenceCallback m_additionalInterferenceCallback
Callback to get additional interference.
virtual SatEnums::RegenerationMode_t GetLinkRegenerationMode()
Get the link regeneration mode.
double CalculateSinr(double rxPowerW, double ifPowerW, double rxNoisePowerW, double rxAciIfPowerW, double rxExtNoisePowerW, double otherInterference)
Function for calculating the SINR.
double m_rxAciIfPowerW
RX Adjacent channel interference.
bool CheckAgainstLinkResults(double cSinr, Ptr< SatSignalParameters > rxParams)
Function for checking the SINR against the link results.
double CalculateCompositeSinr(double sinr1, double sinr2)
Function for calculating the composite SINR.
double m_rxNoisePowerW
RX noise.
static TypeId GetTypeId(void)
Get the TypeId of the class.
void PerformSicCycles(std::vector< SatPhyRxCarrierPerFrame::crdsaPacketRxParams_s > &combinedPacketsForFrame)
Function for receiving decodable packets and removing their interference from the other packets in th...
SatPhyRxCarrierMarsala(uint32_t carrierId, Ptr< SatPhyRxCarrierConf > carrierConf, Ptr< SatWaveformConf > waveformConf, bool randomAccessEnabled)
Constructor.
TracedCallback< uint32_t, const Address &, bool > m_marsalaCorrelationRxTrace
MarsalaCorrelationRx trace source.
bool PerformMarsala(std::vector< SatPhyRxCarrierPerFrame::crdsaPacketRxParams_s > &combinedPacketsForFrame)
Function for performing MARSALA corelation on remaining packets in the frame.
SatPhyRxCarrierPerFrame::crdsaPacketRxParams_s FindReplicaInSlot(const std::list< SatPhyRxCarrierPerFrame::crdsaPacketRxParams_s > &slotContent, const SatPhyRxCarrierPerFrame::crdsaPacketRxParams_s &packet) const
Function for verifying if a replica of a given packet is found in the given slot.
~SatPhyRxCarrierMarsala()
Destructor.
Inherited the functionality of ground station SatPhyRxCarriers and extended it with CRDSA functionali...
void EliminateInterference(std::map< uint32_t, std::list< SatPhyRxCarrierPerFrame::crdsaPacketRxParams_s >>::iterator iter, SatPhyRxCarrierPerFrame::crdsaPacketRxParams_s processedPacket)
Function for eliminating the interference to other packets in the slot from the correctly received pa...
bool IsReplica(const SatPhyRxCarrierPerFrame::crdsaPacketRxParams_s &packet, const SatPhyRxCarrierPerFrame::crdsaPacketRxParams_s &otherPacket) const
Function for identifying whether the packet is a replica of another packet.
virtual void PerformSicCycles(std::vector< SatPhyRxCarrierPerFrame::crdsaPacketRxParams_s > &combinedPacketsForFrame)
Function for receiving decodable packets and removing their interference from the other packets in th...
void FindAndRemoveReplicas(SatPhyRxCarrierPerFrame::crdsaPacketRxParams_s packet)
Function for finding and removing the replicas of the CRDSA packet.
std::map< uint32_t, std::list< SatPhyRxCarrierPerFrame::crdsaPacketRxParams_s > > & GetCrdsaPacketContainer()
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.
static T LinearToDb(T linear)
Converts linear to decibels.
SatArqSequenceNumber is handling the sequence numbers for the ARQ process.
Struct for storing the CRDSA packet specific Rx parameters.
Ptr< SatSignalParameters > rxParams