From 91c4ef481f01fbd35f411a316b41d0821b8502d3 Mon Sep 17 00:00:00 2001 From: Mathieu Lacage Date: Fri, 16 May 2008 10:25:24 -0700 Subject: [PATCH] remove dead code. --- examples/csma-packet-socket.cc | 9 +-- src/internet-node/ascii-trace.cc | 103 --------------------------- src/internet-node/ascii-trace.h | 49 ------------- src/internet-node/pcap-trace.cc | 117 ------------------------------- src/internet-node/pcap-trace.h | 56 --------------- src/internet-node/wscript | 4 -- 6 files changed, 3 insertions(+), 335 deletions(-) delete mode 100644 src/internet-node/ascii-trace.cc delete mode 100644 src/internet-node/ascii-trace.h delete mode 100644 src/internet-node/pcap-trace.cc delete mode 100644 src/internet-node/pcap-trace.h diff --git a/examples/csma-packet-socket.cc b/examples/csma-packet-socket.cc index dfc267e0f..42dfb2e17 100644 --- a/examples/csma-packet-socket.cc +++ b/examples/csma-packet-socket.cc @@ -38,9 +38,6 @@ #include "ns3/node-module.h" #include "ns3/helper-module.h" -#include "ns3/ascii-trace.h" -#include "ns3/pcap-trace.h" - using namespace ns3; NS_LOG_COMPONENT_DEFINE ("CsmaPacketSocketExample"); @@ -105,9 +102,9 @@ main (int argc, char *argv[]) // Configure tracing of all enqueue, dequeue, and NetDevice receive events // Trace output will be sent to the csma-packet-socket.tr file NS_LOG_INFO ("Configure Tracing."); - AsciiTrace asciitrace ("csma-packet-socket.tr"); - asciitrace.TraceAllNetDeviceRx (); - asciitrace.TraceAllQueues (); + std::ofstream os; + os.open ("csma-packet-socket.tr"); + csma.EnableAsciiAll (os); NS_LOG_INFO ("Run Simulation."); Simulator::Run (); diff --git a/src/internet-node/ascii-trace.cc b/src/internet-node/ascii-trace.cc deleted file mode 100644 index 10c8fbc5f..000000000 --- a/src/internet-node/ascii-trace.cc +++ /dev/null @@ -1,103 +0,0 @@ -/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */ -/* - * Copyright (c) 2007 INRIA - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License version 2 as - * published by the Free Software Foundation; - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - * - * Author: Mathieu Lacage - */ -#include "ascii-trace.h" - -#include "ns3/config.h" -#include "ns3/simulator.h" -#include "ns3/node.h" -#include "ns3/packet.h" -#include "ns3/queue.h" - -namespace ns3 { - -AsciiTrace::AsciiTrace (std::string filename) -{ - m_os.open (filename.c_str ()); -} -AsciiTrace::~AsciiTrace () -{ - m_os.close (); -} -void -AsciiTrace::TraceAllQueues (void) -{ - Packet::EnableMetadata (); - Config::Connect ("/NodeList/*/DeviceList/*/TxQueue/Enqueue", - MakeCallback (&AsciiTrace::LogDevQueueEnqueue, this)); - Config::Connect ("/NodeList/*/DeviceList/*/TxQueue/Dequeue", - MakeCallback (&AsciiTrace::LogDevQueueDequeue, this)); - Config::Connect ("/NodeList/*/DeviceList/*/TxQueue/Drop", - MakeCallback (&AsciiTrace::LogDevQueueDrop, this)); -} -void -AsciiTrace::TraceAllNetDeviceRx (void) -{ - Packet::EnableMetadata (); - Config::Connect ("/NodeList/*/DeviceList/*/Rx", - MakeCallback (&AsciiTrace::LogDevRx, this)); -} - -void -AsciiTrace::LogDevQueueEnqueue (std::string context, - Ptr packet) -{ - m_os << "+ "; - m_os << Simulator::Now ().GetSeconds () << " "; - m_os << context; - m_os << " pkt-uid=" << packet->GetUid () << " "; - packet->Print (m_os); - m_os << std::endl; -} - -void -AsciiTrace::LogDevQueueDequeue (std::string context, - Ptr packet) -{ - m_os << "- "; - m_os << Simulator::Now ().GetSeconds () << " "; - m_os << context; - m_os << " pkt-uid=" << packet->GetUid () << " "; - packet->Print (m_os); - m_os << std::endl; -} - -void -AsciiTrace::LogDevQueueDrop (std::string context, - Ptr packet) -{ - m_os << "d "; - m_os << Simulator::Now ().GetSeconds () << " "; - m_os << context; - m_os << " pkt-uid=" << packet->GetUid () << " "; - packet->Print (m_os); - m_os << std::endl; -} -void -AsciiTrace::LogDevRx (std::string context, - Ptr p) -{ - m_os << "r " << Simulator::Now ().GetSeconds () << " "; - m_os << context; - m_os << " pkt-uid=" << p->GetUid () << " "; - p->Print (m_os); - m_os << std::endl; -} - -}//namespace ns3 diff --git a/src/internet-node/ascii-trace.h b/src/internet-node/ascii-trace.h deleted file mode 100644 index 05c505947..000000000 --- a/src/internet-node/ascii-trace.h +++ /dev/null @@ -1,49 +0,0 @@ -/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */ -/* - * Copyright (c) 2007 INRIA - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License version 2 as - * published by the Free Software Foundation; - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - * - * Author: Mathieu Lacage - */ -#ifndef ASCII_TRACE_H -#define ASCII_TRACE_H - -#include -#include -#include "ns3/ptr.h" - -namespace ns3 { - -class Packet; -class TraceContext; - -class AsciiTrace -{ -public: - AsciiTrace (std::string filename); - ~AsciiTrace (); - void TraceAllQueues (void); - void TraceAllNetDeviceRx (void); -private: - void LogDevQueueEnqueue (std::string context, Ptr p); - void LogDevQueueDequeue (std::string context, Ptr p); - void LogDevQueueDrop (std::string context, Ptr p); - void LogDevRx (std::string context, Ptr p); - std::ofstream m_os; -}; - -}//namespace ns3 - -#endif /* ASCII_TRACE_H */ diff --git a/src/internet-node/pcap-trace.cc b/src/internet-node/pcap-trace.cc deleted file mode 100644 index f5d712df2..000000000 --- a/src/internet-node/pcap-trace.cc +++ /dev/null @@ -1,117 +0,0 @@ -/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */ -/* - * Copyright (c) 2007 INRIA - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License version 2 as - * published by the Free Software Foundation; - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - * - * Author: Mathieu Lacage - */ -#include "pcap-trace.h" - -#include - -#include "ns3/config.h" -#include "ns3/callback.h" -#include "ns3/pcap-writer.h" -#include "ns3/node-list.h" -#include "ns3/node.h" -#include "ns3/packet.h" -#include "ns3/log.h" - -#include "ipv4-l3-protocol.h" - -NS_LOG_COMPONENT_DEFINE ("PcapTrace"); - -namespace ns3 { - - -PcapTrace::PcapTrace (std::string filename) - : m_filename (filename) -{} -PcapTrace::~PcapTrace () -{ - for (std::vector::iterator i = m_traces.begin (); - i != m_traces.end (); i++) - { - delete i->writer; - } -} - -void -PcapTrace::TraceAllIp (void) -{ - Config::Connect ("/NodeList/*/$ns3::Ipv4L3Protocol/Tx", - MakeCallback (&PcapTrace::LogTxIp, this)); - Config::Connect ("/NodeList/*/$ns3::Ipv4L3Protocol/Rx", - MakeCallback (&PcapTrace::LogRxIp, this)); -} - -PcapWriter * -PcapTrace::GetStream (uint32_t nodeId, uint32_t interfaceId) -{ - for (std::vector::iterator i = m_traces.begin (); - i != m_traces.end (); i++) - { - if (i->nodeId == nodeId && - i->interfaceId == interfaceId) - { - return i->writer; - } - } - PcapTrace::Trace trace; - trace.nodeId = nodeId; - trace.interfaceId = interfaceId; - trace.writer = new PcapWriter (); - std::ostringstream oss; - oss << m_filename << "-" << nodeId << "-" << interfaceId; - std::string filename = oss.str (); - trace.writer->Open (filename); - trace.writer->WriteIpHeader (); - m_traces.push_back (trace); - return trace.writer; -} - -uint32_t -PcapTrace::GetNodeIndex (std::string context) const -{ - std::string::size_type pos; - pos = context.find ("/NodeList/"); - NS_ASSERT (pos == 0); - std::string::size_type afterNodeIndex = context.find ("/", 11); - NS_ASSERT (afterNodeIndex != std::string::npos); - std::string index = context.substr (10, afterNodeIndex - 10); - NS_LOG_DEBUG ("index="<> nodeIndex; - return nodeIndex; -} - -void -PcapTrace::LogTxIp (std::string context, Ptr p, uint32_t interfaceIndex) -{ - PcapWriter *writer = GetStream (GetNodeIndex (context), interfaceIndex); - writer->WritePacket (p); -} - -void -PcapTrace::LogRxIp (std::string context, Ptr p, uint32_t interfaceIndex) -{ - PcapWriter *writer = GetStream (GetNodeIndex (context), interfaceIndex); - writer->WritePacket (p); -} - - -}//namespace ns3 diff --git a/src/internet-node/pcap-trace.h b/src/internet-node/pcap-trace.h deleted file mode 100644 index 3ab644684..000000000 --- a/src/internet-node/pcap-trace.h +++ /dev/null @@ -1,56 +0,0 @@ -/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */ -/* - * Copyright (c) 2007 INRIA - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License version 2 as - * published by the Free Software Foundation; - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - * - * Author: Mathieu Lacage - */ -#ifndef PCAP_TRACE_H -#define PCAP_TRACE_H - -#include -#include -#include "ns3/ptr.h" - -namespace ns3 { - -class Packet; -class TraceContext; -class PcapWriter; - -class PcapTrace -{ -public: - PcapTrace (std::string filename); - ~PcapTrace (); - - void TraceAllIp (void); -private: - PcapWriter *GetStream (uint32_t nodeId, uint32_t interfaceId); - void LogRxIp (std::string context, Ptr p, uint32_t interfaceIndex); - void LogTxIp (std::string context, Ptr p, uint32_t interfaceIndex); - uint32_t GetNodeIndex (std::string context) const; - std::string m_filename; - struct Trace { - uint32_t nodeId; - uint32_t interfaceId; - PcapWriter *writer; - }; - std::vector m_traces; -}; - -}//namespace ns3 - -#endif /* PCAP_TRACE_H */ diff --git a/src/internet-node/wscript b/src/internet-node/wscript index 2d03561ff..9a7949219 100644 --- a/src/internet-node/wscript +++ b/src/internet-node/wscript @@ -26,8 +26,6 @@ def build(bld): 'tcp-socket.cc', 'ipv4-end-point-demux.cc', 'ipv4-impl.cc', - 'ascii-trace.cc', - 'pcap-trace.cc', 'udp-impl.cc', 'tcp-impl.cc', 'pending-data.cc', @@ -39,8 +37,6 @@ def build(bld): headers.module = 'internet-node' headers.source = [ 'internet-stack.h', - 'ascii-trace.h', - 'pcap-trace.h', 'ipv4-header.h', 'udp-header.h', 'tcp-header.h',