diff --git a/src/node/arp-cache.cc b/src/node/arp-cache.cc index f60561500..d1d477b5c 100644 --- a/src/node/arp-cache.cc +++ b/src/node/arp-cache.cc @@ -26,17 +26,6 @@ #include "arp-cache.h" #include "arp-header.h" -#ifdef TRACE_ARP -#include -#include "simulator.h" -# define TRACE(x) \ -std::cout << "ARP TRACE " << Simulator::Now () << " " \ - << x << std::endl; -#else /* TRACE_ARP */ -# define TRACE(format,...) -#endif /* TRACE_ARP */ - - namespace ns3 { ArpCache::ArpCache (NetDevice *device, Ipv4Interface *interface) diff --git a/src/node/arp.cc b/src/node/arp.cc index 911083c72..4a8a3cb56 100644 --- a/src/node/arp.cc +++ b/src/node/arp.cc @@ -19,6 +19,7 @@ * Author: Mathieu Lacage */ #include "ns3/packet.h" +#include "ns3/debug.h" #include "arp.h" #include "arp-header.h" #include "arp-cache.h" @@ -27,7 +28,7 @@ #include "node.h" #include "ipv4.h" -#define TRACE(x) +NS_DEBUG_COMPONENT_DEFINE ("Arp"); namespace ns3 { @@ -77,7 +78,7 @@ Arp::Receive(Packet& packet, NetDevice *device) if (arp.IsRequest () && arp.GetDestinationIpv4Address () == cache->GetInterface ()->GetAddress ()) { - TRACE ("got request from " << arp.GetSourceIpv4Address () << " -- send reply"); + NS_DEBUG ("got request from " << arp.GetSourceIpv4Address () << " -- send reply"); SendArpReply (cache, arp.GetSourceIpv4Address (), arp.GetSourceHardwareAddress ()); } @@ -91,7 +92,7 @@ Arp::Receive(Packet& packet, NetDevice *device) { if (entry->IsWaitReply ()) { - TRACE ("got reply from " << arp.GetSourceIpv4Address () + NS_DEBUG ("got reply from " << arp.GetSourceIpv4Address () << " for waiting entry -- flush"); MacAddress from_mac = arp.GetSourceHardwareAddress (); Packet waiting = entry->MarkAlive (from_mac); @@ -101,14 +102,14 @@ Arp::Receive(Packet& packet, NetDevice *device) { // ignore this reply which might well be an attempt // at poisening my arp cache. - TRACE ("got reply from " << arp.GetSourceIpv4Address () << + NS_DEBUG ("got reply from " << arp.GetSourceIpv4Address () << " for non-waiting entry -- drop"); // XXX report packet as dropped. } } else { - TRACE ("got reply for unknown entry -- drop"); + NS_DEBUG ("got reply for unknown entry -- drop"); // XXX report packet as dropped. } } @@ -126,19 +127,19 @@ Arp::Lookup (Packet &packet, Ipv4Address destination, { if (entry->IsDead ()) { - TRACE ("dead entry for " << destination << " expired -- send arp request"); + NS_DEBUG ("dead entry for " << destination << " expired -- send arp request"); entry->MarkWaitReply (packet); SendArpRequest (cache, destination); } else if (entry->IsAlive ()) { - TRACE ("alive entry for " << destination << " expired -- send arp request"); + NS_DEBUG ("alive entry for " << destination << " expired -- send arp request"); entry->MarkWaitReply (packet); SendArpRequest (cache, destination); } else if (entry->IsWaitReply ()) { - TRACE ("wait reply for " << destination << " expired -- drop"); + NS_DEBUG ("wait reply for " << destination << " expired -- drop"); entry->MarkDead (); // XXX report packet as 'dropped' } @@ -147,18 +148,18 @@ Arp::Lookup (Packet &packet, Ipv4Address destination, { if (entry->IsDead ()) { - TRACE ("dead entry for " << destination << " valid -- drop"); + NS_DEBUG ("dead entry for " << destination << " valid -- drop"); // XXX report packet as 'dropped' } else if (entry->IsAlive ()) { - TRACE ("alive entry for " << destination << " valid -- send"); + NS_DEBUG ("alive entry for " << destination << " valid -- send"); *hardwareDestination = entry->GetMacAddress (); return true; } else if (entry->IsWaitReply ()) { - TRACE ("wait reply for " << destination << " valid -- drop previous"); + NS_DEBUG ("wait reply for " << destination << " valid -- drop previous"); Packet old = entry->UpdateWaitReply (packet); // XXX report 'old' packet as 'dropped' } @@ -168,7 +169,7 @@ Arp::Lookup (Packet &packet, Ipv4Address destination, else { // This is our first attempt to transmit data to this destination. - TRACE ("no entry for " << destination << " -- send arp request"); + NS_DEBUG ("no entry for " << destination << " -- send arp request"); entry = cache->Add (destination); entry->MarkWaitReply (packet); SendArpRequest (cache, destination); diff --git a/src/node/ipv4-header.cc b/src/node/ipv4-header.cc index 63cf985ba..205e0e479 100644 --- a/src/node/ipv4-header.cc +++ b/src/node/ipv4-header.cc @@ -20,19 +20,11 @@ */ #include "ns3/assert.h" +#include "ns3/debug.h" #include "ns3/header.h" #include "ipv4-header.h" -#define TRACE_CHUNK_IPV4 1 - -#ifdef TRACE_CHUNK_IPV4 -#include -#include "ns3/simulator.h" -# define TRACE(x) \ -std::cout << "CHUNK IPV4 TRACE " << Simulator::Now () << " " << x << std::endl; -#else /* TRACE_CHUNK_IPV4 */ -# define TRACE(format,...) -#endif /* TRACE_CHUNK_IPV4 */ +NS_DEBUG_COMPONENT_DEFINE ("Ipv4Header"); namespace ns3 { @@ -225,7 +217,6 @@ Ipv4Header::SerializeTo (Buffer::Iterator start) const { Buffer::Iterator i = start; - //TRACE ("init ipv4 current="<GetCurrent ()); uint8_t verIhl = (4 << 4) | (5); i.WriteU8 (verIhl); i.WriteU8 (m_tos); @@ -255,10 +246,9 @@ Ipv4Header::SerializeTo (Buffer::Iterator start) const #if 0 // XXX we need to add Buffer::Iterator::PeekData method uint8_t *data = start.PeekData (); - //TRACE ("fini ipv4 current="<GetCurrent ()); uint16_t checksum = UtilsChecksumCalculate (0, data, GetSize ()); checksum = UtilsChecksumComplete (checksum); - //TRACE ("checksum=" <GetAddress ().IsEqual (ipHeader.GetDestination ())) { - TRACE ("for me 1"); + NS_DEBUG ("for me 1"); return false; } } @@ -399,7 +400,7 @@ Ipv4::Forwarding (Packet const &packet, Ipv4Header &ipHeader, NetDevice &device) { if (ipHeader.GetDestination ().IsEqual (interface->GetBroadcast ())) { - TRACE ("for me 2"); + NS_DEBUG ("for me 2"); return false; } break; @@ -408,29 +409,29 @@ Ipv4::Forwarding (Packet const &packet, Ipv4Header &ipHeader, NetDevice &device) if (ipHeader.GetDestination ().IsEqual (Ipv4Address::GetBroadcast ())) { - TRACE ("for me 3"); + NS_DEBUG ("for me 3"); return false; } if (ipHeader.GetDestination ().IsEqual (Ipv4Address::GetAny ())) { - TRACE ("for me 4"); + NS_DEBUG ("for me 4"); return false; } if (ipHeader.GetTtl () == 1) { // Should send ttl expired here // XXX - TRACE ("not for me -- ttl expired. drop."); + NS_DEBUG ("not for me -- ttl expired. drop."); return true; } ipHeader.SetTtl (ipHeader.GetTtl () - 1); Ipv4Route *route = Lookup (ipHeader.GetDestination ()); if (route == 0) { - TRACE ("not for me -- forwarding but no route to host. drop."); + NS_DEBUG ("not for me -- forwarding but no route to host. drop."); return true; } - TRACE ("not for me -- forwarding."); + NS_DEBUG ("not for me -- forwarding."); SendRealOut (packet, ipHeader, *route); return true; } diff --git a/src/node/llc-snap-header.cc b/src/node/llc-snap-header.cc index 77a43c72c..81998f594 100644 --- a/src/node/llc-snap-header.cc +++ b/src/node/llc-snap-header.cc @@ -23,18 +23,6 @@ #include "llc-snap-header.h" -#define noTRACE_LLC_SNAP_HEADER 1 - -#ifdef TRACE_LLC_SNAP_HEADER -#include -#include "ns3/simulator.h" -# define TRACE(x) \ -std::cout << "LLCSNAP HEAD TRACE " << Simulator::Now () << " " << x << std::endl; -#else /* TRACE_LLC_SNAP_HEADER */ -# define TRACE(format,...) -#endif /* TRACE_LLC_SNAP_HEADER */ - - namespace ns3 { LlcSnapHeader::LlcSnapHeader ()