blob: 6fc6b1611b6ae40b3d0255328ca2ab6ace54b20f [file] [log] [blame]
Alexander Afanasyev60a7b622014-12-20 17:04:07 -08001/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
2/**
3 * Copyright (c) 2011-2015 Regents of the University of California.
Alexander Afanasyevc9d5c1a2012-11-21 18:00:26 -08004 *
Alexander Afanasyev60a7b622014-12-20 17:04:07 -08005 * This file is part of ndnSIM. See AUTHORS for complete list of ndnSIM authors and
6 * contributors.
Alexander Afanasyevc9d5c1a2012-11-21 18:00:26 -08007 *
Alexander Afanasyev60a7b622014-12-20 17:04:07 -08008 * ndnSIM is free software: you can redistribute it and/or modify it under the terms
9 * of the GNU General Public License as published by the Free Software Foundation,
10 * either version 3 of the License, or (at your option) any later version.
Alexander Afanasyevc9d5c1a2012-11-21 18:00:26 -080011 *
Alexander Afanasyev60a7b622014-12-20 17:04:07 -080012 * ndnSIM is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY;
13 * without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
14 * PURPOSE. See the GNU General Public License for more details.
Alexander Afanasyevc9d5c1a2012-11-21 18:00:26 -080015 *
Alexander Afanasyev60a7b622014-12-20 17:04:07 -080016 * You should have received a copy of the GNU General Public License along with
17 * ndnSIM, e.g., in COPYING.md file. If not, see <http://www.gnu.org/licenses/>.
18 **/
Alexander Afanasyevc9d5c1a2012-11-21 18:00:26 -080019
Alexander Afanasyev0c395372014-12-20 15:54:02 -080020#include "ndn-l3-tracer.hpp"
Alexander Afanasyevc9d5c1a2012-11-21 18:00:26 -080021#include "ns3/node.h"
22#include "ns3/packet.h"
23#include "ns3/config.h"
24#include "ns3/names.h"
25#include "ns3/callback.h"
26
27#include <boost/lexical_cast.hpp>
28
Spyridon Mastorakisda904f22014-11-05 16:23:33 -080029#include "ns3/ndnSIM/model/ndn-l3-protocol.hpp"
Alexander Afanasyevc9d5c1a2012-11-21 18:00:26 -080030
31namespace ns3 {
32namespace ndn {
Alexander Afanasyev37b84c52013-04-26 13:38:52 -070033
Alexander Afanasyevbe55cf62014-12-20 17:51:09 -080034L3Tracer::L3Tracer(Ptr<Node> node)
35 : m_nodePtr(node)
Alexander Afanasyevc9d5c1a2012-11-21 18:00:26 -080036{
Spyridon Mastorakisda904f22014-11-05 16:23:33 -080037 m_node = boost::lexical_cast<std::string>(m_nodePtr->GetId());
Alexander Afanasyevc9d5c1a2012-11-21 18:00:26 -080038
Alexander Afanasyevbe55cf62014-12-20 17:51:09 -080039 Connect();
Alexander Afanasyevc9d5c1a2012-11-21 18:00:26 -080040
Spyridon Mastorakisda904f22014-11-05 16:23:33 -080041 std::string name = Names::FindName(node);
Alexander Afanasyevbe55cf62014-12-20 17:51:09 -080042 if (!name.empty()) {
43 m_node = name;
44 }
Alexander Afanasyevc9d5c1a2012-11-21 18:00:26 -080045}
46
Alexander Afanasyevbe55cf62014-12-20 17:51:09 -080047L3Tracer::L3Tracer(const std::string& node)
48 : m_node(node)
Alexander Afanasyevc9d5c1a2012-11-21 18:00:26 -080049{
Alexander Afanasyevbe55cf62014-12-20 17:51:09 -080050 Connect();
Alexander Afanasyevc9d5c1a2012-11-21 18:00:26 -080051}
52
Alexander Afanasyevbe55cf62014-12-20 17:51:09 -080053L3Tracer::~L3Tracer(){};
Alexander Afanasyevc9d5c1a2012-11-21 18:00:26 -080054
55void
Alexander Afanasyevbe55cf62014-12-20 17:51:09 -080056L3Tracer::Connect()
Alexander Afanasyevc9d5c1a2012-11-21 18:00:26 -080057{
Spyridon Mastorakisda904f22014-11-05 16:23:33 -080058 Ptr<L3Protocol> l3 = m_nodePtr->GetObject<L3Protocol>();
Alexander Afanasyevbe55cf62014-12-20 17:51:09 -080059
Spyridon Mastorakisda904f22014-11-05 16:23:33 -080060 l3->TraceConnectWithoutContext("OutInterests", MakeCallback(&L3Tracer::OutInterests, this));
61 l3->TraceConnectWithoutContext("InInterests", MakeCallback(&L3Tracer::InInterests, this));
62 l3->TraceConnectWithoutContext("OutData", MakeCallback(&L3Tracer::OutData, this));
63 l3->TraceConnectWithoutContext("InData", MakeCallback(&L3Tracer::InData, this));
Alexander Afanasyevbe55cf62014-12-20 17:51:09 -080064
Spyridon Mastorakisda904f22014-11-05 16:23:33 -080065 // // satisfied/timed out PIs
66 // l3->TraceConnectWithoutContext("SatisfiedInterests",
67 // MakeCallback(&L3Tracer::SatisfiedInterests, this));
68 // l3->TraceConnectWithoutContext("TimedOutInterests",
69 // MakeCallback(&L3Tracer::TimedOutInterests, this));
Alexander Afanasyevc9d5c1a2012-11-21 18:00:26 -080070}
71
72} // namespace ndn
73} // namespace ns3