-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Added the HPFQ scheduler and reference scheduling
This commit adds the HierarchicalPacket Fair Queueing (HPFQ) scheduler from the paper "Programmable packet scheduling at line rate" by Sivaraman, Anirudh, et al. This commit also changes the framework to make it easy to schedule references to flows, queues, or schedulers. It does so by adding a reference with every enqueue operation. By adding the reference with the packet or flow, we can create a rank from packet or flow and queue the reference. This commit adds the HierarchicalPacket Fair Queueing (HPFQ) scheduler from the paper "Programmable packet scheduling at line rate" by Sivaraman, Anirudh, et al. This commit also changes the framework to make it easy to schedule references to flows, queues, or schedulres. Signed-off-by: Frey Alfredsson <[email protected]>
- Loading branch information
1 parent
145b33d
commit 1d341c1
Showing
6 changed files
with
149 additions
and
49 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,87 @@ | ||
#!/usr/bin/env python3 | ||
# coding: utf-8 -*- | ||
# | ||
# SPDX-License-Identifier: GPL-3.0-or-later | ||
# | ||
# pifo-hpfq.py | ||
|
||
"""HierarchicalPacket Fair Queueing (HPFQ) | ||
This scheduling algorithm is mentioned in the paper "Programmable packet | ||
scheduling at line rate" by Sivaraman, Anirudh, et al. It creates a hierarchy of | ||
WFQ schedulers. The central scheduler is called root and contains references to | ||
other WFQ schedulers. Those two WFQ schedulers are called left and right. We | ||
chose that packets with flow ids lower than ten go into the left scheduler in | ||
our implementation. In contrast, the others go into the right scheduler.""" | ||
|
||
__copyright__ = """ | ||
Copyright (c) 2021, Toke Høiland-Jørgensen <[email protected]> | ||
Copyright (c) 2021, Frey Alfredsson <[email protected]> | ||
""" | ||
|
||
__license__ = """ | ||
This program is free software: you can redistribute it and/or modify | ||
it under the terms of the GNU General Public License as published by | ||
the Free Software Foundation, either version 3 of the License, or | ||
(at your option) any later version. | ||
This program is distributed in the hope that it will be useful, | ||
but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
GNU General Public License for more details. | ||
You should have received a copy of the GNU General Public License | ||
along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
""" | ||
|
||
from sched_lib import Packet, Runner, SchedulingAlgorithm | ||
from pifo_wfq import Wfq | ||
|
||
|
||
class Hpfq(SchedulingAlgorithm): | ||
"""HierarchicalPacket Fair Queueing (HPFQ)""" | ||
|
||
def __init__(self, name=None): | ||
super().__init__(name) | ||
self._root = Wfq("root") | ||
self._left = Wfq("Left") | ||
self._right = Wfq("Right") | ||
|
||
def enqueue(self, ref, item): | ||
queue = None | ||
if item.flow < 10: | ||
self._left.enqueue(ref, item) | ||
queue = self._left | ||
else: | ||
self._right.enqueue(ref, item) | ||
queue = self._right | ||
|
||
self._root.enqueue(queue, item) | ||
|
||
def dequeue(self): | ||
queue = self._root.dequeue() | ||
return queue.dequeue() if queue is not None else None | ||
|
||
def dump(self): | ||
print(" Root:") | ||
self._root.dump() | ||
print(" Left:") | ||
self._left.dump() | ||
print(" Right:") | ||
self._right.dump() | ||
|
||
|
||
if __name__ == "__main__": | ||
pkts = [ | ||
Packet(flow=1, idn=1, length=200), | ||
Packet(flow=1, idn=2, length=200), | ||
Packet(flow=10, idn=1, length=200), | ||
Packet(flow=10, idn=2, length=200), | ||
Packet(flow=2, idn=1, length=100), | ||
Packet(flow=2, idn=2, length=100), | ||
Packet(flow=2, idn=3, length=100), | ||
Packet(flow=20, idn=1, length=100), | ||
Packet(flow=20, idn=2, length=100), | ||
Packet(flow=20, idn=3, length=100), | ||
] | ||
Runner(pkts, Hpfq()).run() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters