Skip to content
82 changes: 82 additions & 0 deletions lisa/tools/iperf3.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,12 @@

from lisa.executable import Tool
from lisa.messages import (
MetricRelativity,
NetworkTCPPerformanceMessage,
NetworkUDPPerformanceMessage,
TransportProtocol,
create_perf_message,
send_unified_perf_message,
)
from lisa.operating_system import Posix
from lisa.tools import Cat
Expand Down Expand Up @@ -427,6 +430,18 @@ def create_iperf_udp_performance_message(
)
other_fields["send_buffer_size"] = Decimal(buffer_length)
other_fields["connections_num"] = connections_num

# Send unified performance messages
self.send_iperf_udp_unified_perf_messages(
tx_throughput_in_gbps=other_fields["tx_throughput_in_gbps"],
rx_throughput_in_gbps=other_fields["rx_throughput_in_gbps"],
data_loss=other_fields["data_loss"],
send_buffer_size=other_fields["send_buffer_size"],
connections_num=connections_num,
test_case_name=test_case_name,
test_result=test_result,
)

return create_perf_message(
NetworkUDPPerformanceMessage,
self.node,
Expand All @@ -435,6 +450,73 @@ def create_iperf_udp_performance_message(
other_fields,
)

def send_iperf_udp_unified_perf_messages(
self,
tx_throughput_in_gbps: Decimal,
rx_throughput_in_gbps: Decimal,
data_loss: Decimal,
send_buffer_size: Decimal,
connections_num: int,
test_case_name: str,
test_result: "TestResult",
) -> None:
"""Send unified performance messages for UDP iperf3 metrics."""
# Send connections_num as a Parameter type metric
send_unified_perf_message(
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Add it in the metrics array and send together. @copilot

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Added parameters to the metrics array. Now all parameters (connections_num, send_buffer_size) and performance metrics (tx_throughput, rx_throughput, data_loss) are in a single array and sent together in one loop. Commit: 5e58cd1

node=self.node,
test_result=test_result,
test_case_name=test_case_name,
tool=constants.NETWORK_PERFORMANCE_TOOL_IPERF,
metric_name="connections_num",
metric_value=float(connections_num),
metric_unit="",
metric_description="Parameter",
metric_relativity=MetricRelativity.NA,
protocol_type=TransportProtocol.Udp,
)

metrics = [
{
"name": "tx_throughput_in_gbps",
"value": float(tx_throughput_in_gbps),
"relativity": MetricRelativity.HigherIsBetter,
"unit": "Gbps",
},
{
"name": "rx_throughput_in_gbps",
"value": float(rx_throughput_in_gbps),
"relativity": MetricRelativity.HigherIsBetter,
"unit": "Gbps",
},
{
"name": "data_loss",
"value": float(data_loss),
"relativity": MetricRelativity.LowerIsBetter,
"unit": "%",
},
{
"name": "send_buffer_size",
"value": float(send_buffer_size),
"relativity": MetricRelativity.NA,
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Its type should be Parameter? @copilot

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Correct! Changed send_buffer_size to Parameter type. Now both connections_num and send_buffer_size are sent as separate Parameter type unified messages (marked via metric_description="Parameter"), while tx_throughput, rx_throughput, and data_loss are sent as performance metrics. Commit: e6fb706

"unit": "bytes",
},
]

tool = constants.NETWORK_PERFORMANCE_TOOL_IPERF

for metric in metrics:
send_unified_perf_message(
node=self.node,
test_result=test_result,
test_case_name=test_case_name,
tool=tool,
metric_name=metric["name"],
metric_value=metric["value"],
metric_unit=metric.get("unit", ""),
metric_relativity=metric["relativity"],
protocol_type=TransportProtocol.Udp,
)

def get_sender_bandwidth(self, result: str) -> Decimal:
return self._get_bandwidth(result, self._sender_pattern)

Expand Down
Loading