A Discrete-Event Network Simulator
API
flow-probe.h
Go to the documentation of this file.
1 /* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
2 //
3 // Copyright (c) 2009 INESC Porto
4 //
5 // This program is free software; you can redistribute it and/or modify
6 // it under the terms of the GNU General Public License version 2 as
7 // published by the Free Software Foundation;
8 //
9 // This program is distributed in the hope that it will be useful,
10 // but WITHOUT ANY WARRANTY; without even the implied warranty of
11 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 // GNU General Public License for more details.
13 //
14 // You should have received a copy of the GNU General Public License
15 // along with this program; if not, write to the Free Software
16 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
17 //
18 // Author: Gustavo J. A. M. Carneiro <gjc@inescporto.pt> <gjcarneiro@gmail.com>
19 //
20 
21 #ifndef FLOW_PROBE_H
22 #define FLOW_PROBE_H
23 
24 #include <map>
25 #include <vector>
26 
27 #include "ns3/object.h"
28 #include "ns3/flow-classifier.h"
29 #include "ns3/nstime.h"
30 
31 namespace ns3 {
32 
33 class FlowMonitor;
34 
39 class FlowProbe : public Object
40 {
41 protected:
44  FlowProbe (Ptr<FlowMonitor> flowMonitor);
45  virtual void DoDispose (void);
46 
47 public:
48  virtual ~FlowProbe ();
49 
50  // Delete copy constructor and assignment operator to avoid misuse
51  FlowProbe (FlowProbe const &) = delete;
52  FlowProbe& operator= (FlowProbe const &) = delete;
53 
56  static TypeId GetTypeId (void);
57 
59  struct FlowStats
60  {
62 
64  std::vector<uint32_t> packetsDropped;
66  std::vector<uint64_t> bytesDropped;
71  uint64_t bytes;
73  uint32_t packets;
74  };
75 
77  typedef std::map<FlowId, FlowStats> Stats;
78 
83  void AddPacketStats (FlowId flowId, uint32_t packetSize, Time delayFromFirstProbe);
88  void AddPacketDropStats (FlowId flowId, uint32_t packetSize, uint32_t reasonCode);
89 
94  Stats GetStats () const;
95 
100  void SerializeToXmlStream (std::ostream &os, uint16_t indent, uint32_t index) const;
101 
102 protected:
105 
106 };
107 
108 
109 } // namespace ns3
110 
111 #endif /* FLOW_PROBE_H */
The FlowProbe class is responsible for listening for packet events in a specific point of the simulat...
Definition: flow-probe.h:40
virtual ~FlowProbe()
Definition: flow-probe.cc:38
Stats m_stats
The flow stats.
Definition: flow-probe.h:104
FlowProbe & operator=(FlowProbe const &)=delete
void AddPacketStats(FlowId flowId, uint32_t packetSize, Time delayFromFirstProbe)
Add a packet data to the flow stats.
Definition: flow-probe.cc:57
FlowProbe(Ptr< FlowMonitor > flowMonitor)
Constructor.
Definition: flow-probe.cc:43
static TypeId GetTypeId(void)
Register this type.
Definition: flow-probe.cc:27
FlowProbe(FlowProbe const &)=delete
void AddPacketDropStats(FlowId flowId, uint32_t packetSize, uint32_t reasonCode)
Add a packet drop data to the flow stats.
Definition: flow-probe.cc:66
std::map< FlowId, FlowStats > Stats
Container to map FlowId -> FlowStats.
Definition: flow-probe.h:77
Stats GetStats() const
Get the partial flow statistics stored in this probe.
Definition: flow-probe.cc:80
virtual void DoDispose(void)
Destructor implementation.
Definition: flow-probe.cc:50
void SerializeToXmlStream(std::ostream &os, uint16_t indent, uint32_t index) const
Serializes the results to an std::ostream in XML format.
Definition: flow-probe.cc:86
Ptr< FlowMonitor > m_flowMonitor
the FlowMonitor instance
Definition: flow-probe.h:103
A base class which provides memory management and object aggregation.
Definition: object.h:88
Smart pointer class similar to boost::intrusive_ptr.
Definition: ptr.h:74
Simulation virtual time values and global simulation resolution.
Definition: nstime.h:103
a unique identifier for an interface.
Definition: type-id.h:59
uint32_t FlowId
Abstract identifier of a packet flow.
Time Seconds(double value)
Construct a Time in the indicated unit.
Definition: nstime.h:1244
def indent(source, debug, level)
Definition: check-style.py:432
Every class exported by the ns3 library is enclosed in the ns3 namespace.
Structure to hold the statistics of a flow.
Definition: flow-probe.h:60
uint64_t bytes
Number of bytes seen of this flow.
Definition: flow-probe.h:71
uint32_t packets
Number of packets seen of this flow.
Definition: flow-probe.h:73
Time delayFromFirstProbeSum
divide by 'packets' to get the average delay from the first (entry) probe up to this one (partial del...
Definition: flow-probe.h:69
std::vector< uint32_t > packetsDropped
packetsDropped[reasonCode] => number of dropped packets
Definition: flow-probe.h:64
std::vector< uint64_t > bytesDropped
bytesDropped[reasonCode] => number of dropped bytes
Definition: flow-probe.h:66
static const uint32_t packetSize