blob: b00173a3ebedf80795b2f66a15083f04cf67923f [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
22#ifndef NDNSIM_PER_FIB_LIMITS_H
23#define NDNSIM_PER_FIB_LIMITS_H
24
25#include "ns3/event-id.h"
26
27#include "fw-stats.h"
Alexander Afanasyev5db92172012-08-21 16:52:07 -070028#include "../../utils/ndn-pit-queue.h"
Alexander Afanasyevea9b3e62012-08-13 19:02:54 -070029
30namespace ns3 {
31namespace ndn {
32namespace fw {
33
34/**
35 * \ingroup ndn
36 * \brief Strategy implementing per-FIB entry limits
37 */
38class PerFibLimits :
39 public FwStats
40{
Alexander Afanasyev31cb4692012-08-17 13:08:20 -070041private:
42 typedef FwStats super;
43
Alexander Afanasyevea9b3e62012-08-13 19:02:54 -070044public:
45 static TypeId
46 GetTypeId ();
47
48 /**
49 * @brief Default constructor
50 */
51 PerFibLimits ();
52
53 virtual void
Alexander Afanasyevb1ec2492012-08-28 17:33:33 -070054 OnInterest (Ptr<Face> face,
55 Ptr<const InterestHeader> header,
56 Ptr<const Packet> origPacket);
57
58 virtual void
Alexander Afanasyevea9b3e62012-08-13 19:02:54 -070059 WillEraseTimedOutPendingInterest (Ptr<pit::Entry> pitEntry);
60
Alexander Afanasyev5db92172012-08-21 16:52:07 -070061 virtual void
62 RemoveFace (Ptr<Face> face);
63
Alexander Afanasyevea9b3e62012-08-13 19:02:54 -070064protected:
65 virtual bool
Alexander Afanasyev5db92172012-08-21 16:52:07 -070066 TrySendOutInterest (Ptr<Face> inFace,
67 Ptr<Face> outFace,
68 Ptr<const InterestHeader> header,
69 Ptr<const Packet> origPacket,
70 Ptr<pit::Entry> pitEntry);
Alexander Afanasyevea9b3e62012-08-13 19:02:54 -070071
72 virtual void
Alexander Afanasyev31cb4692012-08-17 13:08:20 -070073 WillSatisfyPendingInterest (Ptr<Face> inFace,
Alexander Afanasyevea9b3e62012-08-13 19:02:54 -070074 Ptr<pit::Entry> pitEntry);
75
Alexander Afanasyev08b7d9e2012-08-23 10:53:46 -070076 virtual void
77 DidReceiveValidNack (Ptr<Face> inFace,
78 uint32_t nackCode,
79 Ptr<pit::Entry> pitEntry);
80
Alexander Afanasyev5db92172012-08-21 16:52:07 -070081private:
82 void
83 ProcessFromQueue ();
Alexander Afanasyevb1ec2492012-08-28 17:33:33 -070084
85 void
86 AnnounceLimits ();
87
88 void
89 ApplyAnnouncedLimit (Ptr<Face> inFace,
90 Ptr<const InterestHeader> header);
Alexander Afanasyev5db92172012-08-21 16:52:07 -070091
Alexander Afanasyevea9b3e62012-08-13 19:02:54 -070092 // from Object
Alexander Afanasyevb1ec2492012-08-28 17:33:33 -070093 virtual void
94 NotifyNewAggregate (); ///< @brief Even when object is aggregated to another Object
95
96 virtual void
Alexander Afanasyevea9b3e62012-08-13 19:02:54 -070097 DoDispose ();
Alexander Afanasyev5db92172012-08-21 16:52:07 -070098
Alexander Afanasyevea9b3e62012-08-13 19:02:54 -070099private:
Alexander Afanasyev5db92172012-08-21 16:52:07 -0700100 typedef std::map< Ptr<Face>, PitQueue > PitQueueMap;
101 PitQueueMap m_pitQueues; // per-outgoing face pit queue
Alexander Afanasyevb1ec2492012-08-28 17:33:33 -0700102
Alexander Afanasyevc7719612012-08-30 17:42:20 -0700103 bool m_announceLimits;
104
Alexander Afanasyevb1ec2492012-08-28 17:33:33 -0700105 EventId m_announceEvent;
Alexander Afanasyevea9b3e62012-08-13 19:02:54 -0700106};
107
108
109} // namespace fw
110} // namespace ndn
111} // namespace ns3
112
113#endif // NDNSIM_PER_FIB_LIMITS_H