Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions examples/client.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,12 @@
client.duration = 1
client.server_hostname = '127.0.0.1'
client.port = 5201
client.congestion_control = "bbr"
client.extra_data = "test data"

print('Connecting to {0}:{1}'.format(client.server_hostname, client.port))
result = client.run()
print(result)

if result.error:
print(result.error)
Expand Down
42 changes: 42 additions & 0 deletions iperf3/iperf3.py
Original file line number Diff line number Diff line change
Expand Up @@ -186,6 +186,14 @@ def __init__(self,
self.lib.iperf_run_server.argtypes = (c_void_p,)
self.lib.iperf_reset_test.restype = None
self.lib.iperf_reset_test.argtypes = (c_void_p,)
self.lib.iperf_get_test_congestion_control.restype = c_char_p
self.lib.iperf_get_test_congestion_control.argtypes = (c_void_p,)
self.lib.iperf_set_test_congestion_control.restype = None
self.lib.iperf_set_test_congestion_control.argtypes = (c_void_p, c_char_p)
self.lib.iperf_get_test_extra_data.restype = c_char_p
self.lib.iperf_get_test_extra_data.argtypes = (c_void_p,)
self.lib.iperf_set_test_extra_data.restype = None
self.lib.iperf_set_test_extra_data.argtypes = (c_void_p, c_char_p)

try:
# Only available from iperf v3.1 and onwards
Expand Down Expand Up @@ -606,6 +614,40 @@ def reverse(self, enabled):

self._reverse = enabled

@property
def congestion_control(self):
"""Enables different TCP congestion control algorithms

:rtype: String
"""
self._congestion_control = self.lib.iperf_get_test_congestion_control(self._test)
return self._congestion_control

@congestion_control.setter
def congestion_control(self, cc: str):
self.lib.iperf_set_test_congestion_control(
self._test,
c_char_p(cc.encode('utf-8'))
)
self._congestion_control = cc

@property
def extra_data(self):
"""Enables extra-data String field to be included in json output

:rtype: String
"""
self._extra_data = self.lib.iperf_get_test_extra_data(self._test)
return self._extra_data

@extra_data.setter
def extra_data(self, dat: str):
self.lib.iperf_set_test_extra_data(
self._test,
c_char_p(dat.encode('utf-8'))
)
self._extra_data = dat

def run(self):
"""Run the current test client.

Expand Down