22 #include <ns3/config.h>
24 #include <ns3/simulator.h>
38 OFSwitch13StatsCalculator::OFSwitch13StatsCalculator()
42 m_ewmaBufferEntries(0.0),
44 m_ewmaGroupEntries(0.0),
45 m_ewmaMeterEntries(0.0),
46 m_ewmaPipelineDelay(0.0),
47 m_ewmaSumFlowEntries(0.0),
71 TypeId(
"ns3::OFSwitch13StatsCalculator")
73 .SetGroupName(
"OFSwitch13")
77 "The EWMA alpha parameter for averaging statistics.",
80 MakeDoubleChecker<double>(0.0, 1.0))
83 "The interval to update and dump switch statistics.",
89 "Filename for dumping switch statistics.",
96 "Dump individual pipeline flow table statistics.",
113 <<
" " << setw(8) <<
"TimeSec"
114 <<
" " << setw(12) <<
"LoaKbps"
115 <<
" " << setw(7) <<
"LoaUsag"
116 <<
" " << setw(7) <<
"Packets"
117 <<
" " << setw(7) <<
"DlyUsec"
118 <<
" " << setw(7) <<
"LoaDrps"
119 <<
" " << setw(7) <<
"MetDrps"
120 <<
" " << setw(7) <<
"TabDrps"
121 <<
" " << setw(7) <<
"FloMods"
122 <<
" " << setw(7) <<
"MetMods"
123 <<
" " << setw(7) <<
"GroMods"
124 <<
" " << setw(7) <<
"PktsIn"
125 <<
" " << setw(7) <<
"PktsOut"
126 <<
" " << setw(7) <<
"FloEntr"
127 <<
" " << setw(7) <<
"FloUsag"
128 <<
" " << setw(7) <<
"MetEntr"
129 <<
" " << setw(7) <<
"MetUsag"
130 <<
" " << setw(7) <<
"GroEntr"
131 <<
" " << setw(7) <<
"GroUsag"
132 <<
" " << setw(7) <<
"BufPkts"
133 <<
" " << setw(7) <<
"BufUsag";
137 for (
size_t i = 0; i <
m_device->GetNPipelineTables(); i++)
139 std::string field1 =
"T" + to_string(i) +
"Entr";
140 std::string field2 =
"T" + to_string(i) +
"Usag";
142 <<
" " << setw(7) << field1 <<
" " << setw(7) << field2;
149 device->TraceConnectWithoutContext(
153 device->TraceConnectWithoutContext(
157 device->TraceConnectWithoutContext(
161 device->TraceConnectWithoutContext(
165 device->TraceConnectWithoutContext(
223 static_cast<double>(
m_device->GetBufferSize()));
229 if (
m_device->GetCpuCapacity().GetBitRate() == 0)
235 static_cast<double>(
m_device->GetCpuCapacity().GetBitRate()));
241 if (
m_device->GetFlowTableSize(tableId) == 0)
247 static_cast<double>(
m_device->GetFlowTableSize(tableId)));
253 if (
m_device->GetGroupTableSize() == 0)
258 static_cast<double>(
m_device->GetGroupTableSize()));
264 if (
m_device->GetMeterTableSize() == 0)
269 static_cast<double>(
m_device->GetMeterTableSize()));
275 uint32_t sumSize = 0;
276 for (
size_t i = 0; i <
m_device->GetNPipelineTables(); i++)
278 if (
m_device->GetFlowTableEntries(i))
280 sumSize +=
m_device->GetFlowTableSize(i);
289 static_cast<double>(sumSize));
338 for (
size_t i = 0; i <
m_device->GetNPipelineTables(); i++)
386 uint64_t flowMods =
m_device->GetFlowModCounter();
387 uint64_t groupMods =
m_device->GetGroupModCounter();
388 uint64_t meterMods =
m_device->GetMeterModCounter();
389 uint64_t packetsIn =
m_device->GetPacketInCounter();
390 uint64_t packetsOut =
m_device->GetPacketOutCounter();
396 uint64_t cpuLoad =
m_bytes * 8 / elapSeconds;
397 uint64_t cpuCapy =
m_device->GetCpuCapacity().GetBitRate();
398 uint32_t cpuUsage = 0;
401 cpuUsage = std::round(
static_cast<double>(cpuLoad) * 100 /
402 static_cast<double>(cpuCapy));
408 <<
static_cast<double>(cpuLoad) / 1000 <<
" " << setw(7) << cpuUsage
409 <<
" " << setw(7) <<
m_packets <<
" " << setw(7)
427 for (
size_t i = 0; i <
m_device->GetNPipelineTables(); i++)
AttributeValue implementation for Boolean.
Class for representing data rates.
This class can be used to hold variables of floating point type such as 'double' or 'float'.
This class monitors a single OpenFlow switch device to collect statistics and periodically write them...
uint32_t GetEwmaGroupTableEntries() const
std::string m_filename
Output file name.
void NotifyConstructionCompleted() override
OpenFlow switch device.
double m_ewmaBufferEntries
DataRate GetEwmaCpuLoad() const
uint32_t GetAvgCpuUsage() const
OpenFlow switch device.
void DumpStatistics()
Read statistics from switch, update internal counters, and dump data into output file.
uint32_t GetEwmaFlowTableEntries(uint8_t tableId) const
~OFSwitch13StatsCalculator() override
Default destructor.
uint32_t GetEwmaSumFlowEntries() const
double m_ewmaMeterEntries
static TypeId GetTypeId()
Register this type.
double m_ewmaGroupEntries
uint32_t GetEwmaBufferEntries() const
void NotifyTableDrop(Ptr< const Packet > packet, uint8_t tableId)
Notify when an unmatched packet is dropped by a flow table without a table-miss entry.
std::vector< double > m_ewmaFlowEntries
uint32_t GetEwmaMeterTableEntries() const
Ptr< OFSwitch13Device > m_device
OpenFlow switch device.
double m_ewmaPipelineDelay
uint32_t GetAvgGroupTableUsage() const
OpenFlow switch device.
double m_alpha
EWMA alpha parameter.
uint32_t GetAvgFlowTableUsage(uint8_t tableId) const
OpenFlow switch device.
uint32_t GetAvgBufferUsage() const
OpenFlow switch device.
Ptr< OutputStreamWrapper > m_wrapper
Output file wrapper.
uint32_t GetAvgActFlowTableUsage() const
OpenFlow switch device.
void NotifyOverloadDrop(Ptr< const Packet > packet)
Notify when a packet is dropped due to pipeline load.
bool m_details
Pipeline table details.
uint32_t GetAvgMeterTableUsage() const
OpenFlow switch device.
void HookSinks(Ptr< OFSwitch13Device > device)
Hook switch device trace sources to internal stats calculator trace sinks.
Time GetEwmaPipelineDelay() const
Time m_lastUpdate
Last update time.
uint64_t m_lastPacketsOut
void NotifyMeterDrop(Ptr< const Packet > packet, uint32_t meterId)
Notify when a packet is dropped by a meter band.
void NotifyPipelinePacket(Ptr< const Packet > packet)
Notify when a packet is sent to pipeline.
void DoDispose() override
Destructor implementation.
Time m_timeout
Update timeout.
void NotifyDatapathTimeout(Ptr< const OFSwitch13Device > device)
Notify when a datapath timeout operation is completed.
double m_ewmaSumFlowEntries
virtual void NotifyConstructionCompleted()
Notifier called once the ObjectBase is fully constructed.
A base class which provides memory management and object aggregation.
std::ostream * GetStream()
Return a pointer to an ostream previously set in the wrapper.
uint32_t GetSize() const
Returns the the size in bytes of the packet (including the zero-filled initial payload).
Smart pointer class similar to boost::intrusive_ptr.
Control the scheduling of simulation events.
static EventId Schedule(const Time &delay, FUNC f, Ts &&... args)
Schedule an event to expire after delay.
static Time Now()
Return the current simulation virtual time.
Hold variables of type string.
Simulation virtual time values and global simulation resolution.
double GetSeconds() const
Get an approximation of the time stored in this instance in the indicated unit.
int64_t GetMicroSeconds() const
Get an approximation of the time stored in this instance in the indicated unit.
AttributeValue implementation for Time.
a unique identifier for an interface.
@ ATTR_GET
The attribute can be read.
@ ATTR_CONSTRUCT
The attribute can be written at construction-time.
TypeId SetParent(TypeId tid)
Set the parent TypeId.
#define NS_ASSERT_MSG(condition, message)
At runtime, in debugging builds, if this condition is not true, the program prints the message to out...
Ptr< const AttributeAccessor > MakeBooleanAccessor(T1 a1)
Create an AttributeAccessor for a class data member, or a lone class get functor or set method.
Ptr< const AttributeChecker > MakeBooleanChecker()
Ptr< const AttributeAccessor > MakeDoubleAccessor(T1 a1)
Create an AttributeAccessor for a class data member, or a lone class get functor or set method.
Ptr< const AttributeChecker > MakeStringChecker()
Ptr< const AttributeAccessor > MakeStringAccessor(T1 a1)
Create an AttributeAccessor for a class data member, or a lone class get functor or set method.
Ptr< const AttributeAccessor > MakeTimeAccessor(T1 a1)
Create an AttributeAccessor for a class data member, or a lone class get functor or set method.
#define NS_LOG_COMPONENT_DEFINE(name)
Define a Log component with a specific name.
#define NS_LOG_FUNCTION(parameters)
If log level LOG_FUNCTION is enabled, this macro will output all input parameters separated by ",...
void(* DataRate)(DataRate oldValue, DataRate newValue)
TracedValue callback signature for DataRate.
#define NS_OBJECT_ENSURE_REGISTERED(type)
Register an Object subclass with the TypeId system.
Time Now()
create an ns3::Time instance which contains the current simulation time.
Time Seconds(double value)
Construct a Time in the indicated unit.
void(* Time)(Time oldValue, Time newValue)
TracedValue callback signature for Time.
Every class exported by the ns3 library is enclosed in the ns3 namespace.
Callback< R, Args... > MakeCallback(R(T::*memPtr)(Args...), OBJ objPtr)
Build Callbacks for class method members which take varying numbers of arguments and potentially retu...
Ptr< const AttributeChecker > MakeTimeChecker(const Time min, const Time max)
Helper to make a Time checker with bounded range.