The number of physical and virtual queues can be configured as:
$dsredq set numQueues_ 1
$dsredq setNumPrec 2
Variable numQueues_ in class dsREDQueue specifies the number of physical queues. It has a default value as 4 defined in ~ns/tcl/lib/ns-default.tcl and can be changed as shown in the example above. Variable setNumPrec sets the number of virtual queues within one physical queue.
RED parameters can be configured for each virtual queue as follows:
$dsredq configQ 0 1 10 20 0.10
The mean packet size (in bytes) is also needed for the average RED queue length calculation.
$dsredq meanPktSize 1500
The variant of MRED used to calculate queue sizes can be configured.
$dsredq setMREDMode RIO-C 0
The above command sets the MRED mode of physical queue 0 to RIO-C. If the second argument was not included, all queues would be set to RIO-C which is the default.
The various MRED modes supported in DiffServ module are:
The following command adds an entry to the PHB Table and maps code point 11 to physical queue 0 and virtual queue 1.
$dsredq addPHBEntry 11 0 1
In ns, packets are defaulted to a code point of zero. Therefore, user must add a PHB entry for the zero code point in order to handle best effort traffic.
In addition, commands are available to allow the user to choose the scheduling mode between physical queues. For example:
$dsredq setSchedularMode WRR
$dsredq addQueueWeights 1 5
The above pair of commands sets the scheduling mode to Weighted Round Robin and the weight for queue 1 to 5. Other scheduling modes supported are Weighted Interleaved Round Robin (WIRR), Round Robin (RR), and Priority (PRI). The default scheduling mode is Round Robin.
For Priority scheduling, priority is arranged in sequential order with queue 0 having the highest priority. Also, one can set the a limit on the maximum bandwidth a particular queue can get using as follows:
$dsredq setSchedularMode PRI
$dsredq addQueueRate 0 5000000
These commands specify the maximum bandwidth that queue 0 can consume is 5Mb.
The addPolicyEntry command is used to add an entry to the Policy Table. It takes different parameters depending on what policer type is used. The first two parameters after the command name are always the source and destination node IDs, and the next parameter is the policer type. Following the policer type are the parameters needed by that policer as summarized below:
Null Initial code point TSW2CM Initial code point CIR TSW3CM Initial code point CIR PIR TokenBucket Initial code point CIR CBS srTCM Initial code point CIR CBS EBS trTCM Initial code point CIR CBS PIR PBS
Note that the Null policer requires only the initial code point. Since this policer does not downgrade packets, other information is not necessary. Consider a Tcl script for which $q is a variable for an edge queue, and $s and $d are source and destination nodes. The following command adds a TSW2CM policer for traffic going from the source to the destination:
$q addPolicyEntry [$s id] [$d id] TSW2CM 10 2000000
Other parameters could be used for different policers in place of "TSW2CM":
Null 10 TSW3CM 10 2000000 3000000 TokenBucket 10 2000000 10000 srTCM 10 2000000 10000 20000 trTCM 10 2000000 10000 3000000 10000
Note, however, that only one policy can be applied to any source destination pair.
The following command adds an entry to the Policer Table, specifying that the trTCM has initial (green) code point 10, downgraded (yellow) code point 11 and further downgraded (red) code point 12:
$dsredq addPolicerEntry trTCM 10 11 12
There must be a Policer Table entry in place for every policer type and initial code point pair. It should be noticed that the Null policer is added in the following way:
$dsredq addPolicerEntry Null 10
Downgrade code points are not specified because the Null policy does not meter traffic characteristics.
Queries supported:
$dsredq printPolicyTable
$dsredq printPolicerTable
$dsredq printPHBTable
$dsredq printStats
Sample output:
Packets Statistics CP TotPkts TxPkts ldrops edrops All 249126 249090 21 15 10 150305 150300 0 5 20 98821 98790 21 10
CP: code point
TotPkts: packets received
TxPkts: packets sent
ldrops: packets are dropped due to link overflow
edrops: RED early dropping).
$dsredq getAverage 0
$dsredq getCBucket
Tom Henderson 2011-11-05