--- a/examples/csma-broadcast.cc Thu Sep 13 12:37:30 2007 -0700
+++ b/examples/csma-broadcast.cc Thu Sep 13 17:47:42 2007 -0700
@@ -36,7 +36,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"
@@ -57,36 +57,40 @@
#include "ns3/ipv4-route.h"
#include "ns3/onoff-application.h"
-
using namespace ns3;
+NS_LOG_COMPONENT_DEFINE ("CsmaBroadcastExample");
-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("Object");
- DebugComponentEnable("Queue");
- DebugComponentEnable("DropTailQueue");
- DebugComponentEnable("Channel");
- DebugComponentEnable("CsmaChannel");
- DebugComponentEnable("NetDevice");
- DebugComponentEnable("CsmaNetDevice");
- DebugComponentEnable("Ipv4L3Protocol");
- DebugComponentEnable("OnOffApplication");
- DebugComponentEnable("PacketSocket");
- DebugComponentEnable("Socket");
- DebugComponentEnable("UdpSocket");
- DebugComponentEnable("UdpL4Protocol");
- DebugComponentEnable("Ipv4L3Protocol");
- DebugComponentEnable("Ipv4StaticRouting");
- DebugComponentEnable("Ipv4Interface");
- DebugComponentEnable("ArpIpv4Interface");
- DebugComponentEnable("Ipv4LoopbackInterface");
+ LogComponentEnable ("CsmaBroadcastExample", LOG_LEVEL_INFO);
+
+ 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
-
// 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
@@ -101,11 +105,13 @@
// 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<InternetNode> ();
Ptr<Node> n1 = Create<InternetNode> ();
Ptr<Node> n2 = Create<InternetNode> ();
// We create the channels first without any IP addressing information
+ NS_LOG_INFO ("Create channels.");
Ptr<CsmaChannel> channel0 =
CsmaTopology::CreateCsmaChannel(
DataRate(5000000), MilliSeconds(2));
@@ -115,6 +121,7 @@
CsmaTopology::CreateCsmaChannel(
DataRate(5000000), MilliSeconds(2));
+ NS_LOG_INFO ("Build Topology.");
uint32_t n0ifIndex0 = CsmaIpv4Topology::AddIpv4CsmaNetDevice (n0, channel0,
Mac48Address("10:54:23:54:0:50"));
uint32_t n0ifIndex1 = CsmaIpv4Topology::AddIpv4CsmaNetDevice (n0, channel1,
@@ -125,6 +132,7 @@
Mac48Address("10:54:23:54:23:52"));
// Later, we add IP addresses.
+ NS_LOG_INFO ("Assign IP Addresses.");
CsmaIpv4Topology::AddIpv4Address (
n0, n0ifIndex0, Ipv4Address("10.1.0.1"), Ipv4Mask("255.255.0.0"));
@@ -152,6 +160,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_LOG_INFO ("Create Applications.");
Ptr<OnOffApplication> ooff = Create<OnOffApplication> (
n0,
InetSocketAddress ("255.255.255.255", 80),
@@ -162,7 +171,7 @@
ooff->Start(Seconds(1.0));
ooff->Stop (Seconds(10.0));
-
+ NS_LOG_INFO ("Configure Tracing.");
// Configure tracing of all enqueue, dequeue, and NetDevice receive events
// Trace output will be sent to the csma-broadcast.tr file
AsciiTrace asciitrace ("csma-broadcast.tr");
@@ -177,7 +186,8 @@
PcapTrace pcaptrace ("csma-broadcast.pcap");
pcaptrace.TraceAllIp ();
- Simulator::Run ();
-
+ NS_LOG_INFO ("Run Simulation.");
+ Simulator::Run ();
Simulator::Destroy ();
+ NS_LOG_INFO ("Done.");
}
--- a/examples/csma-multicast.cc Thu Sep 13 12:37:30 2007 -0700
+++ b/examples/csma-multicast.cc Thu Sep 13 17:47:42 2007 -0700
@@ -33,7 +33,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"
#include "ns3/data-rate.h"
@@ -54,7 +54,7 @@
using namespace ns3;
-NS_DEBUG_COMPONENT_DEFINE ("CsmaMulticast");
+NS_LOG_COMPONENT_DEFINE ("CsmaMulticastExample");
int
main (int argc, char *argv[])
@@ -64,28 +64,30 @@
// for selected modules; the below lines suggest how to do this
//
#if 0
- DebugComponentEnable("CsmaMulticast");
+ LogComponentEnable ("CsmaMulticastExample", LOG_LEVEL_INFO);
- DebugComponentEnable("Object");
- DebugComponentEnable("Queue");
- DebugComponentEnable("DropTailQueue");
- DebugComponentEnable("Channel");
- DebugComponentEnable("CsmaChannel");
- DebugComponentEnable("NetDevice");
- DebugComponentEnable("CsmaNetDevice");
- DebugComponentEnable("Ipv4L3Protocol");
- DebugComponentEnable("OnOffApplication");
- DebugComponentEnable("PacketSocket");
- DebugComponentEnable("Socket");
- DebugComponentEnable("UdpSocket");
- DebugComponentEnable("UdpL4Protocol");
- DebugComponentEnable("Ipv4L3Protocol");
- DebugComponentEnable("Ipv4StaticRouting");
- DebugComponentEnable("Ipv4Interface");
- DebugComponentEnable("ArpIpv4Interface");
- DebugComponentEnable("Ipv4LoopbackInterface");
+ 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
-
//
// Set up default values for the simulation. Use the DefaultValue::Bind()
// technique to tell the system what subclass of Queue to use. The Bind
@@ -101,14 +103,14 @@
//
// Explicitly create the nodes required by the topology (shown above).
//
- NS_DEBUG("Create nodes.");
+ NS_LOG_INFO ("Create nodes.");
Ptr<Node> n0 = Create<InternetNode> ();
Ptr<Node> n1 = Create<InternetNode> ();
Ptr<Node> n2 = Create<InternetNode> ();
Ptr<Node> n3 = Create<InternetNode> ();
Ptr<Node> n4 = Create<InternetNode> ();
- NS_DEBUG("Create channels.");
+ NS_LOG_INFO ("Create channels.");
//
// Explicitly create the channels required by the topology (shown above).
//
@@ -118,7 +120,7 @@
Ptr<CsmaChannel> lan1 =
CsmaTopology::CreateCsmaChannel(DataRate(5000000), MilliSeconds(2));
- NS_DEBUG("Build Topology.");
+ NS_LOG_INFO ("Build Topology.");
//
// Now fill out the topology by creating the net devices required to connect
// the nodes to the channels and hooking them up. AddIpv4CsmaNetDevice will
@@ -144,17 +146,16 @@
uint32_t nd4 = CsmaIpv4Topology::AddIpv4CsmaNetDevice (n4, lan1,
Mac48Address("08:00:2e:00:00:05"));
- NS_DEBUG ("nd0 = " << nd0);
- NS_DEBUG ("nd1 = " << nd1);
- NS_DEBUG ("nd2Lan0 = " << nd2Lan0);
- NS_DEBUG ("nd2Lan1 = " << nd2Lan1);
- NS_DEBUG ("nd3 = " << nd3);
- NS_DEBUG ("nd4 = " << nd3);
+ NS_LOG_INFO ("nd0 = " << nd0);
+ NS_LOG_INFO ("nd1 = " << nd1);
+ NS_LOG_INFO ("nd2Lan0 = " << nd2Lan0);
+ NS_LOG_INFO ("nd2Lan1 = " << nd2Lan1);
+ NS_LOG_INFO ("nd3 = " << nd3);
+ NS_LOG_INFO ("nd4 = " << nd3);
//
// We've got the "hardware" in place. Now we need to add IP addresses.
//
- NS_DEBUG("Assign IP Addresses.");
-
+ NS_LOG_INFO ("Assign IP Addresses.");
CsmaIpv4Topology::AddIpv4Address (n0, nd0, Ipv4Address ("10.1.1.1"),
Ipv4Mask ("255.255.255.0"));
@@ -181,7 +182,7 @@
CsmaIpv4Topology::AddIpv4Address (n4, nd4, Ipv4Address ("10.1.2.3"),
Ipv4Mask ("255.255.255.0"));
- NS_DEBUG("Configure multicasting.");
+ NS_LOG_INFO ("Configure multicasting.");
//
// Now we can configure multicasting. As described above, the multicast
// source is at node zero, which we assigned the IP address of 10.1.1.1
@@ -272,7 +273,7 @@
// Create an OnOff application to send UDP datagrams from node zero to the
// multicast group (node four will be listening).
//
- NS_DEBUG("Create Applications.");
+ NS_LOG_INFO ("Create Applications.");
Ptr<OnOffApplication> ooff = Create<OnOffApplication> (
n0,
InetSocketAddress (multicastGroup, 80),
@@ -290,7 +291,7 @@
// Configure tracing of all enqueue, dequeue, and NetDevice receive events.
// Trace output will be sent to the file "csma-multicast.tr"
//
- NS_DEBUG("Configure Tracing.");
+ NS_LOG_INFO ("Configure Tracing.");
AsciiTrace asciitrace ("csma-multicast.tr");
asciitrace.TraceAllNetDeviceRx ();
asciitrace.TraceAllQueues ();
@@ -306,8 +307,8 @@
//
// Now, do the actual simulation.
//
- NS_DEBUG("Run Simulation.");
+ NS_LOG_INFO ("Run Simulation.");
Simulator::Run ();
Simulator::Destroy ();
- NS_DEBUG("Done.");
+ NS_LOG_INFO ("Done.");
}
--- a/examples/csma-one-subnet.cc Thu Sep 13 12:37:30 2007 -0700
+++ b/examples/csma-one-subnet.cc Thu Sep 13 17:47:42 2007 -0700
@@ -29,7 +29,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"
#include "ns3/data-rate.h"
@@ -50,7 +50,7 @@
using namespace ns3;
-NS_DEBUG_COMPONENT_DEFINE ("CsmaOneSubnet");
+NS_LOG_COMPONENT_DEFINE ("CsmaOneSubnetExample");
int
main (int argc, char *argv[])
@@ -60,26 +60,29 @@
// for selected modules; the below lines suggest how to do this
//
#if 0
- DebugComponentEnable("CsmaOneSubnet");
+ LogComponentEnable ("CsmaOneSubnetExample", LOG_LEVEL_INFO);
- DebugComponentEnable("Object");
- DebugComponentEnable("Queue");
- DebugComponentEnable("DropTailQueue");
- DebugComponentEnable("Channel");
- DebugComponentEnable("CsmaChannel");
- DebugComponentEnable("CsmaNetDevice");
- DebugComponentEnable("Ipv4L3Protocol");
- DebugComponentEnable("NetDevice");
- DebugComponentEnable("PacketSocket");
- DebugComponentEnable("OnOffApplication");
- DebugComponentEnable("Socket");
- DebugComponentEnable("UdpSocket");
- DebugComponentEnable("UdpL4Protocol");
- DebugComponentEnable("Ipv4L3Protocol");
- DebugComponentEnable("Ipv4StaticRouting");
- DebugComponentEnable("Ipv4Interface");
- DebugComponentEnable("ArpIpv4Interface");
- DebugComponentEnable("Ipv4LoopbackInterface");
+ 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
//
// Set up default values for the simulation. Use the DefaultValue::Bind()
@@ -96,20 +99,20 @@
//
// Explicitly create the nodes required by the topology (shown above).
//
- NS_DEBUG("Create nodes.");
+ NS_LOG_INFO ("Create nodes.");
Ptr<Node> n0 = Create<InternetNode> ();
Ptr<Node> n1 = Create<InternetNode> ();
Ptr<Node> n2 = Create<InternetNode> ();
Ptr<Node> n3 = Create<InternetNode> ();
- NS_DEBUG("Create channels.");
+ NS_LOG_INFO ("Create channels.");
//
// Explicitly create the channels required by the topology (shown above).
//
Ptr<CsmaChannel> lan = CsmaTopology::CreateCsmaChannel(
DataRate(5000000), MilliSeconds(2));
- NS_DEBUG("Build Topology.");
+ NS_LOG_INFO ("Build Topology.");
//
// Now fill out the topology by creating the net devices required to connect
// the nodes to the channels and hooking them up. AddIpv4CsmaNetDevice will
@@ -130,15 +133,10 @@
uint32_t nd3 = CsmaIpv4Topology::AddIpv4CsmaNetDevice (n3, lan,
Mac48Address("08:00:2e:00:00:03"));
-
- NS_DEBUG ("nd0 = " << nd0);
- NS_DEBUG ("nd1 = " << nd1);
- NS_DEBUG ("nd2 = " << nd2);
- NS_DEBUG ("nd3 = " << nd3);
//
// We've got the "hardware" in place. Now we need to add IP addresses.
//
- NS_DEBUG("Assign IP Addresses.");
+ NS_LOG_INFO ("Assign IP Addresses.");
//
// XXX BUGBUG
// Need a better way to get the interface index. The point-to-point topology
@@ -165,7 +163,7 @@
//
// Create an OnOff application to send UDP datagrams from node zero to node 1.
//
- NS_DEBUG("Create Applications.");
+ NS_LOG_INFO ("Create Applications.");
Ptr<OnOffApplication> ooff = Create<OnOffApplication> (
n0,
InetSocketAddress ("10.1.1.2", 80),
@@ -193,7 +191,7 @@
// Configure tracing of all enqueue, dequeue, and NetDevice receive events.
// Trace output will be sent to the file "csma-one-subnet.tr"
//
- NS_DEBUG("Configure Tracing.");
+ NS_LOG_INFO ("Configure Tracing.");
AsciiTrace asciitrace ("csma-one-subnet.tr");
asciitrace.TraceAllNetDeviceRx ();
asciitrace.TraceAllQueues ();
@@ -209,8 +207,8 @@
//
// Now, do the actual simulation.
//
- NS_DEBUG("Run Simulation.");
+ NS_LOG_INFO ("Run Simulation.");
Simulator::Run ();
Simulator::Destroy ();
- NS_DEBUG("Done.");
+ NS_LOG_INFO ("Done.");
}
--- 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.");
}
--- a/examples/mixed-global-routing.cc Thu Sep 13 12:37:30 2007 -0700
+++ b/examples/mixed-global-routing.cc Thu Sep 13 17:47:42 2007 -0700
@@ -36,7 +36,7 @@
#include <string>
#include <cassert>
-#include "ns3/debug.h"
+#include "ns3/log.h"
#include "ns3/command-line.h"
#include "ns3/default-value.h"
@@ -68,22 +68,39 @@
using namespace ns3;
-int main (int argc, char *argv[])
+NS_LOG_COMPONENT_DEFINE ("MixedGlobalRoutingExample");
+
+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 ("Object");
- DebugComponentEnable ("Queue");
- DebugComponentEnable ("DropTailQueue");
- DebugComponentEnable ("Channel");
- DebugComponentEnable ("PointToPointChannel");
- DebugComponentEnable ("PointToPointNetDevice");
- DebugComponentEnable ("GlobalRouter");
- DebugComponentEnable ("GlobalRouteManager");
+ LogComponentEnable ("MixedGlobalRoutingExample", LOG_LEVEL_INFO);
+
+ 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
-
// 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
@@ -102,6 +119,7 @@
// Bind ()s at run-time, via command-line arguments
CommandLine::Parse (argc, argv);
+ NS_LOG_INFO ("Create nodes.");
Ptr<Node> n0 = Create<InternetNode> ();
Ptr<Node> n1 = Create<InternetNode> ();
Ptr<Node> n2 = Create<InternetNode> ();
@@ -111,6 +129,7 @@
Ptr<Node> n6 = Create<InternetNode> ();
// We create the channels first without any IP addressing information
+ NS_LOG_INFO ("Create channels.");
Ptr<PointToPointChannel> channel0 =
PointToPointTopology::AddPointToPointLink (
n0, n2, DataRate (5000000), MilliSeconds (2));
@@ -128,6 +147,7 @@
CsmaTopology::CreateCsmaChannel(
DataRate(5000000), MilliSeconds(2));
+ NS_LOG_INFO ("Build Topology.");
uint32_t n2ifIndex = CsmaIpv4Topology::AddIpv4CsmaNetDevice (n2, channelc0,
Mac48Address("10:54:23:54:23:50"));
uint32_t n3ifIndex = CsmaIpv4Topology::AddIpv4CsmaNetDevice (n3, channelc0,
@@ -138,6 +158,7 @@
Mac48Address("10:54:23:54:23:53"));
// Later, we add IP addresses.
+ NS_LOG_INFO ("Assign IP Addresses.");
PointToPointTopology::AddIpv4Addresses (
channel0, n0, Ipv4Address ("10.1.1.1"),
n2, Ipv4Address ("10.1.1.2"));
@@ -168,6 +189,7 @@
// Create the OnOff application to send UDP datagrams of size
// 210 bytes at a rate of 448 Kb/s
+ NS_LOG_INFO ("Create Applications.");
Ptr<OnOffApplication> ooff = Create<OnOffApplication> (
n0,
InetSocketAddress ("10.1.3.2", 80),
@@ -182,6 +204,7 @@
// 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 ("mixed-global-routing.tr");
asciitrace.TraceAllQueues ();
asciitrace.TraceAllNetDeviceRx ();
@@ -193,7 +216,8 @@
PcapTrace pcaptrace ("mixed-global-routing.pcap");
pcaptrace.TraceAllIp ();
+ NS_LOG_INFO ("Run Simulation.");
Simulator::Run ();
-
Simulator::Destroy ();
+ NS_LOG_INFO ("Done.");
}
--- a/examples/simple-global-routing.cc Thu Sep 13 12:37:30 2007 -0700
+++ b/examples/simple-global-routing.cc Thu Sep 13 17:47:42 2007 -0700
@@ -42,7 +42,7 @@
#include <string>
#include <cassert>
-#include "ns3/debug.h"
+#include "ns3/log.h"
#include "ns3/command-line.h"
#include "ns3/default-value.h"
@@ -70,25 +70,41 @@
using namespace ns3;
-int main (int argc, char *argv[])
+NS_LOG_COMPONENT_DEFINE ("SimpleGlobalRoutingExample");
+
+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 ("Object");
- DebugComponentEnable ("Queue");
- DebugComponentEnable ("DropTailQueue");
- DebugComponentEnable ("Channel");
- DebugComponentEnable ("PointToPointChannel");
- DebugComponentEnable ("PointToPointNetDevice");
- DebugComponentEnable ("GlobalRouter");
- DebugComponentEnable ("GlobalRouteMaager");
+ LogComponentEnable ("SimpleGlobalRoutingExample", LOG_LEVEL_INFO);
+
+ 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
-
- // Set up some default values for the simulation. Use the DefaultValue::Bind ()
- // technique to tell the system what subclass of Queue to use,
- // and what the queue limit is
+ // Set up some default values for the simulation. Use the
+ // DefaultValue::Bind () technique to tell the system what subclass of
+ // Queue to use, and what the queue limit is
// The below Bind command tells the queue factory which class to
// instantiate, when the queue factory is invoked in the topology code
@@ -105,12 +121,14 @@
// 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<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_LOG_INFO ("Create channels.");
Ptr<PointToPointChannel> channel0 =
PointToPointTopology::AddPointToPointLink (
n0, n2, DataRate (5000000), MilliSeconds (2));
@@ -124,6 +142,7 @@
n2, n3, DataRate (1500000), MilliSeconds (10));
// Later, we add IP addresses.
+ NS_LOG_INFO ("Assign IP Addresses.");
PointToPointTopology::AddIpv4Addresses (
channel0, n0, Ipv4Address ("10.1.1.1"),
n2, Ipv4Address ("10.1.1.2"));
@@ -142,6 +161,7 @@
// Create the OnOff application to send UDP datagrams of size
// 210 bytes at a rate of 448 Kb/s
+ NS_LOG_INFO ("Create Applications.");
Ptr<OnOffApplication> ooff = Create<OnOffApplication> (
n0,
InetSocketAddress ("10.1.3.2", 80),
@@ -184,6 +204,7 @@
// 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 ();
@@ -195,9 +216,10 @@
PcapTrace pcaptrace ("simple-global-routing.pcap");
pcaptrace.TraceAllIp ();
+ NS_LOG_INFO ("Run Simulation.");
Simulator::Run ();
-
Simulator::Destroy ();
+ NS_LOG_INFO ("Done.");
return 0;
}
--- a/examples/simple-point-to-point.cc Thu Sep 13 12:37:30 2007 -0700
+++ b/examples/simple-point-to-point.cc Thu Sep 13 17:47:42 2007 -0700
@@ -38,7 +38,7 @@
// - Tracing of queues and packet receptions to file
// "simple-point-to-point.tr"
-#include "ns3/debug.h"
+#include "ns3/log.h"
#include "ns3/command-line.h"
#include "ns3/default-value.h"
#include "ns3/ptr.h"
@@ -64,35 +64,37 @@
using namespace ns3;
-NS_DEBUG_COMPONENT_DEFINE ("SimplePointToPoint");
+NS_LOG_COMPONENT_DEFINE ("SimplePointToPointExample");
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
- // remember to add #include "ns3/debug.h" before enabling these
#if 0
- DebugComponentEnable("SimplePointToPoint");
- DebugComponentEnable("Object");
- DebugComponentEnable("Queue");
- DebugComponentEnable("DropTailQueue");
- DebugComponentEnable("Channel");
- DebugComponentEnable("PointToPointChannel");
- DebugComponentEnable("PointToPointNetDevice");
- DebugComponentEnable("Ipv4L3Protocol");
- DebugComponentEnable("NetDevice");
- DebugComponentEnable("PacketSocket");
- DebugComponentEnable("OnOffApplication");
- DebugComponentEnable("Socket");
- DebugComponentEnable("UdpSocket");
- DebugComponentEnable("UdpL4Protocol");
- DebugComponentEnable("Ipv4L3Protocol");
- DebugComponentEnable("Ipv4StaticRouting");
- DebugComponentEnable("Ipv4Interface");
- DebugComponentEnable("ArpIpv4Interface");
- DebugComponentEnable("Ipv4LoopbackInterface");
+ LogComponentEnable ("SimplePointToPointExample", LOG_LEVEL_INFO);
+
+ 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
// Set up some default values for the simulation. Use the Bind()
@@ -114,14 +116,14 @@
// Here, we will explicitly create four nodes. In more sophisticated
// topologies, we could configure a node factory.
- NS_DEBUG("Create nodes.");
+ NS_LOG_INFO ("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.");
+ NS_LOG_INFO ("Create channels.");
Ptr<PointToPointChannel> channel0 =
PointToPointTopology::AddPointToPointLink (
n0, n2, DataRate(5000000), MilliSeconds(2));
@@ -135,7 +137,7 @@
n2, n3, DataRate(1500000), MilliSeconds(10));
// Later, we add IP addresses.
- NS_DEBUG("Assign IP Addresses.");
+ NS_LOG_INFO ("Assign IP Addresses.");
PointToPointTopology::AddIpv4Addresses (
channel0, n0, Ipv4Address("10.1.1.1"),
n2, Ipv4Address("10.1.1.2"));
@@ -152,14 +154,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.");
+ NS_LOG_INFO ("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.");
+ NS_LOG_INFO ("Create Applications.");
Ptr<OnOffApplication> ooff = Create<OnOffApplication> (
n0,
InetSocketAddress ("10.1.3.2", 80),
@@ -201,7 +203,7 @@
// Here, finish off packet routing configuration
// This will likely set by some global StaticRouting object in the future
- NS_DEBUG("Set Default Routes.");
+ NS_LOG_INFO ("Set Default Routes.");
Ptr<Ipv4> ipv4;
ipv4 = n0->QueryInterface<Ipv4> (Ipv4::iid);
ipv4->SetDefaultRoute (Ipv4Address ("10.1.1.2"), 1);
@@ -210,7 +212,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.");
+ NS_LOG_INFO ("Configure Tracing.");
AsciiTrace asciitrace ("simple-point-to-point.tr");
asciitrace.TraceAllQueues ();
asciitrace.TraceAllNetDeviceRx ();
@@ -223,8 +225,8 @@
PcapTrace pcaptrace ("simple-point-to-point.pcap");
pcaptrace.TraceAllIp ();
- NS_DEBUG("Run Simulation.");
+ NS_LOG_INFO ("Run Simulation.");
Simulator::Run ();
Simulator::Destroy ();
- NS_DEBUG("Done.");
+ NS_LOG_INFO ("Done.");
}
--- a/examples/udp-echo.cc Thu Sep 13 12:37:30 2007 -0700
+++ b/examples/udp-echo.cc Thu Sep 13 17:47:42 2007 -0700
@@ -28,7 +28,7 @@
#include "ns3/command-line.h"
#include "ns3/default-value.h"
#include "ns3/ptr.h"
-#include "ns3/debug.h"
+#include "ns3/log.h"
#include "ns3/simulator.h"
#include "ns3/nstime.h"
#include "ns3/data-rate.h"
@@ -50,7 +50,7 @@
using namespace ns3;
-NS_DEBUG_COMPONENT_DEFINE ("UdpEcho");
+NS_LOG_COMPONENT_DEFINE ("UdpEchoExample");
int
main (int argc, char *argv[])
@@ -60,33 +60,30 @@
// for selected modules; the below lines suggest how to do this
//
#if 0
- DebugComponentEnable("UdpEcho");
+ LogComponentEnable ("UdpEchoExample", LOG_LEVEL_INFO);
- DebugComponentEnable("Object");
- DebugComponentEnable("Queue");
- DebugComponentEnable("DropTailQueue");
- DebugComponentEnable("Channel");
- DebugComponentEnable("CsmaChannel");
- DebugComponentEnable("CsmaNetDevice");
- DebugComponentEnable("Ipv4L3Protocol");
- DebugComponentEnable("NetDevice");
- DebugComponentEnable("PacketSocket");
- DebugComponentEnable("OnOffApplication");
- DebugComponentEnable("Socket");
- DebugComponentEnable("UdpSocket");
- DebugComponentEnable("UdpL4Protocol");
- DebugComponentEnable("Ipv4L3Protocol");
- DebugComponentEnable("Ipv4StaticRouting");
- DebugComponentEnable("Ipv4Interface");
- DebugComponentEnable("ArpIpv4Interface");
- DebugComponentEnable("Ipv4LoopbackInterface");
- DebugComponentEnable("UdpEchoClient");
- DebugComponentEnable("UdpEchoServer");
+ 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
-
- DebugComponentEnable("UdpEcho");
- DebugComponentEnable("UdpEchoClient");
- DebugComponentEnable("UdpEchoServer");
//
// Set up default values for the simulation. Use the DefaultValue::Bind()
// technique to tell the system what subclass of Queue to use. The Bind
@@ -102,20 +99,20 @@
//
// Explicitly create the nodes required by the topology (shown above).
//
- NS_DEBUG("Create nodes.");
+ NS_LOG_INFO ("Create nodes.");
Ptr<Node> n0 = Create<InternetNode> ();
Ptr<Node> n1 = Create<InternetNode> ();
Ptr<Node> n2 = Create<InternetNode> ();
Ptr<Node> n3 = Create<InternetNode> ();
- NS_DEBUG("Create channels.");
+ NS_LOG_INFO ("Create channels.");
//
// Explicitly create the channels required by the topology (shown above).
//
Ptr<CsmaChannel> lan = CsmaTopology::CreateCsmaChannel(
DataRate(5000000), MilliSeconds(2));
- NS_DEBUG("Build Topology.");
+ NS_LOG_INFO ("Build Topology.");
//
// Now fill out the topology by creating the net devices required to connect
// the nodes to the channels and hooking them up. AddIpv4CsmaNetDevice will
@@ -139,7 +136,7 @@
//
// We've got the "hardware" in place. Now we need to add IP addresses.
//
- NS_DEBUG("Assign IP Addresses.");
+ NS_LOG_INFO ("Assign IP Addresses.");
//
// XXX BUGBUG
// Need a better way to get the interface index. The point-to-point topology
@@ -164,7 +161,7 @@
CsmaIpv4Topology::AddIpv4Address (n3, nd3, Ipv4Address("10.1.1.4"),
Ipv4Mask("255.255.255.0"));
- NS_DEBUG("Create Applications.");
+ NS_LOG_INFO ("Create Applications.");
//
// Create a UdpEchoServer application on node one.
//
@@ -193,7 +190,7 @@
// Configure tracing of all enqueue, dequeue, and NetDevice receive events.
// Trace output will be sent to the file "udp-echo.tr"
//
- NS_DEBUG("Configure Tracing.");
+ NS_LOG_INFO ("Configure Tracing.");
AsciiTrace asciitrace ("udp-echo.tr");
asciitrace.TraceAllNetDeviceRx ();
asciitrace.TraceAllQueues ();
@@ -209,8 +206,8 @@
//
// Now, do the actual simulation.
//
- NS_DEBUG("Run Simulation.");
+ NS_LOG_INFO ("Run Simulation.");
Simulator::Run ();
Simulator::Destroy ();
- NS_DEBUG("Done.");
+ NS_LOG_INFO ("Done.");
}
--- a/samples/main-channel.cc Thu Sep 13 12:37:30 2007 -0700
+++ b/samples/main-channel.cc Thu Sep 13 17:47:42 2007 -0700
@@ -18,7 +18,7 @@
*/
#include <string>
-#include "ns3/debug.h"
+#include "ns3/log.h"
#include "ns3/assert.h"
#include "ns3/packet.h"
#include "ns3/drop-tail.h"
@@ -27,6 +27,8 @@
using namespace ns3;
+NS_LOG_COMPONENT_DEFINE ("ChannelSample");
+
// ===========================================================================
// Cook up a simplistic Internet Node
// ===========================================================================
@@ -48,19 +50,19 @@
FakeInternetNode::FakeInternetNode ()
{
- NS_DEBUG_UNCOND("FakeInternetNode::FakeInternetNode ()");
+ NS_LOG_FUNCTION;
}
FakeInternetNode::~FakeInternetNode ()
{
- NS_DEBUG_UNCOND("FakeInternetNode::~FakeInternetNode ()");
+ NS_LOG_FUNCTION;
}
void
FakeInternetNode::Doit (void)
{
- NS_DEBUG_UNCOND("FakeInternetNode::Doit ()");
- NS_DEBUG_UNCOND("FakeInternetNode::Doit (): **** Send outbound packet");
+ NS_LOG_FUNCTION;
+ NS_LOG_INFO ("**** Send outbound packet");
Packet p;
m_dtqOutbound.Enqueue(p);
@@ -70,9 +72,9 @@
bool
FakeInternetNode::UpperDoSendUp (Packet &p)
{
- NS_DEBUG_UNCOND("FakeInternetNode::UpperDoSendUp (" << &p << ")");
-
- NS_DEBUG_UNCOND("FakeInternetNode::UpperDoSendUp (): **** Receive inbound packet");
+ NS_LOG_FUNCTION;
+ NS_LOG_PARAM ("(" << &p << ")");
+ NS_LOG_INFO ("**** Receive inbound packet");
m_dtqInbound.Enqueue(p);
return m_dtqInbound.Dequeue(p);
}
@@ -80,7 +82,8 @@
bool
FakeInternetNode::UpperDoPull (Packet &p)
{
- NS_DEBUG_UNCOND("FakeInternetNode::DoPull (" << &p << ")");
+ NS_LOG_FUNCTION;
+ NS_LOG_PARAM ("(" << &p << ")");
return m_dtqOutbound.Dequeue(p);
}
@@ -107,29 +110,29 @@
FakePhysicalLayer::FakePhysicalLayer ()
{
- NS_DEBUG_UNCOND("FakePhysicalLayer::FakePhysicalLayer ()");
+ NS_LOG_FUNCTION;
}
FakePhysicalLayer::~FakePhysicalLayer ()
{
- NS_DEBUG_UNCOND("FakePhysicalLayer::~FakePhysicalLayer ()");
+ NS_LOG_FUNCTION;
}
bool
FakePhysicalLayer::LowerDoNotify (LayerConnectorUpper *upper)
{
- NS_DEBUG_UNCOND("FakePhysicalLayer::LowerDoNotify ()");
+ NS_LOG_FUNCTION;
Packet p;
- NS_DEBUG_UNCOND("FakePhysicalLayer::LowerDoNotify (): Starting pull");
+ NS_LOG_LOGIC ("Starting pull");
NS_ASSERT(m_upperPartner);
m_upperPartner->UpperPull(p);
m_dtqOutbound.Enqueue(p);
- NS_DEBUG_UNCOND("FakePhysicalLayer::LowerDoNotify (): Got bits, Notify lower");
+ NS_LOG_LOGIC ("Got bits, Notify lower");
NS_ASSERT(m_lowerPartner);
return m_lowerPartner->LowerNotify(this);
@@ -138,7 +141,8 @@
bool
FakePhysicalLayer::UpperDoSendUp (Packet &p)
{
- NS_DEBUG_UNCOND("FakePhysicalLayer::UpperDoSendUp (" << &p << ")");
+ NS_LOG_FUNCTION;
+ NS_LOG_PARAM ("(" << &p << ")");
NS_ASSERT(m_upperPartner);
return m_upperPartner->UpperSendUp(p);
@@ -147,7 +151,8 @@
bool
FakePhysicalLayer::UpperDoPull (Packet &p)
{
- NS_DEBUG_UNCOND("FakePhysicalLayer::DoPull (" << &p << ")");
+ NS_LOG_FUNCTION;
+ NS_LOG_PARAM ("(" << &p << ")");
return m_dtqOutbound.Dequeue(p);
}
@@ -164,24 +169,17 @@
FakeChannel::FakeChannel ()
{
- NS_DEBUG_UNCOND("FakeChannel::FakeChannel ()");
+ NS_LOG_FUNCTION;
}
FakeChannel::~FakeChannel ()
{
- NS_DEBUG_UNCOND("FakeChannel::~FakeChannel ()");
+ NS_LOG_FUNCTION;
}
int main (int argc, char *argv[])
{
- NS_DEBUG_UNCOND("Channel Hackorama");
-
-#if 0
- DebugComponentEnable("Queue");
- DebugComponentEnable("DropTailQueue");
- DebugComponentEnable("LayerConnector");
- DebugComponentEnable("Channel");
-#endif
+ NS_LOG_INFO ("Channel Hackorama");
FakeInternetNode node1, node2, node3, node4;
FakePhysicalLayer phys1, phys2, phys3, phys4;
--- a/samples/main-default-value.cc Thu Sep 13 12:37:30 2007 -0700
+++ b/samples/main-default-value.cc Thu Sep 13 17:47:42 2007 -0700
@@ -3,7 +3,7 @@
#include <string>
#include "ns3/default-value.h"
#include "ns3/command-line.h"
-#include "ns3/debug.h"
+#include "ns3/log.h"
using namespace ns3;
@@ -76,9 +76,9 @@
DefaultValue::Bind("testInt1", "57");
TestClass* testclass = new TestClass ();
- NS_DEBUG_UNCOND("TestBool1 default value (" << testclass->m_testBool1 << ")");
- NS_DEBUG_UNCOND("TestInt1 default value (" << testclass->m_testInt1 << ")");
- NS_DEBUG_UNCOND("TestInt2 default value (" << testclass->m_testInt2 << ")");
+ NS_LOG_UNCOND("TestBool1 default value (" << testclass->m_testBool1 << ")");
+ NS_LOG_UNCOND("TestInt1 default value (" << testclass->m_testInt1 << ")");
+ NS_LOG_UNCOND("TestInt2 default value (" << testclass->m_testInt2 << ")");
delete testclass;
return 0;
--- a/samples/main-query-interface.cc Thu Sep 13 12:37:30 2007 -0700
+++ b/samples/main-query-interface.cc Thu Sep 13 17:47:42 2007 -0700
@@ -17,7 +17,7 @@
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
-#include "ns3/debug.h"
+#include "ns3/log.h"
#include "ns3/object.h"
#include "ns3/component-manager.h"
@@ -79,10 +79,11 @@
void
AnInterface::methodA (void)
{
+ NS_LOG_FUNCTION;
// pre-dispatch asserts
- NS_DEBUG_UNCOND("AnInterface pre-condition::methodA");
+ NS_LOG_LOGIC ("pre-condition");
domethodA ();
- NS_DEBUG_UNCOND("AnInterface post-condition::methodA\n");
+ NS_LOG_LOGIC ("post-condition");
// post-dispatch asserts
}
@@ -114,12 +115,13 @@
void
AnImplementation::methodImpl (void)
{
- NS_DEBUG_UNCOND("AnImplementation::methodImpl\n");
+ NS_LOG_FUNCTION;
}
AnImplementation::AnImplementation (void)
{
+ NS_LOG_FUNCTION;
// enable our interface
SetInterfaceId (AnImplementation::iid);
}
@@ -127,7 +129,7 @@
void
AnImplementation::domethodA ()
{
- NS_DEBUG_UNCOND("AnImplementation::domethodA");
+ NS_LOG_FUNCTION;
}
//
@@ -201,7 +203,7 @@
void
ANewImplementation::methodImpl (void)
{
- NS_DEBUG_UNCOND("ANewImplementation::methodImpl\n");
+ NS_LOG_FUNCTION;
}
const InterfaceId ANewImplementation::iid =
@@ -238,7 +240,7 @@
void
AnExtendedImplementation::methodExtendedImpl (void)
{
- NS_DEBUG_UNCOND("AnExtendedImplementation::methodExtendedImpl\n");
+ NS_LOG_FUNCTION;
}
const InterfaceId AnExtendedImplementation::iid =
--- a/samples/main-tw.cc Thu Sep 13 12:37:30 2007 -0700
+++ b/samples/main-tw.cc Thu Sep 13 17:47:42 2007 -0700
@@ -18,14 +18,14 @@
*/
#include <string>
-#include "ns3/debug.h"
+#include "ns3/log.h"
#include "ns3/trace-writer.h"
using namespace ns3;
int main (int argc, char *argv[])
{
- NS_DEBUG_UNCOND("TraceWriter Test")
+ NS_LOG_UNCOND("TraceWriter Test")
TraceWriter writer1;
writer1.Open("trace-writer-test.txt");
--- a/src/applications/onoff/onoff-application.cc Thu Sep 13 12:37:30 2007 -0700
+++ b/src/applications/onoff/onoff-application.cc Thu Sep 13 17:47:42 2007 -0700
@@ -22,7 +22,7 @@
// George F. Riley, Georgia Tech, Spring 2007
// Adapted from ApplicationOnOff in GTNetS.
-#include "ns3/debug.h"
+#include "ns3/log.h"
#include "ns3/address.h"
#include "ns3/node.h"
#include "ns3/nstime.h"
@@ -35,7 +35,7 @@
#include "ns3/packet.h"
#include "onoff-application.h"
-NS_DEBUG_COMPONENT_DEFINE ("OnOffApplication");
+NS_LOG_COMPONENT_DEFINE ("OnOffApplication");
using namespace std;
@@ -73,8 +73,8 @@
: Application(n),
m_cbrRate (rate)
{
- Construct (n, remote, iid,
- ontime, offtime, size);
+ NS_LOG_FUNCTION;
+ Construct (n, remote, iid, ontime, offtime, size);
}
void
@@ -85,6 +85,8 @@
const RandomVariable& offTime,
uint32_t size)
{
+ NS_LOG_FUNCTION;
+
m_socket = 0;
m_peer = remote;
m_connected = false;
@@ -100,34 +102,37 @@
OnOffApplication::~OnOffApplication()
{
- NS_DEBUG("OnOffApplication::~OnOffApplication()");
+ NS_LOG_FUNCTION;
}
void
OnOffApplication::SetMaxBytes(uint32_t maxBytes)
{
- NS_DEBUG("OnOffApplication::SetMaxBytes(" << maxBytes << ")");
+ NS_LOG_FUNCTION;
+ NS_LOG_PARAM ("(" << maxBytes << ")");
m_maxBytes = maxBytes;
}
void
OnOffApplication::SetDefaultRate (const DataRate &rate)
{
- NS_DEBUG("OnOffApplication::SetDefaultRate(" << &rate << ")");
+ NS_LOG_FUNCTION;
+ NS_LOG_PARAM ("(" << &rate << ")");
g_defaultRate.SetValue (rate);
}
void
OnOffApplication::SetDefaultSize (uint32_t size)
{
- NS_DEBUG("OnOffApplication::SetDefaultSize(" << size << ")");
+ NS_LOG_FUNCTION;
+ NS_LOG_PARAM ("(" << size << ")");
g_defaultSize.SetValue (size);
}
void
OnOffApplication::DoDispose (void)
{
- NS_DEBUG("OnOffApplication::DoDispose()");
+ NS_LOG_FUNCTION;
m_socket = 0;
delete m_onTime;
@@ -143,7 +148,7 @@
// Application Methods
void OnOffApplication::StartApplication() // Called at time specified by Start
{
- NS_DEBUG("OnOffApplication::StartApplication()");
+ NS_LOG_FUNCTION;
// Create the socket if not already
if (!m_socket)
@@ -164,7 +169,7 @@
void OnOffApplication::StopApplication() // Called at time specified by Stop
{
- NS_DEBUG("OnOffApplication::StopApplication()");
+ NS_LOG_FUNCTION;
if (m_sendEvent.IsRunning ())
{ // Cancel the pending send packet event
@@ -179,14 +184,14 @@
// Event handlers
void OnOffApplication::StartSending()
{
- NS_DEBUG("OnOffApplication::StartSending ()");
+ NS_LOG_FUNCTION;
ScheduleNextTx(); // Schedule the send packet event
}
void OnOffApplication::StopSending()
{
- NS_DEBUG("OnOffApplication::StopSending ()");
+ NS_LOG_FUNCTION;
Simulator::Cancel(m_sendEvent);
}
@@ -194,15 +199,15 @@
// Private helpers
void OnOffApplication::ScheduleNextTx()
{
- NS_DEBUG("OnOffApplication::ScheduleNextTx ()");
+ NS_LOG_FUNCTION;
if (m_totBytes < m_maxBytes)
{
uint32_t bits = m_pktSize * 8 - m_residualBits;
- NS_DEBUG("OnOffApplication::ScheduleNextTx (): bits = " << bits);
+ NS_LOG_LOGIC ("bits = " << bits);
Time nextTime(Seconds (bits /
static_cast<double>(m_cbrRate.GetBitRate()))); // Time till next packet
- NS_DEBUG("OnOffApplication::ScheduleNextTx (): nextTime = " << nextTime);
+ NS_LOG_LOGIC ("nextTime = " << nextTime);
m_sendEvent = Simulator::Schedule(nextTime,
&OnOffApplication::SendPacket, this);
}
@@ -214,17 +219,16 @@
void OnOffApplication::ScheduleStartEvent()
{ // Schedules the event to start sending data (switch to the "On" state)
- NS_DEBUG("OnOffApplication::ScheduleStartEvent ()");
+ NS_LOG_FUNCTION;
Time offInterval = Seconds(m_offTime->GetValue());
- NS_DEBUG("OnOffApplication::ScheduleStartEvent (): "
- "start at " << offInterval);
+ NS_LOG_LOGIC ("start at " << offInterval);
m_startStopEvent = Simulator::Schedule(offInterval, &OnOffApplication::StartSending, this);
}
void OnOffApplication::ScheduleStopEvent()
{ // Schedules the event to stop sending data (switch to "Off" state)
- NS_DEBUG("OnOffApplication::ScheduleStopEvent ()");
+ NS_LOG_FUNCTION;
Time onInterval = Seconds(m_onTime->GetValue());
Simulator::Schedule(onInterval, &OnOffApplication::StopSending, this);
@@ -233,7 +237,7 @@
void OnOffApplication::SendPacket()
{
- NS_DEBUG("OnOffApplication::SendPacket ()");
+ NS_LOG_FUNCTION;
NS_ASSERT (m_sendEvent.IsExpired ());
m_socket->Send(Packet (m_pktSize));
@@ -245,7 +249,7 @@
void OnOffApplication::ConnectionSucceeded(Ptr<Socket>)
{
- NS_DEBUG("OnOffApplication::ConnectionSucceeded ()");
+ NS_LOG_FUNCTION;
m_connected = true;
ScheduleStartEvent();
@@ -253,6 +257,7 @@
void OnOffApplication::ConnectionFailed(Ptr<Socket>)
{
+ NS_LOG_FUNCTION;
cout << "OnOffApplication, Connection Failed" << endl;
}
--- a/src/applications/packet-sink/packet-sink.cc Thu Sep 13 12:37:30 2007 -0700
+++ b/src/applications/packet-sink/packet-sink.cc Thu Sep 13 17:47:42 2007 -0700
@@ -18,7 +18,7 @@
* Author: Tom Henderson (tomhend@u.washington.edu)
*/
#include "ns3/address.h"
-#include "ns3/debug.h"
+#include "ns3/log.h"
#include "ns3/inet-socket-address.h"
#include "ns3/node.h"
#include "ns3/socket.h"
@@ -31,7 +31,7 @@
namespace ns3 {
-NS_DEBUG_COMPONENT_DEFINE ("PacketSink");
+NS_LOG_COMPONENT_DEFINE ("PacketSinkApplication");
// Constructors
@@ -99,9 +99,9 @@
if (InetSocketAddress::IsMatchingType (from))
{
InetSocketAddress address = InetSocketAddress::ConvertFrom (from);
- NS_DEBUG ( __PRETTY_FUNCTION__ << ": Received " <<
- packet.GetSize() << " bytes from " << address.GetIpv4() << " ["
- << address << "]---'" << packet.PeekData() << "'");
+ NS_LOG_INFO ("Received " << packet.GetSize() << " bytes from " <<
+ address.GetIpv4() << " [" << address << "]---'" <<
+ packet.PeekData() << "'");
// TODO: Add a tracing source here
}
}
--- a/src/applications/udp-echo/udp-echo-client.cc Thu Sep 13 12:37:30 2007 -0700
+++ b/src/applications/udp-echo/udp-echo-client.cc Thu Sep 13 17:47:42 2007 -0700
@@ -15,7 +15,7 @@
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
-#include "ns3/debug.h"
+#include "ns3/log.h"
#include "ns3/ipv4-address.h"
#include "ns3/nstime.h"
#include "ns3/inet-socket-address.h"
@@ -27,7 +27,7 @@
namespace ns3 {
-NS_DEBUG_COMPONENT_DEFINE ("UdpEchoClient");
+NS_LOG_COMPONENT_DEFINE ("UdpEchoClientApplication");
UdpEchoClient::UdpEchoClient (
Ptr<Node> n,
@@ -39,7 +39,8 @@
:
Application(n)
{
- NS_DEBUG ("UdpEchoClient::UdpEchoClient (" << n << ", " << serverAddress <<
+ NS_LOG_FUNCTION;
+ NS_LOG_PARAM ("(" << n << ", " << serverAddress <<
", " << serverPort << ", " << count << ", " << interval <<
", " << size << ")");
@@ -48,7 +49,7 @@
UdpEchoClient::~UdpEchoClient()
{
- NS_DEBUG ("UdpEchoClient::~UdpEchoClient ()");
+ NS_LOG_FUNCTION;
}
void
@@ -60,7 +61,8 @@
Time interval,
uint32_t size)
{
- NS_DEBUG ("UdpEchoClient::Construct (" << n << ", " << serverAddress <<
+ NS_LOG_FUNCTION;
+ NS_LOG_PARAM ("(" << n << ", " << serverAddress <<
", " << serverPort << ", " << count << ", " << interval <<
", " << size << ")");
@@ -80,14 +82,14 @@
void
UdpEchoClient::DoDispose (void)
{
- NS_DEBUG ("UdpEchoClient::DoDispose ()");
+ NS_LOG_FUNCTION;
Application::DoDispose ();
}
void
UdpEchoClient::StartApplication (void)
{
- NS_DEBUG ("UdpEchoClient::StartApplication ()");
+ NS_LOG_FUNCTION;
if (!m_socket)
{
@@ -108,7 +110,7 @@
void
UdpEchoClient::StopApplication ()
{
- NS_DEBUG ("UdpEchoClient::StopApplication ()");
+ NS_LOG_FUNCTION;
if (!m_socket)
{
@@ -122,14 +124,14 @@
void
UdpEchoClient::ScheduleTransmit (Time dt)
{
- NS_DEBUG ("UdpEchoClient::ScheduleTransmit (" << dt << ")");
+ NS_LOG_FUNCTION;
m_sendEvent = Simulator::Schedule(dt, &UdpEchoClient::Send, this);
}
void
UdpEchoClient::Send (void)
{
- NS_DEBUG ("UdpEchoClient::Send ()");
+ NS_LOG_FUNCTION;
NS_ASSERT (m_sendEvent.IsExpired ());
@@ -137,8 +139,7 @@
m_socket->Send (p);
++m_sent;
- NS_DEBUG ("UdpEchoClient::Send (): Sent " << m_size << " bytes to " <<
- m_serverAddress);
+ NS_LOG_INFO ("Sent " << m_size << " bytes to " << m_serverAddress);
if (m_sent < m_count)
{
@@ -152,14 +153,14 @@
const Packet &packet,
const Address &from)
{
- NS_DEBUG ("UdpEchoClient::Receive (" << socket << ", " << packet <<
- ", " << from << ")");
+ NS_LOG_FUNCTION;
+ NS_LOG_PARAM ("(" << socket << ", " << packet << ", " << from << ")");
if (InetSocketAddress::IsMatchingType (from))
{
InetSocketAddress address = InetSocketAddress::ConvertFrom (from);
- NS_DEBUG ("UdpEchoClient::Receive(): Received " <<
- packet.GetSize() << " bytes from " << address.GetIpv4());
+ NS_LOG_INFO ("Received " << packet.GetSize() << " bytes from " <<
+ address.GetIpv4());
}
}
--- a/src/applications/udp-echo/udp-echo-server.cc Thu Sep 13 12:37:30 2007 -0700
+++ b/src/applications/udp-echo/udp-echo-server.cc Thu Sep 13 17:47:42 2007 -0700
@@ -16,7 +16,7 @@
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
-#include "ns3/debug.h"
+#include "ns3/log.h"
#include "ns3/ipv4-address.h"
#include "ns3/nstime.h"
#include "ns3/inet-socket-address.h"
@@ -29,7 +29,7 @@
namespace ns3 {
-NS_DEBUG_COMPONENT_DEFINE ("UdpEchoServer");
+NS_LOG_COMPONENT_DEFINE ("UdpEchoServerApplication");
UdpEchoServer::UdpEchoServer (
Ptr<Node> n,
@@ -37,15 +37,15 @@
:
Application(n)
{
- NS_DEBUG ("UdpEchoServer::UdpEchoServer (" << n << ", " <<
- port << ")");
+ NS_LOG_FUNCTION;
+ NS_LOG_PARAM ("(" << n << ", " << port << ")");
Construct (n, port);
}
UdpEchoServer::~UdpEchoServer()
{
- NS_DEBUG ("UdpEchoServer::~UdpEchoServer ()");
+ NS_LOG_FUNCTION;
}
void
@@ -53,7 +53,8 @@
Ptr<Node> n,
uint16_t port)
{
- NS_DEBUG ("UdpEchoServer::Construct (" << n << ", " << port << ")");
+ NS_LOG_FUNCTION;
+ NS_LOG_PARAM ("(" << n << ", " << port << ")");
m_node = n;
m_port = port;
@@ -65,14 +66,14 @@
void
UdpEchoServer::DoDispose (void)
{
- NS_DEBUG ("UdpEchoServer::DoDispose ()");
+ NS_LOG_FUNCTION;
Application::DoDispose ();
}
void
UdpEchoServer::StartApplication (void)
{
- NS_DEBUG ("UdpEchoServer::StartApplication ()");
+ NS_LOG_FUNCTION;
if (!m_socket)
{
@@ -90,7 +91,8 @@
void
UdpEchoServer::StopApplication ()
{
- NS_DEBUG ("UdpEchoServer::StopApplication ()");
+ NS_LOG_FUNCTION;
+
if (!m_socket)
{
m_socket->SetRecvCallback((Callback<void, Ptr<Socket>, const Packet &,
@@ -104,16 +106,16 @@
const Packet &packet,
const Address &from)
{
- NS_DEBUG ("UdpEchoServer::Receive (" << socket << ", " << packet <<
- ", " << from << ")");
+ NS_LOG_FUNCTION;
+ NS_LOG_PARAM ("(" << socket << ", " << packet << ", " << from << ")");
if (InetSocketAddress::IsMatchingType (from))
{
InetSocketAddress address = InetSocketAddress::ConvertFrom (from);
- NS_DEBUG ("UdpEchoServer::Receive(): Received " <<
- packet.GetSize() << " bytes from " << address.GetIpv4());
+ NS_LOG_INFO ("Received " << packet.GetSize() << " bytes from " <<
+ address.GetIpv4());
- NS_DEBUG ("UdpEchoServer::Receive (): Echoing packet");
+ NS_LOG_LOGIC ("Echoing packet");
socket->SendTo (from, packet);
}
}
--- a/src/common/buffer.cc Thu Sep 13 12:37:30 2007 -0700
+++ b/src/common/buffer.cc Thu Sep 13 17:47:42 2007 -0700
@@ -19,13 +19,13 @@
*/
#include "buffer.h"
#include "ns3/assert.h"
-#include "ns3/debug.h"
+#include "ns3/log.h"
#include <iostream>
-NS_DEBUG_COMPONENT_DEFINE ("Buffer");
+NS_LOG_COMPONENT_DEFINE ("Buffer");
-#define DEBUG_INTERNAL_STATE(y) \
-NS_DEBUG (y << "start="<<m_start<<", end="<<m_end<<", zero start="<<m_zeroAreaStart<< \
+#define LOG_INTERNAL_STATE(y) \
+NS_LOG_LOGIC (y << "start="<<m_start<<", end="<<m_end<<", zero start="<<m_zeroAreaStart<< \
", zero end="<<m_zeroAreaEnd<<", count="<<m_data->m_count<<", size="<<m_data->m_size<< \
", dirty start="<<m_data->m_dirtyStart<<", dirty end="<<m_data->m_dirtyEnd)
@@ -394,7 +394,7 @@
// update dirty area
m_data->m_dirtyStart = m_start;
m_data->m_dirtyEnd = m_end;
- DEBUG_INTERNAL_STATE ("add start=" << start << ", ");
+ LOG_INTERNAL_STATE ("add start=" << start << ", ");
NS_ASSERT (CheckInternalState ());
}
void
@@ -457,7 +457,7 @@
// update dirty area
m_data->m_dirtyStart = m_start;
m_data->m_dirtyEnd = m_end;
- DEBUG_INTERNAL_STATE ("add end=" << end << ", ");
+ LOG_INTERNAL_STATE ("add end=" << end << ", ");
NS_ASSERT (CheckInternalState ());
}
@@ -502,7 +502,7 @@
m_zeroAreaStart = m_end;
}
HEURISTICS (m_maxZeroAreaStart = std::max (m_maxZeroAreaStart, m_zeroAreaStart));
- DEBUG_INTERNAL_STATE ("rem start=" << start << ", ");
+ LOG_INTERNAL_STATE ("rem start=" << start << ", ");
NS_ASSERT (CheckInternalState ());
}
void
@@ -536,7 +536,7 @@
m_zeroAreaStart = m_start;
}
HEURISTICS (m_maxZeroAreaStart = std::max (m_maxZeroAreaStart, m_zeroAreaStart));
- DEBUG_INTERNAL_STATE ("rem end=" << end << ", ");
+ LOG_INTERNAL_STATE ("rem end=" << end << ", ");
NS_ASSERT (CheckInternalState ());
}
--- a/src/common/packet-metadata.cc Thu Sep 13 12:37:30 2007 -0700
+++ b/src/common/packet-metadata.cc Thu Sep 13 17:47:42 2007 -0700
@@ -21,12 +21,12 @@
#include <list>
#include "ns3/assert.h"
#include "ns3/fatal-error.h"
-#include "ns3/debug.h"
+#include "ns3/log.h"
#include "packet-metadata.h"
#include "buffer.h"
#include "chunk-registry.h"
-NS_DEBUG_COMPONENT_DEFINE ("PacketMetadata");
+NS_LOG_COMPONENT_DEFINE ("PacketMetadata");
namespace ns3 {
@@ -610,7 +610,7 @@
struct PacketMetadata::Data *
PacketMetadata::Create (uint32_t size)
{
- NS_DEBUG ("create size="<<size<<", max="<<m_maxSize);
+ NS_LOG_LOGIC ("create size="<<size<<", max="<<m_maxSize);
if (size > m_maxSize)
{
m_maxSize = size;
@@ -621,21 +621,21 @@
m_freeList.pop_back ();
if (data->m_size >= size)
{
- NS_DEBUG ("create found size="<<data->m_size);
+ NS_LOG_LOGIC ("create found size="<<data->m_size);
data->m_count = 1;
return data;
}
PacketMetadata::Deallocate (data);
- NS_DEBUG ("create dealloc size="<<data->m_size);
+ NS_LOG_LOGIC ("create dealloc size="<<data->m_size);
}
- NS_DEBUG ("create alloc size="<<m_maxSize);
+ NS_LOG_LOGIC ("create alloc size="<<m_maxSize);
return PacketMetadata::Allocate (m_maxSize);
}
void
PacketMetadata::Recycle (struct PacketMetadata::Data *data)
{
- NS_DEBUG ("recycle size="<<data->m_size<<", list="<<m_freeList.size ());
+ NS_LOG_LOGIC ("recycle size="<<data->m_size<<", list="<<m_freeList.size ());
NS_ASSERT (data->m_count == 0);
if (m_freeList.size () > 1000 ||
data->m_size < m_maxSize)
@@ -1133,10 +1133,10 @@
while (current != 0xffff)
{
ReadItems (current, &item, &extraItem);
- NS_DEBUG ("bytesWritten=" << bytesWritten << ", typeUid="<<item.typeUid <<
- ", size="<<item.size<<", chunkUid="<<item.chunkUid<<
- ", fragmentStart="<<extraItem.fragmentStart<<", fragmentEnd="<<extraItem.fragmentEnd<<
- ", packetUid="<<extraItem.packetUid);
+ NS_LOG_LOGIC ("bytesWritten=" << bytesWritten << ", typeUid="<<
+ item.typeUid << ", size="<<item.size<<", chunkUid="<<item.chunkUid<<
+ ", fragmentStart="<<extraItem.fragmentStart<<", fragmentEnd="<<
+ extraItem.fragmentEnd<< ", packetUid="<<extraItem.packetUid);
uint32_t uid = (item.typeUid & 0xfffffffe) >> 1;
if (uid != 0)
{
@@ -1215,10 +1215,10 @@
size -= 4;
extraItem.packetUid = i.ReadU32 ();
size -= 4;
- NS_DEBUG ("size=" << size << ", typeUid="<<item.typeUid <<
- ", size="<<item.size<<", chunkUid="<<item.chunkUid<<
- ", fragmentStart="<<extraItem.fragmentStart<<", fragmentEnd="<<extraItem.fragmentEnd<<
- ", packetUid="<<extraItem.packetUid);
+ NS_LOG_LOGIC ("size=" << size << ", typeUid="<<item.typeUid <<
+ ", size="<<item.size<<", chunkUid="<<item.chunkUid<<
+ ", fragmentStart="<<extraItem.fragmentStart<<", fragmentEnd="<<
+ extraItem.fragmentEnd<< ", packetUid="<<extraItem.packetUid);
uint32_t tmp = AddBig (0xffff, m_tail, &item, &extraItem);
UpdateTail (tmp);
}
--- a/src/core/composite-trace-resolver.cc Thu Sep 13 12:37:30 2007 -0700
+++ b/src/core/composite-trace-resolver.cc Thu Sep 13 17:47:42 2007 -0700
@@ -19,9 +19,9 @@
* Author: Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
*/
#include "composite-trace-resolver.h"
-#include "debug.h"
+#include "log.h"
-NS_DEBUG_COMPONENT_DEFINE ("CompositeTraceResolver");
+NS_LOG_COMPONENT_DEFINE ("CompositeTraceResolver");
namespace ns3 {
@@ -174,7 +174,7 @@
void
CompositeTraceResolver::Connect (std::string path, CallbackBase const &cb, const TraceContext &context)
{
- NS_DEBUG ("connect path="<<path);
+ NS_LOG_LOGIC ("connect path="<<path);
class ConnectOperation : public Operation
{
public:
@@ -183,7 +183,7 @@
{}
virtual void Do (std::string subpath, ResolveItem *item) const
{
- NS_DEBUG ("connect to path="<<subpath<<" name="<<item->name);
+ NS_LOG_LOGIC ("connect to path="<<subpath<<" name="<<item->name);
TraceContext context = m_context;
context.Union (item->context);
item->Connect (subpath, m_cb, context);
@@ -272,7 +272,7 @@
void
CompositeTraceResolver::Disconnect (std::string path, CallbackBase const &cb)
{
- NS_DEBUG ("disconnect path="<<path);
+ NS_LOG_LOGIC ("disconnect path="<<path);
class DisconnectOperation : public Operation
{
public:
@@ -281,7 +281,7 @@
{}
virtual void Do (std::string subpath, ResolveItem *item) const
{
- NS_DEBUG ("disconnect from path="<<subpath<<" name="<<item->name);
+ NS_LOG_LOGIC ("disconnect from path="<<subpath<<" name="<<item->name);
item->Disconnect (subpath, m_cb);
}
virtual void DoParent (std::string path, Ptr<TraceResolver> parent) const
@@ -303,7 +303,7 @@
{
for (TraceItems::const_iterator i = m_items.begin (); i != m_items.end (); i++)
{
- NS_DEBUG ("print " << (*i)->name);
+ NS_LOG_LOGIC ("print " << (*i)->name);
(*i)->CollectSources (path, context, collection);
}
if (m_parent != 0)
@@ -316,7 +316,7 @@
{
for (TraceItems::const_iterator i = m_items.begin (); i != m_items.end (); i++)
{
- NS_DEBUG ("print " << (*i)->name);
+ NS_LOG_LOGIC ("print " << (*i)->name);
(*i)->TraceAll (os, context);
}
if (m_parent != 0)
--- a/src/core/fatal-error.h Thu Sep 13 12:37:30 2007 -0700
+++ b/src/core/fatal-error.h Thu Sep 13 17:47:42 2007 -0700
@@ -32,9 +32,8 @@
*
* When this macro is hit at runtime, the user-specified
* error message is output and the program is halted by calling
- * the NS_DEBUG_BREAKPOINT macro. This macro is enabled
- * unconditionally in all builds, including debug and optimized
- * builds.
+ * the NS_BREAKPOINT macro. This macro is enabled unconditionally
+ * in all builds, including debug and optimized builds.
*/
#define NS_FATAL_ERROR(msg) \
do \
--- a/src/core/log.h Thu Sep 13 12:37:30 2007 -0700
+++ b/src/core/log.h Thu Sep 13 17:47:42 2007 -0700
@@ -74,16 +74,28 @@
* defined with the NS_LOG_COMPONENT_DEFINE macro in the
* same file.
*/
-#define NS_LOG(level, msg) \
- do \
- { \
- if (g_log.IsEnabled (level)) \
- { \
- std::clog << msg << std::endl; \
- } \
- } \
+#define NS_LOG(level, msg) \
+ do \
+ { \
+ if (g_log.IsEnabled (level)) \
+ { \
+ std::clog << __PRETTY_FUNCTION__ << " ==> " << \
+ msg << std::endl; \
+ } \
+ } \
while (false)
+#define NS_LOG_F(level) \
+ do \
+ { \
+ if (g_log.IsEnabled (level)) \
+ { \
+ std::clog << __PRETTY_FUNCTION__ << std::endl;\
+ } \
+ } \
+ while (false)
+
+
#define NS_LOG_ERROR(msg) \
NS_LOG(ns3::LOG_LEVEL_ERROR, msg)
@@ -96,8 +108,8 @@
#define NS_LOG_INFO(msg) \
NS_LOG(ns3::LOG_LEVEL_INFO, msg)
-#define NS_LOG_FUNCTION(msg) \
- NS_LOG(ns3::LOG_LEVEL_FUNCTION, msg)
+#define NS_LOG_FUNCTION \
+ NS_LOG_F(ns3::LOG_LEVEL_FUNCTION)
#define NS_LOG_PARAM(msg) \
NS_LOG(ns3::LOG_LEVEL_PARAM, msg)
--- a/src/core/object.cc Thu Sep 13 12:37:30 2007 -0700
+++ b/src/core/object.cc Thu Sep 13 17:47:42 2007 -0700
@@ -23,10 +23,10 @@
#include "singleton.h"
#include "uid-manager.h"
#include "trace-resolver.h"
-#include "debug.h"
+#include "log.h"
#include <vector>
-NS_DEBUG_COMPONENT_DEFINE ("Object");
+NS_LOG_COMPONENT_DEFINE ("Object");
namespace {
@@ -322,7 +322,7 @@
while (current != this)
{
NS_ASSERT (current != 0);
- NS_DEBUG ("collect current=" << current);
+ NS_LOG_LOGIC ("collect current=" << current);
InterfaceId cur = current->m_iid;
while (cur != Object::iid)
{
@@ -330,7 +330,7 @@
std::string fullpath = path;
fullpath.append ("/$");
fullpath.append (name);
- NS_DEBUG ("collect: " << fullpath);
+ NS_LOG_LOGIC("collect: " << fullpath);
current->GetTraceResolver ()->CollectSources (fullpath, context, collection);
cur = InterfaceId::LookupParent (cur);
}
--- a/src/core/random-variable-default-value.cc Thu Sep 13 12:37:30 2007 -0700
+++ b/src/core/random-variable-default-value.cc Thu Sep 13 17:47:42 2007 -0700
@@ -19,9 +19,9 @@
* Author: Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
*/
#include "random-variable-default-value.h"
-#include "debug.h"
+#include "log.h"
-NS_DEBUG_COMPONENT_DEFINE ("RandomVariableDefaultValue");
+NS_LOG_COMPONENT_DEFINE ("RandomVariableDefaultValue");
namespace ns3 {
@@ -75,12 +75,12 @@
double constant = ReadAsDouble (v, ok);
if (mustCreate)
{
- NS_DEBUG ("create Constant constant=" << constant);
+ NS_LOG_LOGIC ("create Constant constant=" << constant);
*pVariable = new ConstantVariable (constant);
}
else
{
- NS_DEBUG ("parse Constant constant=" << constant);
+ NS_LOG_LOGIC ("parse Constant constant=" << constant);
}
return ok;
}
@@ -99,12 +99,12 @@
maxVal = ReadAsDouble (max, ok);
if (mustCreate)
{
- NS_DEBUG ("create Uniform min=" << min << ", max=" << max);
+ NS_LOG_LOGIC ("create Uniform min=" << min << ", max=" << max);
*pVariable = new UniformVariable (minVal, maxVal);
}
else
{
- NS_DEBUG ("parse Uniform min=" << min << ", max=" << max);
+ NS_LOG_LOGIC ("parse Uniform min=" << min << ", max=" << max);
}
return ok;
}
--- a/src/core/trace-resolver.cc Thu Sep 13 12:37:30 2007 -0700
+++ b/src/core/trace-resolver.cc Thu Sep 13 17:47:42 2007 -0700
@@ -19,9 +19,9 @@
* Author: Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
*/
#include "trace-resolver.h"
-#include "debug.h"
+#include "log.h"
-NS_DEBUG_COMPONENT_DEFINE ("TraceResolver");
+NS_LOG_COMPONENT_DEFINE ("TraceResolver");
namespace ns3 {
@@ -43,7 +43,7 @@
m_count--;
if (m_count == 0)
{
- NS_DEBUG ("delete "<<this);
+ NS_LOG_LOGIC ("delete "<<this);
delete this;
}
}
--- a/src/devices/csma/csma-channel.cc Thu Sep 13 12:37:30 2007 -0700
+++ b/src/devices/csma/csma-channel.cc Thu Sep 13 17:47:42 2007 -0700
@@ -23,9 +23,9 @@
#include "csma-net-device.h"
#include "ns3/packet.h"
#include "ns3/simulator.h"
-#include "ns3/debug.h"
+#include "ns3/log.h"
-NS_DEBUG_COMPONENT_DEFINE ("CsmaChannel");
+NS_LOG_COMPONENT_DEFINE ("CsmaChannel");
namespace ns3 {
@@ -55,7 +55,7 @@
m_bps (DataRate(0xffffffff)),
m_delay (Seconds(0))
{
- NS_DEBUG("CsmaChannel::CsmaChannel ()");
+ NS_LOG_FUNCTION;
Init();
}
@@ -67,8 +67,9 @@
m_bps (bps),
m_delay (delay)
{
- NS_DEBUG("CsmaChannel::CsmaChannel (" << Channel::GetName()
- << ", " << bps.GetBitRate() << ", " << delay << ")");
+ NS_LOG_FUNCTION;
+ NS_LOG_PARAM ("(" << Channel::GetName() << ", " << bps.GetBitRate() <<
+ ", " << delay << ")");
Init();
}
@@ -81,8 +82,9 @@
m_bps (bps),
m_delay (delay)
{
- NS_DEBUG("CsmaChannel::CsmaChannel (" << name << ", " <<
- bps.GetBitRate() << ", " << delay << ")");
+ NS_LOG_FUNCTION;
+ NS_LOG_PARAM ("(" << name << ", " << bps.GetBitRate() << ", " << delay <<
+ ")");
Init();
}
@@ -94,7 +96,8 @@
int32_t
CsmaChannel::Attach(Ptr<CsmaNetDevice> device)
{
- NS_DEBUG("CsmaChannel::Attach (" << device << ")");
+ NS_LOG_FUNCTION;
+ NS_LOG_PARAM ("(" << device << ")");
NS_ASSERT(device != 0);
CsmaDeviceRec rec(device);
@@ -106,7 +109,8 @@
bool
CsmaChannel::Reattach(Ptr<CsmaNetDevice> device)
{
- NS_DEBUG("CsmaChannel::Reattach (" << device << ")");
+ NS_LOG_FUNCTION;
+ NS_LOG_PARAM ("(" << device << ")");
NS_ASSERT(device != 0);
std::vector<CsmaDeviceRec>::iterator it;
@@ -131,7 +135,9 @@
bool
CsmaChannel::Reattach(uint32_t deviceId)
{
- NS_DEBUG("CsmaChannel::Reattach (" << deviceId << ")");
+ NS_LOG_FUNCTION;
+ NS_LOG_PARAM ("(" << deviceId << ")");
+
if (deviceId < m_deviceList.size())
{
return false;
@@ -151,22 +157,23 @@
bool
CsmaChannel::Detach(uint32_t deviceId)
{
- NS_DEBUG("CsmaChannel::Detach (" << deviceId << ")");
+ NS_LOG_FUNCTION;
+ NS_LOG_PARAM ("(" << deviceId << ")");
if (deviceId < m_deviceList.size())
{
if (!m_deviceList[deviceId].active)
{
- NS_DEBUG("CsmaChannel::Detach Device is already detached ("
- << deviceId << ")");
+ NS_LOG_WARN ("CsmaChannel::Detach Device is already detached (" <<
+ deviceId << ")");
return false;
}
m_deviceList[deviceId].active = false;
if ((m_state == TRANSMITTING) && (m_currentSrc == deviceId))
{
- NS_DEBUG("CsmaChannel::Detach Device is currently"
- << "transmitting (" << deviceId << ")");
+ NS_LOG_WARN ("CsmaChannel::Detach Device is currently" <<
+ "transmitting (" << deviceId << ")");
// Here we will need to place a warning in the packet
}
@@ -181,7 +188,8 @@
bool
CsmaChannel::Detach(Ptr<CsmaNetDevice> device)
{
- NS_DEBUG("CsmaChannel::Detach (" << device << ")");
+ NS_LOG_FUNCTION;
+ NS_LOG_PARAM ("(" << device << ")");
NS_ASSERT(device != 0);
std::vector<CsmaDeviceRec>::iterator it;
@@ -199,25 +207,23 @@
bool
CsmaChannel::TransmitStart(Packet& p, uint32_t srcId)
{
- NS_DEBUG ("CsmaChannel::TransmitStart (" << &p << ", " << srcId
- << ")");
- NS_DEBUG ("CsmaChannel::TransmitStart (): UID is " <<
- p.GetUid () << ")");
+ NS_LOG_FUNCTION;
+ NS_LOG_PARAM ("(" << &p << ", " << srcId << ")");
+ NS_LOG_INFO ("UID is " << p.GetUid () << ")");
if (m_state != IDLE)
{
- NS_DEBUG("CsmaChannel::TransmitStart (): state is not IDLE");
+ NS_LOG_WARN ("state is not IDLE");
return false;
}
if (!IsActive(srcId))
{
- NS_DEBUG("CsmaChannel::TransmitStart (): ERROR: Seclected "
- << "source is not currently attached to network");
+ NS_LOG_ERROR ("Seclected source is not currently attached to network");
return false;
}
- NS_DEBUG("CsmaChannel::TransmitStart (): switch to TRANSMITTING");
+ NS_LOG_LOGIC ("switch to TRANSMITTING");
m_currentPkt = p;
m_currentSrc = srcId;
m_state = TRANSMITTING;
@@ -233,10 +239,9 @@
bool
CsmaChannel::TransmitEnd()
{
- NS_DEBUG("CsmaChannel::TransmitEnd (" << &m_currentPkt << ", "
- << m_currentSrc << ")");
- NS_DEBUG("CsmaChannel::TransmitEnd (): UID is " <<
- m_currentPkt.GetUid () << ")");
+ NS_LOG_FUNCTION;
+ NS_LOG_PARAM ("(" << &m_currentPkt << ", " << m_currentSrc << ")");
+ NS_LOG_INFO ("UID is " << m_currentPkt.GetUid () << ")");
NS_ASSERT(m_state == TRANSMITTING);
m_state = PROPAGATING;
@@ -244,13 +249,12 @@
bool retVal = true;
if (!IsActive(m_currentSrc)) {
- NS_DEBUG("CsmaChannel::TransmitEnd (): ERROR: Seclected source "
- << "was detached before the end of the transmission");
+ NS_LOG_ERROR ("Seclected source was detached before the end of the"
+ "transmission");
retVal = false;
}
- NS_DEBUG ("CsmaChannel::TransmitEnd (): Schedule event in " <<
- m_delay.GetSeconds () << " sec");
+ NS_LOG_LOGIC ("Schedule event in " << m_delay.GetSeconds () << " sec");
Simulator::Schedule (m_delay,
&CsmaChannel::PropagationCompleteEvent,
@@ -261,14 +265,13 @@
void
CsmaChannel::PropagationCompleteEvent()
{
- NS_DEBUG("CsmaChannel::PropagationCompleteEvent ("
- << &m_currentPkt << ")");
- NS_DEBUG ("CsmaChannel::PropagationCompleteEvent (): UID is " <<
- m_currentPkt.GetUid () << ")");
+ NS_LOG_FUNCTION;
+ NS_LOG_PARAM ("(" << &m_currentPkt << ")");
+ NS_LOG_INFO ("UID is " << m_currentPkt.GetUid () << ")");
NS_ASSERT(m_state == PROPAGATING);
- NS_DEBUG ("CsmaChannel::PropagationCompleteEvent (): Receive");
+ NS_LOG_LOGIC ("Receive");
std::vector<CsmaDeviceRec>::iterator it;
for (it = m_deviceList.begin(); it < m_deviceList.end(); it++)
--- a/src/devices/csma/csma-ipv4-topology.cc Thu Sep 13 12:37:30 2007 -0700
+++ b/src/devices/csma/csma-ipv4-topology.cc Thu Sep 13 17:47:42 2007 -0700
@@ -20,7 +20,6 @@
#include <algorithm>
#include "ns3/assert.h"
-#include "ns3/debug.h"
#include "ns3/fatal-error.h"
#include "ns3/nstime.h"
#include "ns3/internet-node.h"
--- a/src/devices/csma/csma-net-device.cc Thu Sep 13 12:37:30 2007 -0700
+++ b/src/devices/csma/csma-net-device.cc Thu Sep 13 17:47:42 2007 -0700
@@ -19,7 +19,7 @@
* Author: Emmanuelle Laprise <emmanuelle.laprise@bluekazoo.ca>
*/
-#include "ns3/debug.h"
+#include "ns3/log.h"
#include "ns3/queue.h"
#include "ns3/simulator.h"
#include "ns3/composite-trace-resolver.h"
@@ -29,16 +29,22 @@
#include "ns3/ethernet-trailer.h"
#include "ns3/llc-snap-header.h"
-NS_DEBUG_COMPONENT_DEFINE ("CsmaNetDevice");
+NS_LOG_COMPONENT_DEFINE ("CsmaNetDevice");
namespace ns3 {
CsmaTraceType::CsmaTraceType (enum Type type)
: m_type (type)
-{}
+{
+ NS_LOG_FUNCTION;
+}
+
CsmaTraceType::CsmaTraceType ()
: m_type (RX)
-{}
+{
+ NS_LOG_FUNCTION;
+}
+
void
CsmaTraceType::Print (std::ostream &os) const
{
@@ -51,20 +57,26 @@
break;
}
}
+
uint16_t
CsmaTraceType::GetUid (void)
{
+ NS_LOG_FUNCTION;
static uint16_t uid = AllocateUid<CsmaTraceType> ("CsmaTraceType");
return uid;
}
+
std::string
CsmaTraceType::GetTypeName (void) const
{
+ NS_LOG_FUNCTION;
return "ns3::CsmaTraceType";
}
+
enum CsmaTraceType::Type
CsmaTraceType::Get (void) const
{
+ NS_LOG_FUNCTION;
return m_type;
}
@@ -72,7 +84,8 @@
: NetDevice (node, Mac48Address::Allocate ()),
m_bps (DataRate (0xffffffff))
{
- NS_DEBUG ("CsmaNetDevice::CsmaNetDevice (" << node << ")");
+ NS_LOG_FUNCTION;
+ NS_LOG_PARAM ("(" << node << ")");
m_encapMode = IP_ARP;
Init(true, true);
}
@@ -82,7 +95,8 @@
: NetDevice(node, addr),
m_bps (DataRate (0xffffffff))
{
- NS_DEBUG ("CsmaNetDevice::CsmaNetDevice (" << node << ")");
+ NS_LOG_FUNCTION;
+ NS_LOG_PARAM ("(" << node << ")");
m_encapMode = encapMode;
Init(true, true);
@@ -94,7 +108,8 @@
: NetDevice(node, addr),
m_bps (DataRate (0xffffffff))
{
- NS_DEBUG ("CsmaNetDevice::CsmaNetDevice (" << node << ")");
+ NS_LOG_FUNCTION;
+ NS_LOG_PARAM ("(" << node << ")");
m_encapMode = encapMode;
Init(sendEnable, receiveEnable);
@@ -102,13 +117,14 @@
CsmaNetDevice::~CsmaNetDevice()
{
- NS_DEBUG ("CsmaNetDevice::~CsmaNetDevice ()");
+ NS_LOG_FUNCTION;
m_queue = 0;
}
void
CsmaNetDevice::DoDispose ()
{
+ NS_LOG_FUNCTION;
m_channel = 0;
NetDevice::DoDispose ();
}
@@ -125,7 +141,8 @@
CsmaNetDevice&
CsmaNetDevice::operator= (const CsmaNetDevice nd)
{
- NS_DEBUG ("CsmaNetDevice::operator= (" << &nd << ")");
+ NS_LOG_FUNCTION;
+ NS_LOG_PARAM ("(" << &nd << ")");
return *this;
}
*/
@@ -133,6 +150,7 @@
void
CsmaNetDevice::Init(bool sendEnable, bool receiveEnable)
{
+ NS_LOG_FUNCTION;
m_txMachineState = READY;
m_tInterframeGap = Seconds(0);
m_channel = 0;
@@ -148,53 +166,63 @@
void
CsmaNetDevice::SetSendEnable (bool sendEnable)
{
+ NS_LOG_FUNCTION;
m_sendEnable = sendEnable;
}
void
CsmaNetDevice::SetReceiveEnable (bool receiveEnable)
{
+ NS_LOG_FUNCTION;
m_receiveEnable = receiveEnable;
}
+
bool
CsmaNetDevice::IsSendEnabled (void)
{
+ NS_LOG_FUNCTION;
return (m_sendEnable);
}
bool
CsmaNetDevice::IsReceiveEnabled (void)
{
+ NS_LOG_FUNCTION;
return (m_receiveEnable);
}
void
CsmaNetDevice::SetDataRate (DataRate bps)
{
+ NS_LOG_FUNCTION;
m_bps = bps;
}
void
CsmaNetDevice::SetInterframeGap (Time t)
{
+ NS_LOG_FUNCTION;
m_tInterframeGap = t;
}
void
CsmaNetDevice::SetBackoffParams (Time slotTime, uint32_t minSlots,
- uint32_t maxSlots, uint32_t ceiling,
- uint32_t maxRetries)
+ uint32_t maxSlots, uint32_t ceiling,
+ uint32_t maxRetries)
{
+ NS_LOG_FUNCTION;
m_backoff.m_slotTime = slotTime;
m_backoff.m_minSlots = minSlots;
m_backoff.m_maxSlots = maxSlots;
m_backoff.m_ceiling = ceiling;
m_backoff.m_maxRetries = maxRetries;
}
+
void
CsmaNetDevice::AddHeader (Packet& p, Mac48Address dest,
uint16_t protocolNumber)
{
+ NS_LOG_FUNCTION;
if (m_encapMode == RAW)
{
return;
@@ -228,9 +256,11 @@
trailer.CalcFcs(p);
p.AddTrailer(trailer);
}
+
bool
CsmaNetDevice::ProcessHeader (Packet& p, uint16_t & param)
{
+ NS_LOG_FUNCTION;
if (m_encapMode == RAW)
{
return true;
@@ -269,6 +299,7 @@
bool
CsmaNetDevice::DoNeedsArp (void) const
{
+ NS_LOG_FUNCTION;
if ((m_encapMode == IP_ARP) || (m_encapMode == LLC))
{
return true;
@@ -285,9 +316,10 @@
const Address& dest,
uint16_t protocolNumber)
{
+ NS_LOG_FUNCTION;
Packet p = packet;
- NS_DEBUG ("CsmaNetDevice::SendTo (" << &p << ")");
- NS_DEBUG ("CsmaNetDevice::SendTo (): UID is " << p.GetUid () << ")");
+ NS_LOG_LOGIC ("p=" << &p);
+ NS_LOG_LOGIC ("UID is " << p.GetUid () << ")");
NS_ASSERT (IsLinkUp ());
@@ -320,9 +352,9 @@
void
CsmaNetDevice::TransmitStart ()
{
- NS_DEBUG ("CsmaNetDevice::TransmitStart (" << &m_currentPkt << ")");
- NS_DEBUG ("CsmaNetDevice::TransmitStart (): UID is "
- << m_currentPkt.GetUid () << ")");
+ NS_LOG_FUNCTION;
+ NS_LOG_LOGIC ("m_currentPkt=" << &m_currentPkt);
+ NS_LOG_LOGIC ("UID is " << m_currentPkt.GetUid ());
//
// This function is called to start the process of transmitting a packet.
// We need to tell the channel that we've started wiggling the wire and
@@ -349,9 +381,8 @@
m_backoff.IncrNumRetries();
Time backoffTime = m_backoff.GetBackoffTime();
- NS_DEBUG ("CsmaNetDevice::TransmitStart (): "
- << "Channel busy, backing off for "
- << backoffTime.GetSeconds () << "sec");
+ NS_LOG_LOGIC ("Channel busy, backing off for " <<
+ backoffTime.GetSeconds () << " sec");
Simulator::Schedule (backoffTime,
&CsmaNetDevice::TransmitStart,
@@ -364,18 +395,16 @@
m_txMachineState = BUSY;
Time tEvent = Seconds (m_bps.CalculateTxTime(m_currentPkt.GetSize()));
- NS_DEBUG ("CsmaNetDevice::TransmitStart (): " <<
- "Schedule TransmitCompleteEvent in " <<
- tEvent.GetSeconds () << "sec");
+ NS_LOG_LOGIC ("Schedule TransmitCompleteEvent in " <<
+ tEvent.GetSeconds () << "sec");
Simulator::Schedule (tEvent,
&CsmaNetDevice::TransmitCompleteEvent,
this);
if (!m_channel->TransmitStart (m_currentPkt, m_deviceId))
{
- NS_DEBUG ("CsmaNetDevice::TransmitStart (): " <<
- "Channel transmit start did not work at " <<
- tEvent.GetSeconds () << "sec");
+ NS_LOG_WARN ("Channel transmit start did not work at " <<
+ tEvent.GetSeconds () << "sec");
m_txMachineState = READY;
}
else
@@ -390,10 +419,8 @@
void
CsmaNetDevice::TransmitAbort (void)
{
- NS_DEBUG ("CsmaNetDevice::TransmitAbort ()");
-
- NS_DEBUG ("CsmaNetDevice::TransmitAbort (): Pkt UID is " <<
- m_currentPkt.GetUid () << ")");
+ NS_LOG_FUNCTION;
+ NS_LOG_LOGIC ("Pkt UID is " << m_currentPkt.GetUid () << ")");
// Try to transmit a new packet
bool found;
@@ -407,7 +434,7 @@
void
CsmaNetDevice::TransmitCompleteEvent (void)
{
- NS_DEBUG ("CsmaNetDevice::TransmitCompleteEvent ()");
+ NS_LOG_FUNCTION;
//
// This function is called to finish the process of transmitting a packet.
// We need to tell the channel that we've stopped wiggling the wire and
@@ -419,13 +446,10 @@
NS_ASSERT(m_channel->GetState() == TRANSMITTING);
m_txMachineState = GAP;
- NS_DEBUG ("CsmaNetDevice::TransmitCompleteEvent (): Pkt UID is " <<
- m_currentPkt.GetUid () << ")");
+ NS_LOG_LOGIC ("Pkt UID is " << m_currentPkt.GetUid () << ")");
m_channel->TransmitEnd ();
- NS_DEBUG (
- "CsmaNetDevice::TransmitCompleteEvent (): " <<
- "Schedule TransmitReadyEvent in "
+ NS_LOG_LOGIC ("Schedule TransmitReadyEvent in "
<< m_tInterframeGap.GetSeconds () << "sec");
Simulator::Schedule (m_tInterframeGap,
@@ -436,7 +460,7 @@
void
CsmaNetDevice::TransmitReadyEvent (void)
{
- NS_DEBUG ("CsmaNetDevice::TransmitReadyEvent ()");
+ NS_LOG_FUNCTION;
//
// This function is called to enable the transmitter after the interframe
// gap has passed. If there are pending transmissions, we use this opportunity
@@ -462,6 +486,7 @@
Ptr<TraceResolver>
CsmaNetDevice::GetTraceResolver (void) const
{
+ NS_LOG_FUNCTION;
Ptr<CompositeTraceResolver> resolver = Create<CompositeTraceResolver> ();
resolver->AddComposite ("queue", m_queue);
resolver->AddSource ("rx",
@@ -481,7 +506,8 @@
bool
CsmaNetDevice::Attach (Ptr<CsmaChannel> ch)
{
- NS_DEBUG ("CsmaNetDevice::Attach (" << &ch << ")");
+ NS_LOG_FUNCTION;
+ NS_LOG_PARAM ("(" << &ch << ")");
m_channel = ch;
@@ -499,7 +525,8 @@
void
CsmaNetDevice::AddQueue (Ptr<Queue> q)
{
- NS_DEBUG ("CsmaNetDevice::AddQueue (" << q << ")");
+ NS_LOG_FUNCTION;
+ NS_LOG_PARAM ("(" << q << ")");
m_queue = q;
}
@@ -507,6 +534,8 @@
void
CsmaNetDevice::Receive (const Packet& packet)
{
+ NS_LOG_FUNCTION;
+
EthernetHeader header (false);
EthernetTrailer trailer;
Mac48Address broadcast;
@@ -514,7 +543,7 @@
Mac48Address destination;
Packet p = packet;
- NS_DEBUG ("CsmaNetDevice::Receive (): UID is " << p.GetUid());
+ NS_LOG_LOGIC ("UID is " << p.GetUid());
// Only receive if send side of net device is enabled
if (!IsReceiveEnabled())
@@ -533,8 +562,7 @@
trailer.CheckFcs(p);
p.RemoveHeader(header);
- NS_DEBUG ("CsmaNetDevice::Receive (): Pkt destination is " <<
- header.GetDestination ());
+ NS_LOG_LOGIC ("Pkt destination is " << header.GetDestination ());
//
// An IP host group address is mapped to an Ethernet multicast address
// by placing the low-order 23-bits of the IP address into the low-order
@@ -560,7 +588,7 @@
(mcDest != multicast) &&
(header.GetDestination () != destination))
{
- NS_DEBUG ("CsmaNetDevice::Receive (): Dropping pkt ");
+ NS_LOG_LOGIC ("Dropping pkt ");
m_dropTrace (p);
return;
}
@@ -595,15 +623,14 @@
Address
CsmaNetDevice::MakeMulticastAddress(Ipv4Address multicastGroup) const
{
- NS_DEBUG ("CsmaNetDevice::MakeMulticastAddress (" << multicastGroup <<
- ")");
+ NS_LOG_FUNCTION;
+ NS_LOG_PARAM ("(" << multicastGroup << ")");
//
// First, get the generic multicast address.
//
Address hardwareDestination = GetMulticast ();
- NS_DEBUG ("CsmaNetDevice::MakeMulticastAddress (): "
- "Device multicast address: " << hardwareDestination);
+ NS_LOG_LOGIC ("Device multicast address: " << hardwareDestination);
//
// It's our address, and we know we're playing with an EUI-48 address here
// primarily since we know that by construction, but also since the parameter
@@ -641,8 +668,7 @@
// use it by just returning the EUI-48 address which is automagically converted
// to an Address.
//
- NS_DEBUG ("CsmaNetDevice::MakeMulticastAddress (): "
- "multicast address is " << etherAddr);
+ NS_LOG_LOGIC ("multicast address is " << etherAddr);
return etherAddr;
}
@@ -650,13 +676,15 @@
Ptr<Queue>
CsmaNetDevice::GetQueue(void) const
{
- return m_queue;
+ NS_LOG_FUNCTION;
+ return m_queue;
}
Ptr<Channel>
CsmaNetDevice::DoGetChannel(void) const
{
- return m_channel;
+ NS_LOG_FUNCTION;
+ return m_channel;
}
} // namespace ns3
--- a/src/devices/csma/csma-topology.cc Thu Sep 13 12:37:30 2007 -0700
+++ b/src/devices/csma/csma-topology.cc Thu Sep 13 17:47:42 2007 -0700
@@ -22,7 +22,6 @@
// Topology helper for Csma channels in ns3.
#include "ns3/assert.h"
-#include "ns3/debug.h"
#include "ns3/queue.h"
#include "csma-channel.h"
--- a/src/devices/point-to-point/point-to-point-channel.cc Thu Sep 13 12:37:30 2007 -0700
+++ b/src/devices/point-to-point/point-to-point-channel.cc Thu Sep 13 17:47:42 2007 -0700
@@ -23,9 +23,9 @@
#include "point-to-point-net-device.h"
#include "ns3/packet.h"
#include "ns3/simulator.h"
-#include "ns3/debug.h"
+#include "ns3/log.h"
-NS_DEBUG_COMPONENT_DEFINE ("PointToPointChannel");
+NS_LOG_COMPONENT_DEFINE ("PointToPointChannel");
namespace ns3 {
@@ -39,7 +39,7 @@
m_delay (Seconds(0)),
m_nDevices(0)
{
- NS_DEBUG("PointToPointChannel::PointToPointChannel ()");
+ NS_LOG_FUNCTION;
}
PointToPointChannel::PointToPointChannel(
@@ -51,8 +51,9 @@
m_delay (delay),
m_nDevices(0)
{
- NS_DEBUG("PointToPointChannel::PointToPointChannel (" << Channel::GetName()
- << ", " << bps.GetBitRate() << ", " << delay << ")");
+ NS_LOG_FUNCTION;
+ NS_LOG_PARAM ("(" << Channel::GetName() << ", " << bps.GetBitRate() <<
+ ", " << delay << ")");
}
PointToPointChannel::PointToPointChannel(
@@ -65,14 +66,16 @@
m_delay (delay),
m_nDevices(0)
{
- NS_DEBUG("PointToPointChannel::PointToPointChannel (" << name << ", " <<
- bps.GetBitRate() << ", " << delay << ")");
+ NS_LOG_FUNCTION;
+ NS_LOG_PARAM ("(" << name << ", " << bps.GetBitRate() << ", " <<
+ delay << ")");
}
- void
+void
PointToPointChannel::Attach(Ptr<PointToPointNetDevice> device)
{
- NS_DEBUG("PointToPointChannel::Attach (" << device << ")");
+ NS_LOG_FUNCTION;
+ NS_LOG_PARAM ("(" << device << ")");
NS_ASSERT(m_nDevices < N_DEVICES && "Only two devices permitted");
NS_ASSERT(device != 0);
@@ -90,14 +93,14 @@
}
}
-bool PointToPointChannel::TransmitStart(Packet& p,
+bool
+PointToPointChannel::TransmitStart(Packet& p,
Ptr<PointToPointNetDevice> src,
const Time& txTime)
{
- NS_DEBUG ("PointToPointChannel::TransmitStart (" << &p << ", " << src <<
- ")");
- NS_DEBUG ("PointToPointChannel::TransmitStart (): UID is " <<
- p.GetUid () << ")");
+ NS_LOG_FUNCTION;
+ NS_LOG_PARAM ("(" << &p << ", " << src << ")");
+ NS_LOG_LOGIC ("UID is " << p.GetUid () << ")");
NS_ASSERT(m_link[0].m_state != INITIALIZING);
NS_ASSERT(m_link[1].m_state != INITIALIZING);
@@ -116,12 +119,14 @@
uint32_t
PointToPointChannel::GetNDevices (void) const
{
+ NS_LOG_FUNCTION;
return m_nDevices;
}
Ptr<NetDevice>
PointToPointChannel::GetDevice (uint32_t i) const
{
+ NS_LOG_FUNCTION;
NS_ASSERT(i < 2);
return m_link[i].m_src;
}
@@ -129,12 +134,14 @@
const DataRate&
PointToPointChannel::GetDataRate (void)
{
+ NS_LOG_FUNCTION;
return m_bps;
}
const Time&
PointToPointChannel::GetDelay (void)
{
+ NS_LOG_FUNCTION;
return m_delay;
}
--- a/src/devices/point-to-point/point-to-point-net-device.cc Thu Sep 13 12:37:30 2007 -0700
+++ b/src/devices/point-to-point/point-to-point-net-device.cc Thu Sep 13 17:47:42 2007 -0700
@@ -20,7 +20,7 @@
* Revised: George Riley <riley@ece.gatech.edu>
*/
-#include "ns3/debug.h"
+#include "ns3/log.h"
#include "ns3/queue.h"
#include "ns3/simulator.h"
#include "ns3/composite-trace-resolver.h"
@@ -29,7 +29,7 @@
#include "point-to-point-net-device.h"
#include "point-to-point-channel.h"
-NS_DEBUG_COMPONENT_DEFINE ("PointToPointNetDevice");
+NS_LOG_COMPONENT_DEFINE ("PointToPointNetDevice");
namespace ns3 {
@@ -39,21 +39,27 @@
DataRate ("10Mb/s"));
PointToPointTraceType::PointToPointTraceType ()
-{}
+{
+ NS_LOG_FUNCTION;
+}
void
PointToPointTraceType::Print (std::ostream &os) const
{
os << "dev-rx";
}
+
uint16_t
PointToPointTraceType::GetUid (void)
{
+ NS_LOG_FUNCTION;
static uint16_t uid = AllocateUid<PointToPointTraceType> ("PointToPointTraceType");
return uid;
}
+
std::string
PointToPointTraceType::GetTypeName (void) const
{
+ NS_LOG_FUNCTION;
return "ns3::PointToPointTraceType";
}
@@ -69,11 +75,13 @@
m_queue (0),
m_rxTrace ()
{
- NS_DEBUG ("PointToPointNetDevice::PointToPointNetDevice (" << node << ")");
-
-// BUGBUG FIXME
+ NS_LOG_FUNCTION;
+ NS_LOG_PARAM ("(" << node << ")");
+//
+// XXX BUGBUG
//
// You _must_ support broadcast to get any sort of packet from the ARP layer.
+//
EnableBroadcast (Mac48Address ("ff:ff:ff:ff:ff:ff"));
//
// We want to allow multicast packets to flow across this link
@@ -84,13 +92,14 @@
PointToPointNetDevice::~PointToPointNetDevice()
{
- NS_DEBUG ("PointToPointNetDevice::~PointToPointNetDevice ()");
+ NS_LOG_FUNCTION;
m_queue = 0;
}
void
PointToPointNetDevice::AddHeader(Packet& p, uint16_t protocolNumber)
{
+ NS_LOG_FUNCTION;
LlcSnapHeader llc;
llc.SetType (protocolNumber);
p.AddHeader (llc);
@@ -99,6 +108,7 @@
bool
PointToPointNetDevice::ProcessHeader(Packet& p, uint16_t& param)
{
+ NS_LOG_FUNCTION;
LlcSnapHeader llc;
p.RemoveHeader (llc);
@@ -109,26 +119,30 @@
void PointToPointNetDevice::DoDispose()
{
+ NS_LOG_FUNCTION;
m_channel = 0;
NetDevice::DoDispose ();
}
void PointToPointNetDevice::SetDataRate(const DataRate& bps)
{
+ NS_LOG_FUNCTION;
m_bps = bps;
}
void PointToPointNetDevice::SetInterframeGap(const Time& t)
{
+ NS_LOG_FUNCTION;
m_tInterframeGap = t;
}
bool PointToPointNetDevice::SendTo (const Packet& packet, const Address& dest,
uint16_t protocolNumber)
{
+ NS_LOG_FUNCTION;
Packet p = packet;
- NS_DEBUG ("PointToPointNetDevice::SendTo (" << &p << ", " << &dest << ")");
- NS_DEBUG ("PointToPointNetDevice::SendTo (): UID is " << p.GetUid () << ")");
+ NS_LOG_LOGIC ("p=" << &p << ", dest=" << &dest);
+ NS_LOG_LOGIC ("UID is " << p.GetUid ());
// GFR Comment. Why is this an assertion? Can't a link legitimately
// "go down" during the simulation? Shouldn't we just wait for it
@@ -156,9 +170,9 @@
bool
PointToPointNetDevice::TransmitStart (Packet &p)
{
- NS_DEBUG ("PointToPointNetDevice::TransmitStart (" << &p << ")");
- NS_DEBUG (
- "PointToPointNetDevice::TransmitStart (): UID is " << p.GetUid () << ")");
+ NS_LOG_FUNCTION;
+ NS_LOG_PARAM ("(" << &p << ")");
+ NS_LOG_LOGIC ("UID is " << p.GetUid () << ")");
//
// This function is called to start the process of transmitting a packet.
// We need to tell the channel that we've started wiggling the wire and
@@ -169,8 +183,7 @@
Time txTime = Seconds (m_bps.CalculateTxTime(p.GetSize()));
Time txCompleteTime = txTime + m_tInterframeGap;
- NS_DEBUG ("PointToPointNetDevice::TransmitStart (): " <<
- "Schedule TransmitCompleteEvent in " <<
+ NS_LOG_LOGIC ("Schedule TransmitCompleteEvent in " <<
txCompleteTime.GetSeconds () << "sec");
// Schedule the tx complete event
Simulator::Schedule (txCompleteTime,
@@ -181,7 +194,7 @@
void PointToPointNetDevice::TransmitComplete (void)
{
- NS_DEBUG ("PointToPointNetDevice::TransmitCompleteEvent ()");
+ NS_LOG_FUNCTION;
//
// This function is called to finish the process of transmitting a packet.
// We need to tell the channel that we've stopped wiggling the wire and
@@ -198,6 +211,7 @@
Ptr<TraceResolver>
PointToPointNetDevice::GetTraceResolver (void) const
{
+ NS_LOG_FUNCTION;
Ptr<CompositeTraceResolver> resolver = Create<CompositeTraceResolver> ();
resolver->AddComposite ("queue", m_queue);
resolver->AddSource ("rx",
@@ -209,9 +223,11 @@
return resolver;
}
-bool PointToPointNetDevice::Attach (Ptr<PointToPointChannel> ch)
+bool
+PointToPointNetDevice::Attach (Ptr<PointToPointChannel> ch)
{
- NS_DEBUG ("PointToPointNetDevice::Attach (" << &ch << ")");
+ NS_LOG_FUNCTION;
+ NS_LOG_PARAM ("(" << &ch << ")");
m_channel = ch;
@@ -237,14 +253,16 @@
void PointToPointNetDevice::AddQueue (Ptr<Queue> q)
{
- NS_DEBUG ("PointToPointNetDevice::AddQueue (" << q << ")");
+ NS_LOG_FUNCTION;
+ NS_LOG_PARAM ("(" << q << ")");
m_queue = q;
}
void PointToPointNetDevice::Receive (Packet& p)
{
- NS_DEBUG ("PointToPointNetDevice::Receive (" << &p << ")");
+ NS_LOG_FUNCTION;
+ NS_LOG_PARAM ("(" << &p << ")");
uint16_t protocol = 0;
Packet packet = p;
@@ -255,16 +273,19 @@
Ptr<Queue> PointToPointNetDevice::GetQueue(void) const
{
- return m_queue;
+ NS_LOG_FUNCTION;
+ return m_queue;
}
Ptr<Channel> PointToPointNetDevice::DoGetChannel(void) const
{
- return m_channel;
+ NS_LOG_FUNCTION;
+ return m_channel;
}
bool PointToPointNetDevice::DoNeedsArp (void) const
{
+ NS_LOG_FUNCTION;
return false;
}
--- a/src/devices/point-to-point/point-to-point-topology.cc Thu Sep 13 12:37:30 2007 -0700
+++ b/src/devices/point-to-point/point-to-point-topology.cc Thu Sep 13 17:47:42 2007 -0700
@@ -24,7 +24,7 @@
#include <algorithm>
#include "ns3/assert.h"
-#include "ns3/debug.h"
+#include "ns3/log.h"
#include "ns3/fatal-error.h"
#include "ns3/nstime.h"
#include "ns3/internet-node.h"
--- a/src/internet-node/ipv4-end-point-demux.cc Thu Sep 13 12:37:30 2007 -0700
+++ b/src/internet-node/ipv4-end-point-demux.cc Thu Sep 13 17:47:42 2007 -0700
@@ -21,18 +21,21 @@
#include "ipv4-end-point-demux.h"
#include "ipv4-end-point.h"
-#include "ns3/debug.h"
+#include "ns3/log.h"
namespace ns3{
-NS_DEBUG_COMPONENT_DEFINE ("Ipv4EndPointDemux");
+NS_LOG_COMPONENT_DEFINE ("Ipv4EndPointDemux");
Ipv4EndPointDemux::Ipv4EndPointDemux ()
: m_ephemeral (1025)
-{}
+{
+ NS_LOG_FUNCTION;
+}
Ipv4EndPointDemux::~Ipv4EndPointDemux ()
{
+ NS_LOG_FUNCTION;
for (EndPointsI i = m_endPoints.begin (); i != m_endPoints.end (); i++)
{
Ipv4EndPoint *endPoint = *i;
@@ -44,6 +47,7 @@
bool
Ipv4EndPointDemux::LookupPortLocal (uint16_t port)
{
+ NS_LOG_FUNCTION;
for (EndPointsI i = m_endPoints.begin (); i != m_endPoints.end (); i++)
{
if ((*i)->GetLocalPort () == port)
@@ -57,6 +61,7 @@
bool
Ipv4EndPointDemux::LookupLocal (Ipv4Address addr, uint16_t port)
{
+ NS_LOG_FUNCTION;
for (EndPointsI i = m_endPoints.begin (); i != m_endPoints.end (); i++)
{
if ((*i)->GetLocalPort () == port &&
@@ -71,44 +76,49 @@
Ipv4EndPoint *
Ipv4EndPointDemux::Allocate (void)
{
- NS_DEBUG ("Ipv4EndPointDemux::Allocate ()");
+ NS_LOG_FUNCTION;
uint16_t port = AllocateEphemeralPort ();
if (port == 0)
{
- NS_DEBUG ("Ipv4EndPointDemux::Allocate ephemeral port allocation failed.");
+ NS_LOG_WARN ("Ephemeral port allocation failed.");
return 0;
}
Ipv4EndPoint *endPoint = new Ipv4EndPoint (Ipv4Address::GetAny (), port);
m_endPoints.push_back (endPoint);
return endPoint;
}
+
Ipv4EndPoint *
Ipv4EndPointDemux::Allocate (Ipv4Address address)
{
- NS_DEBUG ("Ipv4EndPointDemux::Allocate (address=" << address << ")");
+ NS_LOG_FUNCTION;
+ NS_LOG_PARAM ("(" << address << ")");
uint16_t port = AllocateEphemeralPort ();
if (port == 0)
{
- NS_DEBUG ("Ipv4EndPointDemux::Allocate ephemeral port allocation failed.");
+ NS_LOG_WARN ("Ephemeral port allocation failed.");
return 0;
}
Ipv4EndPoint *endPoint = new Ipv4EndPoint (address, port);
m_endPoints.push_back (endPoint);
return endPoint;
}
+
Ipv4EndPoint *
Ipv4EndPointDemux::Allocate (uint16_t port)
{
+ NS_LOG_FUNCTION;
return Allocate (Ipv4Address::GetAny (), port);
}
+
Ipv4EndPoint *
Ipv4EndPointDemux::Allocate (Ipv4Address address, uint16_t port)
{
- NS_DEBUG ("Ipv4EndPointDemux::Allocate (address=" << address
- << ", port=" << port << ")");
+ NS_LOG_FUNCTION;
+ NS_LOG_PARAM ("(" << address << ", " << port << ")");
if (LookupLocal (address, port))
{
- NS_DEBUG ("Ipv4EndPointDemux::Allocate duplicate address/port; failing.");
+ NS_LOG_WARN ("Duplicate address/port; failing.");
return 0;
}
Ipv4EndPoint *endPoint = new Ipv4EndPoint (address, port);
@@ -120,10 +130,11 @@
Ipv4EndPointDemux::Allocate (Ipv4Address localAddress, uint16_t localPort,
Ipv4Address peerAddress, uint16_t peerPort)
{
- NS_DEBUG ("Ipv4EndPointDemux::Allocate (localAddress=" << localAddress
- << ", localPort=" << localPort
- << ", peerAddress=" << peerAddress
- << ", peerPort=" << peerPort << ")");
+ NS_LOG_FUNCTION;
+ NS_LOG_PARAM ("(localAddress=" << localAddress
+ << ", localPort=" << localPort
+ << ", peerAddress=" << peerAddress
+ << ", peerPort=" << peerPort << ")");
for (EndPointsI i = m_endPoints.begin (); i != m_endPoints.end (); i++)
{
if ((*i)->GetLocalPort () == localPort &&
@@ -131,7 +142,7 @@
(*i)->GetPeerPort () == peerPort &&
(*i)->GetPeerAddress () == peerAddress)
{
- NS_DEBUG ("Ipv4EndPointDemux::Allocate: no way we can allocate this end-point.");
+ NS_LOG_WARN ("No way we can allocate this end-point.");
/* no way we can allocate this end-point. */
return 0;
}
@@ -145,6 +156,7 @@
void
Ipv4EndPointDemux::DeAllocate (Ipv4EndPoint *endPoint)
{
+ NS_LOG_FUNCTION;
for (EndPointsI i = m_endPoints.begin (); i != m_endPoints.end (); i++)
{
if (*i == endPoint)
@@ -156,7 +168,6 @@
}
}
-
/*
* If we have an exact match, we return it.
* Otherwise, if we find a generic match, we return it.
@@ -166,40 +177,42 @@
Ipv4EndPointDemux::Lookup (Ipv4Address daddr, uint16_t dport,
Ipv4Address saddr, uint16_t sport)
{
+ NS_LOG_FUNCTION;
uint32_t genericity = 3;
Ipv4EndPoint *generic = 0;
EndPoints retval;
- NS_DEBUG ("Ipv4EndPointDemux::Lookup (daddr=" << daddr << ", dport=" << dport
- << ", saddr=" << saddr << ", sport=" << sport
- << ")");
+ NS_LOG_PARAM ("(daddr=" << daddr << ", dport=" << dport
+ << ", saddr=" << saddr << ", sport=" << sport << ")");
+
for (EndPointsI i = m_endPoints.begin (); i != m_endPoints.end (); i++)
{
- NS_DEBUG ("Ipv4EndPointDemux::Lookup against " <<
- (*i)->GetLocalAddress ()
- << ":" <<
- (*i)->GetLocalPort ()
- << " " <<
- (*i)->GetPeerAddress ()
- << ":"
- << (*i)->GetPeerPort ());
+ NS_LOG_LOGIC ("Ipv4EndPointDemux::Lookup against " <<
+ (*i)->GetLocalAddress ()
+ << ":" <<
+ (*i)->GetLocalPort ()
+ << " " <<
+ (*i)->GetPeerAddress ()
+ << ":"
+ << (*i)->GetPeerPort ());
+
if ((*i)->GetLocalPort () != dport)
{
continue;
}
- NS_DEBUG ("Ipv4EndPointDemux::Lookup local address matches: "
- << bool ((*i)->GetLocalAddress () == daddr || daddr.IsBroadcast ()));
- NS_DEBUG ("Ipv4EndPointDemux::Lookup peer port matches: "
- << bool ((*i)->GetPeerPort () == sport || sport == 0));
- NS_DEBUG ("Ipv4EndPointDemux::Lookup peer address matches: "
- << bool ((*i)->GetPeerAddress () == saddr ||
- (*i)->GetPeerAddress () == Ipv4Address::GetAny ()));
+ NS_LOG_LOGIC ("Local address matches: " <<
+ bool ((*i)->GetLocalAddress () == daddr || daddr.IsBroadcast ()));
+ NS_LOG_LOGIC ("Peer port matches: " <<
+ bool ((*i)->GetPeerPort () == sport || sport == 0));
+ NS_LOG_LOGIC ("Peer address matches: " <<
+ bool ((*i)->GetPeerAddress () == saddr ||
+ (*i)->GetPeerAddress () == Ipv4Address::GetAny ()));
if ( ((*i)->GetLocalAddress () == daddr || daddr.IsBroadcast ())
&& ((*i)->GetPeerPort () == sport || (*i)->GetPeerPort () == 0)
&& ((*i)->GetPeerAddress () == saddr || (*i)->GetPeerAddress () == Ipv4Address::GetAny ()))
{
- NS_DEBUG ("Ipv4EndPointDemux::Lookup MATCH");
+ NS_LOG_LOGIC ("MATCH");
/* this is an exact match. */
retval.push_back (*i);
}
@@ -228,6 +241,7 @@
uint16_t
Ipv4EndPointDemux::AllocateEphemeralPort (void)
{
+ NS_LOG_FUNCTION;
uint16_t port = m_ephemeral;
do
{
--- a/src/internet-node/ipv4-header.cc Thu Sep 13 12:37:30 2007 -0700
+++ b/src/internet-node/ipv4-header.cc Thu Sep 13 17:47:42 2007 -0700
@@ -20,11 +20,11 @@
*/
#include "ns3/assert.h"
-#include "ns3/debug.h"
+#include "ns3/log.h"
#include "ns3/header.h"
#include "ipv4-header.h"
-NS_DEBUG_COMPONENT_DEFINE ("Ipv4Header");
+NS_LOG_COMPONENT_DEFINE ("Ipv4Header");
namespace ns3 {
@@ -271,7 +271,7 @@
uint8_t *data = start.PeekData ();
uint16_t checksum = UtilsChecksumCalculate (0, data, GetSize ());
checksum = UtilsChecksumComplete (checksum);
- NS_DEBUG ("checksum=" <<checksum);
+ NS_LOG_LOGIC ("checksum=" <<checksum);
i = start;
i.Next (10);
i.WriteU16 (checksum);
--- a/src/internet-node/ipv4-interface.cc Thu Sep 13 12:37:30 2007 -0700
+++ b/src/internet-node/ipv4-interface.cc Thu Sep 13 17:47:42 2007 -0700
@@ -23,9 +23,9 @@
#include "ns3/ipv4-address.h"
#include "ns3/net-device.h"
#include "ns3/trace-resolver.h"
-#include "ns3/debug.h"
+#include "ns3/log.h"
-NS_DEBUG_COMPONENT_DEFINE ("Ipv4Interface");
+NS_LOG_COMPONENT_DEFINE ("Ipv4Interface");
namespace ns3 {
@@ -39,17 +39,19 @@
: m_netdevice (nd),
m_ifup(false)
{
- NS_DEBUG ("Ipv4Interface::Ipv4Interface (" << &nd << ")");
+ NS_LOG_FUNCTION;
+ NS_LOG_PARAM ("(" << &nd << ")");
}
Ipv4Interface::~Ipv4Interface ()
{
- NS_DEBUG ("Ipv4Interface::~Ipv4Interface ()");
+ NS_LOG_FUNCTION;
}
void
Ipv4Interface::DoDispose (void)
{
+ NS_LOG_FUNCTION;
m_netdevice = 0;
Object::DoDispose ();
}
@@ -57,29 +59,30 @@
Ptr<NetDevice>
Ipv4Interface::GetDevice (void) const
{
- NS_DEBUG ("Ipv4Interface::GetDevice ()");
+ NS_LOG_FUNCTION;
return m_netdevice;
}
void
Ipv4Interface::SetAddress (Ipv4Address a)
{
- NS_DEBUG ("Ipv4Interface::SetAddress (" << a << ")");
+ NS_LOG_FUNCTION;
+ NS_LOG_PARAM ("(" << a << ")");
m_address = a;
}
void
Ipv4Interface::SetNetworkMask (Ipv4Mask mask)
{
- NS_DEBUG ("Ipv4Interface::SetMask (" << mask << ")");
+ NS_LOG_FUNCTION;
+ NS_LOG_PARAM ("(" << mask << ")");
m_netmask = mask;
}
Ipv4Address
Ipv4Interface::GetBroadcast (void) const
{
- NS_DEBUG ("Ipv4Interface::GetBroadcast ()");
-
+ NS_LOG_FUNCTION;
uint32_t mask = m_netmask.GetHostOrder ();
uint32_t address = m_address.GetHostOrder ();
Ipv4Address broadcast = Ipv4Address (address | (~mask));
@@ -89,21 +92,21 @@
Ipv4Mask
Ipv4Interface::GetNetworkMask (void) const
{
- NS_DEBUG ("Ipv4Interface::GetNetworkMask ()");
+ NS_LOG_FUNCTION;
return m_netmask;
}
Ipv4Address
Ipv4Interface::GetAddress (void) const
{
- NS_DEBUG ("Ipv4Interface::Address ()");
+ NS_LOG_FUNCTION;
return m_address;
}
uint16_t
Ipv4Interface::GetMtu (void) const
{
- NS_DEBUG ("Ipv4Interface::GetMtu ()");
+ NS_LOG_FUNCTION;
if (m_netdevice == 0)
{
uint32_t mtu = (1<<16) - 1;
@@ -120,28 +123,28 @@
bool
Ipv4Interface::IsUp (void) const
{
- NS_DEBUG ("Ipv4Interface::IsUp ()");
+ NS_LOG_FUNCTION;
return m_ifup;
}
bool
Ipv4Interface::IsDown (void) const
{
- NS_DEBUG ("Ipv4Interface::IsDown ()");
+ NS_LOG_FUNCTION;
return !m_ifup;
}
void
Ipv4Interface::SetUp (void)
{
- NS_DEBUG ("Ipv4Interface::SetUp ()");
+ NS_LOG_FUNCTION;
m_ifup = true;
}
void
Ipv4Interface::SetDown (void)
{
- NS_DEBUG ("Ipv4Interface::SetDown ()");
+ NS_LOG_FUNCTION;
m_ifup = false;
}
@@ -149,10 +152,9 @@
void
Ipv4Interface::Send(Packet p, Ipv4Address dest)
{
- NS_DEBUG ("Ipv4Interface::Send ()");
-
+ NS_LOG_FUNCTION;
if (IsUp()) {
- NS_DEBUG ("Ipv4Interface::Send (): SendTo ()");
+ NS_LOG_LOGIC ("SendTo");
SendTo(p, dest);
}
}
--- a/src/internet-node/ipv4-l3-protocol.cc Thu Sep 13 12:37:30 2007 -0700
+++ b/src/internet-node/ipv4-l3-protocol.cc Thu Sep 13 17:47:42 2007 -0700
@@ -20,7 +20,7 @@
//
#include "ns3/packet.h"
-#include "ns3/debug.h"
+#include "ns3/log.h"
#include "ns3/composite-trace-resolver.h"
#include "ns3/callback.h"
#include "ns3/ipv4-address.h"
@@ -36,7 +36,7 @@
#include "arp-ipv4-interface.h"
#include "ipv4-l4-demux.h"
-NS_DEBUG_COMPONENT_DEFINE ("Ipv4L3Protocol");
+NS_LOG_COMPONENT_DEFINE ("Ipv4L3Protocol");
namespace ns3 {
@@ -45,28 +45,41 @@
Ipv4L3ProtocolTraceContextElement::Ipv4L3ProtocolTraceContextElement ()
: m_type (TX)
-{}
+{
+ NS_LOG_FUNCTION;
+}
+
Ipv4L3ProtocolTraceContextElement::Ipv4L3ProtocolTraceContextElement (enum Type type)
: m_type (type)
-{}
+{
+ NS_LOG_FUNCTION;
+}
+
bool
Ipv4L3ProtocolTraceContextElement::IsTx (void) const
{
+ NS_LOG_FUNCTION;
return m_type == TX;
}
+
bool
Ipv4L3ProtocolTraceContextElement::IsRx (void) const
{
+ NS_LOG_FUNCTION;
return m_type == RX;
}
+
bool
Ipv4L3ProtocolTraceContextElement::IsDrop (void) const
{
+ NS_LOG_FUNCTION;
return m_type == DROP;
}
+
void
Ipv4L3ProtocolTraceContextElement::Print (std::ostream &os) const
{
+ NS_LOG_FUNCTION;
os << "ipv4=";
switch (m_type)
{
@@ -81,44 +94,59 @@
break;
}
}
+
uint16_t
Ipv4L3ProtocolTraceContextElement::GetUid (void)
{
+ NS_LOG_FUNCTION;
static uint16_t uid = AllocateUid<Ipv4L3ProtocolTraceContextElement> ("Ipv4L3ProtocolTraceContextElement");
return uid;
}
+
std::string
Ipv4L3ProtocolTraceContextElement::GetTypeName (void) const
{
+ NS_LOG_FUNCTION;
return "ns3::Ipv4L3ProtocolTraceContextElement";
}
-
Ipv4L3ProtocolInterfaceIndex::Ipv4L3ProtocolInterfaceIndex ()
: m_index (0)
-{}
+{
+ NS_LOG_FUNCTION;
+}
+
Ipv4L3ProtocolInterfaceIndex::Ipv4L3ProtocolInterfaceIndex (uint32_t index)
: m_index (index)
-{}
+{
+ NS_LOG_FUNCTION;
+}
+
uint32_t
Ipv4L3ProtocolInterfaceIndex::Get (void) const
{
+ NS_LOG_FUNCTION;
return m_index;
}
+
void
Ipv4L3ProtocolInterfaceIndex::Print (std::ostream &os) const
{
os << "ipv4-interface=" << m_index;
}
+
uint16_t
Ipv4L3ProtocolInterfaceIndex::GetUid (void)
{
+ NS_LOG_FUNCTION;
static uint16_t uid = AllocateUid<Ipv4L3ProtocolInterfaceIndex> ("Ipv4L3ProtocolInterfaceIndex");
return uid;
}
+
std::string
Ipv4L3ProtocolInterfaceIndex::GetTypeName (void) const
{
+ NS_LOG_FUNCTION;
return "ns3::Ipv4L3ProtocolInterfaceIndex";
}
@@ -129,8 +157,7 @@
m_identification (0),
m_node (node)
{
- NS_DEBUG("Ipv4L3Protocol::Ipv4L3Protocol ()");
-
+ NS_LOG_FUNCTION;
SetInterfaceId (Ipv4L3Protocol::iid);
m_staticRouting = Create<Ipv4StaticRouting> ();
AddRoutingProtocol (m_staticRouting, 0);
@@ -139,14 +166,13 @@
Ipv4L3Protocol::~Ipv4L3Protocol ()
{
- NS_DEBUG("Ipv4L3Protocol::~Ipv4L3Protocol ()");
+ NS_LOG_FUNCTION;
}
void
Ipv4L3Protocol::DoDispose (void)
{
- NS_DEBUG("Ipv4L3Protocol::DoDispose ()");
-
+ NS_LOG_FUNCTION;
m_interfaces.clear ();
m_node = 0;
m_staticRouting->Dispose ();
@@ -157,7 +183,7 @@
void
Ipv4L3Protocol::SetupLoopback (void)
{
- NS_DEBUG("Ipv4L3Protocol::SetupLoopback ()");
+ NS_LOG_FUNCTION;
Ptr<Ipv4LoopbackInterface> interface = Create<Ipv4LoopbackInterface> (m_node);
interface->SetAddress (Ipv4Address::GetLoopback ());
@@ -170,7 +196,7 @@
Ptr<TraceResolver>
Ipv4L3Protocol::GetTraceResolver (void) const
{
- NS_DEBUG("Ipv4L3Protocol::GetTraceResolver ()");
+ NS_LOG_FUNCTION;
Ptr<CompositeTraceResolver> resolver = Create<CompositeTraceResolver> ();
resolver->AddSource ("tx",
@@ -196,7 +222,7 @@
void
Ipv4L3Protocol::SetDefaultTtl (uint8_t ttl)
{
- NS_DEBUG("Ipv4L3Protocol::SetDefaultTtl ()");
+ NS_LOG_FUNCTION;
m_defaultTtl = ttl;
}
@@ -206,8 +232,8 @@
Ipv4Address nextHop,
uint32_t interface)
{
- NS_DEBUG("Ipv4L3Protocol::AddHostRouteTo (" << dest << ", " << nextHop <<
- ", " << interface << ")");
+ NS_LOG_FUNCTION;
+ NS_LOG_PARAM ("(" << dest << ", " << nextHop << ", " << interface << ")");
m_staticRouting->AddHostRouteTo (dest, nextHop, interface);
}
@@ -215,8 +241,8 @@
Ipv4L3Protocol::AddHostRouteTo (Ipv4Address dest,
uint32_t interface)
{
- NS_DEBUG("Ipv4L3Protocol::AddHostRouteTo (" << dest << ", " <<
- interface << ")");
+ NS_LOG_FUNCTION;
+ NS_LOG_PARAM ("(" << dest << ", " << interface << ")");
m_staticRouting->AddHostRouteTo (dest, interface);
}
@@ -226,25 +252,29 @@
Ipv4Address nextHop,
uint32_t interface)
{
- NS_DEBUG("Ipv4L3Protocol::AddNetworkRouteTo (" << network << ", " <<
- networkMask << ", " << nextHop << ", " << interface << ")");
+ NS_LOG_FUNCTION;
+ NS_LOG_PARAM ("(" << network << ", " << networkMask << ", " << nextHop <<
+ ", " << interface << ")");
m_staticRouting->AddNetworkRouteTo (network, networkMask, nextHop, interface);
}
+
void
Ipv4L3Protocol::AddNetworkRouteTo (Ipv4Address network,
Ipv4Mask networkMask,
uint32_t interface)
{
- NS_DEBUG("Ipv4L3Protocol::AddNetworkRouteTo (" << network << ", " <<
- networkMask << ", " << interface << ")");
+ NS_LOG_FUNCTION;
+ NS_LOG_PARAM ("(" << network << ", " << networkMask << ", " << interface <<
+ ")");
m_staticRouting->AddNetworkRouteTo (network, networkMask, interface);
}
+
void
Ipv4L3Protocol::SetDefaultRoute (Ipv4Address nextHop,
uint32_t interface)
{
- NS_DEBUG("Ipv4L3Protocol::SetDefaultRoute (" << nextHop << ", " <<
- interface << ")");
+ NS_LOG_FUNCTION;
+ NS_LOG_PARAM ("(" << nextHop << ", " << interface << ")");
m_staticRouting->SetDefaultRoute (nextHop, interface);
}
@@ -254,8 +284,8 @@
Packet packet,
Ipv4RoutingProtocol::RouteReplyCallback routeReply)
{
- NS_DEBUG("Ipv4L3Protocol::Lookup (" << &ipHeader <<
- ", " << &packet << &routeReply << ")");
+ NS_LOG_FUNCTION;
+ NS_LOG_PARAM ("(" << &ipHeader << ", " << &packet << &routeReply << ")");
Lookup (Ipv4RoutingProtocol::IF_INDEX_ANY, ipHeader, packet, routeReply);
}
@@ -267,15 +297,16 @@
Packet packet,
Ipv4RoutingProtocol::RouteReplyCallback routeReply)
{
- NS_DEBUG("Ipv4L3Protocol::Lookup (" << ifIndex << ", " << &ipHeader <<
- ", " << &packet << &routeReply << ")");
+ NS_LOG_FUNCTION;
+ NS_LOG_PARAM ("(" << ifIndex << ", " << &ipHeader << ", " << &packet <<
+ &routeReply << ")");
for (Ipv4RoutingProtocolList::const_iterator rprotoIter =
m_routingProtocols.begin ();
rprotoIter != m_routingProtocols.end ();
rprotoIter++)
{
- NS_DEBUG("Ipv4L3Protocol::Lookup (): Requesting route");
+ NS_LOG_LOGIC ("Requesting route");
if ((*rprotoIter).second->RequestRoute (ifIndex, ipHeader, packet,
routeReply))
return;
@@ -284,8 +315,7 @@
if (ipHeader.GetDestination ().IsMulticast () &&
ifIndex == Ipv4RoutingProtocol::IF_INDEX_ANY)
{
- NS_DEBUG ("Ipv4L3Protocol::Lookup (): "
- "Multicast destination with local source");
+ NS_LOG_LOGIC ("Multicast destination with local source");
//
// We have a multicast packet originating from the current node and were not
// able to send it using the usual RequestRoute process. Since the usual
@@ -300,8 +330,8 @@
if (route)
{
- NS_DEBUG ("Ipv4StaticRouting::Lookup (): "
- "Local source. Using unicast default route for multicast packet");
+ NS_LOG_LOGIC ("Local source. Using unicast default route for "
+ "multicast packet");
routeReply (true, *route, packet, ipHeader);
return;
@@ -317,8 +347,8 @@
Ipv4L3Protocol::AddRoutingProtocol (Ptr<Ipv4RoutingProtocol> routingProtocol,
int priority)
{
- NS_DEBUG("Ipv4L3Protocol::AddRoutingProtocol (" << &routingProtocol <<
- ", " << priority << ")");
+ NS_LOG_FUNCTION;
+ NS_LOG_PARAM ("(" << &routingProtocol << ", " << priority << ")");
m_routingProtocols.push_back
(std::pair<int, Ptr<Ipv4RoutingProtocol> > (-priority, routingProtocol));
m_routingProtocols.sort ();
@@ -327,21 +357,22 @@
uint32_t
Ipv4L3Protocol::GetNRoutes (void)
{
- NS_DEBUG("Ipv4L3Protocol::GetNRoutes ()");
+ NS_LOG_FUNCTION;
return m_staticRouting->GetNRoutes ();
}
Ipv4Route *
Ipv4L3Protocol::GetRoute (uint32_t index)
{
- NS_DEBUG("Ipv4L3Protocol::GetRoute ()");
+ NS_LOG_FUNCTION;
return m_staticRouting->GetRoute (index);
}
void
Ipv4L3Protocol::RemoveRoute (uint32_t index)
{
- NS_DEBUG("Ipv4L3Protocol::RemoveRoute (" << index << ")");
+ NS_LOG_FUNCTION;
+ NS_LOG_PARAM("(" << index << ")");
m_staticRouting->RemoveRoute (index);
}
@@ -351,8 +382,9 @@
uint32_t inputInterface,
std::vector<uint32_t> outputInterfaces)
{
- NS_DEBUG("Ipv4L3Protocol::AddMulticastRoute (" << origin << ", " <<
- group << ", " << inputInterface << ", " << &outputInterfaces << ")");
+ NS_LOG_FUNCTION;
+ NS_LOG_PARAM ("(" << origin << ", " << group << ", " << inputInterface <<
+ ", " << &outputInterfaces << ")");
m_staticRouting->AddMulticastRoute (origin, group, inputInterface,
outputInterfaces);
@@ -361,8 +393,8 @@
void
Ipv4L3Protocol::SetDefaultMulticastRoute (uint32_t outputInterface)
{
- NS_DEBUG("Ipv4L3Protocol::SetDefaultMulticastRoute (" << outputInterface <<
- ")");
+ NS_LOG_FUNCTION;
+ NS_LOG_PARAM ("(" << outputInterface << ")");
m_staticRouting->SetDefaultMulticastRoute (outputInterface);
}
@@ -370,14 +402,15 @@
uint32_t
Ipv4L3Protocol::GetNMulticastRoutes (void) const
{
- NS_DEBUG("Ipv4L3Protocol::GetNMulticastRoutes ()");
+ NS_LOG_FUNCTION;
return m_staticRouting->GetNMulticastRoutes ();
}
Ipv4MulticastRoute *
Ipv4L3Protocol::GetMulticastRoute (uint32_t index) const
{
- NS_DEBUG("Ipv4L3Protocol::GetMulticastRoute (" << index << ")");
+ NS_LOG_FUNCTION;
+ NS_LOG_PARAM ("(" << index << ")");
return m_staticRouting->GetMulticastRoute (index);
}
@@ -386,22 +419,25 @@
Ipv4Address group,
uint32_t inputInterface)
{
- NS_DEBUG("Ipv4L3Protocol::RemoveMulticastRoute (" << origin << ", " <<
- group << ", " << inputInterface << ")");
+ NS_LOG_FUNCTION;
+ NS_LOG_PARAM ("(" << origin << ", " << group << ", " << inputInterface <<
+ ")");
m_staticRouting->RemoveMulticastRoute (origin, group, inputInterface);
}
void
Ipv4L3Protocol::RemoveMulticastRoute (uint32_t index)
{
- NS_DEBUG("Ipv4L3Protocol::RemoveMulticastRoute (" << index << ")");
+ NS_LOG_FUNCTION;
+ NS_LOG_PARAM ("(" << index << ")");
m_staticRouting->RemoveMulticastRoute (index);
}
uint32_t
Ipv4L3Protocol::AddInterface (Ptr<NetDevice> device)
{
- NS_DEBUG("Ipv4L3Protocol::AddInterface (" << &device << ")");
+ NS_LOG_FUNCTION;
+ NS_LOG_PARAM ("(" << &device << ")");
Ptr<Ipv4Interface> interface = Create<ArpIpv4Interface> (m_node, device);
return AddIpv4Interface (interface);
}
@@ -409,7 +445,8 @@
uint32_t
Ipv4L3Protocol::AddIpv4Interface (Ptr<Ipv4Interface>interface)
{
- NS_DEBUG("Ipv4L3Protocol::AddIpv4Interface (" << interface << ")");
+ NS_LOG_FUNCTION;
+ NS_LOG_PARAM ("(" << interface << ")");
uint32_t index = m_nInterfaces;
m_interfaces.push_back (interface);
m_nInterfaces++;
@@ -419,7 +456,8 @@
Ptr<Ipv4Interface>
Ipv4L3Protocol::GetInterface (uint32_t index) const
{
- NS_DEBUG("Ipv4L3Protocol::GetInterface (" << index << ")");
+ NS_LOG_FUNCTION;
+ NS_LOG_PARAM ("(" << index << ")");
uint32_t tmp = 0;
for (Ipv4InterfaceList::const_iterator i = m_interfaces.begin (); i != m_interfaces.end (); i++)
{
@@ -435,14 +473,15 @@
uint32_t
Ipv4L3Protocol::GetNInterfaces (void) const
{
- NS_DEBUG("Ipv4L3Protocol::GetNInterface ()");
+ NS_LOG_FUNCTION;
return m_nInterfaces;
}
uint32_t
Ipv4L3Protocol::FindInterfaceForAddr (Ipv4Address addr) const
{
- NS_DEBUG("Ipv4L3Protocol::FindInterfaceForAddr (" << addr << ")");
+ NS_LOG_FUNCTION;
+ NS_LOG_PARAM ("(" << addr << ")");
uint32_t ifIndex = 0;
for (Ipv4InterfaceList::const_iterator i = m_interfaces.begin ();
@@ -463,8 +502,8 @@
uint32_t
Ipv4L3Protocol::FindInterfaceForAddr (Ipv4Address addr, Ipv4Mask mask) const
{
- NS_DEBUG("Ipv4L3Protocol::FindInterfaceForAddr (" << addr << ", " <<
- mask << ")");
+ NS_LOG_FUNCTION;
+ NS_LOG_PARAM ("(" << addr << ", " << mask << ")");
uint32_t ifIndex = 0;
for (Ipv4InterfaceList::const_iterator i = m_interfaces.begin ();
@@ -485,7 +524,8 @@
Ptr<Ipv4Interface>
Ipv4L3Protocol::FindInterfaceForDevice (Ptr<const NetDevice> device)
{
- NS_DEBUG("Ipv4L3Protocol::FindInterfaceForDevice (" << &device << ")");
+ NS_LOG_FUNCTION;
+ NS_LOG_PARAM ("(" << &device << ")");
for (Ipv4InterfaceList::const_iterator i = m_interfaces.begin (); i != m_interfaces.end (); i++)
{
if ((*i)->GetDevice () == device)
@@ -499,10 +539,11 @@
void
Ipv4L3Protocol::Receive( Ptr<NetDevice> device, const Packet& p, uint16_t protocol, const Address &from)
{
- NS_DEBUG("Ipv4L3Protocol::Receive (" << &device << ", " << &p << ", " <<
- protocol << ", " << from << ")");
+ NS_LOG_FUNCTION;
+ NS_LOG_PARAM ("(" << &device << ", " << &p << ", " << protocol << ", " <<
+ from << ")");
- NS_DEBUG("Ipv4L3Protocol::Receive (): Packet from " << from);
+ NS_LOG_LOGIC ("Packet from " << from);
uint32_t index = 0;
for (Ipv4InterfaceList::const_iterator i = m_interfaces.begin ();
@@ -530,6 +571,7 @@
return;
}
+ NS_LOG_LOGIC ("Forward up");
ForwardUp (packet, ipHeader);
}
@@ -540,8 +582,9 @@
Ipv4Address destination,
uint8_t protocol)
{
- NS_DEBUG("Ipv4L3Protocol::Send (" << &packet << ", " << source << ", " <<
- ", " << destination << ", " << protocol << ")");
+ NS_LOG_FUNCTION;
+ NS_LOG_PARAM ("(" << &packet << ", " << source << ", " << ", " <<
+ destination << ", " << protocol << ")");
Ipv4Header ipHeader;
@@ -591,18 +634,18 @@
Packet packet,
Ipv4Header const &ipHeader)
{
- NS_DEBUG("Ipv4L3Protocol::SendRealOut (" << found << ", " << &route <<
- ", " << &packet << &ipHeader << ")");
+ NS_LOG_FUNCTION;
+ NS_LOG_PARAM ("(" << found << ", " << &route << ", " << &packet <<
+ &ipHeader << ")");
if (!found)
{
- NS_DEBUG ("Ipv4L3Protocol::SendRealOut (): No route to host. Drop.");
+ NS_LOG_WARN ("No route to host. Drop.");
m_dropTrace (packet);
return;
}
- NS_DEBUG ("Ipv4L3Protocol::SendRealOut (): Send via interface " <<
- route.GetInterface ());
+ NS_LOG_LOGIC ("Send via interface " << route.GetInterface ());
packet.AddHeader (ipHeader);
Ptr<Ipv4Interface> outInterface = GetInterface (route.GetInterface ());
@@ -610,14 +653,12 @@
m_txTrace (packet, route.GetInterface ());
if (route.IsGateway ())
{
- NS_DEBUG ("Ipv4L3Protocol::SendRealOut (): Send to gateway " <<
- route.GetGateway ());
+ NS_LOG_LOGIC ("Send to gateway " << route.GetGateway ());
outInterface->Send (packet, route.GetGateway ());
}
else
{
- NS_DEBUG ("Ipv4L3Protocol::SendRealOut (): Send to destination " <<
- ipHeader.GetDestination ());
+ NS_LOG_LOGIC ("Send to destination " << ipHeader.GetDestination ());
outInterface->Send (packet, ipHeader.GetDestination ());
}
}
@@ -629,16 +670,16 @@
Ipv4Header &ipHeader,
Ptr<NetDevice> device)
{
- NS_DEBUG("Ipv4L3Protocol::Forwarding (" << ifIndex << ", " << &packet <<
- ", " << &ipHeader << ", " << device << ")");
+ NS_LOG_FUNCTION;
+ NS_LOG_PARAM ("(" << ifIndex << ", " << &packet << ", " << &ipHeader <<
+ ", " << device << ")");
for (Ipv4InterfaceList::const_iterator i = m_interfaces.begin ();
i != m_interfaces.end (); i++)
{
if ((*i)->GetAddress ().IsEqual (ipHeader.GetDestination ()))
{
- NS_DEBUG("Ipv4L3Protocol::Forwarding (): "
- "For me (destination match)");
+ NS_LOG_LOGIC ("For me (destination match)");
return false;
}
}
@@ -651,8 +692,7 @@
{
if (ipHeader.GetDestination ().IsEqual (interface->GetBroadcast ()))
{
- NS_DEBUG("Ipv4L3Protocol::Forwarding (): "
- "For me (interface broadcast address)");
+ NS_LOG_LOGIC ("For me (interface broadcast address)");
return false;
}
break;
@@ -661,15 +701,13 @@
if (ipHeader.GetDestination ().IsBroadcast ())
{
- NS_DEBUG("Ipv4L3Protocol::Forwarding (): "
- "For me (Ipv4Addr broadcast address)");
+ NS_LOG_LOGIC ("For me (Ipv4Addr broadcast address)");
return false;
}
if (ipHeader.GetDestination ().IsEqual (Ipv4Address::GetAny ()))
{
- NS_DEBUG("Ipv4L3Protocol::Forwarding (): "
- "For me (Ipv4Addr any address)");
+ NS_LOG_LOGIC ("For me (Ipv4Addr any address)");
return false;
}
@@ -677,14 +715,13 @@
{
// Should send ttl expired here
// XXX
- NS_DEBUG("Ipv4L3Protocol::Forwarding (): "
- "Not for me (TTL expired). Drop");
+ NS_LOG_LOGIC ("Not for me (TTL expired). Drop");
m_dropTrace (packet);
return true;
}
ipHeader.SetTtl (ipHeader.GetTtl () - 1);
- NS_DEBUG("Ipv4L3Protocol::Forwarding (): Forwarding packet.");
+ NS_LOG_LOGIC ("Forwarding packet.");
Lookup (ifIndex, ipHeader, packet,
MakeCallback (&Ipv4L3Protocol::SendRealOut, this));
//
@@ -698,20 +735,21 @@
if ((*i).first.IsEqual (ipHeader.GetSource ()) &&
(*i).second.IsEqual (ipHeader.GetDestination ()))
{
- NS_DEBUG("Ipv4L3Protocol::Forwarding (): "
- "For me (Joined multicast group)");
+ NS_LOG_LOGIC ("For me (Joined multicast group)");
return false;
}
}
- NS_DEBUG("Ipv4L3Protocol::Forwarding (): Not for me.");
+ NS_LOG_LOGIC("Not for me.");
return true;
}
void
Ipv4L3Protocol::ForwardUp (Packet p, Ipv4Header const&ip)
{
- NS_DEBUG("Ipv4L3Protocol::ForwardUp (" << &p << ", " << &ip << ")");
+ NS_LOG_FUNCTION;
+ NS_LOG_PARAM ("(" << &p << ", " << &ip << ")");
+
Ptr<Ipv4L4Demux> demux = m_node->QueryInterface<Ipv4L4Demux> (Ipv4L4Demux::iid);
Ptr<Ipv4L4Protocol> protocol = demux->GetProtocol (ip.GetProtocol ());
protocol->Receive (p, ip.GetSource (), ip.GetDestination ());
@@ -720,8 +758,8 @@
void
Ipv4L3Protocol::JoinMulticastGroup (Ipv4Address origin, Ipv4Address group)
{
- NS_DEBUG("Ipv4L3Protocol::JoinMulticastGroup (" << origin << ", " <<
- group << ")");
+ NS_LOG_FUNCTION;
+ NS_LOG_PARAM ("(" << origin << ", " << group << ")");
m_multicastGroups.push_back(
std::pair<Ipv4Address, Ipv4Address> (origin, group));
}
@@ -729,8 +767,8 @@
void
Ipv4L3Protocol::LeaveMulticastGroup (Ipv4Address origin, Ipv4Address group)
{
- NS_DEBUG("Ipv4L3Protocol::LeaveMulticastGroup (" << origin << ", " <<
- group << ")");
+ NS_LOG_FUNCTION;
+ NS_LOG_PARAM ("(" << origin << ", " << group << ")");
for (Ipv4MulticastGroupList::iterator i = m_multicastGroups.begin ();
i != m_multicastGroups.end ();
@@ -747,7 +785,8 @@
void
Ipv4L3Protocol::SetAddress (uint32_t i, Ipv4Address address)
{
- NS_DEBUG("Ipv4L3Protocol::SetAddress (" << i << ", " << address << ")");
+ NS_LOG_FUNCTION;
+ NS_LOG_PARAM ("(" << i << ", " << address << ")");
Ptr<Ipv4Interface> interface = GetInterface (i);
interface->SetAddress (address);
}
@@ -755,7 +794,8 @@
void
Ipv4L3Protocol::SetNetworkMask (uint32_t i, Ipv4Mask mask)
{
- NS_DEBUG("Ipv4L3Protocol::SetNetworkMask (" << i << ", " << mask << ")");
+ NS_LOG_FUNCTION;
+ NS_LOG_PARAM ("(" << i << ", " << mask << ")");
Ptr<Ipv4Interface> interface = GetInterface (i);
interface->SetNetworkMask (mask);
}
@@ -763,7 +803,8 @@
Ipv4Mask
Ipv4L3Protocol::GetNetworkMask (uint32_t i) const
{
- NS_DEBUG("Ipv4L3Protocol::GetNetworkMask (" << i << ")");
+ NS_LOG_FUNCTION;
+ NS_LOG_PARAM ("(" << i << ")");
Ptr<Ipv4Interface> interface = GetInterface (i);
return interface->GetNetworkMask ();
}
@@ -771,7 +812,8 @@
Ipv4Address
Ipv4L3Protocol::GetAddress (uint32_t i) const
{
- NS_DEBUG("Ipv4L3Protocol::GetAddress (" << i << ")");
+ NS_LOG_FUNCTION;
+ NS_LOG_PARAM ("(" << i << ")");
Ptr<Ipv4Interface> interface = GetInterface (i);
return interface->GetAddress ();
}
@@ -780,8 +822,8 @@
Ipv4L3Protocol::GetIfIndexForDestination (
Ipv4Address destination, uint32_t& ifIndex) const
{
- NS_DEBUG("Ipv4L3Protocol::GetIfIndexForDestination (" << destination <<
- ", " << &ifIndex << ")");
+ NS_LOG_FUNCTION;
+ NS_LOG_PARAM ("(" << destination << ", " << &ifIndex << ")");
//
// The first thing we do in trying to determine a source address is to
// consult the routing protocols. These will also check for a default route
@@ -791,13 +833,12 @@
i != m_routingProtocols.end ();
i++)
{
- NS_DEBUG("Ipv4L3Protocol::Lookup (): Requesting Source Address");
+ NS_LOG_LOGIC ("Requesting Source Address");
uint32_t ifIndexTmp;
if ((*i).second->RequestIfIndex (destination, ifIndexTmp))
{
- NS_DEBUG("Ipv4L3Protocol::GetIfIndexForDestination (): "
- "Found ifIndex " << ifIndexTmp);
+ NS_LOG_LOGIC ("Found ifIndex " << ifIndexTmp);
ifIndex = ifIndexTmp;
return true;
}
@@ -813,8 +854,7 @@
//
if (GetNInterfaces () == 2)
{
- NS_DEBUG("Ipv4L3Protocol::GetIfIndexForDestination (): "
- "One Interface. Using interface 1.");
+ NS_LOG_LOGIC ("One Interface. Using interface 1.");
ifIndex = 1;
return true;
}
@@ -833,8 +873,7 @@
// set to the IP address of the interface set in the default unicast route.
// Also, in the case of a broadcast, the same will be true.
//
- NS_DEBUG("Ipv4L3Protocol::GetIfIndexForDestination (): "
- "Using default unicast route");
+ NS_LOG_LOGIC ("Using default unicast route");
Ipv4Route *route = m_staticRouting->GetDefaultRoute ();
NS_ASSERT_MSG(route,
@@ -843,15 +882,15 @@
ifIndex = route->GetInterface ();
- NS_DEBUG("Ipv4L3Protocol::GetIfIndexForDestination (): "
- "Default route specifies interface " << ifIndex);
+ NS_LOG_LOGIC ("Default route specifies interface " << ifIndex);
return true;
}
uint16_t
Ipv4L3Protocol::GetMtu (uint32_t i) const
{
- NS_DEBUG("Ipv4L3Protocol::GetMtu (" << i << ")");
+ NS_LOG_FUNCTION;
+ NS_LOG_PARAM ("(" << i << ")");
Ptr<Ipv4Interface> interface = GetInterface (i);
return interface->GetMtu ();
}
@@ -859,7 +898,8 @@
bool
Ipv4L3Protocol::IsUp (uint32_t i) const
{
- NS_DEBUG("Ipv4L3Protocol::IsUp (" << i << ")");
+ NS_LOG_FUNCTION;
+ NS_LOG_PARAM ("(" << i << ")");
Ptr<Ipv4Interface> interface = GetInterface (i);
return interface->IsUp ();
}
@@ -867,7 +907,8 @@
void
Ipv4L3Protocol::SetUp (uint32_t i)
{
- NS_DEBUG("Ipv4L3Protocol::SetUp (" << i << ")");
+ NS_LOG_FUNCTION;
+ NS_LOG_PARAM ("(" << i << ")");
Ptr<Ipv4Interface> interface = GetInterface (i);
interface->SetUp ();
@@ -885,7 +926,8 @@
void
Ipv4L3Protocol::SetDown (uint32_t ifaceIndex)
{
- NS_DEBUG("Ipv4L3Protocol::SetDown (" << ifaceIndex << ")");
+ NS_LOG_FUNCTION;
+ NS_LOG_PARAM ("(" << ifaceIndex << ")");
Ptr<Ipv4Interface> interface = GetInterface (ifaceIndex);
interface->SetDown ();
@@ -907,5 +949,4 @@
}
}
-
}//namespace ns3
--- a/src/internet-node/ipv4-loopback-interface.cc Thu Sep 13 12:37:30 2007 -0700
+++ b/src/internet-node/ipv4-loopback-interface.cc Thu Sep 13 17:47:42 2007 -0700
@@ -20,14 +20,14 @@
* Mathieu Lacage <mathieu.lacage@sophia.inria.fr>,
*/
-#include "ns3/debug.h"
+#include "ns3/log.h"
#include "ns3/net-device.h"
#include "ns3/node.h"
#include "ns3/mac48-address.h"
#include "ipv4-loopback-interface.h"
#include "ipv4-l3-protocol.h"
-NS_DEBUG_COMPONENT_DEFINE ("Ipv4LoopbackInterface");
+NS_LOG_COMPONENT_DEFINE ("Ipv4LoopbackInterface");
namespace ns3 {
@@ -35,19 +35,19 @@
: Ipv4Interface (0),
m_node (node)
{
- NS_DEBUG("Ipv4LoopbackInterface::Ipv4LoopbackInterface ()");
+ NS_LOG_FUNCTION;
}
Ipv4LoopbackInterface::~Ipv4LoopbackInterface ()
{
- NS_DEBUG("Ipv4LoopbackInterface::~Ipv4LoopbackInterface ()");
+ NS_LOG_FUNCTION;
}
void
Ipv4LoopbackInterface::SendTo (Packet packet, Ipv4Address dest)
{
- NS_DEBUG("Ipv4LoopbackInterface::SendTo (" << &packet << ", " <<
- dest << ")");
+ NS_LOG_FUNCTION;
+ NS_LOG_PARAM ("(" << &packet << ", " << dest << ")");
Ptr<Ipv4L3Protocol> ipv4 =
m_node->QueryInterface<Ipv4L3Protocol> (Ipv4L3Protocol::iid);
--- a/src/internet-node/ipv4-static-routing.cc Thu Sep 13 12:37:30 2007 -0700
+++ b/src/internet-node/ipv4-static-routing.cc Thu Sep 13 17:47:42 2007 -0700
@@ -19,17 +19,18 @@
// Author: George F. Riley<riley@ece.gatech.edu>
// Gustavo Carneiro <gjc@inescporto.pt>
-#include "ns3/debug.h"
+#include "ns3/log.h"
#include "ipv4-static-routing.h"
#include "ns3/packet.h"
-NS_DEBUG_COMPONENT_DEFINE ("Ipv4StaticRouting");
+NS_LOG_COMPONENT_DEFINE ("Ipv4StaticRouting");
namespace ns3 {
Ipv4StaticRouting::Ipv4StaticRouting ()
: m_defaultRoute (0), m_defaultMulticastRoute (0)
{
+ NS_LOG_FUNCTION;
}
void
@@ -37,7 +38,7 @@
Ipv4Address nextHop,
uint32_t interface)
{
-
+ NS_LOG_FUNCTION;
Ipv4Route *route = new Ipv4Route ();
*route = Ipv4Route::CreateHostRouteTo (dest, nextHop, interface);
m_hostRoutes.push_back (route);
@@ -47,6 +48,7 @@
Ipv4StaticRouting::AddHostRouteTo (Ipv4Address dest,
uint32_t interface)
{
+ NS_LOG_FUNCTION;
Ipv4Route *route = new Ipv4Route ();
*route = Ipv4Route::CreateHostRouteTo (dest, interface);
m_hostRoutes.push_back (route);
@@ -58,6 +60,7 @@
Ipv4Address nextHop,
uint32_t interface)
{
+ NS_LOG_FUNCTION;
Ipv4Route *route = new Ipv4Route ();
*route = Ipv4Route::CreateNetworkRouteTo (network,
networkMask,
@@ -71,6 +74,7 @@
Ipv4Mask networkMask,
uint32_t interface)
{
+ NS_LOG_FUNCTION;
Ipv4Route *route = new Ipv4Route ();
*route = Ipv4Route::CreateNetworkRouteTo (network,
networkMask,
@@ -82,6 +86,7 @@
Ipv4StaticRouting::SetDefaultRoute (Ipv4Address nextHop,
uint32_t interface)
{
+ NS_LOG_FUNCTION;
Ipv4Route *route = new Ipv4Route ();
*route = Ipv4Route::CreateDefaultRoute (nextHop, interface);
delete m_defaultRoute;
@@ -94,6 +99,7 @@
uint32_t inputInterface,
std::vector<uint32_t> outputInterfaces)
{
+ NS_LOG_FUNCTION;
Ipv4MulticastRoute *route = new Ipv4MulticastRoute ();
*route = Ipv4MulticastRoute::CreateMulticastRoute (origin, group,
inputInterface, outputInterfaces);
@@ -103,6 +109,7 @@
void
Ipv4StaticRouting::SetDefaultMulticastRoute(uint32_t outputInterface)
{
+ NS_LOG_FUNCTION;
Ipv4Address origin = Ipv4Address::GetAny ();
Ipv4Address group = Ipv4Address::GetAny ();
uint32_t inputInterface = Ipv4RoutingProtocol::IF_INDEX_ANY;
@@ -121,12 +128,14 @@
uint32_t
Ipv4StaticRouting::GetNMulticastRoutes (void) const
{
+ NS_LOG_FUNCTION;
return m_multicastRoutes.size () + m_defaultMulticastRoute ? 1 : 0;
}
Ipv4MulticastRoute *
Ipv4StaticRouting::GetMulticastRoute (uint32_t index) const
{
+ NS_LOG_FUNCTION;
NS_ASSERT_MSG(index < m_multicastRoutes.size (),
"Ipv4StaticRouting::GetMulticastRoute (): Index out of range");
//
@@ -174,6 +183,7 @@
Ipv4MulticastRoute *
Ipv4StaticRouting::GetDefaultMulticastRoute () const
{
+ NS_LOG_FUNCTION;
if (m_defaultMulticastRoute != 0)
{
return m_defaultMulticastRoute;
@@ -186,9 +196,7 @@
Ipv4Address group,
uint32_t inputInterface)
{
-//
-// This method does not attempt to delete the multicast route.
-//
+ NS_LOG_FUNCTION;
for (MulticastRoutesI i = m_multicastRoutes.begin ();
i != m_multicastRoutes.end ();
i++)
@@ -209,6 +217,7 @@
void
Ipv4StaticRouting::RemoveMulticastRoute(uint32_t index)
{
+ NS_LOG_FUNCTION;
//
// From an external point of view the default route appears to be in slot 0
// of the routing table. The implementation, however, puts it in a separate
@@ -253,6 +262,7 @@
Ipv4Route *
Ipv4StaticRouting::LookupStatic (Ipv4Address dest)
{
+ NS_LOG_FUNCTION;
for (HostRoutesCI i = m_hostRoutes.begin ();
i != m_hostRoutes.end ();
i++)
@@ -289,6 +299,7 @@
Ipv4Address group,
uint32_t ifIndex)
{
+ NS_LOG_FUNCTION;
//
// We treat the "any" address (typically 0.0.0.0) as a wildcard in our matching
// scheme.
@@ -390,6 +401,7 @@
uint32_t
Ipv4StaticRouting::GetNRoutes (void)
{
+ NS_LOG_FUNCTION;
uint32_t n = 0;
if (m_defaultRoute != 0)
{
@@ -403,6 +415,7 @@
Ipv4Route *
Ipv4StaticRouting::GetDefaultRoute ()
{
+ NS_LOG_FUNCTION;
if (m_defaultRoute != 0)
{
return m_defaultRoute;
@@ -416,6 +429,7 @@
Ipv4Route *
Ipv4StaticRouting::GetRoute (uint32_t index)
{
+ NS_LOG_FUNCTION;
if (index == 0 && m_defaultRoute != 0)
{
return m_defaultRoute;
@@ -457,6 +471,7 @@
void
Ipv4StaticRouting::RemoveRoute (uint32_t index)
{
+ NS_LOG_FUNCTION;
if (index == 0 && m_defaultRoute != 0)
{
delete m_defaultRoute;
@@ -506,26 +521,24 @@
Packet packet,
RouteReplyCallback routeReply)
{
- NS_DEBUG ("Ipv4StaticRouting::RequestRoute (" << &ipHeader << ", " <<
- &packet << ", " << &routeReply << ")");
+ NS_LOG_FUNCTION;
+ NS_LOG_PARAM ("(" << ifIndex << &ipHeader << ", " << &packet << ", " <<
+ &routeReply << ")");
- NS_DEBUG ("Ipv4StaticRouting::RequestRoute (): source = " <<
- ipHeader.GetSource ());
+ NS_LOG_LOGIC ("source = " << ipHeader.GetSource ());
- NS_DEBUG ("Ipv4StaticRouting::RequestRoute (): destination = " <<
- ipHeader.GetDestination ());
+ NS_LOG_LOGIC ("destination = " << ipHeader.GetDestination ());
if (ipHeader.GetDestination ().IsMulticast ())
{
- NS_DEBUG ("Ipv4StaticRouting::RequestRoute (): Multicast destination");
+ NS_LOG_LOGIC ("Multicast destination");
Ipv4MulticastRoute *mRoute = LookupStatic(ipHeader.GetSource (),
ipHeader.GetDestination (), ifIndex);
if (mRoute)
{
- NS_DEBUG ("Ipv4StaticRouting::RequestRoute (): "
- "Multicast route found");
+ NS_LOG_LOGIC ("Multicast route found");
for (uint32_t i = 0; i < mRoute->GetNOutputInterfaces (); ++i)
{
@@ -534,8 +547,8 @@
Ipv4Route route =
Ipv4Route::CreateHostRouteTo(h.GetDestination (),
mRoute->GetOutputInterface(i));
- NS_DEBUG ("Ipv4StaticRouting::RequestRoute (): "
- "Send via interface " << mRoute->GetOutputInterface(i));
+ NS_LOG_LOGIC ( "Send via interface " <<
+ mRoute->GetOutputInterface(i));
routeReply (true, route, p, h);
}
return true;
@@ -545,7 +558,7 @@
//
// This is a unicast packet. Check to see if we have a route for it.
//
- NS_DEBUG ("Ipv4StaticRouting::RequestRoute (): Unicast destination");
+ NS_LOG_LOGIC ("Unicast destination");
Ipv4Route *route = LookupStatic (ipHeader.GetDestination ());
if (route != 0)
{
@@ -562,34 +575,31 @@
bool
Ipv4StaticRouting::RequestIfIndex (Ipv4Address destination, uint32_t& ifIndex)
{
- NS_DEBUG ("Ipv4StaticRouting::RequestIfIndex (" << destination << ", " <<
- &ifIndex << ")");
+ NS_LOG_FUNCTION;
+ NS_LOG_PARAM ("(" << destination << ", " << &ifIndex << ")");
//
// 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.
//
if (destination.IsMulticast ())
{
- NS_DEBUG ("Ipv4StaticRouting::RequestIfIndex (): Multicast destination");
+ NS_LOG_LOGIC ("Multicast destination");
Ipv4MulticastRoute *mRoute = LookupStatic(Ipv4Address::GetAny (),
destination, Ipv4RoutingProtocol::IF_INDEX_ANY);
if (mRoute)
{
- NS_DEBUG ("Ipv4StaticRouting::RequestIfIndex (): "
- "Multicast route found");
+ NS_LOG_LOGIC ("Multicast route found");
if (mRoute->GetNOutputInterfaces () != 1)
{
- NS_DEBUG ("Ipv4StaticRouting::RequestIfIndex (): "
- "Route is to multiple interfaces. Ignoring.");
+ NS_LOG_LOGIC ("Route is to multiple interfaces. Ignoring.");
return false;
}
ifIndex = mRoute->GetOutputInterface(0);
- NS_DEBUG ("Ipv4StaticRouting::RequestIfIndex (): "
- "Found ifIndex " << ifIndex);
+ NS_LOG_LOGIC ("Found ifIndex " << ifIndex);
return true;
}
return false; // Let other routing protocols try to handle this
@@ -597,7 +607,7 @@
//
// See if this is a unicast packet we have a route for.
//
- NS_DEBUG ("Ipv4StaticRouting::RequestIfIndex (): Unicast destination");
+ NS_LOG_LOGIC ("Unicast destination");
Ipv4Route *route = LookupStatic (destination);
if (route)
{
@@ -613,6 +623,7 @@
void
Ipv4StaticRouting::DoDispose (void)
{
+ NS_LOG_FUNCTION;
for (HostRoutesI i = m_hostRoutes.begin ();
i != m_hostRoutes.end ();
i = m_hostRoutes.erase (i))
--- a/src/internet-node/udp-l4-protocol.cc Thu Sep 13 12:37:30 2007 -0700
+++ b/src/internet-node/udp-l4-protocol.cc Thu Sep 13 17:47:42 2007 -0700
@@ -19,7 +19,7 @@
* Author: Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
*/
-#include "ns3/debug.h"
+#include "ns3/log.h"
#include "ns3/assert.h"
#include "ns3/packet.h"
#include "ns3/node.h"
@@ -31,7 +31,7 @@
#include "ipv4-l3-protocol.h"
#include "udp-socket.h"
-NS_DEBUG_COMPONENT_DEFINE ("UdpL4Protocol");
+NS_LOG_COMPONENT_DEFINE ("UdpL4Protocol");
namespace ns3 {
@@ -43,18 +43,18 @@
m_node (node),
m_endPoints (new Ipv4EndPointDemux ())
{
- NS_DEBUG("UdpL4Protocol::UdpL4Protocol ()");
+ NS_LOG_FUNCTION;
}
UdpL4Protocol::~UdpL4Protocol ()
{
- NS_DEBUG("UdpL4Protocol::~UdpL4Protocol ()");
+ NS_LOG_FUNCTION;
}
void
UdpL4Protocol::DoDispose (void)
{
- NS_DEBUG("UdpL4Protocol::DoDispose ()");
+ NS_LOG_FUNCTION;
if (m_endPoints != 0)
{
delete m_endPoints;
@@ -67,7 +67,7 @@
Ptr<Socket>
UdpL4Protocol::CreateSocket (void)
{
- NS_DEBUG("UdpL4Protocol::CreateSocket ()");
+ NS_LOG_FUNCTION;
Ptr<Socket> socket = Create<UdpSocket> (m_node, this);
return socket;
}
@@ -75,36 +75,40 @@
Ipv4EndPoint *
UdpL4Protocol::Allocate (void)
{
- NS_DEBUG("UdpL4Protocol::Allocate ()");
+ NS_LOG_FUNCTION;
return m_endPoints->Allocate ();
}
Ipv4EndPoint *
UdpL4Protocol::Allocate (Ipv4Address address)
{
- NS_DEBUG("UdpL4Protocol::Allocate (" << address << ")");
+ NS_LOG_FUNCTION;
+ NS_LOG_PARAM ("(" << address << ")");
return m_endPoints->Allocate (address);
}
Ipv4EndPoint *
UdpL4Protocol::Allocate (uint16_t port)
{
- NS_DEBUG("UdpL4Protocol::Allocate (" << port << ")");
+ NS_LOG_FUNCTION;
+ NS_LOG_PARAM ("(" << port << ")");
return m_endPoints->Allocate (port);
}
Ipv4EndPoint *
UdpL4Protocol::Allocate (Ipv4Address address, uint16_t port)
{
- NS_DEBUG("UdpL4Protocol::Allocate (" << address << ", " << port << ")");
+ NS_LOG_FUNCTION;
+ NS_LOG_PARAM ("(" << address << ", " << port << ")");
return m_endPoints->Allocate (address, port);
}
Ipv4EndPoint *
UdpL4Protocol::Allocate (Ipv4Address localAddress, uint16_t localPort,
Ipv4Address peerAddress, uint16_t peerPort)
{
- NS_DEBUG("UdpL4Protocol::Allocate (" << localAddress << ", " << localPort <<
- ", " << peerAddress << ", " << peerPort << ")");
+ NS_LOG_FUNCTION;
+ NS_LOG_PARAM ("(" << localAddress << ", " << localPort << ", " <<
+ peerAddress << ", " << peerPort << ")");
return m_endPoints->Allocate (localAddress, localPort,
peerAddress, peerPort);
}
@@ -112,7 +116,8 @@
void
UdpL4Protocol::DeAllocate (Ipv4EndPoint *endPoint)
{
- NS_DEBUG("UdpL4Protocol::Deallocate (" << endPoint << ")");
+ NS_LOG_FUNCTION;
+ NS_LOG_PARAM ("(" << endPoint << ")");
m_endPoints->DeAllocate (endPoint);
}
@@ -121,8 +126,9 @@
Ipv4Address const &source,
Ipv4Address const &destination)
{
- NS_DEBUG("UdpL4Protocol::Receive (" << &packet << ", " << source <<
- ", " << destination << ")");
+ NS_LOG_FUNCTION;
+ NS_LOG_PARAM ("(" << &packet << ", " << source << ", " << destination <<
+ ")");
UdpHeader udpHeader;
packet.RemoveHeader (udpHeader);
@@ -141,8 +147,9 @@
Ipv4Address saddr, Ipv4Address daddr,
uint16_t sport, uint16_t dport)
{
- NS_DEBUG("UdpL4Protocol::Send (" << &packet << ", " << saddr <<
- ", " << daddr << ", " << sport << ", " << dport << ")");
+ NS_LOG_FUNCTION;
+ NS_LOG_PARAM ("(" << &packet << ", " << saddr << ", " << daddr << ", " <<
+ sport << ", " << dport << ")");
UdpHeader udpHeader;
udpHeader.SetDestination (dport);
@@ -157,7 +164,7 @@
Ptr<Ipv4L3Protocol> ipv4 = m_node->QueryInterface<Ipv4L3Protocol> (Ipv4L3Protocol::iid);
if (ipv4 != 0)
{
- NS_DEBUG("UdpL4Protocol::Send (): Sending to IP");
+ NS_LOG_LOGIC ("Sending to IP");
ipv4->Send (packet, saddr, daddr, PROT_NUMBER);
}
}
--- a/src/internet-node/udp-socket.cc Thu Sep 13 12:37:30 2007 -0700
+++ b/src/internet-node/udp-socket.cc Thu Sep 13 17:47:42 2007 -0700
@@ -19,7 +19,7 @@
* Author: Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
*/
-#include "ns3/debug.h"
+#include "ns3/log.h"
#include "ns3/node.h"
#include "ns3/inet-socket-address.h"
#include "ns3/ipv4-route.h"
@@ -30,7 +30,7 @@
#include "ipv4-l4-demux.h"
#include "ns3/ipv4.h"
-NS_DEBUG_COMPONENT_DEFINE ("UdpSocket");
+NS_LOG_COMPONENT_DEFINE ("UdpSocket");
namespace ns3 {
@@ -43,12 +43,12 @@
m_shutdownRecv (false),
m_connected (false)
{
- NS_DEBUG("UdpSocket::UdpSocket ()");
+ NS_LOG_FUNCTION;
}
UdpSocket::~UdpSocket ()
{
- NS_DEBUG("UdpSocket::~UdpSocket ()");
+ NS_LOG_FUNCTION;
m_node = 0;
if (m_endPoint != 0)
@@ -72,22 +72,21 @@
enum Socket::SocketErrno
UdpSocket::GetErrno (void) const
{
- NS_DEBUG("UdpSocket::GetErrno ()");
-
+ NS_LOG_FUNCTION;
return m_errno;
}
Ptr<Node>
UdpSocket::GetNode (void) const
{
- NS_DEBUG("UdpSocket::GetNode ()");
+ NS_LOG_FUNCTION;
return m_node;
}
void
UdpSocket::Destroy (void)
{
- NS_DEBUG("UdpSocket::Destroy ()");
+ NS_LOG_FUNCTION;
m_node = 0;
m_endPoint = 0;
m_udp = 0;
@@ -96,8 +95,7 @@
int
UdpSocket::FinishBind (void)
{
- NS_DEBUG("UdpSocket::FinishBind ()");
-
+ NS_LOG_FUNCTION;
if (m_endPoint == 0)
{
return -1;
@@ -110,8 +108,7 @@
int
UdpSocket::Bind (void)
{
- NS_DEBUG("UdpSocket::Bind ()");
-
+ NS_LOG_FUNCTION;
m_endPoint = m_udp->Allocate ();
return FinishBind ();
}
@@ -119,11 +116,12 @@
int
UdpSocket::Bind (const Address &address)
{
- NS_DEBUG("UdpSocket::Bind (" << address << ")");
+ NS_LOG_FUNCTION;
+ NS_LOG_PARAM("(" << address << ")");
if (!InetSocketAddress::IsMatchingType (address))
{
- NS_DEBUG("UdpSocket::Bind (): Not IsMatchingType");
+ NS_LOG_ERROR ("Not IsMatchingType");
return ERROR_INVAL;
}
InetSocketAddress transport = InetSocketAddress::ConvertFrom (address);
@@ -152,7 +150,7 @@
int
UdpSocket::ShutdownSend (void)
{
- NS_DEBUG("UdpSocket::ShutDownSend ()");
+ NS_LOG_FUNCTION;
m_shutdownSend = true;
return 0;
}
@@ -160,7 +158,7 @@
int
UdpSocket::ShutdownRecv (void)
{
- NS_DEBUG("UdpSocket::ShutDownRecv ()");
+ NS_LOG_FUNCTION;
m_shutdownRecv = false;
return 0;
}
@@ -168,7 +166,7 @@
int
UdpSocket::Close(void)
{
- NS_DEBUG("UdpSocket::Close ()");
+ NS_LOG_FUNCTION;
NotifyCloseCompleted ();
return 0;
}
@@ -176,7 +174,8 @@
int
UdpSocket::Connect(const Address & address)
{
- NS_DEBUG ("UdpSocket::Connect (" << address << ")");
+ NS_LOG_FUNCTION;
+ NS_LOG_PARAM ("(" << address << ")");
Ipv4Route routeToDest;
InetSocketAddress transport = InetSocketAddress::ConvertFrom (address);
m_defaultAddress = transport.GetIpv4 ();
@@ -184,7 +183,7 @@
NotifyConnectionSucceeded ();
m_connected = true;
- NS_DEBUG ("UdpSocket::Connect (): Updating local address");
+ NS_LOG_LOGIC ("Updating local address");
uint32_t localIfIndex;
@@ -195,8 +194,7 @@
m_endPoint->SetLocalAddress (ipv4->GetAddress(localIfIndex));
}
- NS_DEBUG ("UdpSocket::Connect (): Local address is " <<
- m_endPoint->GetLocalAddress());
+ NS_LOG_LOGIC ("Local address is " << m_endPoint->GetLocalAddress());
return 0;
}
@@ -204,7 +202,8 @@
int
UdpSocket::Send (const Packet &p)
{
- NS_DEBUG("UdpSocket::Send (" << &p << ")");
+ NS_LOG_FUNCTION;
+ NS_LOG_PARAM ("(" << &p << ")");
if (!m_connected)
{
@@ -217,6 +216,7 @@
int
UdpSocket::DoSend (const Packet &p)
{
+ NS_LOG_FUNCTION;
if (m_endPoint == 0)
{
if (Bind () == -1)
@@ -238,11 +238,12 @@
int
UdpSocket::DoSendTo (const Packet &p, const Address &address)
{
- NS_DEBUG("UdpSocket::DoSendTo (" << &p << ", " << address << ")");
+ NS_LOG_FUNCTION;
+ NS_LOG_PARAM ("(" << &p << ", " << address << ")");
if (!m_connected)
{
- NS_DEBUG("UdpSocket::DoSendTo (): Not connected");
+ NS_LOG_LOGIC ("Not connected");
InetSocketAddress transport = InetSocketAddress::ConvertFrom (address);
Ipv4Address ipv4 = transport.GetIpv4 ();
uint16_t port = transport.GetPort ();
@@ -251,7 +252,7 @@
else
{
// connected UDP socket must use default addresses
- NS_DEBUG("UdpSocket::DoSendTo (): Connected");
+ NS_LOG_LOGIC ("Connected");
return DoSendTo (p, m_defaultAddress, m_defaultPort);
}
}
@@ -259,8 +260,8 @@
int
UdpSocket::DoSendTo (const Packet &p, Ipv4Address dest, uint16_t port)
{
- NS_DEBUG("UdpSocket::DoSendTo (" << &p << ", " << dest << ", " <<
- port << ")");
+ NS_LOG_FUNCTION;
+ NS_LOG_PARAM ("(" << &p << ", " << dest << ", " << port << ")");
Ipv4Route routeToDest;
@@ -288,7 +289,7 @@
//
if (dest.IsBroadcast ())
{
- NS_DEBUG("UdpSocket::DoSendTo (): Limited broadcast");
+ NS_LOG_LOGIC ("Limited broadcast");
for (uint32_t i = 0; i < ipv4->GetNInterfaces (); i++ )
{
Ipv4Address addri = ipv4->GetAddress (i);
@@ -300,7 +301,7 @@
}
else if (ipv4->GetIfIndexForDestination(dest, localIfIndex))
{
- NS_DEBUG("UdpSocket::DoSendTo (): Route exists");
+ NS_LOG_LOGIC ("Route exists");
m_udp->Send (p, ipv4->GetAddress (localIfIndex), dest,
m_endPoint->GetLocalPort (), port);
NotifyDataSent (p.GetSize ());
@@ -308,7 +309,7 @@
}
else
{
- NS_DEBUG("UdpSocket::DoSendTo (): ERROR_NOROUTETOHOST");
+ NS_LOG_ERROR ("ERROR_NOROUTETOHOST");
m_errno = ERROR_NOROUTETOHOST;
return -1;
}
@@ -319,7 +320,8 @@
int
UdpSocket::SendTo(const Address &address, const Packet &p)
{
- NS_DEBUG("UdpSocket::SendTo (" << address << ", " << &p << ")");
+ NS_LOG_FUNCTION;
+ NS_LOG_PARAM ("(" << address << ", " << &p << ")");
InetSocketAddress transport = InetSocketAddress::ConvertFrom (address);
Ipv4Address ipv4 = transport.GetIpv4 ();
uint16_t port = transport.GetPort ();
@@ -329,8 +331,8 @@
void
UdpSocket::ForwardUp (const Packet &packet, Ipv4Address ipv4, uint16_t port)
{
- NS_DEBUG("UdpSocket::ForwardUp (" << &packet << ", " << ipv4 << ", " <<
- port << ")");
+ NS_LOG_FUNCTION;
+ NS_LOG_PARAM ("(" << &packet << ", " << ipv4 << ", " << port << ")");
if (m_shutdownRecv)
{