Traffic actions¶
Traffic actions allow certain predefined operations to be applied to incoming or outgoing packets that are matched by some traffic filter. An example of such an operation is rate policing.
Although traffic actions may exist as standalone objects in the kernel, they must be associated with a traffic filter in order to take effect.
A traffic action is of a certain action kind; police is such an
action kind (the terminology action kind is specific to this package).
Traffic actions are identified by an action index; this index
is per action kind.
This package provides Python classes that correspond to traffic action kinds.
They are implemented as subclasses of the TrafficAction class.
An instance of a TrafficAction subclass
can be created and added to a TrafficFilter instance
before the filter is instantiated.
Traffic actions can be shared. This is implemented by creating
an instance of a TrafficAction subclass and specifying
the action index of an existing action (of the same kind).
Standalone traffic actions are not currently supported.
The linuxnet.qos package supports the following traffic action classes:
Certain classes provide functionality common to all traffic actions.
- class ActionDecision(value)¶
List of decisions for tc(8) actions (see tc-actions(8)); these are also referred-to as controls.
- RECLASSIFY = 'reclassify'¶
Reclassify packet
- PIPE = 'pipe'¶
Pass packet to next action
- DROP = 'drop'¶
Drop packet
- CONTINUE = 'continue'¶
Pass packet to next filter
- PASS = 'pass'¶
End packet classification (packet returned to queuing discipline/class)
- classmethod create_from_string(decision_str: str) ActionDecision¶
Convert from a string to an
ActionDecisionmember.- Parameters:
decision_str – the string representation of
ActionDecisionmember.- Return type:
a
ActionDecisionmember
Raises a
ValueErrorif no match is found.
Traffic actions support statistics. These statistics are collected
in ActionStats instances which are returned from the
TrafficAction.get_stats() method.
- class ActionStats¶
An
ActionStatsinstance holds statistics for a traffic action.- property bytes_sent: int¶
Number of bytes sent.
- property packets_sent: int¶
Number of packets sent.
- property dropped_packets: int¶
Number of packets dropped.
- property requeued_packets: int¶
Number of packets that were requeued for some reason.
- property overlimits: int¶
Number of times a packet was delayed due to rate limits.
- get_byte_backlog() int¶
Backlog in bytes
- get_packet_backlog() int¶
Backlog in packets