satellite-perfect-interference-elimination.cc
Go to the documentation of this file.
1 /* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
2 /*
3  * Copyright (c) 2018 CNES
4  *
5  * This program is free software; you can redistribute it and/or modify
6  * it under the terms of the GNU General Public License version 2 as
7  * published by the Free Software Foundation;
8  *
9  * This program is distributed in the hope that it will be useful,
10  * but WITHOUT ANY WARRANTY; without even the implied warranty of
11  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12  * GNU General Public License for more details.
13  *
14  * You should have received a copy of the GNU General Public License
15  * along with this program; if not, write to the Free Software
16  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
17  *
18  * Author: Mathias Ettinger <mettinger@toulouse.viveris.fr>
19  */
20 
22 
24 
25 #include <ns3/log.h>
26 #include <ns3/simulator.h>
27 
28 #include <cmath>
29 #include <limits>
30 #include <stdint.h>
31 #include <utility>
32 #include <vector>
33 
34 NS_LOG_COMPONENT_DEFINE("SatPerfectInterferenceElimination");
35 
36 namespace ns3
37 {
38 
39 NS_OBJECT_ENSURE_REGISTERED(SatPerfectInterferenceElimination);
40 
41 TypeId
43 {
44  static TypeId tid = TypeId("ns3::SatPerfectInterferenceElimination")
45  .SetParent<SatInterferenceElimination>()
46  .AddConstructor<SatPerfectInterferenceElimination>();
47 
48  return tid;
49 }
50 
51 TypeId
53 {
54  return GetTypeId();
55 }
56 
58 {
59  NS_LOG_FUNCTION(this);
60 }
61 
63 {
64  NS_LOG_FUNCTION(this);
65 }
66 
67 void
69  Ptr<SatSignalParameters> packetInterferedWith,
70  Ptr<SatSignalParameters> processedPacket,
71  double EsNo,
72  bool isRegenerative)
73 {
74  NS_LOG_FUNCTION(this);
75 
76  return EliminateInterferences(packetInterferedWith,
77  processedPacket,
78  EsNo,
79  isRegenerative,
80  0.0,
81  1.0);
82 }
83 
84 void
86  Ptr<SatSignalParameters> packetInterferedWith,
87  Ptr<SatSignalParameters> processedPacket,
88  double EsNo,
89  bool isRegenerative,
90  double startTime,
91  double endTime)
92 {
93  NS_LOG_FUNCTION(this);
94 
95  NS_LOG_INFO("Removing interference power of packet from Beam[Carrier] "
96  << processedPacket->m_beamId << "[" << processedPacket->m_carrierId << "] between "
97  << startTime << " and " << endTime);
98 
99  double oldIfPower;
100  double normalizedTime = 0.0;
101  std::vector<std::pair<double, double>> ifPowerPerFragment;
102  if (isRegenerative)
103  {
104  oldIfPower = packetInterferedWith->GetInterferencePower();
105  ifPowerPerFragment = packetInterferedWith->GetInterferencePowerPerFragment();
106  }
107  else
108  {
109  oldIfPower = packetInterferedWith->GetInterferencePowerInSatellite();
110  ifPowerPerFragment = packetInterferedWith->GetInterferencePowerInSatellitePerFragment();
111  }
112 
113  for (std::pair<double, double>& ifPower : ifPowerPerFragment)
114  {
115  normalizedTime += ifPower.first;
116  if (startTime >= normalizedTime)
117  {
118  continue;
119  }
120  else if (endTime < normalizedTime)
121  {
122  break;
123  }
124 
125  ifPower.second -= (isRegenerative ? processedPacket->m_rxPower_W
126  : processedPacket->GetRxPowerInSatellite());
127  if (std::abs(ifPower.second) < std::numeric_limits<double>::epsilon())
128  {
129  ifPower.second = 0.0;
130  }
131 
132  if (ifPower.second < 0)
133  {
134  NS_FATAL_ERROR("Negative interference " << ifPower.second);
135  }
136  }
137 
138  if (isRegenerative)
139  {
140  packetInterferedWith->SetInterferencePower(ifPowerPerFragment);
141  }
142  else
143  {
144  packetInterferedWith->SetInterferencePowerInSatellite(ifPowerPerFragment);
145  }
146 
147  NS_LOG_INFO("Interfered packet ifPower went from "
148  << oldIfPower << " to " << SatUtils::ScalarProduct(ifPowerPerFragment));
149 }
150 
151 double
152 SatPerfectInterferenceElimination::GetResidualPower(Ptr<SatSignalParameters> processedPacket,
153  double EsNo)
154 {
155  return 0.0;
156 }
157 
158 } // namespace ns3
Abstract class defining interface for interference elimination calculation objects.
double GetResidualPower(Ptr< SatSignalParameters > processedPacket, double EsNo)
Calculate the residual power of interference for a given packet.
void EliminateInterferences(Ptr< SatSignalParameters > packetInterferedWith, Ptr< SatSignalParameters > processedPacket, double EsNo, bool isRegenerative)
Calculate residual power of interference for the given packets.
static double ScalarProduct(const std::vector< std::pair< double, double >> &vector)
Scalar product.
SatArqSequenceNumber is handling the sequence numbers for the ARQ process.