This tracks the queue of point-to-point network devices (part of a ‘link’). Note: if you have a queueing discipline installed, this will also have queues in it: these queue are not tracked by this.
It encompasses the following files:
model/core/ptop-link-queue-tracker.cc/h
-
Link queue trackerhelper/core/ptop-link-queue-tracker-helper.cc/h
-
Helper to install the queue trackers on the network devices in a topology.You can use the application(s) separately, or make use of the helper which requires a topology (which is recommended).
Add the following to the config_ns3.properties
in your run folder:
enable_link_queue_tracking=true
In your code, import the helper:
#include "ns3/ptop-link-queue-tracker-helper.h"
Before the start of the simulation run, in your code add:
// Install link queue trackers
PtopLinkQueueTrackerHelper linkQueueTrackerHelper = PtopLinkQueueTrackerHelper(basicSimulation, topology);
After the run, in your code add:
// Write link queue result
linkQueueTrackerHelper.WriteResults();
After the run, you should have the link queue log files in the logs_ns3
of your run folder.
In your code, import the tracker:
#include "ns3/ptop-link-queue-tracker.h"
Before the start of the simulation run, in your code add:
Ptr<PointToPointNetDevice> networkDevice = ... // Get the network device from somewhere
Ptr<PtopLinkQueueTracker> tracker = CreateObject<PtopLinkQueueTracker>(networkDevice);
// ... store the tracker to keep it alive and later retrieve its results
After the run, in your code add:
const std::vector<std::tuple<int64_t, int64_t, int64_t>> log_entries_pkt = tracker->GetIntervalsNumPackets();
for (size_t j = 0; j < log_entries_pkt.size(); j++) {
int64_t interval_start_ns = std::get<0>(log_entries_pkt[j]);
int64_t interval_end_ns = std::get<1>(log_entries_pkt[j]);
int64_t interval_queue_num_packets = std::get<2>(log_entries_pkt[j]);
// ... then do something with it, print it
}
You MUST set the following key in config_ns3.properties
for queue tracking to be enabled:
enable_link_queue_tracking
:
True iff link qeuue tracking on all links should be enabled (boolean value, either true
or false
)The link queue log files
There are two log files generated by the run in the logs_ns3
folder within the run folder:
link_queue_pkt.csv
: CSV formatted queue size in packets. The format is as follows:
<from>,<to>,<interval start (ns)>,<interval end (ns)>,<number of packets (integer)>
link_queue_byte.csv
: CSV formatted queue size in bytes. The format is as follows:
<from>,<to>,<interval start (ns)>,<interval end (ns)>,<number of bytes (integer)>