Alexander Afanasyev | f249a19 | 2012-07-18 16:52:51 -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_FW_STATS_H |
| 23 | #define NDNSIM_FW_STATS_H |
| 24 | |
Alexander Afanasyev | e55d1e3 | 2012-07-19 15:33:05 -0700 | [diff] [blame] | 25 | #include "ns3/event-id.h" |
| 26 | |
Alexander Afanasyev | f249a19 | 2012-07-18 16:52:51 -0700 | [diff] [blame] | 27 | #include "best-route.h" |
Alexander Afanasyev | 1a2df6a | 2012-08-17 13:21:51 -0700 | [diff] [blame] | 28 | #include "../../utils/stats/stats-tree.h" |
Alexander Afanasyev | f249a19 | 2012-07-18 16:52:51 -0700 | [diff] [blame] | 29 | |
| 30 | namespace ns3 { |
Alexander Afanasyev | 2b4c947 | 2012-08-09 15:00:38 -0700 | [diff] [blame] | 31 | namespace ndn { |
| 32 | namespace fw { |
Alexander Afanasyev | f249a19 | 2012-07-18 16:52:51 -0700 | [diff] [blame] | 33 | |
| 34 | /** |
Alexander Afanasyev | 4aac557 | 2012-08-09 10:49:55 -0700 | [diff] [blame] | 35 | * \ingroup ndn |
Alexander Afanasyev | e55d1e3 | 2012-07-19 15:33:05 -0700 | [diff] [blame] | 36 | * \brief Strategy based on best route and adding statistics gathering capabilities |
Alexander Afanasyev | f249a19 | 2012-07-18 16:52:51 -0700 | [diff] [blame] | 37 | */ |
| 38 | class FwStats : |
| 39 | public BestRoute |
| 40 | { |
| 41 | public: |
| 42 | static TypeId |
Alexander Afanasyev | 2b4c947 | 2012-08-09 15:00:38 -0700 | [diff] [blame] | 43 | GetTypeId (); |
Alexander Afanasyev | f249a19 | 2012-07-18 16:52:51 -0700 | [diff] [blame] | 44 | |
| 45 | /** |
| 46 | * @brief Default constructor |
| 47 | */ |
| 48 | FwStats (); |
| 49 | |
Alexander Afanasyev | b1b7f5d | 2012-08-09 09:59:43 -0700 | [diff] [blame] | 50 | inline |
Alexander Afanasyev | 2b4c947 | 2012-08-09 15:00:38 -0700 | [diff] [blame] | 51 | const ndnSIM::StatsTree & |
Alexander Afanasyev | b1b7f5d | 2012-08-09 09:59:43 -0700 | [diff] [blame] | 52 | GetStatsTree () const; |
| 53 | |
Alexander Afanasyev | 1c0248b | 2012-07-24 15:59:50 -0700 | [diff] [blame] | 54 | virtual void |
Alexander Afanasyev | 31cb469 | 2012-08-17 13:08:20 -0700 | [diff] [blame] | 55 | OnInterest (Ptr<Face> face, |
| 56 | Ptr<const InterestHeader> header, |
| 57 | Ptr<const Packet> origPacket); |
Alexander Afanasyev | 1c0248b | 2012-07-24 15:59:50 -0700 | [diff] [blame] | 58 | |
| 59 | virtual void |
Alexander Afanasyev | 31cb469 | 2012-08-17 13:08:20 -0700 | [diff] [blame] | 60 | OnData (Ptr<Face> face, |
| 61 | Ptr<const ContentObjectHeader> header, |
| 62 | Ptr<Packet> payload, |
| 63 | Ptr<const Packet> origPacket); |
Alexander Afanasyev | 33364b6 | 2012-07-26 17:53:56 -0700 | [diff] [blame] | 64 | |
| 65 | virtual void |
Alexander Afanasyev | 2b4c947 | 2012-08-09 15:00:38 -0700 | [diff] [blame] | 66 | RemoveFace (Ptr<Face> face); |
Alexander Afanasyev | 33364b6 | 2012-07-26 17:53:56 -0700 | [diff] [blame] | 67 | |
Alexander Afanasyev | f249a19 | 2012-07-18 16:52:51 -0700 | [diff] [blame] | 68 | protected: |
| 69 | virtual void |
Alexander Afanasyev | 31cb469 | 2012-08-17 13:08:20 -0700 | [diff] [blame] | 70 | DidCreatePitEntry (Ptr<Face> inFace, |
| 71 | Ptr<const InterestHeader> header, |
| 72 | Ptr<const Packet> packet, |
Alexander Afanasyev | 2b4c947 | 2012-08-09 15:00:38 -0700 | [diff] [blame] | 73 | Ptr<pit::Entry> pitEntry); |
Alexander Afanasyev | f249a19 | 2012-07-18 16:52:51 -0700 | [diff] [blame] | 74 | |
| 75 | virtual void |
Alexander Afanasyev | 31cb469 | 2012-08-17 13:08:20 -0700 | [diff] [blame] | 76 | FailedToCreatePitEntry (Ptr<Face> inFace, |
| 77 | Ptr<const InterestHeader> header, |
| 78 | Ptr<const Packet> packet); |
Alexander Afanasyev | 77495a9 | 2012-07-20 15:38:29 -0700 | [diff] [blame] | 79 | |
| 80 | virtual void |
Alexander Afanasyev | 31cb469 | 2012-08-17 13:08:20 -0700 | [diff] [blame] | 81 | WillSatisfyPendingInterest (Ptr<Face> inFace, |
Alexander Afanasyev | 2b4c947 | 2012-08-09 15:00:38 -0700 | [diff] [blame] | 82 | Ptr<pit::Entry> pitEntry); |
Alexander Afanasyev | f249a19 | 2012-07-18 16:52:51 -0700 | [diff] [blame] | 83 | |
| 84 | virtual void |
Alexander Afanasyev | 31cb469 | 2012-08-17 13:08:20 -0700 | [diff] [blame] | 85 | DidSendOutInterest (Ptr<Face> outFace, |
| 86 | Ptr<const InterestHeader> header, |
| 87 | Ptr<const Packet> origPacket, |
Alexander Afanasyev | 2b4c947 | 2012-08-09 15:00:38 -0700 | [diff] [blame] | 88 | Ptr<pit::Entry> pitEntry); |
Alexander Afanasyev | f249a19 | 2012-07-18 16:52:51 -0700 | [diff] [blame] | 89 | |
| 90 | virtual void |
Alexander Afanasyev | 31cb469 | 2012-08-17 13:08:20 -0700 | [diff] [blame] | 91 | DidSendOutData (Ptr<Face> outFace, |
Alexander Afanasyev | 2b4c947 | 2012-08-09 15:00:38 -0700 | [diff] [blame] | 92 | Ptr<const ContentObjectHeader> header, |
Alexander Afanasyev | 1c0248b | 2012-07-24 15:59:50 -0700 | [diff] [blame] | 93 | Ptr<const Packet> payload, |
Alexander Afanasyev | 31cb469 | 2012-08-17 13:08:20 -0700 | [diff] [blame] | 94 | Ptr<const Packet> origPacket, |
| 95 | Ptr<pit::Entry> pitEntry); |
Alexander Afanasyev | 1c0248b | 2012-07-24 15:59:50 -0700 | [diff] [blame] | 96 | |
| 97 | virtual void |
Alexander Afanasyev | ea9b3e6 | 2012-08-13 19:02:54 -0700 | [diff] [blame] | 98 | WillEraseTimedOutPendingInterest (Ptr<pit::Entry> pitEntry); |
Alexander Afanasyev | e55d1e3 | 2012-07-19 15:33:05 -0700 | [diff] [blame] | 99 | |
Alexander Afanasyev | 70426a0 | 2012-08-15 15:39:18 -0700 | [diff] [blame] | 100 | virtual void |
Alexander Afanasyev | 31cb469 | 2012-08-17 13:08:20 -0700 | [diff] [blame] | 101 | DidExhaustForwardingOptions (Ptr<Face> inFace, |
| 102 | Ptr<const InterestHeader> header, |
| 103 | Ptr<const Packet> origPacket, |
Alexander Afanasyev | 70426a0 | 2012-08-15 15:39:18 -0700 | [diff] [blame] | 104 | Ptr<pit::Entry> pitEntry); |
Alexander Afanasyev | 187cba2 | 2012-08-28 11:16:52 -0700 | [diff] [blame] | 105 | |
| 106 | virtual void |
| 107 | DidReceiveValidNack (Ptr<Face> inFace, |
| 108 | uint32_t nackCode, |
| 109 | Ptr<pit::Entry> pitEntry); |
Alexander Afanasyev | 70426a0 | 2012-08-15 15:39:18 -0700 | [diff] [blame] | 110 | |
Alexander Afanasyev | e55d1e3 | 2012-07-19 15:33:05 -0700 | [diff] [blame] | 111 | // from Object |
| 112 | void |
| 113 | DoDispose (); |
| 114 | |
| 115 | private: |
| 116 | void |
| 117 | RefreshStats (); |
| 118 | |
| 119 | void |
| 120 | ScheduleRefreshingIfNecessary (); |
| 121 | |
Alexander Afanasyev | f249a19 | 2012-07-18 16:52:51 -0700 | [diff] [blame] | 122 | private: |
Alexander Afanasyev | 2b4c947 | 2012-08-09 15:00:38 -0700 | [diff] [blame] | 123 | ndnSIM::StatsTree m_stats; |
Alexander Afanasyev | e55d1e3 | 2012-07-19 15:33:05 -0700 | [diff] [blame] | 124 | EventId m_statsRefreshEvent; |
Alexander Afanasyev | 77495a9 | 2012-07-20 15:38:29 -0700 | [diff] [blame] | 125 | |
Alexander Afanasyev | 2b4c947 | 2012-08-09 15:00:38 -0700 | [diff] [blame] | 126 | TracedCallback< Ptr<ForwardingStrategy>, |
| 127 | const ndnSIM::StatsTree & > m_statsTrace; |
Alexander Afanasyev | f249a19 | 2012-07-18 16:52:51 -0700 | [diff] [blame] | 128 | |
| 129 | typedef BestRoute super; |
| 130 | }; |
| 131 | |
Alexander Afanasyev | 2b4c947 | 2012-08-09 15:00:38 -0700 | [diff] [blame] | 132 | const ndnSIM::StatsTree & |
Alexander Afanasyev | b1b7f5d | 2012-08-09 09:59:43 -0700 | [diff] [blame] | 133 | FwStats::GetStatsTree () const |
| 134 | { |
| 135 | return m_stats; |
| 136 | } |
| 137 | |
Alexander Afanasyev | 2b4c947 | 2012-08-09 15:00:38 -0700 | [diff] [blame] | 138 | } // namespace fw |
| 139 | } // namespace ndn |
Alexander Afanasyev | f249a19 | 2012-07-18 16:52:51 -0700 | [diff] [blame] | 140 | } // namespace ns3 |
| 141 | |
| 142 | #endif // NDNSIM_FW_STATS_H |