aboutsummaryrefslogtreecommitdiff
path: root/ouroboros/qos.py
diff options
context:
space:
mode:
authorDimitri Staessens <dimitri@ouroboros.rocks>2026-03-04 21:26:43 +0100
committerDimitri Staessens <dimitri@ouroboros.rocks>2026-03-07 15:27:04 +0100
commit7a4c37e8b673328dda59cec11ab9dce66c22a312 (patch)
treed2a05d2fa022d97ba79d8af2d32ec9e7cc3bd9e1 /ouroboros/qos.py
parent62924a033cb2a0130cc6a072e03590f8eec5ac72 (diff)
downloadpyouroboros-7a4c37e8b673328dda59cec11ab9dce66c22a312.tar.gz
pyouroboros-7a4c37e8b673328dda59cec11ab9dce66c22a312.zip
ouroboros: Add IRM wrapper
Add ouroboros.irm module wrapping the Ouroboros IRM C API, providing Python interfaces for IPCP lifecycle (create, destroy, bootstrap, enroll, connect), name management (create, destroy, register, list), and program/process binding. Split the monolithic CFFI build into separate _ouroboros_dev_cffi and _ouroboros_irm_cffi modules, each linking only its required library. Also includes: - ouroboros.cli module with higher-level wrappers mirroring CLI tools - FRCT flag support (set/get) in the Flow API - FlowPeer event type in FEventType - QoS defaults updated to match ouroboros source - Bug fixes: flow_set_snd_timeout typo, flow_set_flags calling convention, FlowSet name mangling, fqueue_type return type - .gitignore, copyright updates, version bump to 0.23.0
Diffstat (limited to 'ouroboros/qos.py')
-rw-r--r--ouroboros/qos.py78
1 files changed, 13 insertions, 65 deletions
diff --git a/ouroboros/qos.py b/ouroboros/qos.py
index a43d87d..bb4ecc4 100644
--- a/ouroboros/qos.py
+++ b/ouroboros/qos.py
@@ -1,7 +1,7 @@
#
-# Ouroboros - Copyright (C) 2016 - 2020
+# Ouroboros - Copyright (C) 2016 - 2026
#
-# Python API for applications - QoS
+# Python API for Ouroboros - QoS
#
# Dimitri Staessens <dimitri@ouroboros.rocks>
#
@@ -19,36 +19,35 @@
# Foundation, Inc., http://www.fsf.org/about/contact/.
#
-from _ouroboros_cffi import ffi
-from math import modf
-from typing import Optional
-
# Some constants
MILLION = 1000 * 1000
BILLION = 1000 * 1000 * 1000
+DEFAULT_PEER_TIMEOUT = 120000
+UINT32_MAX = 0xFFFFFFFF
+
class QoSSpec:
"""
- delay: In ms, default 1000s
+ delay: In ms, default UINT32_MAX
bandwidth: In bits / s, default 0
availability: Class of 9s, default 0
- loss: Packet loss in ppm, default MILLION
- ber: Bit error rate, errors per billion bits. default BILLION
+ loss: Packet loss, default 1
+ ber: Bit error rate, errors per billion bits, default 1
in_order: In-order delivery, enables FRCT, default 0
- max_gap: Maximum interruption in ms, default MILLION
+ max_gap: Maximum interruption in ms, default UINT32_MAX
timeout: Peer timeout (ms), default 120000 (2 minutes)
"""
def __init__(self,
- delay: int = MILLION,
+ delay: int = UINT32_MAX,
bandwidth: int = 0,
availability: int = 0,
loss: int = 1,
- ber: int = MILLION,
+ ber: int = 1,
in_order: int = 0,
- max_gap: int = MILLION,
- timeout: int = 120000):
+ max_gap: int = UINT32_MAX,
+ timeout: int = DEFAULT_PEER_TIMEOUT):
self.delay = delay
self.bandwidth = bandwidth
self.availability = availability
@@ -57,54 +56,3 @@ class QoSSpec:
self.in_order = in_order
self.max_gap = max_gap
self.timeout = timeout
-
-
-def _fl_to_timespec(timeo: float):
- if timeo is None:
- return ffi.NULL
- elif timeo <= 0:
- return ffi.new("struct timespec *", [0, 0])
- else:
- frac, whole = modf(timeo)
- _timeo = ffi.new("struct timespec *")
- _timeo.tv_sec = whole
- _timeo.tv_nsec = frac * BILLION
- return _timeo
-
-
-def _timespec_to_fl(_timeo) -> Optional[float]:
- if _timeo is ffi.NULL:
- return None
- elif _timeo.tv_sec <= 0 and _timeo.tv_nsec == 0:
- return 0
- else:
- return _timeo.tv_sec + _timeo.tv_nsec / BILLION
-
-
-def _qos_to_qosspec(qos: QoSSpec):
- if qos is None:
- return ffi.NULL
- else:
- return ffi.new("qosspec_t *",
- [qos.delay,
- qos.bandwidth,
- qos.availability,
- qos.loss,
- qos.ber,
- qos.in_order,
- qos.max_gap,
- qos.timeout])
-
-
-def _qosspec_to_qos(_qos) -> Optional[QoSSpec]:
- if _qos is ffi.NULL:
- return None
- else:
- return QoSSpec(delay=_qos.delay,
- bandwidth=_qos.bandwidth,
- availability=_qos.availability,
- loss=_qos.loss,
- ber=_qos.ber,
- in_order=_qos.in_order,
- max_gap=_qos.max_gap,
- timeout=_qos.timeout)