Add number of CSMA retries to sent packet trace
authorMargherita Filippetti <morag87@gmail.com>
Fri, 25 Apr 2014 23:46:03 +0200
changeset 10756 aef2a6d01b5a
parent 10755 0307ac773941
child 10757 7c77175fd841
Add number of CSMA retries to sent packet trace
src/lr-wpan/model/lr-wpan-csmaca.cc
src/lr-wpan/model/lr-wpan-csmaca.h
src/lr-wpan/model/lr-wpan-mac.cc
src/lr-wpan/model/lr-wpan-mac.h
--- a/src/lr-wpan/model/lr-wpan-csmaca.cc	Sat Apr 26 22:21:13 2014 -0700
+++ b/src/lr-wpan/model/lr-wpan-csmaca.cc	Fri Apr 25 23:46:03 2014 +0200
@@ -378,4 +378,10 @@
   return 1;
 }
 
+uint8_t
+LrWpanCsmaCa::GetNB (void)
+{
+  return m_NB;
+}
+
 } //namespace ns3
--- a/src/lr-wpan/model/lr-wpan-csmaca.h	Sat Apr 26 22:21:13 2014 -0700
+++ b/src/lr-wpan/model/lr-wpan-csmaca.h	Fri Apr 25 23:46:03 2014 +0200
@@ -231,6 +231,13 @@
    */
   int64_t AssignStreams (int64_t stream);
 
+  /**
+   * Get the number of CSMA retries
+   *
+   * \returns the number of CSMA retries
+   */
+  uint8_t GetNB (void);
+
 private:
   virtual void DoDispose (void);
 
--- a/src/lr-wpan/model/lr-wpan-mac.cc	Sat Apr 26 22:21:13 2014 -0700
+++ b/src/lr-wpan/model/lr-wpan-mac.cc	Fri Apr 25 23:46:03 2014 +0200
@@ -106,6 +106,7 @@
   m_macPromiscuousMode = false;
   m_macMaxFrameRetries = 3;
   m_retransmission = 0;
+  m_numCsmacaRetry = 0;
   m_txPkt = 0;
 
   Ptr<UniformRandomVariable> uniformVar = CreateObject<UniformRandomVariable> ();
@@ -675,13 +676,14 @@
 {
   TxQueueElement *txQElement = m_txQueue.front ();
   Ptr<const Packet> p = txQElement->txQPkt;
+  m_numCsmacaRetry += m_csmaCa->GetNB () + 1;
 
   Ptr<Packet> pkt = p->Copy ();
   LrWpanMacHeader hdr;
   pkt->RemoveHeader (hdr);
   if (hdr.GetShortDstAddr () != Mac16Address ("ff:ff"))
     {
-      m_sentPktTrace (p, m_retransmission+1, 0);
+      m_sentPktTrace (p, m_retransmission+1, m_numCsmacaRetry);
     }
 
   txQElement->txQPkt = 0;
@@ -689,6 +691,7 @@
   m_txQueue.pop_front ();
   m_txPkt = 0;
   m_retransmission = 0;
+  m_numCsmacaRetry = 0;
   m_macTxQueueTrace (p, false);
 }
 
@@ -734,6 +737,7 @@
   else
     {
       m_retransmission++;
+      m_numCsmacaRetry += m_csmaCa->GetNB () +1;
       // Start next CCA process for this packet.
       return true;
     }
--- a/src/lr-wpan/model/lr-wpan-mac.h	Sat Apr 26 22:21:13 2014 -0700
+++ b/src/lr-wpan/model/lr-wpan-mac.h	Fri Apr 25 23:46:03 2014 +0200
@@ -318,7 +318,7 @@
    * Only non-broadcast packets are traced.
    *
    * The data should represent:
-   * packet, number of retries, total number of csma backoffs (not currently implemented)
+   * packet, number of retries, total number of csma backoffs
    *
    * \see class CallBackTraceSource
    */
@@ -424,6 +424,7 @@
   Mac64Address m_selfExt;
   std::deque<TxQueueElement*> m_txQueue;
   uint8_t m_retransmission;
+  uint8_t m_numCsmacaRetry;
   EventId m_ackWaitTimeout;
   EventId m_setMacState;
   bool m_macRxOnWhenIdle;