A Discrete-Event Network Simulator
API
ofswitch13-stats-calculator.h
Go to the documentation of this file.
1 /*
2  * Copyright (c) 2017 University of Campinas (Unicamp)
3  *
4  * This program is free software; you can redistribute it and/or modify
5  * it under the terms of the GNU General Public License version 2 as
6  * published by the Free Software Foundation;
7  *
8  * This program is distributed in the hope that it will be useful,
9  * but WITHOUT ANY WARRANTY; without even the implied warranty of
10  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11  * GNU General Public License for more details.
12  *
13  * You should have received a copy of the GNU General Public License
14  * along with this program; if not, write to the Free Software
15  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
16  *
17  * Author: Luciano Jerez Chaves <ljerezchaves@gmail.com>
18  */
19 
20 #ifndef OFSWITCH13_STATS_CALCULATOR_H
21 #define OFSWITCH13_STATS_CALCULATOR_H
22 
23 #include <ns3/ofswitch13-device.h>
24 
25 namespace ns3
26 {
27 
63 {
64  public:
66  ~OFSwitch13StatsCalculator() override;
67 
72  static TypeId GetTypeId();
73 
78  void HookSinks(Ptr<OFSwitch13Device> device);
79 
87  //\{
88  uint32_t GetEwmaBufferEntries() const;
89  DataRate GetEwmaCpuLoad() const;
90  uint32_t GetEwmaFlowTableEntries(uint8_t tableId) const;
91  uint32_t GetEwmaGroupTableEntries() const;
92  uint32_t GetEwmaMeterTableEntries() const;
93  Time GetEwmaPipelineDelay() const;
94  uint32_t GetEwmaSumFlowEntries() const;
95  //\}
96 
106  //\{
107  uint32_t GetAvgBufferUsage() const;
108  uint32_t GetAvgCpuUsage() const;
109  uint32_t GetAvgFlowTableUsage(uint8_t tableId) const;
110  uint32_t GetAvgGroupTableUsage() const;
111  uint32_t GetAvgMeterTableUsage() const;
112  uint32_t GetAvgActFlowTableUsage() const;
113  //\}
114 
115  protected:
117  void DoDispose() override;
118 
119  // Inherited from ObjectBase.
120  void NotifyConstructionCompleted() override;
121 
122  private:
128 
134 
140  void NotifyMeterDrop(Ptr<const Packet> packet, uint32_t meterId);
141 
148  void NotifyTableDrop(Ptr<const Packet> packet, uint8_t tableId);
149 
155 
160  void DumpStatistics();
161 
164  std::string m_filename;
167  double m_alpha;
168  bool m_details;
169 
171  //\{
178 
179  std::vector<double> m_ewmaFlowEntries;
180 
181  uint64_t m_bytes;
182  uint64_t m_lastFlowMods;
183  uint64_t m_lastGroupMods;
184  uint64_t m_lastMeterMods;
185  uint64_t m_lastPacketsIn;
187  uint64_t m_loadDrops;
188  uint64_t m_meterDrops;
189  uint64_t m_tableDrops;
190  uint64_t m_packets;
191  //\}
192 };
193 
194 } // namespace ns3
195 #endif /* OFSWITCH13_STATS_CALCULATOR_H */
Class for representing data rates.
Definition: data-rate.h:90
This class monitors a single OpenFlow switch device to collect statistics and periodically write them...
std::string m_filename
Output file name.
void NotifyConstructionCompleted() override
OpenFlow switch device.
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.
static TypeId GetTypeId()
Register this type.
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.
Ptr< OFSwitch13Device > m_device
OpenFlow switch device.
uint32_t GetAvgGroupTableUsage() const
OpenFlow switch device.
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.
uint32_t GetAvgMeterTableUsage() const
OpenFlow switch device.
void HookSinks(Ptr< OFSwitch13Device > device)
Hook switch device trace sources to internal stats calculator trace sinks.
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.
void NotifyDatapathTimeout(Ptr< const OFSwitch13Device > device)
Notify when a datapath timeout operation is completed.
A base class which provides memory management and object aggregation.
Definition: object.h:89
Smart pointer class similar to boost::intrusive_ptr.
Definition: ptr.h:78
Simulation virtual time values and global simulation resolution.
Definition: nstime.h:105
a unique identifier for an interface.
Definition: type-id.h:60
Every class exported by the ns3 library is enclosed in the ns3 namespace.