Tracking OffTime of OnOff applications

60 views
Skip to first unread message

Garet2k

unread,
Jan 28, 2022, 6:18:50 AM1/28/22
to ns-3-users
I use ns3::UniformRandomVariable to generate random OffTimes from an uniform distribution in an OnOff application. I use the OnOffHelper to setup my OnOff application.


OnOffHelper server ("ns3::TcpSocketFactory", (InetSocketAddress (apInterface.GetAddress(0), 9)));
server.SetAttribute ("PacketSize", UintegerValue (512));
server.SetAttribute ("OnTime", StringValue("ns3::ConstantRandomVariable[Constant=10]"));
server.SetAttribute ("OffTime", StringValue ("ns3::UniformRandomVariable[Min=0|Max=5]"));
server.SetAttribute ("DataRate", DataRateValue (DataRate ("100Mbps")));
ApplicationContainer serverApp = server.Install(staWifiNode);

However, I don't see a way to get the current OffTime when running the simulation. Is there a convenient way to get track of the OffTimes?

Ibrahim Sammour

unread,
Jan 31, 2022, 11:58:33 AM1/31/22
to ns-3-users
You can add a ```TracedCallback``` to the onoff-application.h and call it from the ```ScheduleStartEvent``` of the onoff-application.cc to trace the ```offInterval``` variable

Finally connect to your newly created ```TraceCallback``` from your script using ```Config::Connect```

Soulimane Mammar

unread,
Feb 1, 2022, 4:05:15 PM2/1/22
to ns-3-users
Hi,
An easy way to do it (without modifying source code of the onoff application) is to enable logging (LogComponentEnable(""OnOffApplication"")).
Each time a start or stop is scheduled  you'll get "start at XXXX"  and "stop at YYYY" messages
Reply all
Reply to author
Forward
0 new messages