blob: 816998e3aef357b23bef727d890ed863699f34bb [file] [log] [blame]
Alexander Afanasyev0845c092012-07-13 17:45:33 -07001/* -*- Mode: C++; c-file-style: "gnu"; indent-tabs-mode:nil; -*- */
2/*
3 * Copyright (c) 2011 University of California, Los Angeles
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: Alexander Afanasyev <alexander.afanasyev@ucla.edu>
19 */
20
21#ifndef LOAD_STATS_H
22#define LOAD_STATS_H
23
24#include "ns3/nstime.h"
25#include <boost/tuple/tuple.hpp>
26
Alexander Afanasyev2b4c9472012-08-09 15:00:38 -070027namespace ns3 {
28namespace ndn {
29namespace ndnSIM {
Alexander Afanasyev0845c092012-07-13 17:45:33 -070030
31class LoadStats
32{
33public:
34 typedef boost::tuple<double, double, double> stats_tuple;
35
Alexander Afanasyeve55d1e32012-07-19 15:33:05 -070036 static const double PRECISION;
37
Alexander Afanasyev0845c092012-07-13 17:45:33 -070038 LoadStats ();
39
40 void
41 Step ();
42
43 // void
44 // Increment (uint32_t amount);
45
46 LoadStats &
47 operator ++ (int);
48
49 // uint32_t
50 // GetCounter () const;
51
52 LoadStats &
53 operator += (const LoadStats &stats);
54
Alexander Afanasyev1c0248b2012-07-24 15:59:50 -070055 LoadStats &
56 operator += (uint32_t amount);
57
Alexander Afanasyev0845c092012-07-13 17:45:33 -070058 stats_tuple
59 GetStats () const;
60
61 bool
Alexander Afanasyev0560eec2012-07-16 15:44:31 -070062 IsZero () const;
Alexander Afanasyev0845c092012-07-13 17:45:33 -070063
64private:
Alexander Afanasyev70426a02012-08-15 15:39:18 -070065 uint64_t counter_;
Alexander Afanasyev0845c092012-07-13 17:45:33 -070066
67 double avg1_;
Alexander Afanasyev70426a02012-08-15 15:39:18 -070068 uint64_t avg1Counter_;
69 uint64_t avg1CounterOld_;
70 Time avg1LastUpdate_;
71
Alexander Afanasyeve55d1e32012-07-19 15:33:05 -070072 double avg2_;
Alexander Afanasyev70426a02012-08-15 15:39:18 -070073 uint64_t avg2Counter_;
74 uint64_t avg2CounterOld_;
75 Time avg2LastUpdate_;
76
Alexander Afanasyeve55d1e32012-07-19 15:33:05 -070077 double avg3_;
Alexander Afanasyev0560eec2012-07-16 15:44:31 -070078
79 friend std::ostream &
80 operator << (std::ostream &os, const LoadStats &stats);
Alexander Afanasyev0845c092012-07-13 17:45:33 -070081};
82
83std::ostream &
84operator << (std::ostream &os, const LoadStats &stats);
85
Alexander Afanasyev2b4c9472012-08-09 15:00:38 -070086} // namespace ndnSIM
87} // namespace ndn
88} // namespace ns3
Alexander Afanasyev0845c092012-07-13 17:45:33 -070089
90#endif // LOAD_STATS_H