merge with HEAD
authorMathieu Lacage <mathieu.lacage@sophia.inria.fr>
Fri, 16 May 2008 10:29:34 -0700
changeset 3027 7c575f821f2b
parent 3026 4ef834f6b67d (diff)
parent 3025 d93423ef5ef2 (current diff)
child 3028 d0713d8818c7
merge with HEAD
src/mobility/mobility-model-notifier.cc
src/mobility/mobility-model-notifier.h
--- a/examples/csma-packet-socket.cc	Fri May 16 10:11:49 2008 -0700
+++ b/examples/csma-packet-socket.cc	Fri May 16 10:29:34 2008 -0700
@@ -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 @@
   // 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 ();
--- a/src/internet-node/ascii-trace.cc	Fri May 16 10:11:49 2008 -0700
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -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 <mathieu.lacage@sophia.inria.fr>
- */
-#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<const Packet> 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<const Packet> 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<const Packet> 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<const Packet> 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
--- a/src/internet-node/ascii-trace.h	Fri May 16 10:11:49 2008 -0700
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,48 +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 <mathieu.lacage@sophia.inria.fr>
- */
-#ifndef ASCII_TRACE_H
-#define ASCII_TRACE_H
-
-#include <string>
-#include <fstream>
-#include "ns3/ptr.h"
-
-namespace ns3 {
-
-class Packet;
-
-class AsciiTrace 
-{
-public:
-  AsciiTrace (std::string filename);
-  ~AsciiTrace ();
-  void TraceAllQueues (void);
-  void TraceAllNetDeviceRx (void);
-private:
-  void LogDevQueueEnqueue (std::string context, Ptr<const Packet> p);
-  void LogDevQueueDequeue (std::string context, Ptr<const Packet> p);
-  void LogDevQueueDrop (std::string context, Ptr<const Packet> p);
-  void LogDevRx (std::string context, Ptr<const Packet> p);
-  std::ofstream m_os;
-};
-
-}//namespace ns3
-
-#endif /* ASCII_TRACE_H */
--- a/src/internet-node/pcap-trace.cc	Fri May 16 10:11:49 2008 -0700
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -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 <mathieu.lacage@sophia.inria.fr>
- */
-#include "pcap-trace.h"
-
-#include <sstream>
-
-#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<Trace>::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<Trace>::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="<<index);
-  std::istringstream iss;
-  iss.str (index);
-  uint32_t nodeIndex;
-  iss >> nodeIndex;
-  return nodeIndex;
-}  
-
-void 
-PcapTrace::LogTxIp (std::string context, Ptr<const Packet> p, uint32_t interfaceIndex)
-{
-  PcapWriter *writer = GetStream (GetNodeIndex (context), interfaceIndex);
-  writer->WritePacket (p);
-}
-
-void 
-PcapTrace::LogRxIp (std::string context, Ptr<const Packet> p, uint32_t interfaceIndex)
-{
-  PcapWriter *writer = GetStream (GetNodeIndex (context), interfaceIndex);
-  writer->WritePacket (p);
-}
-
-
-}//namespace ns3
--- a/src/internet-node/pcap-trace.h	Fri May 16 10:11:49 2008 -0700
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,55 +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 <mathieu.lacage@sophia.inria.fr>
- */
-#ifndef PCAP_TRACE_H
-#define PCAP_TRACE_H
-
-#include <string>
-#include <vector>
-#include "ns3/ptr.h"
-
-namespace ns3 {
-
-class Packet;
-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<const Packet> p, uint32_t interfaceIndex);
-  void LogTxIp (std::string context, Ptr<const Packet> 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<Trace> m_traces;
-};
-
-}//namespace ns3
-
-#endif /* PCAP_TRACE_H */
--- a/src/internet-node/wscript	Fri May 16 10:11:49 2008 -0700
+++ b/src/internet-node/wscript	Fri May 16 10:29:34 2008 -0700
@@ -26,8 +26,6 @@
         '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 @@
     headers.module = 'internet-node'
     headers.source = [
         'internet-stack.h',
-        'ascii-trace.h',
-        'pcap-trace.h',
         'ipv4-header.h',
         'udp-header.h',
         'tcp-header.h',