Skip to content

Changes made in PIE code

Shashank edited this page Nov 12, 2018 · 4 revisions

We have modified pie-queue-disc.cc and pie-queue-disc.h files to support ECN.

Changes made in pie-queue-disc.cc

  • Added 1 additional attribute for ECN

    1. UseEcn - It's a Boolean flag. Default value = false. It's True when ECN is enabled otherwise false.
  • Changed DoEnqueue function
    In DoEnqueue function, instead of directly dropping first we have declared packet type - DTYPE_NONE, DTYPE_FORCED, DTYPE_UNFORCED. First check if ECN is enabled and drop probability exceeds threshold mark_ecnth then drop the packet. When DropType = DTYPE_UNFORCED then check whether ECN is enabled, if enabled then mark the packet. If mark is unsuccessful then drop the packet. If DropType = DTYPE_FORCED then drop the packet.

Additional Attributes

In the beginning of the code where all attributes are added. At the end of them add the following attribute -

    .AddAttribute ("UseEcn",
                   "True to use ECN (packets are marked instead of being dropped)",
                   BooleanValue(false),
                   MakeBooleanAccessor (&PieQueueDisc::m_useEcn),
                   MakeBooleanChecker())

Modified DoEnqueue Function

bool
PieQueueDisc::DoEnqueue (Ptr<QueueDiscItem> item)
{
    NS_LOG_FUNCTION (this << item);

    QueueSize nQueued = GetCurrentSize ();
    uint32_t dropType = DTYPE_NONE;
    if (nQueued + item > GetMaxSize ()){
      // Drops due to queue limit: reactive
      dropType = DTYPE_FORCED;
    }
    else if (DropEarly (item, nQueued.GetValue ()))
    {
      // Early probability drop: proactive
      dropType = DTYPE_UNFORCED;
    }
    
    if(m_useEcn && m_dropProb > m_mark_ecnth)
    {
        NS_LOG_DEBUG("\t Dropping packet due to mark_ecnth ");
        DropBeforeEnqueue(item, UNFORCED_DROP);
        return false;
    }
    
    else if(dropType==DTYPE_UNFORCED)
    {
        if(!m_useEcn || !Mark(item, UNFORCED_MARK))
        {
            NS_LOG_DEBUG("\t Dropping packet due to Prob Mark ");
            DropBeforeEnqueue(item, UNFORCED_DROP);
            return false;
        }
        NS_LOG_DEBUG("\t Marking due to Prob Mark ");
    }
    else if(dropType==DTYPE_FORCED)
    {
        NS_LOG_DEBUG("\t Dropping due to queue limit ");
        DropBeforeEnqueue(item, FORCED_DROP);
        return false;
    }


  // No drop
  bool retval = GetInternalQueue (0)->Enqueue (item);

  // If Queue::Enqueue fails, QueueDisc::DropBeforeEnqueue is called by the
  // internal queue because QueueDisc::AddInternalQueue sets the trace callback

  NS_LOG_LOGIC ("\t bytesInQueue  " << GetInternalQueue (0)->GetNBytes ());
  NS_LOG_LOGIC ("\t packetsInQueue  " << GetInternalQueue (0)->GetNPackets ());

  return retval;
}

Changes made in pie-queue-disc.h

  • Added drop types
  • Declared FORCED_MARK and UNFORCED_MARK.
  • Added variables m_useEcn and m_mark_ecnth.

Drop Types

Add the following code after burst types. It declares an enum datatype to specify drop types.

 /** drop types
  *
  */
  enum 
  {
    DTYPE_NONE, // no drop
    DTYPE_FORCED, //forced drop
    DTYPE_UNFORCED, // unforced(random) drop
    
};

Declaration of FORCED_MARK and UNFORCED_MARK

Add the following code after the declaration of FORCED_DROP.

  // reasons for marking packets
  static constexpr const char* UNFORCED_MARK = "Unforced mark";  //!< Early probability mark
  static constexpr const char* FORCED_MARK = "Forced mark";      //!< forced mark

Declaration of m_useEcn

Add the following code at the end where all the variables are declared.

bool m_useEcn;        // true if ecn is used
double m_mark_ecnth;  // additional thresold to revert packet-marking to packet-dropping