blob: 5989a23abf538fae8b8089239c3f4688176520d3 [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
28namespace ns3
29{
Alexander Afanasyev4aac5572012-08-09 10:49:55 -070030class NdnFace;
Alexander Afanasyev0845c092012-07-13 17:45:33 -070031
32namespace ndnSIM
33{
34
35// this thing is actually put into a tree node, associated with each "name entry"
36
37class LoadStatsNode
38{
39public:
Alexander Afanasyev4aac5572012-08-09 10:49:55 -070040 typedef std::map< ns3::Ptr<ns3::NdnFace>, LoadStatsFace > stats_container;
Alexander Afanasyev0845c092012-07-13 17:45:33 -070041
42 LoadStatsNode () {}
43 LoadStatsNode (const LoadStatsNode &) {}
44
45 void
46 Step ();
47
48 /**
49 * Increment face-independent counter
50 */
51 void
52 NewPitEntry ();
53
54 /**
55 * Increment counter to incoming list
56 */
57 void
Alexander Afanasyev4aac5572012-08-09 10:49:55 -070058 AddIncoming (ns3::Ptr<ns3::NdnFace> face);
Alexander Afanasyev0845c092012-07-13 17:45:33 -070059
60 /**
61 * Increment counter to outgoing list
62 */
63 void
Alexander Afanasyev4aac5572012-08-09 10:49:55 -070064 AddOutgoing (ns3::Ptr<ns3::NdnFace> face);
Alexander Afanasyev0845c092012-07-13 17:45:33 -070065
66 /**
67 * Increment counter to both incoming and outgoing lists, for all faces
68 */
69 void
70 Satisfy ();
71
72 /**
73 * Increment counter to both incoming and outgoing lists, for all faces
74 */
75 void
76 Timeout ();
77
Alexander Afanasyev1c0248b2012-07-24 15:59:50 -070078 /**
79 * Increment counter for Tx amount
80 */
81 void
Alexander Afanasyev4aac5572012-08-09 10:49:55 -070082 Rx (ns3::Ptr<ns3::NdnFace> face, uint32_t amount);
Alexander Afanasyev1c0248b2012-07-24 15:59:50 -070083
84 /**
85 * Increment counter for Tx amount
86 */
87 void
Alexander Afanasyev4aac5572012-08-09 10:49:55 -070088 Tx (ns3::Ptr<ns3::NdnFace> face, uint32_t amount);
Alexander Afanasyev1c0248b2012-07-24 15:59:50 -070089
Alexander Afanasyev0845c092012-07-13 17:45:33 -070090 LoadStatsNode &
91 operator += (const LoadStatsNode &stats);
92
93 inline const stats_container &
94 incoming () const;
95
96 inline const stats_container &
97 outgoing () const;
98
99 inline const LoadStatsFace &
100 pit () const;
101
102 bool
Alexander Afanasyev0560eec2012-07-16 15:44:31 -0700103 IsZero () const;
104
105 bool
106 operator == (const LoadStatsNode &other) const;
107
Alexander Afanasyev0845c092012-07-13 17:45:33 -0700108 bool
109 operator != (const LoadStatsNode &other) const
110 {
Alexander Afanasyev0560eec2012-07-16 15:44:31 -0700111 return !(*this == other);
Alexander Afanasyev0845c092012-07-13 17:45:33 -0700112 }
113
114 LoadStatsNode &
115 operator = (const LoadStatsNode &other)
116 {
117 // don't do any copying at all
118 return *this;
119 }
Alexander Afanasyev33364b62012-07-26 17:53:56 -0700120
121 void
Alexander Afanasyev4aac5572012-08-09 10:49:55 -0700122 RemoveFace (ns3::Ptr<ns3::NdnFace> face);
Alexander Afanasyev0845c092012-07-13 17:45:33 -0700123
124private:
125 LoadStatsFace m_pit;
126 stats_container m_incoming;
127 stats_container m_outgoing;
128
129 friend std::ostream&
130 operator << (std::ostream &os, const LoadStatsNode &node);
131};
132
133inline const LoadStatsNode::stats_container &
134LoadStatsNode::incoming () const
135{
136 return m_incoming;
137}
138
139inline const LoadStatsNode::stats_container &
140LoadStatsNode::outgoing () const
141{
142 return m_outgoing;
143}
144
145inline const LoadStatsFace &
146LoadStatsNode::pit () const
147{
148 return m_pit;
149}
150
151std::ostream&
152operator << (std::ostream &os, const LoadStatsNode &node);
153
Alexander Afanasyeve77db792012-08-09 11:10:58 -0700154} // ndnSIM
155} // ns3
Alexander Afanasyev0845c092012-07-13 17:45:33 -0700156
157#endif