flexstack.management Module

The flexstack.management package implements Decentralized Congestion Control (DCC).

Decentralized Congestion Control (DCC)

Adaptive Decentralized Congestion Control algorithm and Gate Keeper.

Implements the adaptive approach specified in ETSI TS 102 687 V1.2.1 (2018-04) clause 5.4 and the gate-keeping packet admission mechanism described in Annex B.

Overview

The adaptive algorithm (LIMERIC) maintains a smoothed estimate of the local Channel Busy Ratio (cbr_its_s) and adjusts a duty-cycle fraction parameter delta so that the ITS-S’s own channel occupancy converges toward a configurable target CBR. delta represents the maximum fraction of the wireless medium that this ITS-S is allowed to occupy over any given interval.

The DccAdaptive class implements the five algorithmic steps of clause 5.4 and is intended to be called at every UTC-modulo-200 ms boundary.

The GateKeeper class implements the packet admission logic of Annex B. It uses the current delta value to compute the earliest time at which the next packet may be admitted to the access layer. When delta is updated by the adaptive algorithm, the gate-opening time is recalculated according to equation B.2 to avoid synchronised transmissions across stations.

class flexstack.management.dcc_adaptive.DccAdaptiveParameters(alpha=0.016, beta=0.0012, cbr_target=0.68, delta_max=0.03, delta_min=0.0006, delta_up_max=0.0005, delta_down_max=-0.00025)[source]

Bases: object

Tunable parameters of the adaptive DCC algorithm.

Default values are taken from Table 3 of ETSI TS 102 687 V1.2.1 (2018-04) clause 5.4.

Variables:
  • alpha (float) – Exponential averaging coefficient used in step 3 (equation 4). Default: 0.016.

  • beta (float) – Proportional gain applied to the CBR error in step 2 (equations 2 and 3). Default: 0.0012.

  • cbr_target (float) – Target Channel Busy Ratio toward which delta is steered. Default: 0.68.

  • delta_max (float) – Hard upper bound on the duty-cycle fraction delta (step 4, equation 5). Corresponds to the maximum duty cycle permitted by ETSI EN 302 571. Default: 0.03.

  • delta_min (float) – Hard lower bound on delta (step 5, equation 6). Prevents complete starvation under extreme congestion. Default: 0.0006.

  • delta_up_max (float) – Upper clamp on the per-step offset when CBR is below the target (equation 2). Default: 0.0005.

  • delta_down_max (float) – Lower clamp on the per-step offset when CBR is at or above the target (equation 3). Must be negative. Default: -0.00025.

Parameters:
  • alpha (float) –

  • beta (float) –

  • cbr_target (float) –

  • delta_max (float) –

  • delta_min (float) –

  • delta_up_max (float) –

  • delta_down_max (float) –

alpha: float = 0.016
beta: float = 0.0012
cbr_target: float = 0.68
delta_max: float = 0.03
delta_min: float = 0.0006
delta_up_max: float = 0.0005
delta_down_max: float = -0.00025
class flexstack.management.dcc_adaptive.DccAdaptive(parameters=<factory>)[source]

Bases: object

Adaptive DCC algorithm as specified in ETSI TS 102 687 V1.2.1 (2018-04) clause 5.4 (LIMERIC).

The algorithm shall be evaluated at every UTC-modulo-200 ms boundary (clause 5.2). Each evaluation executes five ordered steps that update the duty-cycle fraction delta:

  • Step 1 – Compute a smoothed CBR estimate (cbr_its_s) from the two most recent local (or global, if available) CBR measurements.

  • Step 2 – Compute a signed per-step correction (delta_offset) proportional to the distance between cbr_target and cbr_its_s, clamped to [delta_down_max, delta_up_max].

  • Step 3 – Apply an exponential filter to blend the new offset into the current delta.

  • Steps 4–5 – Clamp delta to [delta_min, delta_max].

Parameters:

parameters (DccAdaptiveParameters, optional) – Algorithm tuning parameters. If not supplied the standard default values from Table 3 are used.

Variables:
  • cbr_its_s (float) – Current smoothed CBR estimate (initialised to 0.0).

  • delta (float) – Current duty-cycle fraction (initialised to parameters.delta_min).

Examples

>>> alg = DccAdaptive()
>>> delta = alg.update(cbr_local=0.5, cbr_local_previous=0.5)
>>> 0.0006 <= delta <= 0.03
True
parameters: DccAdaptiveParameters
cbr_its_s: float = 0.0
delta: float = 0.0
update(cbr_local, cbr_local_previous, cbr_global=None, cbr_global_previous=None)[source]

Execute one full adaptive DCC evaluation (steps 1–5 of clause 5.4).

Parameters:
  • cbr_local (float) – Most recent local CBR measurement (CBR_L_0_Hop).

  • cbr_local_previous (float) – Second most recent local CBR measurement (CBR_L_0_Hop_Previous).

  • cbr_global (float or None, optional) – Most recent global CBR (CBR_G), received from a neighbouring ITS-S via GeoNetworking header as described in the NOTE of clause 5.4. When provided, replaces the local value in step 1.

  • cbr_global_previous (float or None, optional) – Second most recent global CBR (CBR_G_Previous). When provided together with cbr_global, replaces the previous local value in step 1.

Returns:

Updated delta value after clamping.

Return type:

float

Raises:

ValueError – If any CBR argument is outside [0.0, 1.0].

class flexstack.management.dcc_adaptive.GateKeeper(delta)[source]

Bases: object

Packet admission gate keeper as described in ETSI TS 102 687 V1.2.1 (2018-04) Annex B.

The gate keeper controls which packets may pass from the Network & Transport layer to the Access layer queue. The gate is open when the Access layer will accept a new packet and closed otherwise.

Lifecycle

  1. A packet arrives at the gate. If the gate is open the packet is admitted: the gate closes and a gate-opening time t_go is scheduled using equation B.1.

  2. From time t_go onward the gate is open again.

  3. Whenever delta is updated by the adaptive algorithm, t_go is recalculated per equation B.2 to preserve relative ordering of gate openings without introducing synchronisation artefacts.

The minimum inter-admission interval is 25 ms and the maximum is 1 s (both from the constraints in ETSI EN 302 571 referenced in Annex B).

param delta:

Initial duty-cycle fraction value obtained from DccAdaptive.

type delta:

float

ivar GATE_OPEN_MIN_INTERVAL_S:

Minimum allowed gate-open interval in seconds (25 ms).

vartype GATE_OPEN_MIN_INTERVAL_S:

float

ivar GATE_OPEN_MAX_INTERVAL_S:

Maximum allowed gate-open interval in seconds (1 s).

vartype GATE_OPEN_MAX_INTERVAL_S:

float

Examples

>>> gk = GateKeeper(delta=0.01)
>>> gk.is_open(t=0.0)
True
>>> admitted = gk.admit_packet(t=0.0, t_on=0.001)
>>> admitted
True
>>> gk.is_open(t=0.0)
False
>>> gk.is_open(t=0.1)
True
GATE_OPEN_MIN_INTERVAL_S: float = 0.025
GATE_OPEN_MAX_INTERVAL_S: float = 1.0
__init__(delta)[source]

Initialise the gate keeper with an initial delta value.

Parameters:

delta (float) – Duty-cycle fraction from the adaptive DCC algorithm.

Return type:

None

is_open(t)[source]

Return True if the gate is currently open at time t.

The gate is open on first use (before any packet has been admitted) and from t_go onward after each admission.

Parameters:

t (float) – Current time in seconds.

Returns:

True if a packet may be admitted, False otherwise.

Return type:

bool

admit_packet(t, t_on)[source]

Attempt to admit one packet at time t.

If the gate is open the packet is accepted, the gate closes, and the next gate-opening time is scheduled per equation B.1:

\[t_{go} = t_{pg} + \min\!\left(\max\!\left( \frac{T_{on\_pp}}{\delta}, 0.025 \right), 1 \right)\]
Parameters:
  • t (float) – Current time in seconds.

  • t_on (float) – Transmission duration of this packet in seconds (T_on_pp in Annex B).

Returns:

True if the packet was admitted; False if the gate was closed and the packet is rejected.

Return type:

bool

Raises:

ValueError – If t_on is not positive.

update_delta(t, delta_new)[source]

Update the duty-cycle fraction and reschedule the gate-opening time.

When delta changes, the gate-opening time is recalculated per equation B.2 to avoid synchronising gate openings across stations:

\[t_{go} = t_{pg} + \min\!\left(\max\!\left( \frac{\delta_{old}}{\delta_{new}} \cdot (t_{go} - t_{pg}), 0.025 \right), 1 \right)\]

If the gate is currently open (no packet has been admitted yet, or t_go has already passed) only delta is updated.

Parameters:
  • t (float) – Current time in seconds (used to determine whether the gate is still closed).

  • delta_new (float) – Updated duty-cycle fraction from the adaptive DCC algorithm.

Raises:

ValueError – If delta_new is not positive.

Return type:

None

Parameters:

delta (float) –

Reactive Decentralized Congestion Control algorithm.

Implements the reactive approach specified in ETSI TS 102 687 V1.2.1 (2018-04) clause 5.3 and Annex A.

The algorithm consists of five states (Relaxed, Active 1, Active 2, Active 3, Restrictive) arranged in a linear sequence. On each evaluation the state may advance at most one step toward the state dictated by the current CBR, which enforces the “one state can only be reached by a neighbouring state” requirement from clause 5.3. Each state maps directly to a maximum allowed packet rate and a minimum inter-packet gap (T_off).

Two parameter tables are defined in Annex A depending on the assumed maximum packet transmission duration (T_on):

  • Table A.1 – used when T_on is at most 1 ms

  • Table A.2 – used when T_on is at most 500 µs

class flexstack.management.dcc_reactive.DccState(value, names=<not given>, *values, module=None, qualname=None, type=None, start=1, boundary=None)[source]

Bases: Enum

Ordered states of the reactive DCC algorithm.

As specified in ETSI TS 102 687 V1.2.1 (2018-04) clause 5.3.

Variables:
  • (0) (RELAXED) – Lowest utilisation state. Fewest restrictions on transmissions.

  • (1) (ACTIVE_1) – First active state. Moderate CBR detected.

  • (2) (ACTIVE_2) – Second active state. Elevated CBR detected.

  • (3) (ACTIVE_3) – Third active state. High CBR detected.

  • (4) (RESTRICTIVE) – Most stringent state. Very high CBR detected.

RELAXED = 0
ACTIVE_1 = 1
ACTIVE_2 = 2
ACTIVE_3 = 3
RESTRICTIVE = 4
class flexstack.management.dcc_reactive.DccStateConfig(cbr_min, cbr_max, packet_rate_hz, t_off_ms)[source]

Bases: object

Channel Busy Ratio thresholds and output parameters for a single state.

As specified in ETSI TS 102 687 V1.2.1 (2018-04) Annex A, Tables A.1 and A.2.

Variables:
  • cbr_min (float) – Inclusive lower CBR bound for this state (0.0 for Relaxed).

  • cbr_max (float) – Exclusive upper CBR bound for this state (1.0 for Restrictive).

  • packet_rate_hz (float) – Maximum allowed packet transmission rate in packets per second.

  • t_off_ms (float) – Minimum required inter-packet gap in milliseconds.

Parameters:
  • cbr_min (float) –

  • cbr_max (float) –

  • packet_rate_hz (float) –

  • t_off_ms (float) –

cbr_min: float
cbr_max: float
packet_rate_hz: float
t_off_ms: float
class flexstack.management.dcc_reactive.DccReactiveOutput(state, packet_rate_hz, t_off_ms)[source]

Bases: object

Output produced by a single reactive DCC evaluation.

Variables:
  • state (DccState) – Current DCC state after the evaluation.

  • packet_rate_hz (float) – Maximum allowed packet transmission rate in packets per second.

  • t_off_ms (float) – Minimum required inter-packet gap in milliseconds (T_off).

Parameters:
  • state (DccState) –

  • packet_rate_hz (float) –

  • t_off_ms (float) –

state: DccState
packet_rate_hz: float
t_off_ms: float
class flexstack.management.dcc_reactive.DccReactive(t_on_max_us=1000)[source]

Bases: object

Reactive DCC algorithm as specified in ETSI TS 102 687 V1.2.1 (2018-04) clause 5.3 and Annex A.

The algorithm is evaluated periodically (at least every 200 ms, per clause 5.2) by calling update() with the most recently measured Channel Busy Ratio (CBR). On each call the state may advance by at most one step toward the state inferred from the CBR table, enforcing the adjacency constraint of clause 5.3.

Parameters:

t_on_max_us (int) – Assumed maximum packet transmission duration in microseconds. When this value is at most 500 the parameter table from Annex A Table A.2 is used; otherwise Table A.1 is used. Defaults to 1000 (1 ms), which selects Table A.1.

Variables:

state (DccState) – Current algorithm state. Starts at DccState.RELAXED.

Examples

>>> dcc = DccReactive()
>>> out = dcc.update(cbr=0.35)
>>> out.state
<DccState.ACTIVE_1: 1>
>>> out.packet_rate_hz
5.0
__init__(t_on_max_us=1000)[source]

Initialise the reactive DCC algorithm.

Parameters:

t_on_max_us (int, optional) – Maximum packet transmission duration in microseconds. Values ≤ 500 select Annex A Table A.2; all other values select Table A.1. Defaults to 1000.

Return type:

None

update(cbr)[source]

Evaluate the algorithm with the current Channel Busy Ratio.

The state advances by at most one step toward the state implied by cbr, satisfying the adjacency constraint from clause 5.3.

Parameters:

cbr (float) – Current Channel Busy Ratio value in the range [0.0, 1.0].

Returns:

Updated state together with the corresponding transmission constraints (maximum packet rate and minimum T_off).

Return type:

DccReactiveOutput

Raises:

ValueError – If cbr is outside the range [0.0, 1.0].