Bugzilla – Bug 2872
Packet copy in CsmaChannel breaks netanim tracing
Last modified: 2018-03-10 12:17:54 UTC
Since version 3.27 CsmaChannel::TransmitStart() receives a Ptr to a constant Packet. As a result Packet must be copied. However, tracing in CsmaNetdevice ( m_phyTxBeginTrace() ) will append its tag to the original packet so that the copy in the channel does not contain the tag. Subsequently, the Rx-Trace cannot find a tag on the packet and will not trace the packet.
If we move the TxBegin trace to before the TransmitStart() call, then it should fix this. However, the behavior would change slightly; drops would see the TxBegin() trace followed immediately by a TxDrop() trace (rather than just a TxDrop() alone). // // The channel is free, transmit the packet // if (m_channel->TransmitStart (m_currentPkt, m_deviceId) == false) { NS_LOG_WARN ("Channel TransmitStart returns an error"); m_phyTxDropTrace (m_currentPkt); m_currentPkt = 0; m_txMachineState = READY; } else { // // Transmission succeeded, reset the backoff time parameters and // schedule a transmit complete event. // m_backoff.ResetBackoffTime (); m_txMachineState = BUSY; m_phyTxBeginTrace (m_currentPkt); Time tEvent = m_bps.CalculateBytesTxTime (m_currentPkt->GetSize ()); NS_LOG_LOGIC ("Schedule TransmitCompleteEvent in " << tEvent.GetSeconds () << "sec"); Simulator::Schedule (tEvent, &CsmaNetDevice::TransmitCompleteEvent, this); }
What I proposed above would make it consistent with how PointToPointNetDevice handles it: m_phyTxBeginTrace (m_currentPkt); Time txTime = m_bps.CalculateBytesTxTime (p->GetSize ()); Time txCompleteTime = txTime + m_tInterframeGap; NS_LOG_LOGIC ("Schedule TransmitCompleteEvent in " << txCompleteTime.GetSeconds () << "sec"); Simulator::Schedule (txCompleteTime, &PointToPointNetDevice::TransmitComplete, this); bool result = m_channel->TransmitStart (p, this, txTime); if (result == false) { m_phyTxDropTrace (p); }
Created attachment 3086 [details] patch to fix
I pushed a change in changeset 13408:07055158a65d; please let me know if it does not resolve the issue for you. I tested it on NetAnim and it seemed to resolve it.