Skip to content

Commit 0ca2633

Browse files
tools: run netperf server/client with specific IP
Add support to run netperf server/client with specific IP. Signed-off-by: Smit Gardhariya <[email protected]>
1 parent 8a0e6a4 commit 0ca2633

File tree

1 file changed

+15
-3
lines changed

1 file changed

+15
-3
lines changed

lisa/tools/netperf.py

Lines changed: 15 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -31,10 +31,17 @@ def can_install(self) -> bool:
3131
def dependencies(self) -> List[Type[Tool]]:
3232
return [Gcc, Git, Make, Texinfo]
3333

34-
def run_as_server(self, port: int = 30000, daemon: bool = True) -> None:
34+
def run_as_server(
35+
self,
36+
port: int = 30000,
37+
daemon: bool = True,
38+
interface_ip: str = "",
39+
) -> None:
3540
cmd = f"netserver -p {port} "
3641
if not daemon:
3742
cmd += " -D "
43+
if interface_ip:
44+
cmd += f" -L {interface_ip}"
3845
self.node.execute(
3946
cmd,
4047
sudo=True,
@@ -50,9 +57,11 @@ def run_as_client_async(
5057
test_name: str = "TCP_RR",
5158
seconds: int = 150,
5259
time_unit: int = 1,
60+
interface_ip: str = "",
5361
send_recv_offset: str = "THROUGHPUT, THROUGHPUT_UNITS, MIN_LATENCY, MAX_LATENCY, MEAN_LATENCY, REQUEST_SIZE, RESPONSE_SIZE, STDDEV_LATENCY", # noqa: E501
5462
) -> Process:
5563
# -H: Specify the target machine and/or local ip and family
64+
# -L: Specify the IP for client interface to be used
5665
# -p: Specify netserver port number and/or local port
5766
# -t: Specify test to perform
5867
# -n: Set the number of processors for CPU util
@@ -61,8 +70,11 @@ def run_as_client_async(
6170
# initial guess for units per second. A negative value for time will make
6271
# heavy use of the system's timestamping functionality
6372
# -O: Set the remote send,recv buffer offset
64-
cmd = (
65-
f"-H {server_ip} -p {port} -t {test_name} -n {core_count} -l {seconds}"
73+
cmd: str = ""
74+
if interface_ip:
75+
cmd += f" -L {interface_ip}"
76+
cmd += (
77+
f" -H {server_ip} -p {port} -t {test_name} -n {core_count} -l {seconds}"
6678
f" -D {time_unit} -- -O '{send_recv_offset}'"
6779
)
6880
process = self.node.execute_async(f"{self.command} {cmd}", sudo=True)

0 commit comments

Comments
 (0)