Loading...
Searching...
No Matches
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#include <cstddef>
27#include <stdint.h>
28#include <utility>
29#include <vector>
30
31NS_LOG_COMPONENT_DEFINE("SatPerFragmentInterference");
32
33namespace ns3
34{
35
36NS_OBJECT_ENSURE_REGISTERED(SatPerFragmentInterference);
37
38TypeId
40{
41 static TypeId tid = TypeId("ns3::SatPerFragmentInterference")
42 .SetParent<SatPerPacketInterference>()
43 .AddConstructor<SatPerFragmentInterference>();
44
45 return tid;
46}
47
55
57 double rxBandwidthHz)
58 : SatPerPacketInterference(channelType, rxBandwidthHz),
61{
62 NS_LOG_FUNCTION(this);
63}
64
69
70std::vector<std::pair<double, double>>
71SatPerFragmentInterference::DoCalculate(Ptr<SatInterference::InterferenceChangeEvent> event)
72{
73 NS_LOG_FUNCTION(this);
74
77
78 // Use the per packet interference computation hooks to store
79 // interferences at each event associated to the current packet
81
82 std::size_t fragmentsCount = m_ifPowerAtEventChangeW.size();
83 if (!fragmentsCount)
84 {
85 NS_FATAL_ERROR("Interference computation did not find a single fragment");
86 }
87
88 if (fragmentsCount > m_maxFragmentsCount)
89 {
90 m_maxFragmentsCount = fragmentsCount;
91 }
92
93 // Convert time ratio into durations
94 std::vector<std::pair<double, double>> ifPowerPerFragment;
95 ifPowerPerFragment.reserve(fragmentsCount);
96
97 std::vector<std::pair<double, double>>::const_iterator iter = m_ifPowerAtEventChangeW.begin();
98 std::pair<double, double> eventChangeInPower = *iter;
99 for (++iter; iter != m_ifPowerAtEventChangeW.end(); ++iter)
100 {
101 ifPowerPerFragment.emplace_back(iter->first - eventChangeInPower.first,
102 eventChangeInPower.second);
103 eventChangeInPower = *iter;
104 }
105
106 // Account for the last fragment duration
107 if (eventChangeInPower.first != 1.0)
108 {
109 ifPowerPerFragment.emplace_back(1.0 - eventChangeInPower.first, eventChangeInPower.second);
110 }
111
112 return ifPowerPerFragment;
113}
114
115void
117{
118 // Hook into per packet interference computation to store
119 // interference level at the beginning of the packet
120 m_ifPowerAtEventChangeW.emplace_back(0.0, ifPowerW);
121}
122
123void
125 double interferenceValue,
126 double& ifPowerW)
127{
128 // Hook into per packet interference computation to store
129 // interference level at each event change
130 ifPowerW += interferenceValue;
131 m_ifPowerAtEventChangeW.emplace_back(1.0 - timeRatio, ifPowerW);
132}
133
134} // namespace ns3
ChannelType_t
Types of channel.
Packet fragment by packet fragment interference.
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.