diff --git a/src/internet-node/arp-l3-protocol.cc b/src/internet-node/arp-l3-protocol.cc index e00b85669..784984d48 100644 --- a/src/internet-node/arp-l3-protocol.cc +++ b/src/internet-node/arp-l3-protocol.cc @@ -22,6 +22,7 @@ #include "ns3/node.h" #include "ns3/net-device.h" #include "ns3/object-vector.h" +#include "ns3/trace-source-accessor.h" #include "ipv4-l3-protocol.h" #include "arp-l3-protocol.h" @@ -47,6 +48,9 @@ ArpL3Protocol::GetTypeId (void) ObjectVectorValue (), MakeObjectVectorAccessor (&ArpL3Protocol::m_cacheList), MakeObjectVectorChecker ()) + .AddTraceSource ("Drop", + "Packet dropped because not enough room in pending queue for a specific cache entry.", + MakeTraceSourceAccessor (&ArpL3Protocol::m_dropTrace)) ; return tid; } @@ -169,13 +173,13 @@ ArpL3Protocol::Receive(Ptr device, Ptr packet, uint16_t proto NS_LOG_LOGIC("node="<GetId ()<<", got reply from " << arp.GetSourceIpv4Address () << " for non-waiting entry -- drop"); - // XXX report packet as dropped. + m_dropTrace (packet); } } else { NS_LOG_LOGIC ("node="<GetId ()<<", got reply for unknown entry -- drop"); - // XXX report packet as dropped. + m_dropTrace (packet); } } else @@ -216,7 +220,16 @@ ArpL3Protocol::Lookup (Ptr packet, Ipv4Address destination, NS_LOG_LOGIC ("node="<GetId ()<< ", wait reply for " << destination << " expired -- drop"); entry->MarkDead (); - // XXX report packet as 'dropped' + while (true) + { + Ptr pending = entry->DequeuePending(); + if (pending != 0) + { + break; + } + m_dropTrace (pending); + } + m_dropTrace (packet); } } else @@ -225,7 +238,7 @@ ArpL3Protocol::Lookup (Ptr packet, Ipv4Address destination, { NS_LOG_LOGIC ("node="<GetId ()<< ", dead entry for " << destination << " valid -- drop"); - // XXX report packet as 'dropped' + m_dropTrace (packet); } else if (entry->IsAlive ()) { @@ -238,8 +251,10 @@ ArpL3Protocol::Lookup (Ptr packet, Ipv4Address destination, { NS_LOG_LOGIC ("node="<GetId ()<< ", wait reply for " << destination << " valid -- drop previous"); - // XXX potentially report current packet as 'dropped' - entry->UpdateWaitReply (packet); + if (!entry->UpdateWaitReply (packet)) + { + m_dropTrace (packet); + } } } } diff --git a/src/internet-node/arp-l3-protocol.h b/src/internet-node/arp-l3-protocol.h index efd61966b..b2365ff56 100644 --- a/src/internet-node/arp-l3-protocol.h +++ b/src/internet-node/arp-l3-protocol.h @@ -24,6 +24,7 @@ #include "ns3/ipv4-address.h" #include "ns3/address.h" #include "ns3/ptr.h" +#include "ns3/traced-callback.h" namespace ns3 { @@ -73,6 +74,7 @@ private: void SendArpReply (Ptr cache, Ipv4Address toIp, Address toMac); CacheList m_cacheList; Ptr m_node; + TracedCallback > m_dropTrace; }; }//namespace ns3