25 #include <ns3/boolean.h>
27 #include <ns3/simulator.h>
29 NS_LOG_COMPONENT_DEFINE(
"SatPhyRxCarrierMarsala");
34 NS_OBJECT_ENSURE_REGISTERED(SatPhyRxCarrierMarsala);
37 Ptr<SatPhyRxCarrierConf> carrierConf,
38 Ptr<SatWaveformConf> waveformConf,
39 bool randomAccessEnabled)
42 NS_LOG_FUNCTION(
this);
47 NS_LOG_FUNCTION(
this);
54 TypeId(
"ns3::SatPhyRxCarrierMarsala")
57 "MarsalaCorrelationRx",
58 "Correlate a CRDSA packet replica through Random Access",
60 "ns3::SatPhyRxCarrierPacketProbe::RxStatusCallback");
66 std::vector<SatPhyRxCarrierPerFrame::crdsaPacketRxParams_s>& combinedPacketsForFrame)
68 NS_LOG_FUNCTION(
this);
81 const std::list<SatPhyRxCarrierPerFrame::crdsaPacketRxParams_s>& slotContent,
84 bool replicaFound =
false;
93 NS_FATAL_ERROR(
"Found more than one replica in the same slot!");
96 replica = currentPacket;
102 NS_FATAL_ERROR(
"Could not find a replica of a packet in the given slot!");
110 std::vector<SatPhyRxCarrierPerFrame::crdsaPacketRxParams_s>& combinedPacketsForFrame)
112 NS_LOG_FUNCTION(
this);
115 NS_LOG_INFO(
"Number of slots: " << nbSlots);
117 std::map<uint32_t, std::list<SatPhyRxCarrierPerFrame::crdsaPacketRxParams_s>>::iterator iter;
120 NS_LOG_INFO(
"Iterating slot: " << iter->first);
122 std::list<SatPhyRxCarrierPerFrame::crdsaPacketRxParams_s>& slotContent = iter->second;
123 if (slotContent.size() < 1)
125 NS_FATAL_ERROR(
"No packet in slot! This should not happen");
128 std::list<SatPhyRxCarrierPerFrame::crdsaPacketRxParams_s>::iterator currentPacket;
129 for (currentPacket = slotContent.begin(); currentPacket != slotContent.end();
132 NS_LOG_INFO(
"Iterating packet in slot: " << currentPacket->ownSlotId);
135 uint32_t otherReplicasCount = currentPacket->slotIdsForOtherReplicas.size();
136 uint32_t replicasCount = 1 + otherReplicasCount;
137 uint32_t replicasCountSquared = replicasCount * replicasCount;
138 uint32_t packetsInSlotsCount = slotContent.size();
140 double replicasIfPower = currentPacket->rxParams->GetInterferencePower();
145 double replicasIfPowerInSatellite =
146 currentPacket->rxParams->GetInterferencePowerInSatellite();
147 double replicasNoisePowerInSatellite =
148 currentPacket->rxParams->GetRxNoisePowerInSatellite();
149 double replicasAciIfPowerInSatellite =
150 currentPacket->rxParams->GetRxAciIfPowerInSatellite();
151 double replicasExtNoisePowerInSatellite =
152 currentPacket->rxParams->GetRxExtNoisePowerInSatellite();
155 for (uint16_t& replicaSlotId : currentPacket->slotIdsForOtherReplicas)
157 NS_LOG_INFO(
"Processing replica in slot: " << replicaSlotId);
160 std::list<SatPhyRxCarrierPerFrame::crdsaPacketRxParams_s>>::iterator
165 NS_FATAL_ERROR(
"Slot " << replicaSlotId <<
" not found in frame!");
167 packetsInSlotsCount += replicaSlot->second.size();
171 replicasIfPower += replica.
rxParams->GetInterferencePower();
172 replicasIfPowerInSatellite += replica.
rxParams->GetInterferencePowerInSatellite();
173 replicasNoisePowerInSatellite += replica.
rxParams->GetRxNoisePowerInSatellite();
174 replicasAciIfPowerInSatellite += replica.
rxParams->GetRxAciIfPowerInSatellite();
175 replicasExtNoisePowerInSatellite +=
176 replica.
rxParams->GetRxExtNoisePowerInSatellite();
179 double sinr =
CalculateSinr(replicasCountSquared * currentPacket->rxParams->m_rxPower_W,
183 replicasExtNoisePower,
191 replicasCountSquared * currentPacket->rxParams->GetRxPowerInSatellite(),
192 replicasIfPowerInSatellite,
193 replicasNoisePowerInSatellite,
194 replicasAciIfPowerInSatellite,
195 replicasExtNoisePowerInSatellite,
196 currentPacket->rxParams->GetAdditionalInterference());
205 currentPacket->rxParams->m_packetsInBurst;
206 SatSignalParameters::PacketsInBurst_t::const_iterator i;
207 for (i = packets.begin(); i != packets.end(); i++)
210 (*i)->RemovePacketTag(satUplinkInfoTag);
212 (*i)->AddPacketTag(satUplinkInfoTag);
222 NS_LOG_INFO(
"MARSALA correlation computation, Replicas: "
223 << replicasCount <<
" Interferents: "
224 << (packetsInSlotsCount - replicasCount) <<
" Correlated SINR: " << cSinr);
228 uint32_t correlations = 1;
229 for (uint32_t i = nbSlots - otherReplicasCount; i < nbSlots; ++i)
234 currentPacket->sourceAddress,
235 currentPacket->phyError);
237 NS_LOG_INFO(
"Packet error: " << currentPacket->phyError);
239 if (!currentPacket->phyError)
243 NS_LOG_INFO(
"Packet successfully received, removing its interference and "
244 "processing the replicas");
246 slotContent.erase(currentPacket);
249 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