blob: 365db557ce00e795cc55c8ce52785a818509adb9 [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 /**
74 * Increment counter to both incoming and outgoing lists, for all faces
75 */
76 void
77 Timeout ();
78
Alexander Afanasyev1c0248b2012-07-24 15:59:50 -070079 /**
80 * Increment counter for Tx amount
81 */
82 void
Alexander Afanasyev2b4c9472012-08-09 15:00:38 -070083 Rx (ns3::Ptr<Face> face, uint32_t amount);
Alexander Afanasyev1c0248b2012-07-24 15:59:50 -070084
85 /**
86 * Increment counter for Tx amount
87 */
88 void
Alexander Afanasyev2b4c9472012-08-09 15:00:38 -070089 Tx (ns3::Ptr<Face> face, uint32_t amount);
Alexander Afanasyev1c0248b2012-07-24 15:59:50 -070090
Alexander Afanasyev0845c092012-07-13 17:45:33 -070091 LoadStatsNode &
92 operator += (const LoadStatsNode &stats);
93
94 inline const stats_container &
95 incoming () const;
96
97 inline const stats_container &
98 outgoing () const;
99
100 inline const LoadStatsFace &
101 pit () const;
102
103 bool
Alexander Afanasyev0560eec2012-07-16 15:44:31 -0700104 IsZero () const;
105
106 bool
107 operator == (const LoadStatsNode &other) const;
108
Alexander Afanasyev0845c092012-07-13 17:45:33 -0700109 bool
110 operator != (const LoadStatsNode &other) const
111 {
Alexander Afanasyev0560eec2012-07-16 15:44:31 -0700112 return !(*this == other);
Alexander Afanasyev0845c092012-07-13 17:45:33 -0700113 }
114
115 LoadStatsNode &
116 operator = (const LoadStatsNode &other)
117 {
118 // don't do any copying at all
119 return *this;
120 }
Alexander Afanasyev33364b62012-07-26 17:53:56 -0700121
122 void
Alexander Afanasyev2b4c9472012-08-09 15:00:38 -0700123 RemoveFace (ns3::Ptr<Face> face);
Alexander Afanasyev0845c092012-07-13 17:45:33 -0700124
125private:
126 LoadStatsFace m_pit;
127 stats_container m_incoming;
128 stats_container m_outgoing;
129
130 friend std::ostream&
131 operator << (std::ostream &os, const LoadStatsNode &node);
132};
133
134inline const LoadStatsNode::stats_container &
135LoadStatsNode::incoming () const
136{
137 return m_incoming;
138}
139
140inline const LoadStatsNode::stats_container &
141LoadStatsNode::outgoing () const
142{
143 return m_outgoing;
144}
145
146inline const LoadStatsFace &
147LoadStatsNode::pit () const
148{
149 return m_pit;
150}
151
152std::ostream&
153operator << (std::ostream &os, const LoadStatsNode &node);
154
Alexander Afanasyeve77db792012-08-09 11:10:58 -0700155} // ndnSIM
Alexander Afanasyev2b4c9472012-08-09 15:00:38 -0700156} // ndn
Alexander Afanasyeve77db792012-08-09 11:10:58 -0700157} // ns3
Alexander Afanasyev0845c092012-07-13 17:45:33 -0700158
159#endif