From bcae4f9ea16b159b2564cdbf7f9640a6489f03a0 Mon Sep 17 00:00:00 2001 From: "Gustavo J. A. M. Carneiro" Date: Mon, 7 Jul 2008 10:37:09 +0100 Subject: [PATCH] Move the csma packet-from-self receive filtering away from the CsmaChannel into the CsmaNetDevice, with the help of an extra Ptr parameter in Receive(). As discussed in the mailing list. --- src/devices/csma/csma-channel.cc | 4 ++-- src/devices/csma/csma-net-device.cc | 15 +++++++++++++-- src/devices/csma/csma-net-device.h | 3 ++- 3 files changed, 17 insertions(+), 5 deletions(-) diff --git a/src/devices/csma/csma-channel.cc b/src/devices/csma/csma-channel.cc index 30100b3c8..3ba7564e5 100644 --- a/src/devices/csma/csma-channel.cc +++ b/src/devices/csma/csma-channel.cc @@ -235,9 +235,9 @@ CsmaChannel::PropagationCompleteEvent() 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++; } diff --git a/src/devices/csma/csma-net-device.cc b/src/devices/csma/csma-net-device.cc index 5cf20ac52..77cf52312 100644 --- a/src/devices/csma/csma-net-device.cc +++ b/src/devices/csma/csma-net-device.cc @@ -452,12 +452,23 @@ CsmaNetDevice::SetReceiveErrorModel (Ptr em) m_receiveErrorModel = em; } - void -CsmaNetDevice::Receive (Ptr packet) +void +CsmaNetDevice::Receive (Ptr packet, Ptr 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 // diff --git a/src/devices/csma/csma-net-device.h b/src/devices/csma/csma-net-device.h index bc7a205b3..bcfc70616 100644 --- a/src/devices/csma/csma-net-device.h +++ b/src/devices/csma/csma-net-device.h @@ -158,8 +158,9 @@ public: * * @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 p); + void Receive (Ptr p, Ptr sender); /** * Is the send side of the network device enabled?