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