traffic_generator - Base TG ABC
The base traffic generator.
These traffic generators can’t capture received traffic, only count the number of received packets.
- class TrafficGenerator
Bases:
ABCThe base traffic generator.
Exposes the common public methods of all traffic generators and defines private methods that must implement the traffic generation logic in subclasses. This class also extends from
framework.utils.MultiInheritanceBaseClassto allow subclasses the ability to inherit from multiple classes to fulfil the traffic generating functionality without breaking single inheritance.- __init__(tg_node: Node, config: TrafficGeneratorConfig, **kwargs: Any) None
Initialize the traffic generator.
Additional keyword arguments can be passed through kwargs if needed for fulfilling other constructors in the case of multiple inheritance.
- Parameters:
tg_node (Node) – The traffic generator node where the created traffic generator will be running.
config (TrafficGeneratorConfig) – The traffic generator’s test run configuration.
**kwargs (Any) – Any additional arguments if any.
- send_packets(packets: list[scapy.packet.Packet], port: Port) None
Send packets and block until they are fully sent.
Send packets on port, then wait until packets are fully sent.
- Parameters:
packets (list[scapy.packet.Packet]) – The packets to send.
port (Port) – The egress port on the TG node.
- setup(topology: Topology) None
Setup the traffic generator.
- teardown() None
Teardown the traffic generator.
- property is_capturing: bool
This traffic generator can’t capture traffic.
- abstract close() None
Free all resources used by the traffic generator.
- property is_setup: bool
Indicates whether the traffic generator application is currently running.