blob: b8ca50d2f548ad55ea7155dc62788e41d6019d46 [file] [log] [blame]
Alexander Afanasyevea9b3e62012-08-13 19:02:54 -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 _NDN_LIMITS_H_
22#define _NDN_LIMITS_H_
23
24#include "ns3/ptr.h"
25#include "ns3/object.h"
26#include "ns3/nstime.h"
27#include "ns3/traced-value.h"
28
29namespace ns3 {
30namespace ndn {
31
32/**
33 * \ingroup ndn
34 * \brief Structure to manage limits for outstanding interests
35 */
36class Limits :
37 public Object
38{
39public:
40 static TypeId
41 GetTypeId ();
42
43 /**
44 * \brief Constructor
45 * \param prefix smart pointer to the prefix for the FIB entry
46 */
47 Limits ()
48 : m_maxLimit (0)
49 , m_curMaxLimit (0)
50 , m_outstanding (0)
51 { }
52
53 /**
54 * Set per-prefix limit
55 */
56 void
57 SetMaxLimit (uint32_t max);
58
59 /**
60 * Decay current limit (exponential decaying)
61 */
62 void
63 DecayCurrentLimit ();
64
65 /**
66 * Increase current limit (additive increase)
67 */
68 void
69 IncreaseLimit ();
70
71 /**
72 * Decrease current limit (multiplicative decrease)
73 */
74 void
75 DecreaseLimit ();
76
77 ////////////////////////////////////////////////////////////////////////////
78 ////////////////////////////////////////////////////////////////////////////
79 ////////////////////////////////////////////////////////////////////////////
80
81 /**
82 * Check if new interest can be send out, if yes, number of outstanding will be increased
83 */
84 bool
85 IsBelowLimit ();
86
87 /**
88 * Remove outstanding interests
89 */
90 void
91 RemoveOutstanding ();
92
93public:
94 uint32_t m_maxLimit;
95
96 TracedValue< double > m_curMaxLimit;
97 TracedValue< uint32_t > m_outstanding;
98
99 Time m_lastDecrease;
100 Time m_lastDecay;
101};
102
103} // namespace ndn
104} // namespace ns3
105
106#endif // _NDN_LIMITS_H_