tg_node - Traffic Generator Node
Traffic generator node.
A traffic generator (TG) generates traffic that’s sent towards the SUT node. A TG node is where the TG runs.
- class TGNode
Bases:
Node
The traffic generator node.
The TG node extends
Node
with TG specific features:Traffic generator initialization,
The sending of traffic and receiving packets,
The sending of traffic without receiving packets.
Not all traffic generators are capable of capturing traffic, which is why there must be a way to send traffic without that.
- traffic_generator
The traffic generator running on the node.
- __init__(node_config: TGNodeConfiguration)
Extend the constructor with TG node specifics.
Initialize the traffic generator on the TG node.
- Parameters:
node_config (TGNodeConfiguration) – The TG node’s test run configuration.
- send_packets_and_capture(packets: list[scapy.packet.Packet], send_port: Port, receive_port: Port, filter_config: PacketFilteringConfig = PacketFilteringConfig(no_lldp=True, no_arp=True), duration: float = 1) list[scapy.packet.Packet]
Send packets, return received traffic.
Send packets on send_port and then return all traffic captured on receive_port for the given duration. Also record the captured traffic in a pcap file.
- Parameters:
packets (list[scapy.packet.Packet]) – The packets to send.
send_port (Port) – The egress port on the TG node.
receive_port (Port) – The ingress port in the TG node.
filter_config (PacketFilteringConfig) – The filter to use when capturing packets.
duration (float) – Capture traffic for this amount of time after sending packet.
- Returns:
A list of received packets. May be empty if no packets are captured.
- Return type:
list[scapy.packet.Packet]
- send_packets(packets: list[scapy.packet.Packet], port: Port)
Send packets without capturing resulting received packets.
- Parameters:
packets (list[scapy.packet.Packet]) – Packets to send.
port (Port) – Port to send the packets on.
- close() None
Free all resources used by the node.
This extends the superclass method with TG cleanup.