A Discrete-Event Network Simulator
API
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
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 private:
43  FlowProbe (FlowProbe const &);
46  FlowProbe& operator= (FlowProbe const &);
47 
48 protected:
51  FlowProbe (Ptr<FlowMonitor> flowMonitor);
52  virtual void DoDispose (void);
53 
54 public:
55  virtual ~FlowProbe ();
56 
58  struct FlowStats
59  {
60  FlowStats () : delayFromFirstProbeSum (Seconds (0)), bytes (0), packets (0) {}
61 
63  std::vector<uint32_t> packetsDropped;
65  std::vector<uint64_t> bytesDropped;
70  uint64_t bytes;
72  uint32_t packets;
73  };
74 
76  typedef std::map<FlowId, FlowStats> Stats;
77 
82  void AddPacketStats (FlowId flowId, uint32_t packetSize, Time delayFromFirstProbe);
87  void AddPacketDropStats (FlowId flowId, uint32_t packetSize, uint32_t reasonCode);
88 
93  Stats GetStats () const;
94 
99  void SerializeToXmlStream (std::ostream &os, int indent, uint32_t index) const;
100 
101 protected:
104 
105 };
106 
107 
108 } // namespace ns3
109 
110 #endif /* FLOW_PROBE_H */
Simulation virtual time values and global simulation resolution.
Definition: nstime.h:79
smart pointer class similar to boost::intrusive_ptr
Definition: ptr.h:60
std::vector< uint64_t > bytesDropped
bytesDropped[reasonCode] => number of dropped bytes
Definition: flow-probe.h:65
virtual ~FlowProbe()
Definition: flow-probe.cc:27
void AddPacketStats(FlowId flowId, uint32_t packetSize, Time delayFromFirstProbe)
Add a packet data to the flow stats.
Definition: flow-probe.cc:46
Ptr< FlowMonitor > m_flowMonitor
the FlowMonitor instance
Definition: flow-probe.h:102
uint32_t packets
Number of packets seen of this flow.
Definition: flow-probe.h:72
uint64_t bytes
Number of bytes seen of this flow.
Definition: flow-probe.h:70
FlowProbe & operator=(FlowProbe const &)
Defined and not implemented to avoid misuse.
std::vector< uint32_t > packetsDropped
packetsDropped[reasonCode] => number of dropped packets
Definition: flow-probe.h:63
Structure to hold the statistics of a flow.
Definition: flow-probe.h:58
void AddPacketDropStats(FlowId flowId, uint32_t packetSize, uint32_t reasonCode)
Add a packet drop data to the flow stats.
Definition: flow-probe.cc:55
The FlowProbe class is responsible for listening for packet events in a specific point of the simulat...
Definition: flow-probe.h:39
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:68
void SerializeToXmlStream(std::ostream &os, int indent, uint32_t index) const
Serializes the results to an std::ostream in XML format.
Definition: flow-probe.cc:75
std::map< FlowId, FlowStats > Stats
Container to map FlowId -> FlowStats.
Definition: flow-probe.h:76
Stats GetStats() const
Get the partial flow statistics stored in this probe.
Definition: flow-probe.cc:69
a base class which provides memory management and object aggregation
Definition: object.h:64
FlowProbe(FlowProbe const &)
Defined and not implemented to avoid misuse.
virtual void DoDispose(void)
This method is called by Object::Dispose or by the object's destructor, whichever comes first...
Definition: flow-probe.cc:39
Stats m_stats
The flow stats.
Definition: flow-probe.h:103
uint32_t FlowId
Abstract identifier of a packet flow.