src/network/doc/queue.rst
author Tom Henderson <tomh@tomh.org>
Tue, 05 Jun 2012 16:29:04 -0700
changeset 8844 ae540de68a25
child 10408 5c604e8ec2e1
permissions -rw-r--r--
add queue documentation
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
8844
ae540de68a25 add queue documentation
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
     1
Queues
ae540de68a25 add queue documentation
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
     2
------
ae540de68a25 add queue documentation
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
     3
ae540de68a25 add queue documentation
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
     4
.. heading hierarchy:
ae540de68a25 add queue documentation
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
     5
   ------------- Chapter
ae540de68a25 add queue documentation
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
     6
   ************* Section (#.#)
ae540de68a25 add queue documentation
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
     7
   ============= Subsection (#.#.#)
ae540de68a25 add queue documentation
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
     8
   ############# Paragraph (no number)
ae540de68a25 add queue documentation
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
     9
ae540de68a25 add queue documentation
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
    10
This section documents a few queue objects, typically associated with
ae540de68a25 add queue documentation
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
    11
NetDevice models, that are maintained as part of the ``network`` module:
ae540de68a25 add queue documentation
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
    12
ae540de68a25 add queue documentation
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
    13
* DropTail
ae540de68a25 add queue documentation
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
    14
* Random Early Detection 
ae540de68a25 add queue documentation
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
    15
ae540de68a25 add queue documentation
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
    16
Model Description
ae540de68a25 add queue documentation
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
    17
*****************
ae540de68a25 add queue documentation
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
    18
ae540de68a25 add queue documentation
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
    19
The source code for the new module lives in the directory ``src/network/utils``.
ae540de68a25 add queue documentation
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
    20
ae540de68a25 add queue documentation
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
    21
ns-3 provides a couple of classic queue models and the ability to
ae540de68a25 add queue documentation
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
    22
trace certain queue operations such as enqueuing, dequeuing, and dropping.
ae540de68a25 add queue documentation
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
    23
These may be added to certain NetDevice objects that take a Ptr<Queue>
ae540de68a25 add queue documentation
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
    24
pointer.
ae540de68a25 add queue documentation
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
    25
ae540de68a25 add queue documentation
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
    26
Note that not all device models use these queue models.  
ae540de68a25 add queue documentation
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
    27
In particular, WiFi, WiMax, and LTE use specialized device queues.
ae540de68a25 add queue documentation
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
    28
The queue models described here are more often used with simpler ns-3 
ae540de68a25 add queue documentation
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
    29
device models such as PointToPoint and Csma.
ae540de68a25 add queue documentation
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
    30
ae540de68a25 add queue documentation
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
    31
Design
ae540de68a25 add queue documentation
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
    32
======
ae540de68a25 add queue documentation
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
    33
ae540de68a25 add queue documentation
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
    34
An abstract base class, class Queue, is typically used and subclassed
ae540de68a25 add queue documentation
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
    35
for specific scheduling and drop policies.  Common operations
ae540de68a25 add queue documentation
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
    36
include:
ae540de68a25 add queue documentation
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
    37
ae540de68a25 add queue documentation
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
    38
* ``bool Enqueue (Ptr<Packet> p)``:  Enqueue a packet
ae540de68a25 add queue documentation
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
    39
* ``Ptr<Packet> Dequeue (void)``:  Dequeue a packet
ae540de68a25 add queue documentation
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
    40
* ``uint32_t GetNPackets (void)``:  Get the queue depth, in packets
ae540de68a25 add queue documentation
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
    41
* ``uint32_t GetNBytes (void)``:  Get the queue depth, in packets
ae540de68a25 add queue documentation
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
    42
ae540de68a25 add queue documentation
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
    43
as well as tracking some statistics on queue operations.
ae540de68a25 add queue documentation
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
    44
ae540de68a25 add queue documentation
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
    45
There are three trace sources that may be hooked:
ae540de68a25 add queue documentation
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
    46
ae540de68a25 add queue documentation
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
    47
* ``Enqueue``
ae540de68a25 add queue documentation
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
    48
* ``Dequeue``
ae540de68a25 add queue documentation
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
    49
* ``Drop``
ae540de68a25 add queue documentation
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
    50
ae540de68a25 add queue documentation
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
    51
DropTail
ae540de68a25 add queue documentation
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
    52
########
ae540de68a25 add queue documentation
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
    53
ae540de68a25 add queue documentation
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
    54
This is a basic first-in-first-out (FIFO) queue that performs a tail drop
ae540de68a25 add queue documentation
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
    55
when the queue is full.
ae540de68a25 add queue documentation
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
    56
ae540de68a25 add queue documentation
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
    57
Random Early Detection
ae540de68a25 add queue documentation
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
    58
######################
ae540de68a25 add queue documentation
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
    59
ae540de68a25 add queue documentation
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
    60
Random Early Detection (RED) is a queue variant that aims to provide
ae540de68a25 add queue documentation
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
    61
early signals to transport protocol congestion control (e.g. TCP) that
ae540de68a25 add queue documentation
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
    62
congestion is imminent, so that they back off their rate gracefully
ae540de68a25 add queue documentation
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
    63
rather than with a bunch of tail-drop losses (possibly incurring
ae540de68a25 add queue documentation
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
    64
TCP timeout).  The model in ns-3 is a port of Sally Floyd's ns-2
ae540de68a25 add queue documentation
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
    65
RED model.
ae540de68a25 add queue documentation
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
    66
ae540de68a25 add queue documentation
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
    67
Scope and Limitations
ae540de68a25 add queue documentation
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
    68
=====================
ae540de68a25 add queue documentation
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
    69
ae540de68a25 add queue documentation
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
    70
The RED model just supports default RED.  Adaptive RED is not supported.
ae540de68a25 add queue documentation
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
    71
ae540de68a25 add queue documentation
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
    72
References
ae540de68a25 add queue documentation
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
    73
==========
ae540de68a25 add queue documentation
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
    74
ae540de68a25 add queue documentation
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
    75
The RED queue aims to be close to the results cited in:
ae540de68a25 add queue documentation
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
    76
S.Floyd, K.Fall http://icir.org/floyd/papers/redsims.ps
ae540de68a25 add queue documentation
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
    77
ae540de68a25 add queue documentation
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
    78
Usage
ae540de68a25 add queue documentation
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
    79
*****
ae540de68a25 add queue documentation
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
    80
ae540de68a25 add queue documentation
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
    81
Helpers
ae540de68a25 add queue documentation
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
    82
=======
ae540de68a25 add queue documentation
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
    83
ae540de68a25 add queue documentation
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
    84
A typical usage pattern is to create a device helper and to configure
ae540de68a25 add queue documentation
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
    85
the queue type and attributes from the helper, such as this example
ae540de68a25 add queue documentation
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
    86
from ``src/network/examples/red-tests.cc``:
ae540de68a25 add queue documentation
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
    87
ae540de68a25 add queue documentation
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
    88
:: 
ae540de68a25 add queue documentation
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
    89
ae540de68a25 add queue documentation
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
    90
  PointToPointHelper p2p;
ae540de68a25 add queue documentation
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
    91
ae540de68a25 add queue documentation
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
    92
  p2p.SetQueue ("ns3::DropTailQueue");
ae540de68a25 add queue documentation
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
    93
  p2p.SetDeviceAttribute ("DataRate", StringValue ("10Mbps"));
ae540de68a25 add queue documentation
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
    94
  p2p.SetChannelAttribute ("Delay", StringValue ("2ms"));
ae540de68a25 add queue documentation
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
    95
  NetDeviceContainer devn0n2 = p2p.Install (n0n2);
ae540de68a25 add queue documentation
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
    96
ae540de68a25 add queue documentation
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
    97
  p2p.SetQueue ("ns3::DropTailQueue");
ae540de68a25 add queue documentation
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
    98
  p2p.SetDeviceAttribute ("DataRate", StringValue ("10Mbps"));
ae540de68a25 add queue documentation
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
    99
  p2p.SetChannelAttribute ("Delay", StringValue ("3ms"));
ae540de68a25 add queue documentation
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   100
  NetDeviceContainer devn1n2 = p2p.Install (n1n2);
ae540de68a25 add queue documentation
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   101
ae540de68a25 add queue documentation
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   102
  p2p.SetQueue ("ns3::RedQueue", // only backbone link has RED queue
ae540de68a25 add queue documentation
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   103
                "LinkBandwidth", StringValue (redLinkDataRate),
ae540de68a25 add queue documentation
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   104
                "LinkDelay", StringValue (redLinkDelay));
ae540de68a25 add queue documentation
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   105
  p2p.SetDeviceAttribute ("DataRate", StringValue (redLinkDataRate));
ae540de68a25 add queue documentation
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   106
  p2p.SetChannelAttribute ("Delay", StringValue (redLinkDelay));
ae540de68a25 add queue documentation
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   107
  NetDeviceContainer devn2n3 = p2p.Install (n2n3);
ae540de68a25 add queue documentation
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   108
ae540de68a25 add queue documentation
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   109
ae540de68a25 add queue documentation
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   110
Attributes
ae540de68a25 add queue documentation
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   111
==========
ae540de68a25 add queue documentation
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   112
ae540de68a25 add queue documentation
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   113
The RED queue contains a number of attributes that control the RED
ae540de68a25 add queue documentation
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   114
policies:
ae540de68a25 add queue documentation
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   115
ae540de68a25 add queue documentation
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   116
* Mode (bytes or packets)
ae540de68a25 add queue documentation
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   117
* MeanPktSize
ae540de68a25 add queue documentation
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   118
* IdlePktSize
ae540de68a25 add queue documentation
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   119
* Wait (time)
ae540de68a25 add queue documentation
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   120
* Gentle mode
ae540de68a25 add queue documentation
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   121
* MinTh, MaxTh
ae540de68a25 add queue documentation
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   122
* QueueLimit
ae540de68a25 add queue documentation
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   123
* Queue weight
ae540de68a25 add queue documentation
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   124
* LInterm
ae540de68a25 add queue documentation
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   125
* LinkBandwidth
ae540de68a25 add queue documentation
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   126
* LinkDelay
ae540de68a25 add queue documentation
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   127
ae540de68a25 add queue documentation
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   128
Consult the ns-3 documentation for explanation of these attributes.
ae540de68a25 add queue documentation
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   129
ae540de68a25 add queue documentation
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   130
Output
ae540de68a25 add queue documentation
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   131
======
ae540de68a25 add queue documentation
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   132
ae540de68a25 add queue documentation
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   133
The ns-3 ascii trace helpers used by many of the NetDevices will hook
ae540de68a25 add queue documentation
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   134
the Enqueue, Dequeue, and Drop traces of these queues and print out 
ae540de68a25 add queue documentation
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   135
trace statements, such as the following from ``examples/udp/udp-echo.cc``:
ae540de68a25 add queue documentation
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   136
ae540de68a25 add queue documentation
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   137
::
ae540de68a25 add queue documentation
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   138
ae540de68a25 add queue documentation
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   139
  + 2 /NodeList/0/DeviceList/1/$ns3::CsmaNetDevice/TxQueue/Enqueue ns3::EthernetHeader 
ae540de68a25 add queue documentation
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   140
  ( length/type=0x806, source=00:00:00:00:00:01, destination=ff:ff:ff:ff:ff:ff) 
ae540de68a25 add queue documentation
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   141
  ns3::ArpHeader (request source mac: 00-06-00:00:00:00:00:01 source ipv4: 10.1.1.1 
ae540de68a25 add queue documentation
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   142
  dest ipv4: 10.1.1.2) Payload (size=18) ns3::EthernetTrailer (fcs=0)
ae540de68a25 add queue documentation
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   143
  - 2 /NodeList/0/DeviceList/1/$ns3::CsmaNetDevice/TxQueue/Dequeue ns3::EthernetHeader 
ae540de68a25 add queue documentation
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   144
  ( length/type=0x806, source=00:00:00:00:00:01, destination=ff:ff:ff:ff:ff:ff) 
ae540de68a25 add queue documentation
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   145
  ns3::ArpHeader (request source mac: 00-06-00:00:00:00:00:01 source ipv4: 10.1.1.1 
ae540de68a25 add queue documentation
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   146
  dest ipv4: 10.1.1.2) Payload (size=18) ns3::EthernetTrailer (fcs=0)
ae540de68a25 add queue documentation
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   147
ae540de68a25 add queue documentation
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   148
which shows an enqueue "+" and dequeue "-" event at time 2 seconds.
ae540de68a25 add queue documentation
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   149
ae540de68a25 add queue documentation
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   150
Users are, of course, free to define and hook their own trace sinks to
ae540de68a25 add queue documentation
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   151
these trace sources.
ae540de68a25 add queue documentation
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   152
ae540de68a25 add queue documentation
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   153
Examples
ae540de68a25 add queue documentation
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   154
========
ae540de68a25 add queue documentation
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   155
ae540de68a25 add queue documentation
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   156
The drop-tail queue is used in several examples, such as 
ae540de68a25 add queue documentation
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   157
``examples/udp/udp-echo.cc``.  The RED queue example is found at
ae540de68a25 add queue documentation
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   158
``src/network/examples/red-tests.cc``.
ae540de68a25 add queue documentation
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   159
ae540de68a25 add queue documentation
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   160
Validation
ae540de68a25 add queue documentation
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   161
**********
ae540de68a25 add queue documentation
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   162
ae540de68a25 add queue documentation
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   163
The RED model has been validated and the report is currently stored
ae540de68a25 add queue documentation
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   164
at: https://github.com/downloads/talau/ns-3-tcp-red/report-red-ns3.pdf 
ae540de68a25 add queue documentation
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   165