diff --git a/doc/models/Makefile b/doc/models/Makefile index b5c66324f..600f24bd7 100644 --- a/doc/models/Makefile +++ b/doc/models/Makefile @@ -313,6 +313,8 @@ SOURCEFIGS = \ $(SRC)/spectrum/doc/spectrum-tv-cofdm.png \ $(SRC)/traffic-control/doc/classful-queue-disc.dia \ $(SRC)/traffic-control/doc/multi-queue-aware-queue-disc.dia \ + $(SRC)/traffic-control/doc/figures/collision_prob.jpeg \ + $(SRC)/traffic-control/doc/figures/overlapped.jpeg \ $(SRC)/lr-wpan/doc/lr-wpan-arch.dia \ $(SRC)/lr-wpan/doc/lr-wpan-data-example.dia \ $(SRC)/lr-wpan/doc/lr-wpan-primitives.dia \ diff --git a/src/traffic-control/doc/figures/collision_prob.jpeg b/src/traffic-control/doc/figures/collision_prob.jpeg new file mode 100644 index 000000000..52ddbe45a Binary files /dev/null and b/src/traffic-control/doc/figures/collision_prob.jpeg differ diff --git a/src/traffic-control/doc/figures/overlapped.jpeg b/src/traffic-control/doc/figures/overlapped.jpeg new file mode 100644 index 000000000..00571d258 Binary files /dev/null and b/src/traffic-control/doc/figures/overlapped.jpeg differ diff --git a/src/traffic-control/doc/fq-codel.rst b/src/traffic-control/doc/fq-codel.rst index 84cbb97d9..c6d983f84 100644 --- a/src/traffic-control/doc/fq-codel.rst +++ b/src/traffic-control/doc/fq-codel.rst @@ -29,10 +29,24 @@ The source code for the FqCoDel queue disc is located in the directory and `fq-codel-queue-disc.cc` defining a FqCoDelQueueDisc class and a helper FqCoDelFlow class. The code was ported to |ns3| based on Linux kernel code implemented by Eric Dumazet. +Set associative hashing is also based on the Linux kernel `CAKE `_ queue management code. +Set associative hashing is used to reduce the number of hash collisions in +comparison to choosing queues normally with a simple hash. For a given number of +queues, set associative hashing has fewer collisions than a traditional +hash, as long as the number of flows is lesser than the number of queues. +Essentially, it makes the queue management system more efficient. Set associative +hashing is a vital component of CAKE, which is another popular flow management +algorithm that is implemented in Linux and is being tested for FqCoDel. +Furthermore, this module can be directly used with CAKE when its other +components are implemented in ns-3. The only changes needed to incorporate this +new hashing scheme are in the SetAssociativeHash and DoEnqueue methods, +as described below. * class :cpp:class:`FqCoDelQueueDisc`: This class implements the main FqCoDel algorithm: - * ``FqCoDelQueueDisc::DoEnqueue ()``: If no packet filter has been configured, this routine calls the QueueDiscItem::Hash() method to classify the given packet into an appropriate queue. Otherwise, the configured filters are used to classify the packet. If the filters are unable to classify the packet, the packet is dropped. Otherwise, it is handed over to the CoDel algorithm for timestamping. Then, if the queue is not currently active (i.e., if it is not in either the list of new or the list of old queues), it is added to the end of the list of new queues, and its deficit is initiated to the configured quantum. Otherwise, the queue is left in its current queue list. Finally, the total number of enqueued packets is compared with the configured limit, and if it is above this value (which can happen since a packet was just enqueued), packets are dropped from the head of the queue with the largest current byte count until the number of dropped packets reaches the configured drop batch size or the backlog of the queue has been halved. Note that this in most cases means that the packet that was just enqueued is not among the packets that get dropped, which may even be from a different queue. + * ``FqCoDelQueueDisc::DoEnqueue ()``: If no packet filter has been configured, this routine calls the QueueDiscItem::Hash() method to classify the given packet into an appropriate queue. Otherwise, the configured filters are used to classify the packet. If the filters are unable to classify the packet, the packet is dropped. Otherwise, an option is provided if set associative hashing is to be used.The packet is now handed over to the CoDel algorithm for timestamping. Then, if the queue is not currently active (i.e., if it is not in either the list of new or the list of old queues), it is added to the end of the list of new queues, and its deficit is initiated to the configured quantum. Otherwise, the queue is left in its current queue list. Finally, the total number of enqueued packets is compared with the configured limit, and if it is above this value (which can happen since a packet was just enqueued), packets are dropped from the head of the queue with the largest current byte count until the number of dropped packets reaches the configured drop batch size or the backlog of the queue has been halved. Note that this in most cases means that the packet that was just enqueued is not among the packets that get dropped, which may even be from a different queue. + + * ``FqCoDelQueueDisc::SetAssociativeHash()``: An outer hash is identified for the given packet. This corresponds to the set into which the packet is to be enqueued. A set consists of a group of queues. The set determined by outer hash is enumerated; if a queue corresponding to this packet's flow is found (we use per-queue tags to achieve this), or in case of an inactive queue, or if a new queue can be created for this set without exceeding the maximum limit, the index of this queue is returned. Otherwise, all queues of this full set are active and correspond to flows different from the current packet's flow. In such cases, the index of first queue of this set is returned. We don’t consider creating new queues for the packet in these cases, since this approach may waste resources in the long run. The situation highlighted is a guaranteed collision and cannot be avoided without increasing the overall number of queues. * ``FqCoDelQueueDisc::DoDequeue ()``: The first task performed by this routine is selecting a queue from which to dequeue a packet. To this end, the scheduler first looks at the list of new queues; for the queue at the head of that list, if that queue has a negative deficit (i.e., it has already dequeued at least a quantum of bytes), it is given an additional amount of deficit, the queue is put onto the end of the list of old queues, and the routine selects the next queue and starts again. Otherwise, that queue is selected for dequeue. If the list of new queues is empty, the scheduler proceeds down the list of old queues in the same fashion (checking the deficit, and either selecting the queue for dequeuing, or increasing deficit and putting the queue back at the end of the list). After having selected a queue from which to dequeue a packet, the CoDel algorithm is invoked on that queue. As a result of this, one or more packets may be discarded from the head of the selected queue, before the packet that should be dequeued is returned (or nothing is returned if the queue is or becomes empty while being handled by the CoDel algorithm). Finally, if the CoDel algorithm does not return a packet, then the queue must be empty, and the scheduler does one of two things: if the queue selected for dequeue came from the list of new queues, it is moved to the end of the list of old queues. If instead it came from the list of old queues, that queue is removed from the list, to be added back (as a new queue) the next time a packet for that queue arrives. Then (since no packet was available for dequeue), the whole dequeue process is restarted from the beginning. If, instead, the scheduler did get a packet back from the CoDel algorithm, it subtracts the size of the packet from the byte deficit for the selected queue and returns the packet as the result of the dequeue operation. @@ -41,10 +55,10 @@ implemented by Eric Dumazet. * class :cpp:class:`FqCoDelFlow`: This class implements a flow queue, by keeping its current status (whether it is in the list of new queues, in the list of old queues or inactive) and its current deficit. In Linux, by default, packet classification is done by hashing (using a Jenkins -hash function) on the 5-tuple of IP protocol, and source and destination IP -addresses and port numbers (if they exist), and taking the hash value modulo -the number of queues. The hash is salted by modulo addition of a random value -selected at initialisation time, to prevent possible DoS attacks if the hash +hash function) the 5-tuple of IP protocol, source and destination IP +addresses and port numbers (if they exist). This value modulo +the number of queues is salted by a random value +selected at initialization time, to prevent possible DoS attacks if the hash is predictable ahead of time. Alternatively, any other packet filter can be configured. In |ns3|, packet classification is performed in the same way as in Linux. @@ -71,6 +85,7 @@ The key attributes that the FqCoDelQueue class holds include the following: * ``Flows:`` The number of flow queues managed by FqCoDel. * ``DropBatchSize:`` The maximum number of packets dropped from the fat flow. * ``Perturbation:`` The salt used as an additional input to the hash function used to classify packets. +* ``EnableSetAssociativeHash:`` The parameter used to enable set associative hash. Perturbation is an optional configuration attribute and can be used to generate different hash outcomes for different inputs. For instance, the tuples @@ -107,6 +122,7 @@ The FqCoDel model is tested using :cpp:class:`FqCoDelQueueDiscTestSuite` class d * Test 3: The third test checks the dequeue operation and the deficit round robin-based scheduler. * Test 4: The fourth test checks that TCP packets with distinct port numbers are enqueued into different flow queues. * Test 5: The fifth test checks that UDP packets with distinct port numbers are enqueued into different flow queues. +* Test 6: The sixth test checks the working of set associative hashing and its linear probing capabilities by using TCP packets with different hashes enqueued into different sets and queues. The test suite can be run using the following commands:: @@ -118,3 +134,17 @@ or:: $ NS_LOG="FqCoDelQueueDisc" ./waf --run "test-runner --suite=fq-codel-queue-disc" +Set associative hashing is tested by generating a probability collision graph. +This graph is then overlapped with the theoretical graph provided in the original +CAKE paper (refer to Figure 1 from `CAKE `_). +The generated graph is linked below: + + .. image:: figures/collision_prob.jpeg + :alt: Generated Collision Probability Graph + +The overlapped graph is also linked below: + + .. image:: figures/overlapped.jpeg + :alt: Overlapped Image with the graph from CAKE paper + +The steps to replicate this graph are available on this `link `_.