many debug prints

This commit is contained in:
Craig Dowell committed 2007-08-12 22:41:24 -07:00
1 parent 09b235eaec
commit 6520f1335a
9 files changed
+213 -68

No files matched your search

+23 -5
View File
@@ -31,18 +31,26 @@
#include "ipv4-l3-protocol.h"
#include "arp-l3-protocol.h"
NS_DEBUG_COMPONENT_DEFINE ("ArpIpv4Interface");
namespace ns3 {
ArpIpv4Interface::ArpIpv4Interface (Ptr<Node> node, Ptr<NetDevice> device)
: Ipv4Interface (device),
m_node (node)
{}
{
NS_DEBUG ("ArpIpv4Interface::ArpIpv4Interface ()");
}
ArpIpv4Interface::~ArpIpv4Interface ()
{}
{
NS_DEBUG ("ArpIpv4Interface::~ArpIpv4Interface ()");
}
TraceResolver *
ArpIpv4Interface::DoCreateTraceResolver (TraceContext const &context)
{
NS_DEBUG ("ArpIpv4Interface::DoCreateTraceResolver ()");
CompositeTraceResolver *resolver = new CompositeTraceResolver (context);
if (GetDevice () != 0)
{
@@ -56,31 +64,41 @@ 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<ArpL3Protocol> arp = m_node->QueryInterface<ArpL3Protocol> (ArpL3Protocol::iid);
NS_DEBUG ("ArpIpv4Interface::SendTo (): Needs ARP");
Ptr<ArpL3Protocol> arp =
m_node->QueryInterface<ArpL3Protocol> (ArpL3Protocol::iid);
Address hardwareDestination;
bool found;
if (dest.IsBroadcast ())
{
NS_DEBUG ("ArpIpv4Interface::SendTo (): IsBroadcast");
hardwareDestination = GetDevice ()->GetBroadcast ();
found = true;
}
else
{
NS_DEBUG ("ArpIpv4Interface::SendTo (): ARP Lookup");
found = arp->Lookup (p, dest, GetDevice (), &hardwareDestination);
}
if (found)
{
GetDevice ()->Send (p, hardwareDestination, Ipv4L3Protocol::PROT_NUMBER);
NS_DEBUG ("ArpIpv4Interface::SendTo (): Address Resolved. Send.");
GetDevice ()->Send (p, hardwareDestination,
Ipv4L3Protocol::PROT_NUMBER);
}
}
else
{
GetDevice ()->Send (p, GetDevice ()->GetBroadcast (), Ipv4L3Protocol::PROT_NUMBER);
NS_DEBUG ("ArpIpv4Interface::SendTo (): Doesn't need ARP");
GetDevice ()->Send (p, GetDevice ()->GetBroadcast (),
Ipv4L3Protocol::PROT_NUMBER);
}
}
+33 -7
View File
@@ -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<NetDevice> nd)
: m_netdevice (nd),
m_ifup(false)
{}
{
NS_DEBUG ("Ipv4Interface::Ipv4Interface (" << &nd << ")");
}
Ipv4Interface::~Ipv4Interface ()
{}
{
NS_DEBUG ("Ipv4Interface::~Ipv4Interface ()");
}
Ptr<NetDevice>
Ipv4Interface::GetDevice (void) const
{
NS_DEBUG ("Ipv4Interface::GetDevice ()");
return m_netdevice;
}
TraceResolver *
Ipv4Interface::CreateTraceResolver (TraceContext const &context)
{
NS_DEBUG ("Ipv4Interface::CreateTraceResolver (" << &context << ")");
return DoCreateTraceResolver (context);
}
void
Ipv4Interface::SetAddress (Ipv4Address a)
{
NS_DEBUG ("Ipv4Interface::SetAddress (" << a << ")");
m_address = a;
}
void
Ipv4Interface::SetNetworkMask (Ipv4Mask mask)
{
NS_DEBUG ("Ipv4Interface::SetMask (" << mask << ")");
m_netmask = mask;
}
Ipv4Address
Ipv4Interface::GetBroadcast (void) const
{
NS_DEBUG ("Ipv4Interface::GetBroadcast ()");
uint32_t mask = m_netmask.GetHostOrder ();
uint32_t address = m_address.GetHostOrder ();
Ipv4Address broadcast = Ipv4Address (address | (~mask));
return broadcast;
}
Ipv4Mask
Ipv4Interface::GetNetworkMask (void) const
{
NS_DEBUG ("Ipv4Interface::GetNetworkMask ()");
return m_netmask;
}
Ipv4Address
Ipv4Interface::GetAddress (void) const
{
NS_DEBUG ("Ipv4Interface::Address ()");
return m_address;
}
uint16_t
Ipv4Interface::GetMtu (void) const
{
NS_DEBUG ("Ipv4Interface::GetMtu ()");
if (m_netdevice == 0)
{
uint32_t mtu = (1<<16) - 1;
@@ -92,32 +111,36 @@ 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);
}
}
+25 -10
View File
@@ -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<NetDevice> device)
{
@@ -524,7 +531,8 @@ Ipv4L3Protocol::Forwarding (Packet const &packet, Ipv4Header &ipHeader, Ptr<NetD
{
if ((*i)->GetAddress ().IsEqual (ipHeader.GetDestination ()))
{
NS_DEBUG ("for me 1");
NS_DEBUG("Ipv4L3Protocol::Forwarding (): "
"For me (destination match)");
return false;
}
}
@@ -537,7 +545,8 @@ Ipv4L3Protocol::Forwarding (Packet const &packet, Ipv4Header &ipHeader, Ptr<NetD
{
if (ipHeader.GetDestination ().IsEqual (interface->GetBroadcast ()))
{
NS_DEBUG ("for me 2");
NS_DEBUG("Ipv4L3Protocol::Forwarding (): "
"For me (interface broadcast address)");
return false;
}
break;
@@ -546,25 +555,30 @@ Ipv4L3Protocol::Forwarding (Packet const &packet, Ipv4Header &ipHeader, Ptr<NetD
if (ipHeader.GetDestination ().IsBroadcast ())
{
NS_DEBUG ("for me 3");
NS_DEBUG("Ipv4L3Protocol::Forwarding (): "
"For me (Ipv4Addr broadcast address)");
return false;
}
if (ipHeader.GetDestination ().IsEqual (Ipv4Address::GetAny ()))
{
NS_DEBUG ("for me 4");
NS_DEBUG("Ipv4L3Protocol::Forwarding (): "
"For me (Ipv4Addr any address)");
return false;
}
if (ipHeader.GetTtl () == 1)
{
// Should send ttl expired here
// XXX
NS_DEBUG ("not for me -- ttl expired. drop.");
NS_DEBUG("Ipv4L3Protocol::Forwarding (): "
"Not for me (TTL expired). Drop");
m_dropTrace (packet);
return true;
}
ipHeader.SetTtl (ipHeader.GetTtl () - 1);
NS_DEBUG ("forwarding.");
NS_DEBUG("Ipv4L3Protocol::Forwarding (): Forwarding packet.");
Lookup (ipHeader, packet,
MakeCallback (&Ipv4L3Protocol::SendRealOut, this));
//
@@ -578,12 +592,13 @@ Ipv4L3Protocol::Forwarding (Packet const &packet, Ipv4Header &ipHeader, Ptr<NetD
if ((*i).first.IsEqual (ipHeader.GetSource ()) &&
(*i).second.IsEqual (ipHeader.GetDestination ()))
{
NS_DEBUG ("for me 5");
NS_DEBUG("Ipv4L3Protocol::Forwarding (): "
"For me (Joined multicast group)");
return false;
}
}
NS_DEBUG ("not for me.");
NS_DEBUG("Ipv4L3Protocol::Forwarding (): Not for me.");
return true;
}
+20 -4
View File
@@ -19,6 +19,8 @@
* Authors:
* Mathieu Lacage <mathieu.lacage@sophia.inria.fr>,
*/
#include "ns3/debug.h"
#include "ns3/empty-trace-resolver.h"
#include "ns3/net-device.h"
#include "ns3/node.h"
@@ -26,26 +28,40 @@
#include "ipv4-loopback-interface.h"
#include "ipv4-l3-protocol.h"
NS_DEBUG_COMPONENT_DEFINE ("Ipv4LoopbackInterface");
namespace ns3 {
Ipv4LoopbackInterface::Ipv4LoopbackInterface (Ptr<Node> node)
: Ipv4Interface (0),
m_node (node)
{}
{
NS_DEBUG("Ipv4LoopbackInterface::Ipv4LoopbackInterface ()");
}
Ipv4LoopbackInterface::~Ipv4LoopbackInterface ()
{}
{
NS_DEBUG("Ipv4LoopbackInterface::~Ipv4LoopbackInterface ()");
}
TraceResolver *
Ipv4LoopbackInterface::DoCreateTraceResolver (TraceContext const &context)
{
NS_DEBUG("Ipv4LoopbackInterface::DoCreateTraceResolver ()");
return new EmptyTraceResolver (context);
}
void
Ipv4LoopbackInterface::SendTo (Packet packet, Ipv4Address dest)
{
Ptr<Ipv4L3Protocol> ipv4 = m_node->QueryInterface<Ipv4L3Protocol> (Ipv4L3Protocol::iid);
ipv4->Receive (GetDevice (), packet, Ipv4L3Protocol::PROT_NUMBER, Eui48Address ("ff:ff:ff:ff:ff:ff"));
NS_DEBUG("Ipv4LoopbackInterface::SendTo (" << &packet << ", " <<
dest << ")");
Ptr<Ipv4L3Protocol> ipv4 =
m_node->QueryInterface<Ipv4L3Protocol> (Ipv4L3Protocol::iid);
ipv4->Receive (GetDevice (), packet, Ipv4L3Protocol::PROT_NUMBER,
Eui48Address ("ff:ff:ff:ff:ff:ff"));
}
}//namespace ns3
+4 -2
View File
@@ -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)
{