blob: 6092682a36eef00360e2bc968f30a408be9e3304 [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 Afanasyev8db3cba2012-09-11 16:33:44 -070046 public FwStats
Alexander Afanasyev31cb4692012-08-17 13:08:20 -070047{
48public:
Alexander Afanasyev8db3cba2012-09-11 16:33:44 -070049 typedef FwStats super;
50
Alexander Afanasyev31cb4692012-08-17 13:08:20 -070051 static TypeId
52 GetTypeId ();
53
54 /**
55 * @brief Default constructor
56 */
57 StatsBasedRandomizedInterestAccept ();
58
59 virtual void
60 WillEraseTimedOutPendingInterest (Ptr<pit::Entry> pitEntry);
61
62protected:
63 virtual bool
Alexander Afanasyev5db92172012-08-21 16:52:07 -070064 TrySendOutInterest (Ptr<Face> inFace,
65 Ptr<Face> outFace,
66 Ptr<const InterestHeader> header,
67 Ptr<const Packet> origPacket,
68 Ptr<pit::Entry> pitEntry);
Alexander Afanasyev31cb4692012-08-17 13:08:20 -070069
70 virtual void
71 WillSatisfyPendingInterest (Ptr<Face> inFace,
72 Ptr<pit::Entry> pitEntry);
73
74 // from Object
75 void
76 DoDispose ();
77
78private:
79 double m_threshold;
80 double m_graceAcceptProbability;
Alexander Afanasyev31cb4692012-08-17 13:08:20 -070081};
82
83
84} // namespace fw
85} // namespace ndn
86} // namespace ns3
87
88#endif // NDNSIM_STATS_BASED_RANDOMIZED_INTEREST_ACCEPT_H