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.

This commit is contained in:
Gustavo J. A. M. Carneiro
2008-07-07 10:37:09 +01:00
parent 95be482f24
commit bcae4f9ea1
3 changed files with 17 additions and 5 deletions

View File

@@ -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++;
}

View File

@@ -452,12 +452,23 @@ CsmaNetDevice::SetReceiveErrorModel (Ptr<ErrorModel> em)
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
//

View File

@@ -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<Packet> p);
void Receive (Ptr<Packet> p, Ptr<CsmaNetDevice> sender);
/**
* Is the send side of the network device enabled?