NetDevices: packet can be dropped without being traced
This problem affects practically all the NetDevices. The following code is from PointToPoint, and it is explicative:
m_macRxTrace (originalPacket);
m_rxCallback (this, packet, protocol, GetRemote ());m_rxCallback returns a value, but it is silently ignored.
The problem is: the callback can return something different than true? The answer is in Node:
bool
Node::ReceiveFromDevice (Ptr<NetDevice> device, Ptr<const Packet> packet, uint16_t protocol,
const Address &from, const Address &to, NetDevice::PacketType packetType, bool promiscuous)
{
NS_LOG_FUNCTION (this << device << packet << protocol << &from << &to << packetType << promiscuous);
NS_ASSERT_MSG (Simulator::GetContext () == GetId (), "Received packet with erroneous context ; " <<
"make sure the channels in use are correctly updating events context " <<
"when transferring events from one node to another.");
NS_LOG_DEBUG ("Node " << GetId () << " ReceiveFromDevice: dev "
<< device->GetIfIndex () << " (type=" << device->GetInstanceTypeId ().GetName ()
<< ") Packet UID " << packet->GetUid ());
bool found = false;
for (ProtocolHandlerList::iterator i = m_handlers.begin ();
i != m_handlers.end (); i++)
{
if (i->device == 0 ||
(i->device != 0 && i->device == device))
{
if (i->protocol == 0 ||
i->protocol == protocol)
{
if (promiscuous == i->promiscuous)
{
i->handler (device, packet, protocol, from, to, packetType);
found = true;
}
}
}
}
return found;
}Shortly put, it will return false if there is no protocol available to handle that particular packet. I.e., if I transmit a packet for (let's say) IPX, and our nodes don't have the IPX stack, the packet will be discarded without being logged.
In order to fix this (very minor) problem we could:
- Add a specific trace in
Node::ReceiveFromDevice(but then why theNetDeviceReceiveCallbackhas a return value?) or - Modify the NetDevices to fire an appropriate trace.