MCPcopy Create free account
hub / github.com/F-Stack/f-stack / TGNode

Class TGNode

dpdk/dts/framework/testbed_model/tg_node.py:31–80  ·  view source on GitHub ↗

Manage connections to a node with a traffic generator. Apart from basic node management capabilities, the Traffic Generator node has specialized methods for handling the traffic generator running on it. Arguments: node_config: The user configuration of the traffic generator nod

Source from the content-addressed store, hash-verified

29
30
31class TGNode(Node):
32 """Manage connections to a node with a traffic generator.
33
34 Apart from basic node management capabilities, the Traffic Generator node has
35 specialized methods for handling the traffic generator running on it.
36
37 Arguments:
38 node_config: The user configuration of the traffic generator node.
39
40 Attributes:
41 traffic_generator: The traffic generator running on the node.
42 """
43
44 traffic_generator: CapturingTrafficGenerator
45
46 def __init__(self, node_config: TGNodeConfiguration):
47 super(TGNode, self).__init__(node_config)
48 self.traffic_generator = create_traffic_generator(self, node_config.traffic_generator)
49 self._logger.info(f"Created node: {self.name}")
50
51 def send_packet_and_capture(
52 self,
53 packet: Packet,
54 send_port: Port,
55 receive_port: Port,
56 duration: float = 1,
57 ) -> list[Packet]:
58 """Send a packet, return received traffic.
59
60 Send a packet on the send_port and then return all traffic captured
61 on the receive_port for the given duration. Also record the captured traffic
62 in a pcap file.
63
64 Args:
65 packet: The packet to send.
66 send_port: The egress port on the TG node.
67 receive_port: The ingress port in the TG node.
68 duration: Capture traffic for this amount of time after sending the packet.
69
70 Returns:
71 A list of received packets. May be empty if no packets are captured.
72 """
73 return self.traffic_generator.send_packet_and_capture(
74 packet, send_port, receive_port, duration
75 )
76
77 def close(self) -> None:
78 """Free all resources used by the node"""
79 self.traffic_generator.close()
80 super(TGNode, self).close()
81
82
83def create_traffic_generator(

Callers 1

run_allFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected