blob: 135c5f032fc62575ec1efb961e2bbf1def8ce558 [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_NODE_H
22#define LOAD_STATS_NODE_H
23
24#include "load-stats-face.h"
25#include <map>
26#include "ns3/ptr.h"
27
Alexander Afanasyev2b4c9472012-08-09 15:00:38 -070028namespace ns3 {
29namespace ndn {
30
31class Face;
Alexander Afanasyev0845c092012-07-13 17:45:33 -070032
33namespace ndnSIM
34{
35
36// this thing is actually put into a tree node, associated with each "name entry"
37
38class LoadStatsNode
39{
40public:
Alexander Afanasyev2b4c9472012-08-09 15:00:38 -070041 typedef std::map< ns3::Ptr<Face>, LoadStatsFace > stats_container;
Alexander Afanasyev0845c092012-07-13 17:45:33 -070042
43 LoadStatsNode () {}
44 LoadStatsNode (const LoadStatsNode &) {}
45
46 void
47 Step ();
48
49 /**
50 * Increment face-independent counter
51 */
52 void
53 NewPitEntry ();
54
55 /**
56 * Increment counter to incoming list
57 */
58 void
Alexander Afanasyev2b4c9472012-08-09 15:00:38 -070059 AddIncoming (ns3::Ptr<Face> face);
Alexander Afanasyev0845c092012-07-13 17:45:33 -070060
61 /**
62 * Increment counter to outgoing list
63 */
64 void
Alexander Afanasyev2b4c9472012-08-09 15:00:38 -070065 AddOutgoing (ns3::Ptr<Face> face);
Alexander Afanasyev0845c092012-07-13 17:45:33 -070066
67 /**
68 * Increment counter to both incoming and outgoing lists, for all faces
69 */
70 void
71 Satisfy ();
72
73 /**
Alexander Afanasyevc7719612012-08-30 17:42:20 -070074 * Remove a packet from all stats
75 */
76 void
77 RemoveFromStats ();
78
79 /**
Alexander Afanasyev0845c092012-07-13 17:45:33 -070080 * Increment counter to both incoming and outgoing lists, for all faces
81 */
82 void
83 Timeout ();
84
Alexander Afanasyev1c0248b2012-07-24 15:59:50 -070085 /**
86 * Increment counter for Tx amount
87 */
88 void
Alexander Afanasyev2b4c9472012-08-09 15:00:38 -070089 Rx (ns3::Ptr<Face> face, uint32_t amount);
Alexander Afanasyev1c0248b2012-07-24 15:59:50 -070090
91 /**
92 * Increment counter for Tx amount
93 */
94 void
Alexander Afanasyev2b4c9472012-08-09 15:00:38 -070095 Tx (ns3::Ptr<Face> face, uint32_t amount);
Alexander Afanasyev1c0248b2012-07-24 15:59:50 -070096
Alexander Afanasyev0845c092012-07-13 17:45:33 -070097 LoadStatsNode &
98 operator += (const LoadStatsNode &stats);
99
100 inline const stats_container &
101 incoming () const;
102
103 inline const stats_container &
104 outgoing () const;
105
106 inline const LoadStatsFace &
107 pit () const;
108
109 bool
Alexander Afanasyev0560eec2012-07-16 15:44:31 -0700110 IsZero () const;
111
112 bool
113 operator == (const LoadStatsNode &other) const;
114
Alexander Afanasyev0845c092012-07-13 17:45:33 -0700115 bool
116 operator != (const LoadStatsNode &other) const
117 {
Alexander Afanasyev0560eec2012-07-16 15:44:31 -0700118 return !(*this == other);
Alexander Afanasyev0845c092012-07-13 17:45:33 -0700119 }
120
121 LoadStatsNode &
122 operator = (const LoadStatsNode &other)
123 {
124 // don't do any copying at all
125 return *this;
126 }
Alexander Afanasyev33364b62012-07-26 17:53:56 -0700127
128 void
Alexander Afanasyev2b4c9472012-08-09 15:00:38 -0700129 RemoveFace (ns3::Ptr<Face> face);
Alexander Afanasyev0845c092012-07-13 17:45:33 -0700130
131private:
132 LoadStatsFace m_pit;
133 stats_container m_incoming;
134 stats_container m_outgoing;
135
136 friend std::ostream&
137 operator << (std::ostream &os, const LoadStatsNode &node);
138};
139
140inline const LoadStatsNode::stats_container &
141LoadStatsNode::incoming () const
142{
143 return m_incoming;
144}
145
146inline const LoadStatsNode::stats_container &
147LoadStatsNode::outgoing () const
148{
149 return m_outgoing;
150}
151
152inline const LoadStatsFace &
153LoadStatsNode::pit () const
154{
155 return m_pit;
156}
157
158std::ostream&
159operator << (std::ostream &os, const LoadStatsNode &node);
160
Alexander Afanasyeve77db792012-08-09 11:10:58 -0700161} // ndnSIM
Alexander Afanasyev2b4c9472012-08-09 15:00:38 -0700162} // ndn
Alexander Afanasyeve77db792012-08-09 11:10:58 -0700163} // ns3
Alexander Afanasyev0845c092012-07-13 17:45:33 -0700164
165#endif