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 |
Alexander Afanasyev | 5db9217 | 2012-08-21 16:52:07 -0700 | [diff] [blame] | 62 | TrySendOutInterest (Ptr<Face> inFace, |
| 63 | Ptr<Face> outFace, |
| 64 | Ptr<const InterestHeader> header, |
| 65 | Ptr<const Packet> origPacket, |
| 66 | Ptr<pit::Entry> pitEntry); |
Alexander Afanasyev | 31cb469 | 2012-08-17 13:08:20 -0700 | [diff] [blame] | 67 | |
| 68 | virtual void |
| 69 | WillSatisfyPendingInterest (Ptr<Face> inFace, |
| 70 | Ptr<pit::Entry> pitEntry); |
| 71 | |
| 72 | // from Object |
| 73 | void |
| 74 | DoDispose (); |
| 75 | |
| 76 | private: |
| 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 |