satellite-constant-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/double.h>
26 #include <ns3/log.h>
27 #include <ns3/simulator.h>
28 
29 #include <stdint.h>
30 #include <utility>
31 #include <vector>
32 
33 NS_LOG_COMPONENT_DEFINE("SatConstantInterference");
34 
35 namespace ns3
36 {
37 
38 NS_OBJECT_ENSURE_REGISTERED(SatConstantInterference);
39 
40 TypeId
42 {
43  static TypeId tid = TypeId("ns3::SatConstantInterference")
44  .SetParent<SatInterference>()
45  .AddConstructor<SatConstantInterference>()
46  .AddAttribute("ConstantInterferencePower",
47  "Constant interference power in linear format.",
48  DoubleValue(0.0),
49  MakeDoubleAccessor(&SatConstantInterference::m_power),
50  MakeDoubleChecker<double_t>());
51  return tid;
52 }
53 
54 TypeId
56 {
57  return GetTypeId();
58 }
59 
61  : m_power(0.0),
62  m_rxing(false)
63 {
64 }
65 
67 {
68  Reset();
69 }
70 
71 Ptr<SatInterference::InterferenceChangeEvent>
72 SatConstantInterference::DoAdd(Time duration, double power, Address rxAddress)
73 {
74  NS_LOG_FUNCTION(this << duration.GetSeconds() << power << rxAddress);
75 
76  Ptr<SatInterference::InterferenceChangeEvent> event;
77  event = Create<SatInterference::InterferenceChangeEvent>(0, duration, power, rxAddress);
78 
79  return event;
80 }
81 
82 std::vector<std::pair<double, double>>
83 SatConstantInterference::DoCalculate(Ptr<SatInterference::InterferenceChangeEvent> event)
84 {
85  NS_LOG_FUNCTION(this);
86 
87  if (m_rxing == false)
88  {
89  NS_LOG_WARN("Most likely two overlapping receptions! With random access carrier"
90  " this should be fine, but with dedicated access prohibited!");
91  }
92 
93  std::vector<std::pair<double, double>> ifPowerPerFragment;
94  ifPowerPerFragment.emplace_back(1.0, m_power);
95 
96  return ifPowerPerFragment;
97 }
98 
99 void
101 {
102  NS_LOG_FUNCTION(this);
103 
104  m_rxing = false;
105 }
106 
107 void
108 SatConstantInterference::DoNotifyRxStart(Ptr<SatInterference::InterferenceChangeEvent> event)
109 {
110  NS_LOG_FUNCTION(this);
111 
112  m_rxing = true;
113 }
114 
115 void
116 SatConstantInterference::DoNotifyRxEnd(Ptr<SatInterference::InterferenceChangeEvent> event)
117 {
118  NS_LOG_FUNCTION(this);
119 
120  m_rxing = false;
121 }
122 
123 } // namespace ns3
124 
125 // namespace ns3
virtual Ptr< SatInterference::InterferenceChangeEvent > DoAdd(Time rxDuration, double rxPower, Address rxAddress)
Adds interference power to interference object.
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.
~SatConstantInterference()
Destructor for SatConstantInterference.
virtual void DoNotifyRxEnd(Ptr< SatInterference::InterferenceChangeEvent > event)
Notifies that RX is ended by a receiver.
virtual void DoReset(void)
Resets current interference.
virtual void DoNotifyRxStart(Ptr< SatInterference::InterferenceChangeEvent > event)
Notifies that RX is started by a receiver.
static TypeId GetTypeId(void)
Get the type ID.
Abstract class defining interface for interference calculations objects.
void Reset(void)
Resets current interference.
SatArqSequenceNumber is handling the sequence numbers for the ARQ process.