blob: 25e9f07ed1b17f0b82d92d95a260c16f3f7cb9a1 [file] [log] [blame]
Alexander Afanasyevc9d5c1a2012-11-21 18:00:26 -08001/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil -*- */
2/*
3 * Copyright (c) 2011 UCLA
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
Alexander Afanasyev0c395372014-12-20 15:54:02 -080021#include "ndn-l3-tracer.hpp"
Alexander Afanasyevc9d5c1a2012-11-21 18:00:26 -080022#include "ns3/node.h"
23#include "ns3/packet.h"
24#include "ns3/config.h"
25#include "ns3/names.h"
26#include "ns3/callback.h"
Alexander Afanasyev0c395372014-12-20 15:54:02 -080027#include "ns3/ndn-forwarding-strategy.hpp"
Alexander Afanasyevc9d5c1a2012-11-21 18:00:26 -080028
29#include <boost/lexical_cast.hpp>
30
Alexander Afanasyev0c395372014-12-20 15:54:02 -080031#include "ns3/ndn-face.hpp"
Alexander Afanasyev0c395372014-12-20 15:54:02 -080032#include "ns3/ndn-pit-entry.hpp"
Alexander Afanasyevc9d5c1a2012-11-21 18:00:26 -080033
34using namespace std;
35
36namespace ns3 {
37namespace ndn {
Alexander Afanasyev37b84c52013-04-26 13:38:52 -070038
Alexander Afanasyevbe55cf62014-12-20 17:51:09 -080039L3Tracer::L3Tracer(Ptr<Node> node)
40 : m_nodePtr(node)
Alexander Afanasyevc9d5c1a2012-11-21 18:00:26 -080041{
Alexander Afanasyevbe55cf62014-12-20 17:51:09 -080042 m_node = boost::lexical_cast<string>(m_nodePtr->GetId());
Alexander Afanasyevc9d5c1a2012-11-21 18:00:26 -080043
Alexander Afanasyevbe55cf62014-12-20 17:51:09 -080044 Connect();
Alexander Afanasyevc9d5c1a2012-11-21 18:00:26 -080045
Alexander Afanasyevbe55cf62014-12-20 17:51:09 -080046 string name = Names::FindName(node);
47 if (!name.empty()) {
48 m_node = name;
49 }
Alexander Afanasyevc9d5c1a2012-11-21 18:00:26 -080050}
51
Alexander Afanasyevbe55cf62014-12-20 17:51:09 -080052L3Tracer::L3Tracer(const std::string& node)
53 : m_node(node)
Alexander Afanasyevc9d5c1a2012-11-21 18:00:26 -080054{
Alexander Afanasyevbe55cf62014-12-20 17:51:09 -080055 Connect();
Alexander Afanasyevc9d5c1a2012-11-21 18:00:26 -080056}
57
Alexander Afanasyevbe55cf62014-12-20 17:51:09 -080058L3Tracer::~L3Tracer(){};
Alexander Afanasyevc9d5c1a2012-11-21 18:00:26 -080059
60void
Alexander Afanasyevbe55cf62014-12-20 17:51:09 -080061L3Tracer::Connect()
Alexander Afanasyevc9d5c1a2012-11-21 18:00:26 -080062{
Alexander Afanasyevbe55cf62014-12-20 17:51:09 -080063 Ptr<ForwardingStrategy> fw = m_nodePtr->GetObject<ForwardingStrategy>();
64
65 fw->TraceConnectWithoutContext("OutInterests", MakeCallback(&L3Tracer::OutInterests, this));
66 fw->TraceConnectWithoutContext("InInterests", MakeCallback(&L3Tracer::InInterests, this));
67 fw->TraceConnectWithoutContext("DropInterests", MakeCallback(&L3Tracer::DropInterests, this));
68
69 fw->TraceConnectWithoutContext("OutData", MakeCallback(&L3Tracer::OutData, this));
70 fw->TraceConnectWithoutContext("InData", MakeCallback(&L3Tracer::InData, this));
71 fw->TraceConnectWithoutContext("DropData", MakeCallback(&L3Tracer::DropData, this));
Alexander Afanasyevc9d5c1a2012-11-21 18:00:26 -080072
73 // only for some strategies
Alexander Afanasyevbe55cf62014-12-20 17:51:09 -080074 fw->TraceConnectWithoutContext("OutNacks", MakeCallback(&L3Tracer::OutNacks, this));
75 fw->TraceConnectWithoutContext("InNacks", MakeCallback(&L3Tracer::InNacks, this));
76 fw->TraceConnectWithoutContext("DropNacks", MakeCallback(&L3Tracer::DropNacks, this));
77
Alexander Afanasyev37b84c52013-04-26 13:38:52 -070078 // satisfied/timed out PIs
Alexander Afanasyevbe55cf62014-12-20 17:51:09 -080079 fw->TraceConnectWithoutContext("SatisfiedInterests",
80 MakeCallback(&L3Tracer::SatisfiedInterests, this));
81 fw->TraceConnectWithoutContext("TimedOutInterests",
82 MakeCallback(&L3Tracer::TimedOutInterests, this));
Alexander Afanasyevc9d5c1a2012-11-21 18:00:26 -080083}
84
85} // namespace ndn
86} // namespace ns3