satellite-traced-interference.cc
Go to the documentation of this file.
1 /* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
2 /*
3  * Copyright (c) 2013 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: Sami Rantanen <sami.rantanen@magister.fi>
20  * Author: Mathias Ettinger <mettinger@toulouse.viveris.fr>
21  */
22 
24 
25 #include <ns3/log.h>
26 #include <ns3/simulator.h>
27 #include <ns3/singleton.h>
28 
29 #include <limits>
30 #include <stdint.h>
31 #include <utility>
32 #include <vector>
33 
34 NS_LOG_COMPONENT_DEFINE("SatTracedInterference");
35 
36 namespace ns3
37 {
38 
39 NS_OBJECT_ENSURE_REGISTERED(SatTracedInterference);
40 
41 TypeId
43 {
44  static TypeId tid = TypeId("ns3::SatTracedInterference")
45  .SetParent<SatInterference>()
46  .AddConstructor<SatTracedInterference>();
47 
48  return tid;
49 }
50 
51 TypeId
53 {
54  return GetTypeId();
55 }
56 
58  double rxBandwidth)
59  : m_rxing(false),
60  m_power(0),
61  m_channelType(channeltype),
62  m_rxBandwidth_Hz(rxBandwidth)
63 {
64  NS_LOG_FUNCTION(this);
65 
66  if (m_rxBandwidth_Hz <= std::numeric_limits<double>::epsilon())
67  {
68  NS_FATAL_ERROR("SatTracedInterference::SatTracedInterference - Invalid value");
69  }
70 }
71 
73  : m_rxing(false),
74  m_power(),
75  m_channelType(),
76  m_rxBandwidth_Hz()
77 {
78  NS_LOG_FUNCTION(this);
79 
80  NS_FATAL_ERROR("SatTracedInterference::SatTracedInterference - Constructor not in use");
81 }
82 
84 {
85  NS_LOG_FUNCTION(this);
86 
87  Reset();
88 }
89 
90 Ptr<SatInterference::InterferenceChangeEvent>
91 SatTracedInterference::DoAdd(Time duration, double power, Address rxAddress)
92 {
93  NS_LOG_FUNCTION(this << duration.GetSeconds() << power << rxAddress);
94 
95  Ptr<SatInterference::InterferenceChangeEvent> event;
96  event = Create<SatInterference::InterferenceChangeEvent>(0, duration, power, rxAddress);
97 
98  return event;
99 }
100 
101 std::vector<std::pair<double, double>>
102 SatTracedInterference::DoCalculate(Ptr<SatInterference::InterferenceChangeEvent> event)
103 {
104  NS_LOG_FUNCTION(this);
105 
107  Singleton<SatInterferenceInputTraceContainer>::Get()->GetInterferenceDensity(
108  std::make_pair(event->GetSatEarthStationAddress(), m_channelType));
109 
110  std::vector<std::pair<double, double>> powerPerFragment;
111  powerPerFragment.emplace_back(1.0, m_power);
112 
113  return powerPerFragment;
114 }
115 
116 void
118 {
119  NS_LOG_FUNCTION(this);
120 }
121 
122 void
123 SatTracedInterference::DoNotifyRxStart(Ptr<SatInterference::InterferenceChangeEvent> event)
124 {
125  NS_LOG_FUNCTION(this);
126 
127  m_rxing = true;
128 }
129 
130 void
131 SatTracedInterference::DoNotifyRxEnd(Ptr<SatInterference::InterferenceChangeEvent> event)
132 {
133  NS_LOG_FUNCTION(this);
134 
135  m_rxing = false;
136 }
137 
138 void
140 {
141  NS_LOG_FUNCTION(this);
142 
143  SatInterference::DoDispose();
144 }
145 
146 void
148 {
149  NS_LOG_FUNCTION(this);
150 
151  if (rxBandwidth <= std::numeric_limits<double>::epsilon())
152  {
153  NS_FATAL_ERROR("SatTracedInterference::SetRxBandwidth - Invalid value");
154  }
155 
156  m_rxBandwidth_Hz = rxBandwidth;
157 }
158 
159 } // namespace ns3
160 
161 // namespace ns3
ChannelType_t
Types of channel.
Abstract class defining interface for interference calculations objects.
void Reset(void)
Resets current interference.
static TypeId GetTypeId(void)
Derived from Object.
virtual void DoNotifyRxEnd(Ptr< SatInterference::InterferenceChangeEvent > event)
Notifies that RX is ended by a receiver.
TypeId GetInstanceTypeId(void) const
Derived from Object.
virtual void DoReset(void)
Resets current interference.
void DoDispose()
Dispose of SatTracedInterference.
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.
void SetRxBandwidth(double rxBandwidth)
Set Rx bandwidth.
SatTracedInterference()
Default constructor, not used.
virtual void DoNotifyRxStart(Ptr< SatInterference::InterferenceChangeEvent > event)
Notifies that RX is started by a receiver.
double m_rxBandwidth_Hz
RX Bandwidth in Hz.
virtual Ptr< SatInterference::InterferenceChangeEvent > DoAdd(Time rxDuration, double rxPower, Address rxAddress)
Adds interference power to interference object.
SatArqSequenceNumber is handling the sequence numbers for the ARQ process.