HTB¶
The following classes provide access to the htb
(Hierarchy Token Bucket) queueing discipline and
its statistics:
- class HTBQDisc(qdisc_handle: Handle, parent_handle: Optional[Handle], *, default_class_minor: Optional[int] = None, r2q: Optional[int] = None)[source]¶
This class provides access to the Hierarchy Token Bucket queueing discipline of Linux (see tc-htb(8)).
- Parameters:
qdisc_handle – handle of this queuing discipline
parent_handle – handle of parent,
Noneif this is a root queuing disciplinedefault_class_minor – minor number of default class
r2q – when a queuing class of this queuing discipline has not an explicitly specified quantaum, its quantum is computed as
rate/r2q
- get_description() str[source]¶
Returns a string describing the queuing discipline and its attributes
- create_filter(traffic_filter: TrafficFilter) None¶
Create the filter
traffic_filter.
- delete_filter(traffic_filter: TrafficFilter) None¶
Delete the filter
traffic_filter.
- dump(outfile: TextIO, level=0, qclass_map: Optional[Mapping[Handle, QClass]] = None)¶
Recursively dump this
Qdisctooutfile.The
qclass_map, if present, is used to determine the destinationQClassobjects of traffic filters.
- get_child_count() int¶
Return number of children of this
QDisc/QClass
- get_child_iter() Iterator[QClass]¶
Returns an iterator for the
QClasschildren of thisQDisc/QClass.
- get_config() QDiscConfig¶
Returns the
QDiscConfigwhere thisQDisc/QClasshas been instantiated, orNoneif not instantiated.
- get_filters(refresh=False) List[TrafficFilter]¶
Returns (a copy of) the list of filters at this
QDisc/QClass- Parameters:
refresh – if
True, a fresh copy of the filter list is obtained using the tc(8) command.
- get_handle() Handle¶
Returns the
QDisc/QClasshandle
- get_interface() Optional[str]¶
Returns the interface where this
QDisc/QClasshas been instantiated, orNoneif theQDisc/QClassis not instantiated.
- get_parent_handle() Optional[Handle]¶
Returns the handle of the parent of this
QDisc/QClass
- is_default() bool¶
Returns
Trueif thisQDiscis the default qdisc used by the kernel.
- static is_ingress() bool¶
Returns
Trueif thisQDiscis the ingress qdisc
- is_root() bool¶
Returns
Trueif this is a rootQDisc
- class HTBQClass(class_handle: Handle, parent_handle: Handle, *, rate: int, ceil: Optional[int] = None, prio: Optional[int] = None, burst: Optional[int] = None, cburst: Optional[int] = None, quantum: Optional[int] = None, class_name: Optional[str] = None)[source]¶
A class of the HTB qdisc
- Parameters:
class_handle – handle of this
HTBQClassrate – guaranteed rate (unit: bits/sec)
ceil – max rate (unit: bits/sec)
prio – priority
burst – amount of bytes that can be sent at
ceilspeedcburst – amount of bytes that can be sent at interface speed
quantum – transmission quantum (aka interface packet size) in bytes; the kernel computes this from the HTB queuing discipline
r2qif not explicitly specified at HTB class creation time
- get_priority() int[source]¶
Returns the class priority, or -1 if the class has no priority specified
- get_residual_rate() int[source]¶
Returns the residual rate, which is the guaranteed bandwidth left at this class after all its children have been allocated their guaranteed bandwidth.
- get_stats() Optional[HTBQClassStats][source]¶
Returns class stats (an
HTBQClassStatsinstance) orNoneif no stats are available.
- child_admission_check(new_child_class: HTBQClass) None[source]¶
Perform sanity tests before adding a child class:
child is an
HTBQClasschild ceil <= parent ceil
aggr children rate <= parent rate
Raises a
TcBandwidthErrorif the check fails
- create_filter(traffic_filter: TrafficFilter) None¶
Create the filter
traffic_filter.
- delete_filter(traffic_filter: TrafficFilter) None¶
Delete the filter
traffic_filter.
- dump(outfile: TextIO, level: int, qclass_map: Optional[Mapping[Handle, QClass]] = None)¶
Recursively dump this
QClasstooutfile.The
qclass_map, if present, is used to determine the destinationQClassobjects of traffic filters.
- get_child_count() int¶
Return number of children of this
QDisc/QClass
- get_child_iter() Iterator[QClass]¶
Returns an iterator for the
QClasschildren of thisQDisc/QClass.
- get_class_name() str¶
Returns the class name
- get_config() QDiscConfig¶
Returns the
QDiscConfigwhere thisQDisc/QClasshas been instantiated, orNoneif not instantiated.
- get_filters(refresh=False) List[TrafficFilter]¶
Returns (a copy of) the list of filters at this
QDisc/QClass- Parameters:
refresh – if
True, a fresh copy of the filter list is obtained using the tc(8) command.
- get_handle() Handle¶
Returns the
QDisc/QClasshandle
- get_interface() Optional[str]¶
Returns the interface where this
QDisc/QClasshas been instantiated, orNoneif theQDisc/QClassis not instantiated.
- get_parent_handle() Optional[Handle]¶
Returns the handle of the parent of this
QDisc/QClass
- get_qdisc() Optional[QDisc]¶
Returns the
QDiscunder thisQClass; returnsNoneif there is noQDisc, or if this is not a leaf queuing class
- is_leaf() bool¶
Returns
Trueif this is a leaf queuing class
- set_class_name(class_name: str) None¶
Sets the class name
- class HTBQClassStats[source]¶
Bases:
QStatsHTB-specific class stats (see
QStatsfor inherited stats)- property packets_lent: int¶
Number of packets lent.
- property packets_borrowed: int¶
Number of packets borrowed.
- property overlimits: int¶
Number of times a rate limit was exceeded.
- property giant_packets: int¶
Number of packets exceeding interface MTU
- property tokens: int¶
Tokens available for transmitting at the guaranteed rate (measured in packet scheduler ticks).
This value is not a statistic; it reflects the class state at the time the stats were obtained.
- property ctokens: int¶
Tokens available for transmitting at the maximum (ceil) rate (measured in packet scheduler ticks)
This value is not a statistic; it reflects the class state at the time the stats were obtained.
- dump(outfile: TextIO, width: Optional[int] = None) None[source]¶
Dump stats to
outfile. There is one stat per line output. Each line has the format:header: value
The
header:part occupies at leastwidthcharacters.
- property bitrate: int¶
Consumed bandwidth measured in bits/sec
- property bytes_sent: int¶
Number of bytes sent.
- property dropped_packets: int¶
Number of packets dropped.
- get_byte_backlog() int¶
Queue backlog in bytes
- get_overlimits() int¶
Number of times a packet was delayed due to rate limits.
- get_packet_backlog() int¶
Queue backlog in packets
- property packetrate: int¶
Consumed bandwidth measured in packets/sec
- property packets_sent: int¶
Number of packets sent.
- property requeued_packets: int¶
Number of packets that were requeued for some reason.