Skip to content

Commit

Permalink
applications: Add state trace source to OnOffApplication
Browse files Browse the repository at this point in the history
  • Loading branch information
Gabrielcarvfer committed Nov 14, 2024
1 parent e87bf91 commit d45e1af
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 2 deletions.
1 change: 1 addition & 0 deletions CHANGES.md
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
9 changes: 7 additions & 2 deletions src/applications/model/onoff-application.cc
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}

Expand Down Expand Up @@ -268,15 +272,16 @@ OnOffApplication::StartSending()
m_lastStartTime = Simulator::Now();
ScheduleNextTx(); // Schedule the send packet event
ScheduleStopEvent();
m_state = true;
}

void
OnOffApplication::StopSending()
{
NS_LOG_FUNCTION(this);
CancelEvents();

ScheduleStartEvent();
m_state = false;
}

// Private helpers
Expand Down
3 changes: 3 additions & 0 deletions src/applications/model/onoff-application.h
Original file line number Diff line number Diff line change
Expand Up @@ -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
{
Expand Down Expand Up @@ -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
Expand Down

0 comments on commit d45e1af

Please sign in to comment.