blob: 619b76eb8a7f72f0c30312d77ec0abe0838383a2 [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"
27
28#include <boost/lexical_cast.hpp>
29
Spyridon Mastorakisda904f22014-11-05 16:23:33 -080030#include "ns3/ndnSIM/model/ndn-l3-protocol.hpp"
Alexander Afanasyevc9d5c1a2012-11-21 18:00:26 -080031
32namespace ns3 {
33namespace ndn {
Alexander Afanasyev37b84c52013-04-26 13:38:52 -070034
Alexander Afanasyevbe55cf62014-12-20 17:51:09 -080035L3Tracer::L3Tracer(Ptr<Node> node)
36 : m_nodePtr(node)
Alexander Afanasyevc9d5c1a2012-11-21 18:00:26 -080037{
Spyridon Mastorakisda904f22014-11-05 16:23:33 -080038 m_node = boost::lexical_cast<std::string>(m_nodePtr->GetId());
Alexander Afanasyevc9d5c1a2012-11-21 18:00:26 -080039
Alexander Afanasyevbe55cf62014-12-20 17:51:09 -080040 Connect();
Alexander Afanasyevc9d5c1a2012-11-21 18:00:26 -080041
Spyridon Mastorakisda904f22014-11-05 16:23:33 -080042 std::string name = Names::FindName(node);
Alexander Afanasyevbe55cf62014-12-20 17:51:09 -080043 if (!name.empty()) {
44 m_node = name;
45 }
Alexander Afanasyevc9d5c1a2012-11-21 18:00:26 -080046}
47
Alexander Afanasyevbe55cf62014-12-20 17:51:09 -080048L3Tracer::L3Tracer(const std::string& node)
49 : m_node(node)
Alexander Afanasyevc9d5c1a2012-11-21 18:00:26 -080050{
Alexander Afanasyevbe55cf62014-12-20 17:51:09 -080051 Connect();
Alexander Afanasyevc9d5c1a2012-11-21 18:00:26 -080052}
53
Alexander Afanasyevbe55cf62014-12-20 17:51:09 -080054L3Tracer::~L3Tracer(){};
Alexander Afanasyevc9d5c1a2012-11-21 18:00:26 -080055
56void
Alexander Afanasyevbe55cf62014-12-20 17:51:09 -080057L3Tracer::Connect()
Alexander Afanasyevc9d5c1a2012-11-21 18:00:26 -080058{
Spyridon Mastorakisda904f22014-11-05 16:23:33 -080059 Ptr<L3Protocol> l3 = m_nodePtr->GetObject<L3Protocol>();
Alexander Afanasyevbe55cf62014-12-20 17:51:09 -080060
Spyridon Mastorakisda904f22014-11-05 16:23:33 -080061 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 Afanasyevbe55cf62014-12-20 17:51:09 -080065
Spyridon Mastorakisda904f22014-11-05 16:23:33 -080066 // // satisfied/timed out PIs
67 // l3->TraceConnectWithoutContext("SatisfiedInterests",
68 // MakeCallback(&L3Tracer::SatisfiedInterests, this));
69 // l3->TraceConnectWithoutContext("TimedOutInterests",
70 // MakeCallback(&L3Tracer::TimedOutInterests, this));
Alexander Afanasyevc9d5c1a2012-11-21 18:00:26 -080071}
72
73} // namespace ndn
74} // namespace ns3