many debug prints
authorCraig Dowell <craigdo@ee.washington.edu>
Sun, 12 Aug 2007 22:41:24 -0700
changeset 1430 25fa26a6533e
parent 1429 31cb0668defd
child 1431 3760d52ef5d1
many debug prints
examples/csma-multicast.cc
examples/csma-one-subnet.cc
examples/simple-point-to-point.cc
src/devices/csma/csma-ipv4-topology.cc
src/internet-node/arp-ipv4-interface.cc
src/internet-node/ipv4-interface.cc
src/internet-node/ipv4-l3-protocol.cc
src/internet-node/ipv4-loopback-interface.cc
src/internet-node/ipv4-static-routing.cc
--- a/examples/csma-multicast.cc	Sun Aug 12 15:51:12 2007 -0700
+++ b/examples/csma-multicast.cc	Sun Aug 12 22:41:24 2007 -0700
@@ -67,17 +67,23 @@
   // for selected modules; the below lines suggest how to do this
 #if 0 
   DebugComponentEnable("Me");
+  DebugComponentEnable("Object");
+  DebugComponentEnable("Queue");
+  DebugComponentEnable("DropTailQueue");
+  DebugComponentEnable("Channel");
+  DebugComponentEnable("CsmaChannel");
   DebugComponentEnable("CsmaNetDevice");
   DebugComponentEnable("Ipv4L3Protocol");
   DebugComponentEnable("NetDevice");
-  DebugComponentEnable("Channel");
-  DebugComponentEnable("CsmaChannel");
   DebugComponentEnable("PacketSocket");
   DebugComponentEnable("OnOffApplication");
   DebugComponentEnable("UdpSocket");
   DebugComponentEnable("UdpL4Protocol");
   DebugComponentEnable("Ipv4L3Protocol");
   DebugComponentEnable("Ipv4StaticRouting");
+  DebugComponentEnable("Ipv4Interface");
+  DebugComponentEnable("ArpIpv4Interface");
+  DebugComponentEnable("Ipv4LoopbackInterface");
 #endif
 
   DebugComponentEnable("Me");
@@ -88,6 +94,9 @@
   DebugComponentEnable("Ipv4StaticRouting");
   DebugComponentEnable("CsmaNetDevice");
   DebugComponentEnable("CsmaChannel");
+  DebugComponentEnable("Ipv4Interface");
+  DebugComponentEnable("ArpIpv4Interface");
+  DebugComponentEnable("Ipv4LoopbackInterface");
 
   // Set up some default values for the simulation.  Use the Bind()
   // technique to tell the system what subclass of Queue to use,
--- a/examples/csma-one-subnet.cc	Sun Aug 12 15:51:12 2007 -0700
+++ b/examples/csma-one-subnet.cc	Sun Aug 12 22:41:24 2007 -0700
@@ -58,23 +58,47 @@
 #include "ns3/ipv4-route.h"
 #include "ns3/onoff-application.h"
 
-
 using namespace ns3;
 
+NS_DEBUG_COMPONENT_DEFINE ("Me");
 
-int main (int argc, char *argv[])
+int 
+main (int argc, char *argv[])
 {
-
   // Users may find it convenient to turn on explicit debugging
   // for selected modules; the below lines suggest how to do this
 #if 0 
+  DebugComponentEnable("Me");
+  DebugComponentEnable("Object");
+  DebugComponentEnable("Queue");
+  DebugComponentEnable("DropTailQueue");
+  DebugComponentEnable("Channel");
+  DebugComponentEnable("CsmaChannel");
   DebugComponentEnable("CsmaNetDevice");
   DebugComponentEnable("Ipv4L3Protocol");
   DebugComponentEnable("NetDevice");
-  DebugComponentEnable("Channel");
+  DebugComponentEnable("PacketSocket");
+  DebugComponentEnable("OnOffApplication");
+  DebugComponentEnable("UdpSocket");
+  DebugComponentEnable("UdpL4Protocol");
+  DebugComponentEnable("Ipv4L3Protocol");
+  DebugComponentEnable("Ipv4StaticRouting");
+  DebugComponentEnable("Ipv4Interface");
+  DebugComponentEnable("ArpIpv4Interface");
+  DebugComponentEnable("Ipv4LoopbackInterface");
+#endif
+
+  DebugComponentEnable("Me");
+  DebugComponentEnable("OnOffApplication");
+  DebugComponentEnable("UdpSocket");
+  DebugComponentEnable("UdpL4Protocol");
+  DebugComponentEnable("Ipv4L3Protocol");
+  DebugComponentEnable("Ipv4StaticRouting");
+  DebugComponentEnable("CsmaNetDevice");
   DebugComponentEnable("CsmaChannel");
-  DebugComponentEnable("PacketSocket");
-#endif
+  DebugComponentEnable("Ipv4Interface");
+  DebugComponentEnable("ArpIpv4Interface");
+  DebugComponentEnable("Ipv4LoopbackInterface");
 
   // Set up some default values for the simulation.  Use the Bind()
   // technique to tell the system what subclass of Queue to use,
@@ -90,16 +114,19 @@
 
   // Here, we will explicitly create four nodes.  In more sophisticated
   // topologies, we could configure a node factory.
+  NS_DEBUG("Create nodes.");
   Ptr<Node> n0 = Create<InternetNode> ();
   Ptr<Node> n1 = Create<InternetNode> (); 
   Ptr<Node> n2 = Create<InternetNode> (); 
   Ptr<Node> n3 = Create<InternetNode> ();
 
   // We create the channels first without any IP addressing information
+  NS_DEBUG("Create channels.");
   Ptr<CsmaChannel> channel0 = 
     CsmaTopology::CreateCsmaChannel(
       DataRate(5000000), MilliSeconds(2));
 
+  NS_DEBUG("Build Topology.");
   uint32_t n0ifIndex = CsmaIpv4Topology::AddIpv4CsmaNode (n0, channel0, 
                                          Eui48Address("10:54:23:54:23:50"));
   uint32_t n1ifIndex = CsmaIpv4Topology::AddIpv4CsmaNode (n1, channel0,
@@ -110,6 +137,7 @@
                                          Eui48Address("10:54:23:54:23:53"));
 
   // Later, we add IP addresses.  
+  NS_DEBUG("Assign IP Addresses.");
   CsmaIpv4Topology::AddIpv4Address (
       n0, n0ifIndex, Ipv4Address("10.1.1.1"), Ipv4Mask("255.255.255.0"));
 
@@ -125,6 +153,7 @@
   // Create the OnOff application to send UDP datagrams of size
   // 210 bytes at a rate of 448 Kb/s
   // from n0 to n1
+  NS_DEBUG("Create Applications.");
   Ptr<OnOffApplication> ooff = Create<OnOffApplication> (
     n0, 
     InetSocketAddress ("10.1.1.2", 80), 
@@ -148,6 +177,7 @@
  
   // Configure tracing of all enqueue, dequeue, and NetDevice receive events
   // Trace output will be sent to the csma-one-subnet.tr file
+  NS_DEBUG("Configure Tracing.");
   AsciiTrace asciitrace ("csma-one-subnet.tr");
   asciitrace.TraceAllNetDeviceRx ();
   asciitrace.TraceAllQueues ();
@@ -160,7 +190,8 @@
   PcapTrace pcaptrace ("csma-one-subnet.pcap");
   pcaptrace.TraceAllIp ();
 
+  NS_DEBUG("Run Simulation.");
   Simulator::Run ();
-    
   Simulator::Destroy ();
+  NS_DEBUG("Done.");
 }
--- a/examples/simple-point-to-point.cc	Sun Aug 12 15:51:12 2007 -0700
+++ b/examples/simple-point-to-point.cc	Sun Aug 12 22:41:24 2007 -0700
@@ -38,11 +38,7 @@
 // - Tracing of queues and packet receptions to file 
 //   "simple-point-to-point.tr"
 
-#include <iostream>
-#include <fstream>
-#include <string>
-#include <cassert>
-
+#include "ns3/debug.h"
 #include "ns3/command-line.h"
 #include "ns3/default-value.h"
 #include "ns3/ptr.h"
@@ -67,20 +63,47 @@
 
 using namespace ns3;
 
-int main (int argc, char *argv[])
+NS_DEBUG_COMPONENT_DEFINE ("Me");
+
+int 
+main (int argc, char *argv[])
 {
 
   // Users may find it convenient to turn on explicit debugging
   // for selected modules; the below lines suggest how to do this
 #if 0 
+  DebugComponentEnable("Me");
   DebugComponentEnable("Object");
   DebugComponentEnable("Queue");
   DebugComponentEnable("DropTailQueue");
   DebugComponentEnable("Channel");
   DebugComponentEnable("PointToPointChannel");
   DebugComponentEnable("PointToPointNetDevice");
+  DebugComponentEnable("Ipv4L3Protocol");
+  DebugComponentEnable("NetDevice");
+  DebugComponentEnable("PacketSocket");
+  DebugComponentEnable("OnOffApplication");
+  DebugComponentEnable("UdpSocket");
+  DebugComponentEnable("UdpL4Protocol");
+  DebugComponentEnable("Ipv4L3Protocol");
+  DebugComponentEnable("Ipv4StaticRouting");
+  DebugComponentEnable("Ipv4Interface");
+  DebugComponentEnable("ArpIpv4Interface");
+  DebugComponentEnable("Ipv4LoopbackInterface");
 #endif
 
+  DebugComponentEnable("Me");
+  DebugComponentEnable("OnOffApplication");
+  DebugComponentEnable("UdpSocket");
+  DebugComponentEnable("UdpL4Protocol");
+  DebugComponentEnable("Ipv4L3Protocol");
+  DebugComponentEnable("Ipv4StaticRouting");
+  DebugComponentEnable("PointToPointChannel");
+  DebugComponentEnable("PointToPointNetDevice");
+  DebugComponentEnable("Ipv4Interface");
+  DebugComponentEnable("ArpIpv4Interface");
+  DebugComponentEnable("Ipv4LoopbackInterface");
+
   // Set up some default values for the simulation.  Use the Bind()
   // technique to tell the system what subclass of Queue to use,
   // and what the queue limit is
@@ -100,12 +123,14 @@
 
   // Here, we will explicitly create four nodes.  In more sophisticated
   // topologies, we could configure a node factory.
+  NS_DEBUG("Create nodes.");
   Ptr<Node> n0 = Create<InternetNode> ();
   Ptr<Node> n1 = Create<InternetNode> (); 
   Ptr<Node> n2 = Create<InternetNode> (); 
   Ptr<Node> n3 = Create<InternetNode> ();
 
   // We create the channels first without any IP addressing information
+  NS_DEBUG("Create channels.");
   Ptr<PointToPointChannel> channel0 = 
     PointToPointTopology::AddPointToPointLink (
       n0, n2, DataRate(5000000), MilliSeconds(2));
@@ -119,6 +144,7 @@
       n2, n3, DataRate(1500000), MilliSeconds(10));
   
   // Later, we add IP addresses.  
+  NS_DEBUG("Assign IP Addresses.");
   PointToPointTopology::AddIpv4Addresses (
       channel0, n0, Ipv4Address("10.1.1.1"),
       n2, Ipv4Address("10.1.1.2"));
@@ -135,13 +161,14 @@
   // NetDevice creation, IP Address assignment, and routing) are 
   // separated because there may be a need to postpone IP Address
   // assignment (emulation) or modify to use dynamic routing
+  NS_DEBUG("Add Static Routes.");
   PointToPointTopology::AddIpv4Routes(n0, n2, channel0);
   PointToPointTopology::AddIpv4Routes(n1, n2, channel1);
   PointToPointTopology::AddIpv4Routes(n2, n3, channel2);
 
-
   // Create the OnOff application to send UDP datagrams of size
   // 210 bytes at a rate of 448 Kb/s
+  NS_DEBUG("Create Applications.");
   Ptr<OnOffApplication> ooff = Create<OnOffApplication> (
     n0, 
     InetSocketAddress ("10.1.3.2", 80), 
@@ -165,6 +192,7 @@
 
   // Here, finish off packet routing configuration
   // This will likely set by some global StaticRouting object in the future
+  NS_DEBUG("Set Default Routes.");
   Ptr<Ipv4> ipv4;
   ipv4 = n0->QueryInterface<Ipv4> (Ipv4::iid);
   ipv4->SetDefaultRoute (Ipv4Address ("10.1.1.2"), 1);
@@ -173,6 +201,7 @@
   
   // Configure tracing of all enqueue, dequeue, and NetDevice receive events
   // Trace output will be sent to the simple-point-to-point.tr file
+  NS_DEBUG("Configure Tracing.");
   AsciiTrace asciitrace ("simple-point-to-point.tr");
   asciitrace.TraceAllQueues ();
   asciitrace.TraceAllNetDeviceRx ();
@@ -185,7 +214,8 @@
   PcapTrace pcaptrace ("simple-point-to-point.pcap");
   pcaptrace.TraceAllIp ();
 
-  Simulator::Run ();
-    
+  NS_DEBUG("Run Simulation.");
+  Simulator::Run ();    
   Simulator::Destroy ();
+  NS_DEBUG("Done.");
 }
--- a/src/devices/csma/csma-ipv4-topology.cc	Sun Aug 12 15:51:12 2007 -0700
+++ b/src/devices/csma/csma-ipv4-topology.cc	Sun Aug 12 22:41:24 2007 -0700
@@ -36,15 +36,15 @@
 
 uint32_t
 CsmaIpv4Topology::AddIpv4CsmaNode(Ptr<Node> n1,
-                                      Ptr<CsmaChannel> ch,
-                                      Eui48Address addr)
+                                  Ptr<CsmaChannel> ch,
+                                  Eui48Address addr)
 {
   Ptr<Queue> q = Queue::CreateDefault ();
 
   // assume full-duplex
   Ptr<CsmaNetDevice> nd0 = Create<CsmaNetDevice> (n1, addr, 
-                                                      ns3::CsmaNetDevice::IP_ARP,
-                                                      true, true);
+                                                  ns3::CsmaNetDevice::IP_ARP,
+                                                  true, true);
   nd0->AddQueue(q);
   nd0->Attach (ch);
   return nd0->GetIfIndex ();
@@ -53,51 +53,50 @@
 
 void
 CsmaIpv4Topology::AddIpv4LlcCsmaNode(Ptr<Node> n1,
-                                         Ptr<CsmaChannel> ch,
-                                         Eui48Address addr)
+                                     Ptr<CsmaChannel> ch,
+                                     Eui48Address addr)
 {
   Ptr<Queue> q = Queue::CreateDefault ();
 
   Ptr<CsmaNetDevice> nd0 = Create<CsmaNetDevice> (n1, addr,
-                                                      ns3::CsmaNetDevice::LLC,
-                                                      true, false);
+                                                  ns3::CsmaNetDevice::LLC,
+                                                  true, false);
   nd0->AddQueue(q);
   nd0->Attach (ch);
 
   Ptr<CsmaNetDevice> nd1 = Create<CsmaNetDevice> (n1, addr,
-                                                      ns3::CsmaNetDevice::LLC,
-                                                      false, true);
+                                                  ns3::CsmaNetDevice::LLC,
+                                                  false, true);
   nd1->AddQueue(q);
   nd1->Attach (ch);
 }
 
 void
 CsmaIpv4Topology::AddIpv4RawCsmaNode(Ptr<Node> n1,
-                                         Ptr<CsmaChannel> ch,
-                                         Eui48Address addr)
+                                     Ptr<CsmaChannel> ch,
+                                     Eui48Address addr)
 {
   Ptr<Queue> q = Queue::CreateDefault ();
 
   Ptr<CsmaNetDevice> nd0 = Create<CsmaNetDevice> (n1, addr,
-                                                      ns3::CsmaNetDevice::RAW,
-                                                      true, false);
+                                                  ns3::CsmaNetDevice::RAW,
+                                                  true, false);
   nd0->AddQueue(q);
   nd0->Attach (ch);
 
   Ptr<CsmaNetDevice> nd1 = Create<CsmaNetDevice> (n1, addr,
-                                                      ns3::CsmaNetDevice::RAW,
-                                                      false, true);
+                                                  ns3::CsmaNetDevice::RAW,
+                                                  false, true);
   nd1->AddQueue(q);
   nd1->Attach (ch);
 }
 
 void
 CsmaIpv4Topology::AddIpv4Address(Ptr<Node> n1,
-                                       int ndNum,
-                                       const Ipv4Address& addr1,
-                                       const Ipv4Mask& netmask1)
+                                 int ndNum,
+                                 const Ipv4Address& addr1,
+                                 const Ipv4Mask& netmask1)
 {
-
   // Duplex link is assumed to be subnetted as a /30
   // May run this unnumbered in the future?
   Ipv4Mask netmask(netmask1);
@@ -110,7 +109,6 @@
   ip1->SetAddress (index1, addr1);
   ip1->SetNetworkMask (index1, netmask);
   ip1->SetUp (index1);
-
 }
 
 void
@@ -133,7 +131,7 @@
           found = true;
         }
     }
-  NS_ASSERT(found);
+  NS_ASSERT (found);
 
   uint32_t index2 = 0;
   found = false;
@@ -145,7 +143,7 @@
           found = true;
         }
     }
-  NS_ASSERT(found);
+  NS_ASSERT (found);
 
   ip1->AddHostRouteTo (ip2-> GetAddress (index2), index1);
   ip2->AddHostRouteTo (ip1-> GetAddress (index1), index2); 
--- a/src/internet-node/arp-ipv4-interface.cc	Sun Aug 12 15:51:12 2007 -0700
+++ b/src/internet-node/arp-ipv4-interface.cc	Sun Aug 12 22:41:24 2007 -0700
@@ -31,18 +31,26 @@
 #include "ipv4-l3-protocol.h"
 #include "arp-l3-protocol.h"
 
+NS_DEBUG_COMPONENT_DEFINE ("ArpIpv4Interface");
+
 namespace ns3 {
 
 ArpIpv4Interface::ArpIpv4Interface (Ptr<Node> node, Ptr<NetDevice> device)
   : Ipv4Interface (device),
     m_node (node)
-{}
+{
+  NS_DEBUG ("ArpIpv4Interface::ArpIpv4Interface ()");
+}
+
 ArpIpv4Interface::~ArpIpv4Interface ()
-{}
+{
+  NS_DEBUG ("ArpIpv4Interface::~ArpIpv4Interface ()");
+}
 
 TraceResolver *
 ArpIpv4Interface::DoCreateTraceResolver (TraceContext const &context)
 {
+  NS_DEBUG ("ArpIpv4Interface::DoCreateTraceResolver ()");
   CompositeTraceResolver *resolver = new CompositeTraceResolver (context);
   if (GetDevice () != 0)
     {
@@ -56,31 +64,41 @@
 void 
 ArpIpv4Interface::SendTo (Packet p, Ipv4Address dest)
 {
+  NS_DEBUG ("ArpIpv4Interface::SendTo (" << &p << ", " << dest << ")");
+
   NS_ASSERT (GetDevice () != 0);
   if (GetDevice ()->NeedsArp ())
     {
-      Ptr<ArpL3Protocol> arp = m_node->QueryInterface<ArpL3Protocol> (ArpL3Protocol::iid);
+      NS_DEBUG ("ArpIpv4Interface::SendTo (): Needs ARP");
+      Ptr<ArpL3Protocol> arp = 
+        m_node->QueryInterface<ArpL3Protocol> (ArpL3Protocol::iid);
       Address hardwareDestination;
       bool found;
 
       if (dest.IsBroadcast ())
         {
+          NS_DEBUG ("ArpIpv4Interface::SendTo (): IsBroadcast");
           hardwareDestination = GetDevice ()->GetBroadcast ();
           found = true;
         }
       else
         {
+          NS_DEBUG ("ArpIpv4Interface::SendTo (): ARP Lookup");
           found = arp->Lookup (p, dest, GetDevice (), &hardwareDestination);
         }
 
       if (found)
         {
-          GetDevice ()->Send (p, hardwareDestination, Ipv4L3Protocol::PROT_NUMBER);
+          NS_DEBUG ("ArpIpv4Interface::SendTo (): Address Resolved.  Send.");
+          GetDevice ()->Send (p, hardwareDestination, 
+            Ipv4L3Protocol::PROT_NUMBER);
         }
     }
   else
     {
-      GetDevice ()->Send (p, GetDevice ()->GetBroadcast (), Ipv4L3Protocol::PROT_NUMBER);
+      NS_DEBUG ("ArpIpv4Interface::SendTo (): Doesn't need ARP");
+      GetDevice ()->Send (p, GetDevice ()->GetBroadcast (), 
+        Ipv4L3Protocol::PROT_NUMBER);
     }
 }
 
--- a/src/internet-node/ipv4-interface.cc	Sun Aug 12 15:51:12 2007 -0700
+++ b/src/internet-node/ipv4-interface.cc	Sun Aug 12 22:41:24 2007 -0700
@@ -22,6 +22,9 @@
 #include "ipv4-interface.h"
 #include "ns3/ipv4-address.h"
 #include "ns3/net-device.h"
+#include "ns3/debug.h"
+
+NS_DEBUG_COMPONENT_DEFINE ("Ipv4Interface");
 
 namespace ns3 {
 
@@ -34,56 +37,72 @@
 Ipv4Interface::Ipv4Interface (Ptr<NetDevice> nd) 
   : m_netdevice (nd), 
     m_ifup(false)
-{}
+{
+  NS_DEBUG ("Ipv4Interface::Ipv4Interface (" << &nd << ")");
+}
 
 Ipv4Interface::~Ipv4Interface ()
-{}
+{
+  NS_DEBUG ("Ipv4Interface::~Ipv4Interface ()");
+}
 
 Ptr<NetDevice>
 Ipv4Interface::GetDevice (void) const
 {
+  NS_DEBUG ("Ipv4Interface::GetDevice ()");
   return m_netdevice;
 }
 
 TraceResolver *
 Ipv4Interface::CreateTraceResolver (TraceContext const &context)
 {
+  NS_DEBUG ("Ipv4Interface::CreateTraceResolver (" << &context << ")");
   return DoCreateTraceResolver (context);
 }
 
 void 
 Ipv4Interface::SetAddress (Ipv4Address a)
 {
+  NS_DEBUG ("Ipv4Interface::SetAddress (" << a << ")");
   m_address = a;
 }
+
 void 
 Ipv4Interface::SetNetworkMask (Ipv4Mask mask)
 {
+  NS_DEBUG ("Ipv4Interface::SetMask (" << mask << ")");
   m_netmask = mask;
 }
 
 Ipv4Address
 Ipv4Interface::GetBroadcast (void) const
 {
+  NS_DEBUG ("Ipv4Interface::GetBroadcast ()");
+
   uint32_t mask = m_netmask.GetHostOrder ();
   uint32_t address = m_address.GetHostOrder ();
   Ipv4Address broadcast = Ipv4Address (address | (~mask));
   return broadcast;
 }
+
 Ipv4Mask 
 Ipv4Interface::GetNetworkMask (void) const
 {
+  NS_DEBUG ("Ipv4Interface::GetNetworkMask ()");
   return m_netmask;
 }
+
 Ipv4Address 
 Ipv4Interface::GetAddress (void) const
 {
+  NS_DEBUG ("Ipv4Interface::Address ()");
   return m_address;
 }
 
 uint16_t 
 Ipv4Interface::GetMtu (void) const
 {
+  NS_DEBUG ("Ipv4Interface::GetMtu ()");
   if (m_netdevice == 0)
     {
       uint32_t mtu = (1<<16) - 1;
@@ -92,32 +111,36 @@
   return m_netdevice->GetMtu ();
 }
 
-  /**
-   * These are IP interface states and may be distinct from 
-   * NetDevice states, such as found in real implementations
-   * (where the device may be down but IP interface state is still up).
-   */
+/**
+ * These are IP interface states and may be distinct from 
+ * NetDevice states, such as found in real implementations
+ * (where the device may be down but IP interface state is still up).
+ */
 bool 
 Ipv4Interface::IsUp (void) const
 {
+  NS_DEBUG ("Ipv4Interface::IsUp ()");
   return m_ifup;
 }
 
 bool 
 Ipv4Interface::IsDown (void) const
 {
+  NS_DEBUG ("Ipv4Interface::IsDown ()");
   return !m_ifup;
 }
 
 void 
 Ipv4Interface::SetUp (void)
 {
+  NS_DEBUG ("Ipv4Interface::SetUp ()");
   m_ifup = true;
 }
 
 void 
 Ipv4Interface::SetDown (void)
 {
+  NS_DEBUG ("Ipv4Interface::SetDown ()");
   m_ifup = false;
 }
 
@@ -125,7 +148,10 @@
 void 
 Ipv4Interface::Send(Packet p, Ipv4Address dest)
 {
+  NS_DEBUG ("Ipv4Interface::Send ()");
+
   if (IsUp()) {
+    NS_DEBUG ("Ipv4Interface::Send (): SendTo ()");
     SendTo(p, dest);
   }
 }
--- a/src/internet-node/ipv4-l3-protocol.cc	Sun Aug 12 15:51:12 2007 -0700
+++ b/src/internet-node/ipv4-l3-protocol.cc	Sun Aug 12 22:41:24 2007 -0700
@@ -494,25 +494,32 @@
 
   if (!found)
     {
-      NS_DEBUG ("no route to host. drop.");
+      NS_DEBUG ("Ipv4L3Protocol::SendRealOut (): No route to host.  Drop.");
       m_dropTrace (packet);
       return;
     }
+
+  NS_DEBUG ("Ipv4L3Protocol::SendRealOut (): Send via interface " <<
+        route.GetInterface ());
+
   packet.AddHeader (ipHeader);
   Ipv4Interface *outInterface = GetInterface (route.GetInterface ());
   NS_ASSERT (packet.GetSize () <= outInterface->GetMtu ());
   m_txTrace (packet, route.GetInterface ());
   if (route.IsGateway ()) 
     {
+      NS_DEBUG ("Ipv4L3Protocol::SendRealOut (): Send to gateway " <<
+        route.GetGateway ());
       outInterface->Send (packet, route.GetGateway ());
     } 
   else 
     {
+      NS_DEBUG ("Ipv4L3Protocol::SendRealOut (): Send to destination " <<
+        ipHeader.GetDestination ());
       outInterface->Send (packet, ipHeader.GetDestination ());
     }
 }
 
-
 bool
 Ipv4L3Protocol::Forwarding (Packet const &packet, Ipv4Header &ipHeader, Ptr<NetDevice> device)
 {
@@ -524,7 +531,8 @@
     {
       if ((*i)->GetAddress ().IsEqual (ipHeader.GetDestination ())) 
         {
-          NS_DEBUG ("for me 1");
+          NS_DEBUG("Ipv4L3Protocol::Forwarding (): "
+            "For me (destination match)");
           return false;
         }
     }
@@ -537,7 +545,8 @@
 	{
 	  if (ipHeader.GetDestination ().IsEqual (interface->GetBroadcast ())) 
 	    {
-	      NS_DEBUG ("for me 2");
+              NS_DEBUG("Ipv4L3Protocol::Forwarding (): "
+                "For me (interface broadcast address)");
 	      return false;
 	    }
 	  break;
@@ -546,25 +555,30 @@
       
   if (ipHeader.GetDestination ().IsBroadcast ()) 
     {
-      NS_DEBUG ("for me 3");
+      NS_DEBUG("Ipv4L3Protocol::Forwarding (): "
+        "For me (Ipv4Addr broadcast address)");
       return false;
     }
+
   if (ipHeader.GetDestination ().IsEqual (Ipv4Address::GetAny ())) 
     {
-      NS_DEBUG ("for me 4");
+      NS_DEBUG("Ipv4L3Protocol::Forwarding (): "
+        "For me (Ipv4Addr any address)");
       return false;
     }
+
   if (ipHeader.GetTtl () == 1) 
     {
       // Should send ttl expired here
       // XXX
-      NS_DEBUG ("not for me -- ttl expired. drop.");
+      NS_DEBUG("Ipv4L3Protocol::Forwarding (): "
+        "Not for me (TTL expired).  Drop");
       m_dropTrace (packet);
       return true;
     }
   ipHeader.SetTtl (ipHeader.GetTtl () - 1);
 
-  NS_DEBUG ("forwarding.");
+  NS_DEBUG("Ipv4L3Protocol::Forwarding (): Forwarding packet.");
   Lookup (ipHeader, packet,
           MakeCallback (&Ipv4L3Protocol::SendRealOut, this));
 //
@@ -578,12 +592,13 @@
       if ((*i).first.IsEqual (ipHeader.GetSource ()) &&
           (*i).second.IsEqual (ipHeader.GetDestination ()))
         {
-          NS_DEBUG ("for me 5");
+          NS_DEBUG("Ipv4L3Protocol::Forwarding (): "
+            "For me (Joined multicast group)");
           return false;
         }
     }
   
-  NS_DEBUG ("not for me.");
+  NS_DEBUG("Ipv4L3Protocol::Forwarding (): Not for me.");
   return true;
 }
 
--- a/src/internet-node/ipv4-loopback-interface.cc	Sun Aug 12 15:51:12 2007 -0700
+++ b/src/internet-node/ipv4-loopback-interface.cc	Sun Aug 12 22:41:24 2007 -0700
@@ -19,6 +19,8 @@
  * Authors: 
  *  Mathieu Lacage <mathieu.lacage@sophia.inria.fr>,
  */
+
+#include "ns3/debug.h"
 #include "ns3/empty-trace-resolver.h"
 #include "ns3/net-device.h"
 #include "ns3/node.h"
@@ -26,26 +28,40 @@
 #include "ipv4-loopback-interface.h"
 #include "ipv4-l3-protocol.h"
 
+NS_DEBUG_COMPONENT_DEFINE ("Ipv4LoopbackInterface");
+
 namespace ns3 {
 
 Ipv4LoopbackInterface::Ipv4LoopbackInterface (Ptr<Node> node)
   : Ipv4Interface (0),
     m_node (node)
-{}
+{
+  NS_DEBUG("Ipv4LoopbackInterface::Ipv4LoopbackInterface ()");
+}
+
 Ipv4LoopbackInterface::~Ipv4LoopbackInterface ()
-{}
+{
+  NS_DEBUG("Ipv4LoopbackInterface::~Ipv4LoopbackInterface ()");
+}
 
 TraceResolver *
 Ipv4LoopbackInterface::DoCreateTraceResolver (TraceContext const &context)
 {
+  NS_DEBUG("Ipv4LoopbackInterface::DoCreateTraceResolver ()");
   return new EmptyTraceResolver (context);
 }
 
 void 
 Ipv4LoopbackInterface::SendTo (Packet packet, Ipv4Address dest)
 {
-  Ptr<Ipv4L3Protocol> ipv4 = m_node->QueryInterface<Ipv4L3Protocol> (Ipv4L3Protocol::iid);
-  ipv4->Receive (GetDevice (), packet, Ipv4L3Protocol::PROT_NUMBER, Eui48Address ("ff:ff:ff:ff:ff:ff"));
+  NS_DEBUG("Ipv4LoopbackInterface::SendTo (" << &packet << ", " << 
+    dest << ")");
+
+  Ptr<Ipv4L3Protocol> ipv4 = 
+    m_node->QueryInterface<Ipv4L3Protocol> (Ipv4L3Protocol::iid);
+
+  ipv4->Receive (GetDevice (), packet, Ipv4L3Protocol::PROT_NUMBER, 
+    Eui48Address ("ff:ff:ff:ff:ff:ff"));
 }
 
 }//namespace ns3
--- a/src/internet-node/ipv4-static-routing.cc	Sun Aug 12 15:51:12 2007 -0700
+++ b/src/internet-node/ipv4-static-routing.cc	Sun Aug 12 22:41:24 2007 -0700
@@ -27,7 +27,6 @@
 
 namespace ns3 {
 
-
 void 
 Ipv4StaticRouting::AddHostRouteTo (Ipv4Address dest, 
                                    Ipv4Address nextHop, 
@@ -325,7 +324,6 @@
 
   NS_DEBUG ("Ipv4StaticRouting::RequestRoute (): destination = " << 
     ipHeader.GetDestination ());
-
 //
 // First, see if this is a multicast packet we have a route for.  If we
 // have a route, then send the packet down each of the specified interfaces.
@@ -334,12 +332,15 @@
                                             ipHeader.GetDestination ());
   if (mRoute)
     {
+      NS_DEBUG ("Ipv4StaticRouting::RequestRoute (): Multicast route");
       for (uint32_t i = 0; i < mRoute->GetNOutputInterfaces (); ++i)
         {
           Packet p = packet;
           Ipv4Route route = 
             Ipv4Route::CreateHostRouteTo(ipHeader.GetDestination (), 
               mRoute->GetOutputInterface(i));
+          NS_DEBUG ("Ipv4StaticRouting::RequestRoute (): "
+            "Send via interface " << mRoute->GetOutputInterface(i));
           routeReply (true, route, p, ipHeader);
           return true;
         }
@@ -347,6 +348,7 @@
 //
 // See if this is a unicast packet we have a route for.
 //
+  NS_DEBUG ("Ipv4StaticRouting::RequestRoute (): Unicast route");
   Ipv4Route *route = LookupStatic (ipHeader.GetDestination ());
   if (route != 0)
     {