examples/csma-packet-socket.cc
changeset 1504 36ecc970ba96
parent 1494 c2985e1cd091
child 2230 9f13ac3291e0
--- a/examples/csma-packet-socket.cc	Thu Sep 13 12:37:30 2007 -0700
+++ b/examples/csma-packet-socket.cc	Thu Sep 13 17:47:42 2007 -0700
@@ -37,7 +37,7 @@
 #include "ns3/default-value.h"
 #include "ns3/ptr.h"
 #include "ns3/random-variable.h"
-#include "ns3/debug.h"
+#include "ns3/log.h"
 
 #include "ns3/simulator.h"
 #include "ns3/nstime.h"
@@ -56,6 +56,8 @@
 
 using namespace ns3;
 
+NS_LOG_COMPONENT_DEFINE ("CsmaPacketSocketExample");
+
 static Ptr<CsmaNetDevice>
 CreateCsmaDevice (Ptr<Node> node, Ptr<CsmaChannel> channel)
 {
@@ -66,28 +68,56 @@
   return device;
 }
 
+int
+main (int argc, char *argv[])
+{
+#if 0 
+  LogComponentEnable ("CsmaPacketSocketExample", LOG_LEVEL_INFO);
 
-int main (int argc, char *argv[])
-{
+  LogComponentEnable("Object", LOG_LEVEL_ALL);
+  LogComponentEnable("Queue", LOG_LEVEL_ALL);
+  LogComponentEnable("DropTailQueue", LOG_LEVEL_ALL);
+  LogComponentEnable("Channel", LOG_LEVEL_ALL);
+  LogComponentEnable("CsmaChannel", LOG_LEVEL_ALL);
+  LogComponentEnable("NetDevice", LOG_LEVEL_ALL);
+  LogComponentEnable("CsmaNetDevice", LOG_LEVEL_ALL);
+  LogComponentEnable("Ipv4L3Protocol", LOG_LEVEL_ALL);
+  LogComponentEnable("PacketSocket", LOG_LEVEL_ALL);
+  LogComponentEnable("Socket", LOG_LEVEL_ALL);
+  LogComponentEnable("UdpSocket", LOG_LEVEL_ALL);
+  LogComponentEnable("UdpL4Protocol", LOG_LEVEL_ALL);
+  LogComponentEnable("Ipv4L3Protocol", LOG_LEVEL_ALL);
+  LogComponentEnable("Ipv4StaticRouting", LOG_LEVEL_ALL);
+  LogComponentEnable("Ipv4Interface", LOG_LEVEL_ALL);
+  LogComponentEnable("ArpIpv4Interface", LOG_LEVEL_ALL);
+  LogComponentEnable("Ipv4LoopbackInterface", LOG_LEVEL_ALL);
+  LogComponentEnable("OnOffApplication", LOG_LEVEL_ALL);
+  LogComponentEnable("PacketSinkApplication", LOG_LEVEL_ALL);
+  LogComponentEnable("UdpEchoClientApplication", LOG_LEVEL_ALL);
+  LogComponentEnable("UdpEchoServerApplication", LOG_LEVEL_ALL);
+#endif
+
   CommandLine::Parse (argc, argv);
 
   // Here, we will explicitly create four nodes.  In more sophisticated
   // topologies, we could configure a node factory.
+  NS_LOG_INFO ("Create nodes.");
   Ptr<Node> n0 = Create<Node> ();
   Ptr<Node> n1 = Create<Node> (); 
   Ptr<Node> n2 = Create<Node> (); 
   Ptr<Node> n3 = Create<Node> ();
 
   // create the shared medium used by all csma devices.
+  NS_LOG_INFO ("Create channels.");
   Ptr<CsmaChannel> channel = Create<CsmaChannel> (DataRate(5000000), MilliSeconds(2));
 
   // use a helper function to connect our nodes to the shared channel.
+  NS_LOG_INFO ("Build Topology.");
   Ptr<NetDevice> n0If = CreateCsmaDevice (n0, channel);
   Ptr<NetDevice> n1If = CreateCsmaDevice (n1, channel);
   Ptr<NetDevice> n2If = CreateCsmaDevice (n2, channel);
   Ptr<NetDevice> n3If = CreateCsmaDevice (n3, channel);
 
-
   // create the address which identifies n1 from n0
   PacketSocketAddress n0ToN1;
   n0ToN1.SetSingleDevice (n0If->GetIfIndex ());      // set outgoing interface for outgoing packets
@@ -103,6 +133,7 @@
   // Create the OnOff application to send raw datagrams of size
   // 210 bytes at a rate of 448 Kb/s
   // from n0 to n1
+  NS_LOG_INFO ("Create Applications.");
   Ptr<OnOffApplication> ooff = Create<OnOffApplication> (
     n0, 
     n0ToN1,
@@ -126,11 +157,13 @@
  
   // 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 ();
 
+  NS_LOG_INFO ("Run Simulation.");
   Simulator::Run ();
-    
   Simulator::Destroy ();
+  NS_LOG_INFO ("Done.");
 }