blob: 84494d7b624402e7e550399aa8923068498e8d49 [file] [log] [blame]
Alexander Afanasyev31cb4692012-08-17 13:08:20 -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
22#ifndef NDNSIM_STATS_BASED_RANDOMIZED_INTEREST_ACCEPT_H
23#define NDNSIM_STATS_BASED_RANDOMIZED_INTEREST_ACCEPT_H
24
25#include "ns3/event-id.h"
26
Alexander Afanasyevcaeade22012-09-04 16:31:12 -070027#include "dynamic-limits.h"
Alexander Afanasyev31cb4692012-08-17 13:08:20 -070028
29namespace ns3 {
30namespace ndn {
31namespace fw {
32
33/**
34 * \ingroup ndn
35 * \brief Strategy implementing stats-based randomized accept for interests
36 *
37 * (prerequisite) Window-based limits should be enabled
38 *
39 * This strategy has several limitation to accept interest for further processing:
40 * - if per-fib-entry limit or per-face limit is exhausted, Interest will not be accepted
41 * - if the number of interests received from the incoming face is less than threshold, then no special handling
42 * - if this number is greater than threshold, an Interest will be accepted with probability equal to satisfaction ratio for this incoming face (overall per-face).
43 * (probability is shifted to allow small rate of acceptance (1% by default) of Interests from faces with 0 satisfaction ratio.
44 */
45class StatsBasedRandomizedInterestAccept :
Alexander Afanasyevcaeade22012-09-04 16:31:12 -070046 public DynamicLimits
Alexander Afanasyev31cb4692012-08-17 13:08:20 -070047{
48public:
49 static TypeId
50 GetTypeId ();
51
52 /**
53 * @brief Default constructor
54 */
55 StatsBasedRandomizedInterestAccept ();
56
57 virtual void
58 WillEraseTimedOutPendingInterest (Ptr<pit::Entry> pitEntry);
59
60protected:
61 virtual bool
Alexander Afanasyev5db92172012-08-21 16:52:07 -070062 TrySendOutInterest (Ptr<Face> inFace,
63 Ptr<Face> outFace,
64 Ptr<const InterestHeader> header,
65 Ptr<const Packet> origPacket,
66 Ptr<pit::Entry> pitEntry);
Alexander Afanasyev31cb4692012-08-17 13:08:20 -070067
68 virtual void
69 WillSatisfyPendingInterest (Ptr<Face> inFace,
70 Ptr<pit::Entry> pitEntry);
71
72 // from Object
73 void
74 DoDispose ();
75
76private:
77 double m_threshold;
78 double m_graceAcceptProbability;
79
80 typedef FwStats super;
81};
82
83
84} // namespace fw
85} // namespace ndn
86} // namespace ns3
87
88#endif // NDNSIM_STATS_BASED_RANDOMIZED_INTEREST_ACCEPT_H