Bug 2872 - Packet copy in CsmaChannel breaks netanim tracing
Packet copy in CsmaChannel breaks netanim tracing
Status: RESOLVED FIXED
Product: ns-3
Classification: Unclassified
Component: csma
ns-3.27
All All
: P3 minor
Assigned To: ns-bugs
:
Depends on:
Blocks:
  Show dependency treegraph
 
Reported: 2018-02-16 07:48 UTC by klb
Modified: 2018-03-10 12:17 UTC (History)
1 user (show)

See Also:


Attachments
patch to fix (2.11 KB, patch)
2018-03-09 13:27 UTC, Tom Henderson
Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description klb 2018-02-16 07:48:47 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.
Comment 1 Tom Henderson 2018-03-05 23:50:24 UTC
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);
        }
Comment 2 Tom Henderson 2018-03-05 23:52:46 UTC
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);
    }
Comment 3 Tom Henderson 2018-03-09 13:27:37 UTC
Created attachment 3086 [details]
patch to fix
Comment 4 Tom Henderson 2018-03-10 12:17:54 UTC
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.