A Discrete-Event Network Simulator
API
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Groups Pages
flow-probe.h
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:
42  FlowProbe (FlowProbe const &);
43  FlowProbe& operator= (FlowProbe const &);
44 
45 protected:
46 
47  FlowProbe (Ptr<FlowMonitor> flowMonitor);
48  virtual void DoDispose (void);
49 
50 public:
51  virtual ~FlowProbe ();
52 
53  struct FlowStats
54  {
55  FlowStats () : delayFromFirstProbeSum (Seconds (0)), bytes (0), packets (0) {}
56 
58  std::vector<uint32_t> packetsDropped;
60  std::vector<uint64_t> bytesDropped;
65  uint64_t bytes;
67  uint32_t packets;
68  };
69 
70  typedef std::map<FlowId, FlowStats> Stats;
71 
72  void AddPacketStats (FlowId flowId, uint32_t packetSize, Time delayFromFirstProbe);
73  void AddPacketDropStats (FlowId flowId, uint32_t packetSize, uint32_t reasonCode);
74 
78  Stats GetStats () const;
79 
80  void SerializeToXmlStream (std::ostream &os, int indent, uint32_t index) const;
81 
82 protected:
83  Ptr<FlowMonitor> m_flowMonitor;
84  Stats m_stats;
85 
86 };
87 
88 
89 } // namespace ns3
90 
91 #endif /* FLOW_PROBE_H */
keep track of time unit.
Definition: nstime.h:149
smart pointer class similar to boost::intrusive_ptr
Definition: ptr.h:59
std::vector< uint64_t > bytesDropped
bytesDropped[reasonCode] => number of dropped bytes
Definition: flow-probe.h:60
uint32_t packets
Number of packets seen of this flow.
Definition: flow-probe.h:67
uint64_t bytes
Number of bytes seen of this flow.
Definition: flow-probe.h:65
std::vector< uint32_t > packetsDropped
packetsDropped[reasonCode] => number of dropped packets
Definition: flow-probe.h:58
Time Seconds(double seconds)
create ns3::Time instances in units of seconds.
Definition: nstime.h:586
Stats GetStats() const
Definition: flow-probe.cc:69
a base class which provides memory management and object aggregation
Definition: object.h:63
virtual void DoDispose(void)
Definition: flow-probe.cc:39