26 #include <ns3/simulator.h>
27 #include <ns3/singleton.h>
38 NS_LOG_COMPONENT_DEFINE(
"SatPerPacketInterference");
43 NS_OBJECT_ENSURE_REGISTERED(SatPerPacketInterference);
48 static TypeId tid = TypeId(
"ns3::SatPerPacketInterference")
50 .AddConstructor<SatPerPacketInterference>();
58 NS_LOG_FUNCTION(
this);
64 : m_residualPowerW(0.0),
67 m_enableTraceOutput(false),
71 NS_LOG_FUNCTION(
this);
76 : m_residualPowerW(0.0),
79 m_enableTraceOutput(true),
80 m_channelType(channelType),
81 m_rxBandwidth_Hz(rxBandwidthHz)
83 NS_LOG_FUNCTION(
this << channelType << rxBandwidthHz);
87 NS_FATAL_ERROR(
"SatPerPacketInterference::SatPerPacketInterference - Invalid value");
93 NS_LOG_FUNCTION(
this);
98 Ptr<SatInterference::InterferenceChangeEvent>
101 NS_LOG_FUNCTION(
this << duration << power << rxAddress);
103 Ptr<SatInterference::InterferenceChangeEvent> event;
104 event = Create<SatInterference::InterferenceChangeEvent>(
m_nextEventId++,
108 Time now =
event->GetStartTime();
110 NS_LOG_INFO(
"Add change: Duration= " << duration <<
", Power= " << power <<
", Time: " << now);
120 long double powerValue;
121 std::tie(eventID, powerValue, std::ignore) = i->second;
123 NS_LOG_INFO(
"Change to erase: Time= " << i->first <<
", Id= " << eventID
124 <<
", PowerValue= " << powerValue);
150 std::make_pair(event->GetEndTime(),
InterferenceChange(event->GetId(), -power,
true)));
157 NS_FATAL_ERROR(
"First power negative!!!");
163 std::vector<std::pair<double, double>>
166 NS_LOG_FUNCTION(
this);
170 NS_FATAL_ERROR(
"Receiving is not set on!!!");
174 double rxDuration =
event->GetDuration().GetDouble();
175 double rxEndTime =
event->GetEndTime().GetDouble();
176 bool ownStartReached =
false;
178 NS_LOG_INFO(
"Calculate: IfPower (W)= " << ifPowerW <<
", Event ID= " << event->GetId()
179 <<
", Duration= " << event->GetDuration()
180 <<
", StartTime= " << event->GetStartTime()
181 <<
", EndTime= " << event->GetEndTime());
189 long double powerValue;
191 std::tie(eventID, powerValue, isEndEvent) = currentItem->second;
193 if (event->GetId() == eventID)
197 NS_LOG_INFO(
"IfPower after end event: " << ifPowerW);
203 ownStartReached =
true;
206 else if (ownStartReached)
210 double itemTime = currentItem->first.GetDouble();
213 NS_LOG_INFO(
"Update (partial): ID: " << eventID <<
", Power (W)= " << powerValue
214 <<
", Time= " << currentItem->first
215 <<
", DeltaTime= " << (rxEndTime - itemTime));
217 NS_LOG_INFO(
"IfPower after update: " << ifPowerW);
222 ifPowerW += powerValue;
224 NS_LOG_INFO(
"Update (full): ID: " << eventID <<
", Power (W)= " << powerValue);
225 NS_LOG_INFO(
"IfPower after update: " << ifPowerW);
233 std::vector<double> tempVector;
234 tempVector.push_back(Now().GetSeconds());
236 Singleton<SatInterferenceOutputTraceContainer>::Get()->AddToContainer(
237 std::make_pair(event->GetSatEarthStationAddress(),
m_channelType),
241 std::vector<std::pair<double, double>> ifPowerPerFragment;
242 ifPowerPerFragment.emplace_back(1.0, ifPowerW);
244 return ifPowerPerFragment;
255 double interferenceValue,
258 ifPowerW += timeRatio * interferenceValue;
264 NS_LOG_FUNCTION(
this);
274 NS_LOG_FUNCTION(
this);
276 std::pair<std::set<uint32_t>::iterator,
bool> result =
m_rxEventIds.insert(event->GetId());
278 NS_ASSERT(result.second);
285 NS_LOG_FUNCTION(
this);
298 NS_LOG_FUNCTION(
this);
300 SatInterference::DoDispose();
306 NS_LOG_FUNCTION(
this << rxBandwidth);
308 if (rxBandwidth <= std::numeric_limits<double>::epsilon())
310 NS_FATAL_ERROR(
"SatPerPacketInterference::SetRxBandwidth - Invalid value");
ChannelType_t
Types of channel.
Abstract class defining interface for interference calculations objects.
void Reset(void)
Resets current interference.
virtual void DoReset(void)
Resets current interference.
bool m_rxing
flag to indicate that at least one receiving is on
double m_rxBandwidth_Hz
RX Bandwidth in Hz.
SatPerPacketInterference()
void SetRxBandwidth(double rxBandwidth)
long double m_residualPowerW
Residual power value for interference.
static TypeId GetTypeId(void)
~SatPerPacketInterference()
virtual void DoNotifyRxEnd(Ptr< SatInterference::InterferenceChangeEvent > event)
Notifies that RX is ended by a receiver.
InterferenceChanges m_interferenceChanges
interference change list
virtual void DoNotifyRxStart(Ptr< SatInterference::InterferenceChangeEvent > event)
Notifies that RX is started by a receiver.
uint32_t m_nextEventId
event id for Events
std::set< uint32_t > m_rxEventIds
notified interference event IDs
virtual void onInterferentEvent(long double timeRatio, double interferenceValue, double &ifPowerW)
Helper function meant for subclasses to override.
std::tuple< uint32_t, long double, bool > InterferenceChange
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.
SatEnums::ChannelType_t m_channelType
TypeId GetInstanceTypeId(void) const
virtual void onOwnStartReached(double ifPowerW)
Helper function meant for subclasses to override.
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.