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:
MultiInheritanceBaseClass
,ABC
The 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.MultiInheritanceBaseClass
to 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)
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.
- send_packet(packet: scapy.packet.Packet, port: Port) None
Send packet and block until it is fully sent.
Send packet on port, then wait until packet is fully sent.
- Parameters:
packet (scapy.packet.Packet) – The packet to send.
port (Port) – The egress port on the TG node.
- 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.
- property is_capturing: bool
This traffic generator can’t capture traffic.
- abstract close() None
Free all resources used by the traffic generator.