Loading...
Searching...
No Matches
satellite-phy-rx-carrier-uplink.cc
Go to the documentation of this file.
1/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
2/*
3 * Copyright (c) 2014 Magister Solutions Ltd.
4 * Copyright (c) 2018 CNES
5 *
6 * This program is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License version 2 as
8 * published by the Free Software Foundation;
9 *
10 * This program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
14 *
15 * You should have received a copy of the GNU General Public License
16 * along with this program; if not, write to the Free Software
17 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
18 *
19 * Author: Jani Puttonen <jani.puttonen@magister.fi>
20 * Author: Mathias Ettinger <mettinger@toulouse.viveris.fr>
21 */
22
24
26
27#include "ns3/log.h"
28#include "ns3/simulator.h"
29
30NS_LOG_COMPONENT_DEFINE("SatPhyRxCarrierUplink");
31
32namespace ns3
33{
34
35NS_OBJECT_ENSURE_REGISTERED(SatPhyRxCarrierUplink);
36
38 Ptr<SatPhyRxCarrierConf> carrierConf,
39 Ptr<SatWaveformConf> waveformConf,
40 bool randomAccessEnabled)
41 : SatPhyRxCarrier(carrierId, carrierConf, waveformConf, randomAccessEnabled)
42{
43 NS_LOG_FUNCTION(this);
44}
45
47{
48 NS_LOG_FUNCTION(this);
49}
50
51TypeId
53{
54 static TypeId tid = TypeId("ns3::SatPhyRxCarrierUplink").SetParent<SatPhyRxCarrier>();
55 return tid;
56}
57
58Ptr<SatInterference::InterferenceChangeEvent>
59SatPhyRxCarrierUplink::CreateInterference(Ptr<SatSignalParameters> rxParams, Address senderAddress)
60{
61 NS_LOG_FUNCTION(this << rxParams << senderAddress);
62 return GetInterferenceModel()->Add(rxParams->m_duration, rxParams->m_rxPower_W, senderAddress);
63}
64
65bool
66SatPhyRxCarrierUplink::StartRx(Ptr<SatSignalParameters> rxParams)
67{
68 NS_LOG_FUNCTION(this << rxParams);
69
70 if (this->SatPhyRxCarrier::StartRx(rxParams))
71 {
74 bool phyError(false);
75
76 // Forward packet to ground entity without delay in the satellite
77 m_rxCallback(rxParams, phyError);
78
79 return true;
80 }
81
82 return false;
83}
84
85void
87{
88 NS_LOG_FUNCTION(this << key);
89 NS_LOG_INFO("State: " << GetState());
90
91 NS_ASSERT(GetState() == RX);
92
93 auto packetRxParams = GetStoredRxParams(key);
94
95 DecreaseNumOfRxState(packetRxParams.rxParams->m_txInfo.packetType);
96
97 packetRxParams.rxParams->SetInterferencePower(
98 GetInterferenceModel()->Calculate(packetRxParams.interferenceEvent));
99
101 packetRxParams.rxParams->SetInterferencePowerInSatellite(
102 packetRxParams.rxParams->GetInterferencePowerPerFragment());
103 packetRxParams.rxParams->SetRxPowersInSatellite(packetRxParams.rxParams->m_rxPower_W,
107
109 double sinr = CalculateSinr(packetRxParams.rxParams->m_rxPower_W,
110 packetRxParams.rxParams->GetInterferencePower(),
115
116 // Update link specific SINR trace
118 {
119 m_linkSinrTrace(SatUtils::LinearToDb(sinr), packetRxParams.destAddress);
120 }
122 {
123 m_linkSinrTrace(SatUtils::LinearToDb(sinr), packetRxParams.sourceAddress);
124 }
125 else
126 {
127 NS_FATAL_ERROR("Incorrect channel for satPhyRxCarrierUplink: "
129 }
130
131 NS_ASSERT(!packetRxParams.rxParams->HasSinrComputed());
132
134 packetRxParams.rxParams->SetSinr(sinr, m_additionalInterferenceCallback());
135
137 m_linkBudgetTrace(packetRxParams.rxParams,
139 packetRxParams.destAddress,
140 packetRxParams.rxParams->GetInterferencePower(),
141 sinr);
142
143 GetInterferenceModel()->NotifyRxEnd(packetRxParams.interferenceEvent);
144
146 packetRxParams.rxParams = nullptr;
147 packetRxParams.interferenceEvent = nullptr;
149}
150
151} // namespace ns3
static std::string GetChannelTypeName(ChannelType_t channelType)
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< Ptr< SatSignalParameters >, Mac48Address, Mac48Address, double, double > m_linkBudgetTrace
The trace source on packet receptiong.
SatPhyRxCarrierConf::AdditionalInterferenceCallback m_additionalInterferenceCallback
Callback to get additional interference.
void DecreaseNumOfRxState(SatEnums::PacketType_t packetType)
Function for decreasing the number of ongoing transmissions.
virtual SatEnums::ChannelType_t GetChannelType()
Get the channel type.
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.
double m_rxAciIfPowerW
RX Adjacent channel interference.
virtual bool StartRx(Ptr< SatSignalParameters > rxParams)
Function for starting packet reception from the SatChannel.
rxParams_s GetStoredRxParams(uint32_t key)
Get stored rxParams under a key.
Ptr< SatInterference > GetInterferenceModel()
Get pointer to the current interference model.
SatPhyRxCarrier(uint32_t carrierId, Ptr< SatPhyRxCarrierConf > carrierConf, Ptr< SatWaveformConf > waveformConf, bool isRandomAccessEnabled)
Constructor.
State GetState()
Get the state of the carrier.
Mac48Address GetOwnAddress()
Get the MAC address of the carrier.
static T LinearToDb(T linear)
Converts linear to decibels.
SatArqSequenceNumber is handling the sequence numbers for the ARQ process.