Alexander Afanasyev | 31cb469 | 2012-08-17 13:08:20 -0700 | [diff] [blame] | 1 | /* -*- 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 | |
| 27 | #include "fw-stats.h" |
| 28 | |
| 29 | namespace ns3 { |
| 30 | namespace ndn { |
| 31 | namespace 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 | */ |
| 45 | class StatsBasedRandomizedInterestAccept : |
| 46 | public FwStats |
| 47 | { |
| 48 | public: |
| 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 | |
| 60 | protected: |
| 61 | virtual bool |
| 62 | WillSendOutInterest (Ptr<Face> outFace, |
| 63 | Ptr<const InterestHeader> header, |
| 64 | Ptr<pit::Entry> pitEntry); |
| 65 | |
| 66 | virtual void |
| 67 | WillSatisfyPendingInterest (Ptr<Face> inFace, |
| 68 | Ptr<pit::Entry> pitEntry); |
| 69 | |
| 70 | // from Object |
| 71 | void |
| 72 | DoDispose (); |
| 73 | |
| 74 | private: |
| 75 | double m_threshold; |
| 76 | double m_graceAcceptProbability; |
| 77 | |
| 78 | typedef FwStats super; |
| 79 | }; |
| 80 | |
| 81 | |
| 82 | } // namespace fw |
| 83 | } // namespace ndn |
| 84 | } // namespace ns3 |
| 85 | |
| 86 | #endif // NDNSIM_STATS_BASED_RANDOMIZED_INTEREST_ACCEPT_H |