Alexander Afanasyev | c9d5c1a | 2012-11-21 18:00:26 -0800 | [diff] [blame] | 1 | /* -*- 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 Afanasyev | 0c39537 | 2014-12-20 15:54:02 -0800 | [diff] [blame] | 21 | #include "ndn-l3-tracer.hpp" |
Alexander Afanasyev | c9d5c1a | 2012-11-21 18:00:26 -0800 | [diff] [blame] | 22 | #include "ns3/node.h" |
| 23 | #include "ns3/packet.h" |
| 24 | #include "ns3/config.h" |
| 25 | #include "ns3/names.h" |
| 26 | #include "ns3/callback.h" |
| 27 | |
| 28 | #include <boost/lexical_cast.hpp> |
| 29 | |
Spyridon Mastorakis | da904f2 | 2014-11-05 16:23:33 -0800 | [diff] [blame^] | 30 | #include "ns3/ndnSIM/model/ndn-l3-protocol.hpp" |
Alexander Afanasyev | c9d5c1a | 2012-11-21 18:00:26 -0800 | [diff] [blame] | 31 | |
| 32 | namespace ns3 { |
| 33 | namespace ndn { |
Alexander Afanasyev | 37b84c5 | 2013-04-26 13:38:52 -0700 | [diff] [blame] | 34 | |
Alexander Afanasyev | be55cf6 | 2014-12-20 17:51:09 -0800 | [diff] [blame] | 35 | L3Tracer::L3Tracer(Ptr<Node> node) |
| 36 | : m_nodePtr(node) |
Alexander Afanasyev | c9d5c1a | 2012-11-21 18:00:26 -0800 | [diff] [blame] | 37 | { |
Spyridon Mastorakis | da904f2 | 2014-11-05 16:23:33 -0800 | [diff] [blame^] | 38 | m_node = boost::lexical_cast<std::string>(m_nodePtr->GetId()); |
Alexander Afanasyev | c9d5c1a | 2012-11-21 18:00:26 -0800 | [diff] [blame] | 39 | |
Alexander Afanasyev | be55cf6 | 2014-12-20 17:51:09 -0800 | [diff] [blame] | 40 | Connect(); |
Alexander Afanasyev | c9d5c1a | 2012-11-21 18:00:26 -0800 | [diff] [blame] | 41 | |
Spyridon Mastorakis | da904f2 | 2014-11-05 16:23:33 -0800 | [diff] [blame^] | 42 | std::string name = Names::FindName(node); |
Alexander Afanasyev | be55cf6 | 2014-12-20 17:51:09 -0800 | [diff] [blame] | 43 | if (!name.empty()) { |
| 44 | m_node = name; |
| 45 | } |
Alexander Afanasyev | c9d5c1a | 2012-11-21 18:00:26 -0800 | [diff] [blame] | 46 | } |
| 47 | |
Alexander Afanasyev | be55cf6 | 2014-12-20 17:51:09 -0800 | [diff] [blame] | 48 | L3Tracer::L3Tracer(const std::string& node) |
| 49 | : m_node(node) |
Alexander Afanasyev | c9d5c1a | 2012-11-21 18:00:26 -0800 | [diff] [blame] | 50 | { |
Alexander Afanasyev | be55cf6 | 2014-12-20 17:51:09 -0800 | [diff] [blame] | 51 | Connect(); |
Alexander Afanasyev | c9d5c1a | 2012-11-21 18:00:26 -0800 | [diff] [blame] | 52 | } |
| 53 | |
Alexander Afanasyev | be55cf6 | 2014-12-20 17:51:09 -0800 | [diff] [blame] | 54 | L3Tracer::~L3Tracer(){}; |
Alexander Afanasyev | c9d5c1a | 2012-11-21 18:00:26 -0800 | [diff] [blame] | 55 | |
| 56 | void |
Alexander Afanasyev | be55cf6 | 2014-12-20 17:51:09 -0800 | [diff] [blame] | 57 | L3Tracer::Connect() |
Alexander Afanasyev | c9d5c1a | 2012-11-21 18:00:26 -0800 | [diff] [blame] | 58 | { |
Spyridon Mastorakis | da904f2 | 2014-11-05 16:23:33 -0800 | [diff] [blame^] | 59 | Ptr<L3Protocol> l3 = m_nodePtr->GetObject<L3Protocol>(); |
Alexander Afanasyev | be55cf6 | 2014-12-20 17:51:09 -0800 | [diff] [blame] | 60 | |
Spyridon Mastorakis | da904f2 | 2014-11-05 16:23:33 -0800 | [diff] [blame^] | 61 | l3->TraceConnectWithoutContext("OutInterests", MakeCallback(&L3Tracer::OutInterests, this)); |
| 62 | l3->TraceConnectWithoutContext("InInterests", MakeCallback(&L3Tracer::InInterests, this)); |
| 63 | l3->TraceConnectWithoutContext("OutData", MakeCallback(&L3Tracer::OutData, this)); |
| 64 | l3->TraceConnectWithoutContext("InData", MakeCallback(&L3Tracer::InData, this)); |
Alexander Afanasyev | be55cf6 | 2014-12-20 17:51:09 -0800 | [diff] [blame] | 65 | |
Spyridon Mastorakis | da904f2 | 2014-11-05 16:23:33 -0800 | [diff] [blame^] | 66 | // // satisfied/timed out PIs |
| 67 | // l3->TraceConnectWithoutContext("SatisfiedInterests", |
| 68 | // MakeCallback(&L3Tracer::SatisfiedInterests, this)); |
| 69 | // l3->TraceConnectWithoutContext("TimedOutInterests", |
| 70 | // MakeCallback(&L3Tracer::TimedOutInterests, this)); |
Alexander Afanasyev | c9d5c1a | 2012-11-21 18:00:26 -0800 | [diff] [blame] | 71 | } |
| 72 | |
| 73 | } // namespace ndn |
| 74 | } // namespace ns3 |