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 | * Ilya Moiseenko <iliamo@cs.ucla.edu> |
| 20 | */ |
| 21 | |
| 22 | #include "fw-stats.h" |
| 23 | |
| 24 | #include "ns3/ccnx-interest-header.h" |
| 25 | #include "ns3/ccnx-content-object-header.h" |
| 26 | #include "ns3/ccnx-pit.h" |
| 27 | #include "ns3/ccnx-pit-entry.h" |
| 28 | |
| 29 | #include "ns3/assert.h" |
| 30 | #include "ns3/log.h" |
| 31 | |
| 32 | #include <boost/foreach.hpp> |
| 33 | #include <boost/lambda/lambda.hpp> |
| 34 | #include <boost/lambda/bind.hpp> |
| 35 | namespace ll = boost::lambda; |
| 36 | |
| 37 | NS_LOG_COMPONENT_DEFINE ("NdnSimFwStats"); |
| 38 | |
| 39 | namespace ns3 { |
| 40 | namespace ndnSIM { |
| 41 | |
| 42 | NS_OBJECT_ENSURE_REGISTERED (FwStats); |
| 43 | |
| 44 | TypeId |
| 45 | FwStats::GetTypeId (void) |
| 46 | { |
| 47 | static TypeId tid = TypeId ("ns3::ndnSIM::FwStats") |
| 48 | .SetGroupName ("Ccnx") |
| 49 | .SetParent <BestRoute> () |
| 50 | .AddConstructor <FwStats> () |
| 51 | ; |
| 52 | return tid; |
| 53 | } |
| 54 | |
| 55 | FwStats::FwStats () |
| 56 | { |
| 57 | } |
| 58 | |
| 59 | void |
| 60 | FwStats::DidCreatePitEntry (const Ptr<CcnxFace> &incomingFace, |
| 61 | Ptr<CcnxInterestHeader> header, |
| 62 | const Ptr<const Packet> &packet, |
| 63 | Ptr<CcnxPitEntry> pitEntry) |
| 64 | { |
| 65 | super::DidCreatePitEntry (incomingFace, header, packet, pitEntry); |
| 66 | |
| 67 | m_stats.NewPitEntry (header->GetName ()); |
| 68 | m_stats.Incoming (header->GetName (), incomingFace); |
| 69 | } |
| 70 | |
| 71 | void |
| 72 | FwStats::WillSatisfyPendingInterest (const Ptr<CcnxFace> &incomingFace, |
| 73 | Ptr<CcnxPitEntry> pitEntry) |
| 74 | { |
| 75 | super::WillSatisfyPendingInterest (incomingFace, pitEntry); |
| 76 | |
| 77 | m_stats.Satisfy (pitEntry->GetPrefix ()); |
| 78 | } |
| 79 | |
| 80 | void |
| 81 | FwStats::DidSendOutInterest (const Ptr<CcnxFace> &outgoingFace, |
| 82 | Ptr<CcnxInterestHeader> header, |
| 83 | Ptr<CcnxPitEntry> pitEntry) |
| 84 | { |
| 85 | super::DidSendOutInterest (outgoingFace, header, pitEntry); |
| 86 | |
| 87 | m_stats.Outgoing (header->GetName (), outgoingFace); |
| 88 | } |
| 89 | |
| 90 | void |
| 91 | FwStats::WillErasePendingInterest (Ptr<CcnxPitEntry> pitEntry) |
| 92 | { |
| 93 | super::WillErasePendingInterest (pitEntry); |
| 94 | |
| 95 | m_stats.Timeout (pitEntry->GetPrefix ()); |
| 96 | } |
| 97 | |
| 98 | |
| 99 | } // namespace ndnSIM |
| 100 | } // namespace ns3 |