Branch: master
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Type Name Latest commit message Commit time
Failed to load latest commit information.
queue Init DWRR and its test scripts Feb 15, 2016
mqecn.patch Init patch & Remove old files Feb 14, 2016

MQ-ECN NS2 Simulation

Software requirements

To reproduce simulation results (Figure 9-13) of MQ-ECN paper, you need following softwares:


Download Network Simulator (NS) 2.35 and unzip it.

$ tar -zxvf ns-allinone-2.35.tar.gz

Copy mqecn.patch to the top ns-2.35 folder (ns-allinone-2.35) and apply the patch. Then install NS2.

$ cd ns-allinone-2.35
$ patch -p1 --ignore-whitespace -i mqecn.patch
$ ./install

Copy files of MQ-ECN code to ns-allinone-2.35/ns-2.35/queue/

Add queue/wrr.o queue/dwrr.o to ns-allinone-2.35/ns-2.35/Makefile

Run make on /ns-allinone-2.35/ns-2.35

Running Basic Simulations

Before running large-scale simulations, you can run several small-scale simulations to understand the basic properties of MQ-ECN. The scripts for basic simulations are test-wrr.tcl, test-wrr-2.tcl, test-dwrr.tcl and test-dwrr-2.tcl. The basic simulation scripts will generate three files:, and

  • The gives aggregate goodputs of different services. It has the following format:

    Time, Goodput of Service 1, ..., Goodput of Service N
  • The gives queue lengths (in bytes) of different service queues. It has the following format:

    Time, Queue Length of Service Queue 1, ..., Queue Length of Service N
  • The gives the total queue length (in bytes) of the congested switch port. It has the following format:

    Time, Queue Length of Switch Port

Running Large-Scale Simulations

At the beginning, we briefly introduce the usage of each file in scripts directory.

Hence, to run simulations in parallel:


There are many parameters to configue in Note that you need to modify ns_path and sim_script correspondingly. By default, it runs 20x simulations in parallel and iterates over the per-queue ECN with the standard threshold, per-queue ECN with the minimum threshold and MQ-ECN. For each simulation, it will create a directory with the following name:

diffserv_[scheduler]_[transport]_scheme_[ECN scheme]_load_[network load]_service_[number of queues]

Each direcotry consists of two files: and The gives flow completion time results with the following format:

number of packets, flow completion time, number of timeouts, src ID, dst ID, service (queue) ID

You can use to parse files as follows:

$ python -a -i [directory_path]/


If you have any question about MQ-ECN simulation code, please contact Wei Bai.


We thank Mohammad Alizadeh for sharing pFabric simulation code and DCTCP patch.