satellite-per-fragment-interference.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.com>
19  */
20 
22 
23 #include <ns3/log.h>
24 #include <ns3/simulator.h>
25 
26 NS_LOG_COMPONENT_DEFINE("SatPerFragmentInterference");
27 
28 namespace ns3
29 {
30 
31 NS_OBJECT_ENSURE_REGISTERED(SatPerFragmentInterference);
32 
33 TypeId
35 {
36  static TypeId tid = TypeId("ns3::SatPerFragmentInterference")
37  .SetParent<SatPerPacketInterference>()
38  .AddConstructor<SatPerFragmentInterference>();
39 
40  return tid;
41 }
42 
43 TypeId
45 {
46  NS_LOG_FUNCTION(this);
47  return GetTypeId();
48 }
49 
52  m_ifPowerAtEventChangeW(),
53  m_maxFragmentsCount(1)
54 {
55  NS_LOG_FUNCTION(this);
56 }
57 
59  double rxBandwidthHz)
60  : SatPerPacketInterference(channelType, rxBandwidthHz),
61  m_ifPowerAtEventChangeW(),
62  m_maxFragmentsCount(1)
63 {
64  NS_LOG_FUNCTION(this);
65 }
66 
68 {
69  NS_LOG_FUNCTION(this);
70 }
71 
72 std::vector<std::pair<double, double>>
73 SatPerFragmentInterference::DoCalculate(Ptr<SatInterference::InterferenceChangeEvent> event)
74 {
75  NS_LOG_FUNCTION(this);
76 
79 
80  // Use the per packet interference computation hooks to store
81  // interferences at each event associated to the current packet
83 
84  std::size_t fragmentsCount = m_ifPowerAtEventChangeW.size();
85  if (!fragmentsCount)
86  {
87  NS_FATAL_ERROR("Interference computation did not find a single fragment");
88  }
89 
90  if (fragmentsCount > m_maxFragmentsCount)
91  {
92  m_maxFragmentsCount = fragmentsCount;
93  }
94 
95  // Convert time ratio into durations
96  std::vector<std::pair<double, double>> ifPowerPerFragment;
97  ifPowerPerFragment.reserve(fragmentsCount);
98 
99  std::vector<std::pair<double, double>>::const_iterator iter = m_ifPowerAtEventChangeW.begin();
100  std::pair<double, double> eventChangeInPower = *iter;
101  for (++iter; iter != m_ifPowerAtEventChangeW.end(); ++iter)
102  {
103  ifPowerPerFragment.emplace_back(iter->first - eventChangeInPower.first,
104  eventChangeInPower.second);
105  eventChangeInPower = *iter;
106  }
107 
108  // Account for the last fragment duration
109  if (eventChangeInPower.first != 1.0)
110  {
111  ifPowerPerFragment.emplace_back(1.0 - eventChangeInPower.first, eventChangeInPower.second);
112  }
113 
114  return ifPowerPerFragment;
115 }
116 
117 void
119 {
120  // Hook into per packet interference computation to store
121  // interference level at the beginning of the packet
122  m_ifPowerAtEventChangeW.emplace_back(0.0, ifPowerW);
123 }
124 
125 void
127  double interferenceValue,
128  double& ifPowerW)
129 {
130  // Hook into per packet interference computation to store
131  // interference level at each event change
132  ifPowerW += interferenceValue;
133  m_ifPowerAtEventChangeW.emplace_back(1.0 - timeRatio, ifPowerW);
134 }
135 
136 } // namespace ns3
ChannelType_t
Types of channel.
TypeId GetInstanceTypeId(void) const
Inherited from ObjectBase base class.
static TypeId GetTypeId()
Inherited from ObjectBase base class.
void onInterferentEvent(long double timeRatio, double interferenceValue, double &ifPowerW)
Helper function meant for subclasses to override.
std::vector< std::pair< double, double > > m_ifPowerAtEventChangeW
void onOwnStartReached(double ifPowerW)
Helper function meant for subclasses to override.
std::vector< std::pair< double, double > > DoCalculate(Ptr< SatInterference::InterferenceChangeEvent > event)
Calculates interference power for the given reference Sets final power at end time to finalPower.
virtual std::vector< std::pair< double, double > > DoCalculate(Ptr< SatInterference::InterferenceChangeEvent > event)
Calculates interference power for the given reference Sets final power at end time to finalPower.
SatArqSequenceNumber is handling the sequence numbers for the ARQ process.