applications: Add state trace source to OnOffApplication

This commit is contained in:
Gabriel Ferreira
2024-11-05 10:37:03 +01:00
parent e87bf91596
commit d45e1afeb3
3 changed files with 11 additions and 2 deletions

View File

@@ -18,6 +18,7 @@ This file is a best-effort approach to solving this issue; we will do our best b
* (applications) Added two new base classes for source and sink applications, `SourceApplication` and `SinkApplication`, respectively.
* (wifi) Changes have been made to the `WifiRemoteStationManager` interface for what concerns the update of the frame retry count of the MPDUs and the decision of dropping MPDUs (possibly based on the max retry limit). The `NeedRetransmission` method has been replaced by the `GetMpdusToDropOnTxFailure` method and the `DoNeedRetransmission` method has been replaced by the `DoGetMpdusToDropOnTxFailure` method. Also, the `DoIncrementRetryCountOnTxFailure` method has been added to implement custom policies for the update of the frame retry count of MPDUs upon transmission failure.
* (applications) Added an `OnOffState` trace source to `OnOffApplication`, to track whether the application is transmitting or not.
### Changes to existing API

View File

@@ -96,7 +96,11 @@ OnOffApplication::GetTypeId()
.AddTraceSource("TxWithSeqTsSize",
"A new packet is created with SeqTsSizeHeader",
MakeTraceSourceAccessor(&OnOffApplication::m_txTraceWithSeqTsSize),
"ns3::PacketSink::SeqTsSizeCallback");
"ns3::PacketSink::SeqTsSizeCallback")
.AddTraceSource("OnOffState",
"Application state (0-OFF, 1-ON)",
MakeTraceSourceAccessor(&OnOffApplication::m_state),
"ns3::TracedValueCallback::Bool");
return tid;
}
@@ -268,6 +272,7 @@ OnOffApplication::StartSending()
m_lastStartTime = Simulator::Now();
ScheduleNextTx(); // Schedule the send packet event
ScheduleStopEvent();
m_state = true;
}
void
@@ -275,8 +280,8 @@ OnOffApplication::StopSending()
{
NS_LOG_FUNCTION(this);
CancelEvents();
ScheduleStartEvent();
m_state = false;
}
// Private helpers

View File

@@ -20,6 +20,7 @@
#include "ns3/event-id.h"
#include "ns3/ptr.h"
#include "ns3/traced-callback.h"
#include "ns3/traced-value.h"
namespace ns3
{
@@ -189,6 +190,8 @@ class OnOffApplication : public SourceApplication
* @param socket the not connected socket
*/
void ConnectionFailed(Ptr<Socket> socket);
TracedValue<bool> m_state; //!< State of application (0-OFF, 1-ON)
};
} // namespace ns3