1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560
|
%
% Most parts are ported from the Manual of diffserv from Nortel
% -xuanc (Nov 16, 2000)
%
% Second cut by xuanc (Oct 18, 2001)
%
\chapter{Differentiated Services Module in \ns}
\label{chap:diffserv}
\textbf{Note: The Differentiated Services module described in this chapter has been integrated into ns-2.1b8.}
Differentiated Services, or DiffServ, is an IP QoS architecture based on
packet marking that allows packets to be prioritized according to user
requirements.
During the time of congestion,
more low priority packets are discarded than high priority packets.
This chapter describes the DiffServ module that was originally
implemented by the Advanced IP Networks group in
Nortel Networks~\cite{Diffserv}.
\section{Overview}
\label{sec:diffservoverview}
The DiffServ architecture provides QoS by
dividing traffic into different categories,
marking each packet with a code point that indicates its category,
and scheduling packets according accordingly.
The DiffServ module in~\ns can support four classes of traffic,
each of which has three dropping precedences allowing
differential treatment of traffic within a single class.
Packets in a single class of traffic are enqueued into
one corresponding physical RED queue,
which contains three virtual queues (one for each drop precedence).
Different RED parameters can be configured for virtual queues,
causing packets from one virtual queue to be dropped
more frequently than packets from another.
A packet with a lower dropping precedence is given
better treatment in times of congestion
because it is assigned a code point that corresponds to a virtual
queue with relatively lenient RED parameters.
The DiffServ module in~\ns has three major components:
\begin{description}
\item [Policy:]
Policy is specified by network administrator about
the level of service a class of traffic should receive in the network.
\item [Edge router:]
Edge router marks packets with a code point according to the policy specified.
\item [Core router:]
Core router examines packets' code point marking and forwarding them accordingly.
\end{description}
DiffServ attempts to restrict complexity to only the edge routers.
\section{Implementation}
\label{sec:diffservimplement}
The procedures and functions described in this section can be found in
\nsf{diffserv/dsred, dsredq, dsEdge, dsCore, dsPolicy.\{cc, h\}}.
\subsection{RED queue in DiffServ module}
\label{sec:dsredq}
A DiffServ queue (in class~\code{dsREDQueue}) derived from
the base class~\code{Queue} is implemented in DiffServ module to
provide the basic DiffServ router functionality,
see \code{dsred.\{h,cc\}}).
\code{dsREDQueue} has the following abilities:
\begin{itemize}
\item
to implement multiple physical RED queues along a single link;
\item
to implement multiple virtual queues within a physical queue,
with individual set of parameters for each virtual queue;
\item
to determine in which physical and virtual queue a packet is enqueued
according to its code point;
\item
to determine in from which physical and virtual queue a packet is dequeued
according to the scheduling scheme chosen.
\end{itemize}
The class~\code{dsREDQueue} consists of four physical RED queues,
each containing three virtual queues.
The number of physical and virtual queues are
defined in~\code{numPrec} and~\code{numQueues_}.
Each combination of physical and virtual queue number is associated with
a code point (or a drop preference),
which specifies a certain level of service.
The physical queue is defined in class~\code{redQueue},
which enables traffic differentiation by defining virtual queues with
independent configuration and state parameters,
see~\code{dsredq.\{h,cc\}}.
For example,
the length of each virtual queue is calculated only on packets mapped to
that queue.
Thus, packet dropping decisions can be applied based on
the state and configuration parameters of that virtual queues.
Class~\code{redQueue} is not equivalent to class~\code{REDQueue},
which was already present in~\ns.
Instead, it is a modified version of RED implementation with
the notion of virtual queues and
is only used by class~\code{redQueue} to realize physical queues.
All user interaction with class~\code{redQueue}
is handled through the command interface of class~\code{dsREDQueue}.
Class~\code{dsREDQueue} contains a data structure known as
the Per Hop Behavior (PHB) Table
In DiffServ, edge routers mark packets with code points and
core routers simply respond to existing code points;
both of them use PHB table to map a code point to
a particular physical and virtual queue.
The PHB Table is defined as an array with three fields:
\begin{program}
struct phbParam \{
int codePt_; // corresponding code point
int queue_; // physical queue
int prec_; // virtual queue (drop precedence)
\};
\end{program}
\subsection{Edge and core routers}
\label{sec:dsedge}
The DiffServ edge and core routers are defined in
class~\code{edgeQueue} and class~\code{coreQueue},
which are derived from class~\code{dsREDQueue},
see \code{dsEdge, dsCore.\{h,cc\}}.
Packet marking is implemented in class~\code{edgeQueue}.
A packet is marked with a code point according to
the policy specified
before it is put into the corresponding physical and virtual queue.
Class~\code{edgeQueue} has a reference to an instance of
class~\code{PolicyClassifier},
which contains policies for packet marking.
\subsection{Policy}
\label{sec:dspolicy}
Class~\code{Policy} and its sub-classes (see~\code{dsPolicy.\{cc, h\}})
define the policies used by edge routers to mark incoming packets.
A policy is established between a source and destination node.
All flows matching that source-destination pair are
treated as a single traffic aggregate.
Policy for each different traffic aggregate has
an associated policer type, meter type, and initial code point.
The meter type specifies the method for measuring the state variables
needed by the policer.
For example,
the TSW Tagger is a meter that measures the average traffic rate,
using a specified time window.
When a packet arrives at an edge router,
it is examined to determine to which aggregate it belongs.
The meter specified by the corresponding policy is invoked to
update all state variables.
The policer is invoked to determine how to mark the packet
depending on the aggregate's state variables:
the specified initial code point or
a downgraded code point.
Then the packet is enqueued accordingly.
Currently, six different policy models are defined:
\begin{enumerate}
\item
Time Sliding Window with 2 Color Marking (TSW2CMPolicer):
uses a CIR and two drop precedences.
The lower precedence is used probabilistically when the CIR is exceeded.
\item
Time Sliding Window with 3 Color Marking (TSW3CMPolicer):
uses a CIR, a PIR, and three drop precedences.
The medium drop precedence is used probabilistically
when the CIR is exceeded and the lowest drop precedence is used
probabilistic ally when the PIR is exceeded.
\item
Token Bucket (tokenBucketPolicer):
uses a CIR and a CBS and two drop precedences.
An arriving packet is marked with the lower precedence if and
only if it is larger than the token bucket.
\item
Single Rate Three Color Marker (srTCMPolicer):
uses a CIR, CBS, and an EBS to choose from three drop precedences.
\item
Two Rate Three Color Marker (trTCMPolicer):
uses a CIR, CBS, PIR, and a PBS to choose from three drop precedences.
\item
NullPolicer: does not downgrade any packets
\end{enumerate}
The policies above are defined as a sub-classes of \code{dsPolicy}.
The specific meter and policer are implemented in functions
\code{applyMeter} and \code{applyPolicer},
which are defined as virtual functions in class~\code{dsPolicy}.
User specified policy can be added in the similar way.
Please refer to~\code{NullPolicy} as the simplest example.
All policies are stored in the policy table in class~\code{PolicyClassifier}.
This table is an array that includes fields for
the source and destination nodes,
a policer type, a meter type,
an initial code point, and various state information as shown below:
\begin{quote}
The rates CIR and PIR are specified in bits per second:
CIR: committed information rate
PIR: peak information rate
The buckets CBS, EBS, and PBS are specified in bytes:
CBS: committed burst size
EBS: excess burst size
PBS: peak burst size
C bucket: current size of the committed bucket
E bucket: current size of the excess bucket
P bucket: current size of the peak bucket
Arrival time of last packet
Average sending rate
TSW window length
\end{quote}
Class~\code{PolicyClassifier} also contains a Policer Table to
store the mappings from a policy type and initial code point pair to
its associated downgraded code point(s).
\section{Configuration}
\label{sec:diffservconfig}
The number of physical and virtual queues can be configured as:
\code{$dsredq set numQueues_ 1}
\code{$dsredq setNumPrec 2}
Variable~\code{numQueues_} in class~\code{dsREDQueue}
specifies the number of physical queues.
It has a default value as 4 defined in~\nsf{tcl/lib/ns-default.tcl}
and can be changed as shown in the example above.
Variable~\code{setNumPrec} sets the number of virtual queues
within one physical queue.
RED parameters can be configured for each virtual queue as follows:
\code{$dsredq configQ 0 1 10 20 0.10}
The mean packet size (in bytes) is also needed for
the average RED queue length calculation.
\code{$dsredq meanPktSize 1500}
The variant of MRED used to calculate queue sizes can be configured.
\code{$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:
\begin{description}
\item [RIO-C (RIO Coupled):]
The probability of dropping an out-of-profile packet is based on
the weighted average lengths of all virtual queues;
while the probability of dropping an in-profile packet is based solely on
the weighted average length of its virtual queue.
\item [RIO-D (RIO De-coupled):]
Similar to RIO-C;
except the probability of dropping an out-of-profile packet is based on
the size of its virtual queue.
\item [WRED (Weighted RED):]
All probabilities are based on a single queue length.
\item [DROP:]
Same as a drop tail queue with queue limit set by RED minimum threshold:
when the queue size reaches the minimum threshold,
all packets are dropped regardless of marking.
\end{description}
The following command adds an entry to the PHB Table and
maps code point 11 to physical queue 0 and virtual queue 1.
\code{$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:
\code{$dsredq setSchedularMode WRR}
\code{$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:
\code{$dsredq setSchedularMode PRI}
\code{$dsredq addQueueRate 0 5000000}
These commands specify the maximum bandwidth that
queue 0 can consume is 5Mb.
The \code{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:
\begin{quote}
\begin{tabular}{llllll}
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
\end{tabular}
\end{quote}
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
\code{$q} is a variable for an edge queue,
and \code{$s} and \code{$d} are source and destination nodes.
The following command adds a TSW2CM policer for traffic going from
the source to the destination:
\code{$q addPolicyEntry [$s id] [$d id] TSW2CM 10 2000000}
Other parameters could be used for different policers
in place of "TSW2CM":
\begin{quote}
\begin{tabular}{llllll}
Null&10\\
TSW3CM&10&2000000&3000000\\
TokenBucket&10&2000000&10000\\
srTCM&10&2000000&10000&20000\\
trTCM&10&2000000&10000&3000000&10000
\end{tabular}
\end{quote}
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:
\code{$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:
\code{$dsredq addPolicerEntry Null 10}
Downgrade code points are not specified because the Null policy does not
meter traffic characteristics.
Queries supported:
\begin{description}
\item
Output entires in Policy Table, one line at a time:
\code{$dsredq printPolicyTable}
\item
Output entires in Policer Table, one line at a time:
\code{$dsredq printPolicerTable}
\item
Output entries in PHB table, one line at a time:
\code{$dsredq printPHBTable}
\item
Packets statistic results:
\code{$dsredq printStats}
Sample output:
\begin{quote}
\begin{tabular}{lllll}
\multicolumn{5}{l}{Packets Statistics} \\
\hline\hline
CP & TotPkts & TxPkts & ldrops & edrops \\
\hline
All & 249126 & 249090 & 21 & 15 \\
10 & 150305 & 150300 & 0 & 5 \\
20 & 98821 & 98790 & 21 & 10 \\
\end{tabular}
\end{quote}
\begin{quote}
CP: code point
TotPkts: packets received
TxPkts: packets sent
ldrops: packets are dropped due to link overflow
edrops: RED early dropping).
\end{quote}
\item
Returns the RED weighted average size of the specified physical queue:
\code{$dsredq getAverage 0}
\item
Returns the current size of the C Bucket (in bytes):
\code{$dsredq getCBucket}
\end{description}
\section{Commands at a glance}
\label{sec:diffservcommand}
The following is a list of related commands commonly used in
simulation scripts:
\begin{program}
\$ns simplex-link \$edge \$core 10Mb 5ms dsRED/edge
\$ns simplex-link \$core \$edge 10Mb 5ms dsRED/core
\end{program}
These two commands create the queues along
the link between an edge router and a core router.
\begin{program}
set qEC [[\$ns link \$edge \$core] queue]
# Set DS RED parameters from Edge to Core:
\$qEC meanPktSize \$packetSize
\$qEC set numQueues_ 1
\$qEC setNumPrec 2
\$qEC addPolicyEntry [$s1 id] [$dest id] TokenBucket 10 $cir0 $cbs0
\$qEC addPolicyEntry [$s2 id] [$dest id] TokenBucket 10 $cir1 $cbs1
\$qEC addPolicerEntry TokenBucket 10 11
\$qEC addPHBEntry 10 0 0
\$qEC addPHBEntry 11 0 1
\$qEC configQ 0 0 20 40 0.02
\$qEC configQ 0 1 10 20 0.10
\end{program}
This block of code obtains handle to the DiffServ queue
from an edge router to a core router and
configures all of the parameters for it.
The meanPktSize command is required for the RED state variables to be
calculated accurately.
Setting the number of physical queues and precedence levels is optional,
but it aids efficiency.
Because neither the scheduling or MRED mode type are set,
they default to Round Robin scheduling and RIO-C Active Queue Management.
The addPolicyEntry commands establish two policies at the edge queue:
one between nodes S1 and Dest and one between nodes S2 and Dest.
Note that the \code{[$s1 id]} command returns the ID value
needed by \code{addPolicyEntry}.
The CIR and CBS values used in the policies are the ones set at
the beginning of the script.
The \code{addPolicerEntry} line is required
because each policer type and initial code point pair requires
an entry in the Policer Table.
Each of the policies uses the same policer and initial code point,
so only one entry is needed.
The~\code{addPHBEntry} commands map each code point to
a combination of physical and virtual queue.
Although each code point in this example maps to
a unique combination of physical and virtual queue,
multiple code points could receive identical treatment.
Finally, the~\code{configQ} commands set the RED parameters for
each virtual queue.
It specifies the virtual queue by first two parameters,
for example, 0 and 1.
The next three parameters are the minimum threshold, maximum threshold,
and the maximum dropping probability.
Note that as the precedence value increases,
the RED parameters become harsher.
\begin{program}
set qCE [[\$ns link \$core \$e1] queue]
# Set DS RED parameters from Core to Edge:
\$qCE meanPktSize \$packetSize
\$qCE set numQueues_ 1
\$qCE setNumPrec 2
\$qCE addPHBEntry 10 0 0
\$qCE addPHBEntry 11 0 1
\$qCE configQ 0 0 20 40 0.02
\$qCE configQ 0 1 10 20 0.10
\end{program}
Note that the configuration of a core queue matches that of an edge queue,
except that there is no Policy Table or Policer Table to
configure at a core router.
A core router's chief requirement is that it has a PHB entry for
all code points that it will see.
\begin{program}
\$qE1C printPolicyTable
\$qCE2 printCoreStats
\end{program}
These methods output the policy or policer tables on link and different
statistics.
For further information, please refer to the example scripts under
\nsf{tcl/ex/diffserv}.
|