port to new pcap/ascii trace helpers
authorMathieu Lacage <mathieu.lacage@sophia.inria.fr>
Fri, 28 Mar 2008 13:40:08 -0700
changeset 2788 ad1404dcfad4
parent 2787 83b3e68557e1
child 2789 47e92324cf4b
port to new pcap/ascii trace helpers
examples/csma-broadcast.cc
examples/simple-alternate-routing.cc
examples/simple-error-model.cc
examples/simple-global-routing.cc
examples/tcp-large-transfer.cc
examples/udp-echo.cc
--- a/examples/csma-broadcast.cc	Fri Mar 28 13:19:14 2008 -0700
+++ b/examples/csma-broadcast.cc	Fri Mar 28 13:40:08 2008 -0700
@@ -34,7 +34,6 @@
 
 #include "ns3/core-module.h"
 #include "ns3/helper-module.h"
-#include "ns3/internet-node-module.h"
 #include "ns3/simulator-module.h"
 
 using namespace ns3;
--- a/examples/simple-alternate-routing.cc	Fri Mar 28 13:19:14 2008 -0700
+++ b/examples/simple-alternate-routing.cc	Fri Mar 28 13:40:08 2008 -0700
@@ -41,8 +41,6 @@
 #include "ns3/simulator-module.h"
 #include "ns3/helper-module.h"
 #include "ns3/global-route-manager.h"
-#include "ns3/ascii-trace.h"
-#include "ns3/pcap-trace.h"
 
 using namespace ns3;
 
@@ -105,6 +103,9 @@
   // DefaultValue::Bind ()s at run-time, via command-line arguments
   cmd.Parse (argc, argv);
 
+  std::ofstream ascii;
+  ascii.open ("simple-alternate-routing.tr");
+
   // Here, we will explicitly create four nodes.  In more sophisticated
   // topologies, we could configure a node factory.
   NS_LOG_INFO ("Create nodes.");
@@ -118,6 +119,8 @@
   // We create the channels first without any IP addressing information
   NS_LOG_INFO ("Create channels.");
   PointToPointHelper p2p;
+  p2p.EnablePcap ("simple-alternate-routing.pcap");
+  p2p.EnableAscii (ascii);
   p2p.SetChannelParameter ("BitRate", DataRate (5000000));
   p2p.SetChannelParameter ("Delay", MilliSeconds (2));
   NetDeviceContainer d0d2 = p2p.Build (n0n2);
@@ -177,19 +180,6 @@
   apps.Start (Seconds (1.1));
   apps.Stop (Seconds (10.0));
 
-  // Configure tracing of all enqueue, dequeue, and NetDevice receive events
-  // Trace output will be sent to the simple-alternate-routing.tr file
-  NS_LOG_INFO ("Configure Tracing.");
-  AsciiTrace asciitrace ("simple-alternate-routing.tr");
-  asciitrace.TraceAllQueues ();
-  asciitrace.TraceAllNetDeviceRx ();
-
-  // Also configure some tcpdump traces; each interface will be traced
-  // The output files will be named simple-p2p.pcap-<nodeId>-<interfaceId>
-  // and can be read by the "tcpdump -r" command (use "-tt" option to
-  // display timestamps correctly)
-  PcapTrace pcaptrace ("simple-alternate-routing.pcap");
-  pcaptrace.TraceAllIp ();
 
   NS_LOG_INFO ("Run Simulation.");
   Simulator::Run ();
--- a/examples/simple-error-model.cc	Fri Mar 28 13:19:14 2008 -0700
+++ b/examples/simple-error-model.cc	Fri Mar 28 13:40:08 2008 -0700
@@ -38,12 +38,11 @@
 // - Tracing of queues and packet receptions to file 
 //   "simple-error-model.tr"
 
+#include <fstream>
 #include "ns3/core-module.h"
 #include "ns3/common-module.h"
 #include "ns3/simulator-module.h"
 #include "ns3/helper-module.h"
-#include "ns3/ascii-trace.h"
-#include "ns3/pcap-trace.h"
 #include "ns3/global-route-manager.h"
 
 using namespace ns3;
@@ -72,6 +71,9 @@
   CommandLine cmd;
   cmd.Parse (argc, argv);
 
+  std::ofstream ascii;
+  ascii.open ("simple-error-model.pcap");
+
   // Here, we will explicitly create four nodes.  In more sophisticated
   // topologies, we could configure a node factory.
   NS_LOG_INFO ("Create nodes.");
@@ -87,6 +89,8 @@
   // We create the channels first without any IP addressing information
   NS_LOG_INFO ("Create channels.");
   PointToPointHelper p2p;
+  p2p.EnablePcap ("simple-error-model.pcap");
+  p2p.EnableAscii (ascii);
   p2p.SetChannelParameter ("BitRate", DataRate (5000000));
   p2p.SetChannelParameter ("Delay", MilliSeconds (2));
   NetDeviceContainer d0d2 = p2p.Build (n0n2);
@@ -162,12 +166,6 @@
   pem->SetList (sampleList);
   d0d2.Get (1)->SetAttribute ("ReceiveErrorModel", pem);
 
-  // Configure tracing of all enqueue, dequeue, and NetDevice receive events
-  // Trace output will be sent to the simple-error-model.tr file
-  NS_LOG_INFO ("Configure Tracing.");
-  AsciiTrace asciitrace ("simple-error-model.tr");
-  asciitrace.TraceAllQueues ();
-  asciitrace.TraceAllNetDeviceRx ();
 
   NS_LOG_INFO ("Run Simulation.");
   Simulator::Run ();    
--- a/examples/simple-global-routing.cc	Fri Mar 28 13:19:14 2008 -0700
+++ b/examples/simple-global-routing.cc	Fri Mar 28 13:40:08 2008 -0700
@@ -45,8 +45,6 @@
 #include "ns3/core-module.h"
 #include "ns3/simulator-module.h"
 #include "ns3/helper-module.h"
-#include "ns3/ascii-trace.h"
-#include "ns3/pcap-trace.h"
 #include "ns3/global-route-manager.h"
 
 using namespace ns3;
@@ -95,6 +93,9 @@
   CommandLine cmd;
   cmd.Parse (argc, argv);
 
+  std::ofstream ascii;
+  ascii.open ("simple-global-routing.tr");
+
   // Here, we will explicitly create four nodes.  In more sophisticated
   // topologies, we could configure a node factory.
   NS_LOG_INFO ("Create nodes.");
@@ -110,6 +111,8 @@
   // We create the channels first without any IP addressing information
   NS_LOG_INFO ("Create channels.");
   PointToPointHelper p2p;
+  p2p.EnablePcap ("simple-global-routing.pcap");
+  p2p.EnableAscii (ascii);
   p2p.SetChannelParameter ("BitRate", DataRate (5000000));
   p2p.SetChannelParameter ("Delay", MilliSeconds (2));
   NetDeviceContainer d0d2 = p2p.Build (n0n2);
@@ -167,19 +170,6 @@
   apps.Start (Seconds (1.1));
   apps.Stop (Seconds (10.0));
 
-  // Configure tracing of all enqueue, dequeue, and NetDevice receive events
-  // Trace output will be sent to the simple-global-routing.tr file
-  NS_LOG_INFO ("Configure Tracing.");
-  AsciiTrace asciitrace ("simple-global-routing.tr");
-  asciitrace.TraceAllQueues ();
-  asciitrace.TraceAllNetDeviceRx ();
-
-  // Also configure some tcpdump traces; each interface will be traced
-  // The output files will be named simple-p2p.pcap-<nodeId>-<interfaceId>
-  // and can be read by the "tcpdump -r" command (use "-tt" option to
-  // display timestamps correctly)
-  PcapTrace pcaptrace ("simple-global-routing.pcap");
-  pcaptrace.TraceAllIp ();
 
   NS_LOG_INFO ("Run Simulation.");
   Simulator::Run ();
--- a/examples/tcp-large-transfer.cc	Fri Mar 28 13:19:14 2008 -0700
+++ b/examples/tcp-large-transfer.cc	Fri Mar 28 13:40:08 2008 -0700
@@ -40,9 +40,6 @@
 #include "ns3/global-route-manager.h"
 #include "ns3/simulator-module.h"
 
-#include "ns3/ascii-trace.h"
-#include "ns3/pcap-trace.h"
-
 using namespace ns3;
 
 NS_LOG_COMPONENT_DEFINE ("TcpLargeTransfer");
@@ -133,8 +130,13 @@
   c1.Add (c0.Get (1));
   c1.Create (1);
 
+  std::ofstream ascii;
+  ascii.open ("tcp-large-transfer.tr");
+
   // We create the channels first without any IP addressing information
   PointToPointHelper p2p;
+  p2p.EnablePcap ("tcp-large-transfer.pcap");
+  p2p.EnableAscii (ascii);
   p2p.SetChannelParameter ("BitRate", DataRate(10000000));
   p2p.SetChannelParameter ("Delay", MilliSeconds(10));
   NetDeviceContainer dev0 = p2p.Build (c0);
@@ -180,21 +182,6 @@
   Simulator::ScheduleNow (&StartFlow, localSocket, nBytes,
                           ipInterfs.GetAddress (1), servPort);
 
-  // Configure tracing of all enqueue, dequeue, and NetDevice receive events
-  // Trace output will be sent to the simple-examples.tr file
-  AsciiTrace asciitrace ("tcp-large-transfer.tr");
-  asciitrace.TraceAllQueues ();
-  asciitrace.TraceAllNetDeviceRx ();
-
-  
-  // Also configure some tcpdump traces; each interface will be traced
-  // The output files will be named 
-  // simple-examples.pcap-<nodeId>-<interfaceId>
-  // and can be read by the "tcpdump -r" command (use "-tt" option to
-  // display timestamps correctly)
-  PcapTrace pcaptrace ("tcp-large-transfer.pcap");
-  pcaptrace.TraceAllIp ();
-
   Config::ConnectWithoutContext ("/NodeList/*/ApplicationList/*/Rx", 
                    MakeCallback (&ApplicationTraceSink));
 
--- a/examples/udp-echo.cc	Fri Mar 28 13:19:14 2008 -0700
+++ b/examples/udp-echo.cc	Fri Mar 28 13:40:08 2008 -0700
@@ -25,11 +25,10 @@
 // - DropTail queues 
 // - Tracing of queues and packet receptions to file "udp-echo.tr"
 
+#include <fstream>
 #include "ns3/core-module.h"
 #include "ns3/simulator-module.h"
 #include "ns3/helper-module.h"
-#include "ns3/ascii-trace.h"
-#include "ns3/pcap-trace.h"
 
 using namespace ns3;
 
@@ -83,11 +82,16 @@
   InternetStackHelper internet;
   internet.Build (n);
 
+  std::ofstream ascii;
+  ascii.open ("udp-echo.tr");
+
   NS_LOG_INFO ("Create channels.");
 //
 // Explicitly create the channels required by the topology (shown above).
 //
   CsmaHelper csma;
+  csma.EnablePcap ("udp-echo.pcap");
+  csma.EnableAscii (ascii);
   csma.SetChannelParameter ("BitRate", DataRate(5000000));
   csma.SetChannelParameter ("Delay", MilliSeconds (2));
   NetDeviceContainer d = csma.Build (n);
@@ -128,23 +132,6 @@
   apps.Stop (Seconds (10.0));
 
 //
-// Configure tracing of all enqueue, dequeue, and NetDevice receive events.
-// Trace output will be sent to the file "udp-echo.tr"
-//
-  NS_LOG_INFO ("Configure Tracing.");
-  AsciiTrace asciitrace ("udp-echo.tr");
-  asciitrace.TraceAllNetDeviceRx ();
-  asciitrace.TraceAllQueues ();
-//
-// Also configure some tcpdump traces; each interface will be traced.
-// The output files will be named:
-//     udp-echo.pcap-<nodeId>-<interfaceId>
-// and can be read by the "tcpdump -r" command (use "-tt" option to
-// display timestamps correctly)
-//
-  PcapTrace pcaptrace ("udp-echo.pcap");
-  pcaptrace.TraceAllIp ();
-//
 // Now, do the actual simulation.
 //
   NS_LOG_INFO ("Run Simulation.");