Move the csma packet-from-self receive filtering away from the CsmaChannel into the CsmaNetDevice, with the help of an extra Ptr<CsmaNetDevice> parameter in Receive(). As discussed in the mailing list.
--- a/src/devices/csma/csma-channel.cc Mon Jul 07 10:26:00 2008 +0100
+++ b/src/devices/csma/csma-channel.cc Mon Jul 07 10:37:09 2008 +0100
@@ -235,9 +235,9 @@
uint32_t devId = 0;
for (it = m_deviceList.begin (); it < m_deviceList.end(); it++)
{
- if (it->IsActive () && m_currentSrc != devId)
+ if (it->IsActive ())
{
- it->devicePtr->Receive (m_currentPkt->Copy ());
+ it->devicePtr->Receive (m_currentPkt->Copy (), m_deviceList[m_currentSrc].devicePtr);
}
devId++;
}
--- a/src/devices/csma/csma-net-device.cc Mon Jul 07 10:26:00 2008 +0100
+++ b/src/devices/csma/csma-net-device.cc Mon Jul 07 10:37:09 2008 +0100
@@ -452,12 +452,23 @@
m_receiveErrorModel = em;
}
- void
-CsmaNetDevice::Receive (Ptr<Packet> packet)
+void
+CsmaNetDevice::Receive (Ptr<Packet> packet, Ptr<CsmaNetDevice> senderDevice)
{
NS_LOG_FUNCTION_NOARGS ();
NS_LOG_LOGIC ("UID is " << packet->GetUid ());
+
+ //
+ // We never forward up packets that we sent. Real devices don't do this since
+ // their receivers are disabled during send, so we don't. Drop the packet
+ // silently (no tracing) since it would really never get here in a real device.
+ //
+ if (senderDevice == this)
+ {
+ return;
+ }
+
//
// Only receive if the send side of net device is enabled
//
--- a/src/devices/csma/csma-net-device.h Mon Jul 07 10:26:00 2008 +0100
+++ b/src/devices/csma/csma-net-device.h Mon Jul 07 10:37:09 2008 +0100
@@ -158,8 +158,9 @@
*
* @see CsmaChannel
* \param p a reference to the received packet
+ * \param sender the CsmaNetDevice that transmitted the packet in the first place
*/
- void Receive (Ptr<Packet> p);
+ void Receive (Ptr<Packet> p, Ptr<CsmaNetDevice> sender);
/**
* Is the send side of the network device enabled?