Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Changed and refactored the code #2

Open
wants to merge 6 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
45 changes: 23 additions & 22 deletions queue-exp/eiffel-hierarchical.py
100644 → 100755
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
# -*- coding: utf-8 -*-
#!/usr/bin/env python3
# coding: utf-8 -*-
#
# eiffel-hiearch.py
#
Expand Down Expand Up @@ -84,26 +85,26 @@ def dump(self):

if __name__ == "__main__":
pkts = [
Packet(1, 1, 1),
Packet(1, 2, 1),
Packet(1, 3, 1),
Packet(2, 1, 1),
Packet(2, 2, 1),
Packet(2, 3, 1),
Packet(2, 4, 1),
Packet(2, 5, 1),
Packet(3, 1, 1),
Packet(3, 2, 1),
Packet(3, 3, 1),
Packet(4, 1, 1),
Packet(4, 2, 1),
Packet(4, 3, 1),
Packet(4, 4, 1),
Packet(4, 5, 1),
Packet(4, 6, 1),
Packet(4, 7, 1),
Packet(4, 8, 1),
Packet(4, 9, 1),
Packet(4, 10, 1),
Packet(flow=1, idn=1, length=1),
Packet(flow=1, idn=2, length=1),
Packet(flow=1, idn=3, length=1),
Packet(flow=2, idn=1, length=1),
Packet(flow=2, idn=2, length=1),
Packet(flow=2, idn=3, length=1),
Packet(flow=2, idn=4, length=1),
Packet(flow=2, idn=5, length=1),
Packet(flow=3, idn=1, length=1),
Packet(flow=3, idn=2, length=1),
Packet(flow=3, idn=3, length=1),
Packet(flow=4, idn=1, length=1),
Packet(flow=4, idn=2, length=1),
Packet(flow=4, idn=3, length=1),
Packet(flow=4, idn=4, length=1),
Packet(flow=4, idn=5, length=1),
Packet(flow=4, idn=6, length=1),
Packet(flow=4, idn=7, length=1),
Packet(flow=4, idn=8, length=1),
Packet(flow=4, idn=9, length=1),
Packet(flow=4, idn=10, length=1),
]
Runner(pkts, Policy()).run()
45 changes: 23 additions & 22 deletions queue-exp/eiffel-procedural.py
100644 → 100755
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
# -*- coding: utf-8 -*-
#!/usr/bin/env python3
# coding: utf-8 -*-
#
# eiffel-procedural.py
#
Expand Down Expand Up @@ -89,26 +90,26 @@ def dump(self):

if __name__ == "__main__":
pkts = [
Packet(1, 1, 1),
Packet(1, 2, 1),
Packet(1, 3, 1),
Packet(2, 1, 1),
Packet(2, 2, 1),
Packet(2, 3, 1),
Packet(2, 4, 1),
Packet(2, 5, 1),
Packet(3, 1, 1),
Packet(3, 2, 1),
Packet(3, 3, 1),
Packet(4, 1, 1),
Packet(4, 2, 1),
Packet(4, 3, 1),
Packet(4, 4, 1),
Packet(4, 5, 1),
Packet(4, 6, 1),
Packet(4, 7, 1),
Packet(4, 8, 1),
Packet(4, 9, 1),
Packet(4, 10, 1),
Packet(flow=1, idn=1, length=1),
Packet(flow=1, idn=2, length=1),
Packet(flow=1, idn=3, length=1),
Packet(flow=2, idn=1, length=1),
Packet(flow=2, idn=2, length=1),
Packet(flow=2, idn=3, length=1),
Packet(flow=2, idn=4, length=1),
Packet(flow=2, idn=5, length=1),
Packet(flow=3, idn=1, length=1),
Packet(flow=3, idn=2, length=1),
Packet(flow=3, idn=3, length=1),
Packet(flow=4, idn=1, length=1),
Packet(flow=4, idn=2, length=1),
Packet(flow=4, idn=3, length=1),
Packet(flow=4, idn=4, length=1),
Packet(flow=4, idn=5, length=1),
Packet(flow=4, idn=6, length=1),
Packet(flow=4, idn=7, length=1),
Packet(flow=4, idn=8, length=1),
Packet(flow=4, idn=9, length=1),
Packet(flow=4, idn=10, length=1),
]
Runner(pkts, Policy()).run()
15 changes: 8 additions & 7 deletions queue-exp/eiffel.py
100644 → 100755
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
# -*- coding: utf-8 -*-
#!/usr/bin/env python3
# coding: utf-8 -*-
#
# eiffel.py
#
Expand Down Expand Up @@ -119,12 +120,12 @@ def get_rank(self, _flow):

if __name__ == "__main__":
pkts = [
Packet(1, 1, 1),
Packet(1, 2, 1),
Packet(1, 3, 1),
Packet(2, 1, 1),
Packet(2, 2, 1),
Packet(2, 3, 1),
Packet(flow=1, idn=1, length=1),
Packet(flow=1, idn=2, length=1),
Packet(flow=1, idn=3, length=1),
Packet(flow=2, idn=1, length=1),
Packet(flow=2, idn=2, length=1),
Packet(flow=2, idn=3, length=1),
]
Runner(pkts, Fifo()).run()
Runner(pkts, Stfq()).run()
54 changes: 0 additions & 54 deletions queue-exp/pifo-basic.py

This file was deleted.

67 changes: 67 additions & 0 deletions queue-exp/pifo_fifo.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,67 @@
#!/usr/bin/env python3
# coding: utf-8 -*-
#
# SPDX-License-Identifier: GPL-3.0-or-later
#
# pifo-fifo.py

"""First in, first out (FIFO)

The FIFO scheduling algorithm preserves the order of the scheduled packets. This
implementation is here for completeness and uses a PIFO. It is here to help
people understand how to add new scheduling algorithms to this framework.
"""

__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 pifo_lib import Packet, Runner, Pifo
from pifo_lib import SchedulingAlgorithm


class Fifo(SchedulingAlgorithm):
"""First in, first out (FIFO)"""

def __init__(self):
self._pifo = Pifo()

def enqueue(self, item):
rank = self.get_rank(item)
self._pifo.enqueue(item, rank)

def get_rank(self, item):
return self._pifo.qlen

def dequeue(self):
return self._pifo.dequeue()

def dump(self):
self._pifo.dump()


if __name__ == "__main__":
pkts = [
Packet(flow=1, idn=1, length=2),
Packet(flow=1, idn=2, length=2),
Packet(flow=2, idn=1, length=1),
Packet(flow=2, idn=2, length=1),
Packet(flow=2, idn=3, length=1),
]
Runner(pkts, Fifo()).run()
Loading