LIBIPERF(3)
β¨ NAME β¨
libiperf β the API for the iperf3 network throughput tester π¦
okay so real talk, this is the manual page for LIBIPERF, section 3 (that's the library-calls section, iykyk). It lives in the User Manuals shelf and it's your all-access pass to the guts of iperf3 without ever touching a shell. π
π SYNOPSIS π
#include <iperf_api.h>
-liperf
Like, that's it. Include the header, link the library, go be iconic. π
π DESCRIPTION π
Libiperf hands you every single bit of the functionality of the iperf3 network testing tool. No cap. π«Ά
The whole point? You can build it directly into your own program instead of having to run it as a shell command. That's the vibe β iperf3 energy, but it's your code now. π
πΈ CALLS πΈ
π£ Initialization / termination
struct iperf_test *iperf_new_test();β makes you a fresh test object, blank canvas energy π¨int iperf_defaults(struct iperf_test *t);β fills in the defaults so you're not starting from zerovoid iperf_free_test(struct iperf_test *t);β cleanup time bestie, free the whole thing π§Ή
ποΈ Setting test parameters
void iperf_set_test_role( struct iperf_test *pt, char role );β are we clienting or servering today?void iperf_set_test_bind_address( struct iperf_test *t, char *bind_address );β pin it to a bind addressvoid iperf_set_test_bind_dev( struct iperf_test *t, char *bind_dev );β or pin it to a bind devicevoid iperf_set_test_server_hostname( struct iperf_test *t, char *server_host );β where's the server at πΊοΈvoid iperf_set_test_server_port( struct iperf_test *t, int server_port );β which port thovoid iperf_set_test_duration( struct iperf_test *t, int duration );β how long we running thisvoid iperf_set_test_blksize( struct iperf_test *t, int blksize );β block size, the classicvoid iperf_set_test_num_streams( struct iperf_test *t, int num_streams );β how many streams, go offvoid iperf_set_test_json_output( struct iperf_test *t, int json_output );β JSON output toggle β¨void iperf_set_test_json_stream( struct iperf_test *t, int json_stream );β and the streaming JSON toggleint iperf_has_zerocopy( void );β does this build even have zerocopy? vibe check πvoid iperf_set_test_zerocopy( struct iperf_test* t, int zerocopy );β turn zerocopy on/offvoid iperf_set_test_tos( struct iperf_test* t, int tos );β set the TOS
π Authentication functions
void iperf_set_test_client_username(struct iperf_test *ipt, char *client_username)β the username, bestievoid iperf_set_test_client_password(struct iperf_test *ipt, char *client_password)β the password π€«void iperf_set_test_client_rsa_pubkey(struct iperf_test *ipt, char *client_rsa_pubkey_base64)β the RSA public key, base64 flavored
π Running a test
int iperf_run_client(struct iperf_test *);β run the clientint iperf_run_server(struct iperf_test *);β run the servervoid iperf_reset_test(struct iperf_test *);β reset it and run it again, main character energy π
π€ Output
FILE *iperf_get_test_outfile(struct iperf_test *);β grab the output file handlechar* iperf_get_test_json_output_string(struct iperf_test *);β grab the JSON output as a string π
π¨ Error reporting
void iperf_err(struct iperf_test *t, const char *format, ...);β report an error, varargs stylechar *iperf_strerror(int);β turn an error number into a human stringextern int i_errno;β the global errno, she's right there
Heads up: this is not a complete list of the available calls. See the include file for more. π
π EXAMPLES π
Okay here's some sample code that runs an iperf client:
struct iperf_test *test;
test = iperf_new_test();
if ( test == NULL ) {
fprintf( stderr, "%s: failed to create test0, argv0 );
exit( EXIT_FAILURE );
}
iperf_defaults( test );
iperf_set_test_role( test, 'c' );
iperf_set_test_server_hostname( test, host );
iperf_set_test_server_port( test, port );
if ( iperf_run_client( test ) < 0 ) {
fprintf( stderr, "%s: error - %s0, argv0, iperf_strerror( i_errno ) );
exit( EXIT_FAILURE );
}
iperf_free_test( test );
And here's a server:
struct iperf_test *test;
test = iperf_new_test();
if ( test == NULL ) {
fprintf( stderr, "%s: failed to create test0, argv0 );
exit( EXIT_FAILURE );
}
iperf_defaults( test );
iperf_set_test_role( test, 's' );
iperf_set_test_server_port( test, port );
for (;;) {
if ( iperf_run_server( test ) < 0 )
fprintf( stderr, "%s: error - %s0, argv0, iperf_strerror( i_errn
o ) );
iperf_reset_test( test );
}
iperf_free_test( test );
π«§ These are not complete programs, just excerpts. The full runnable source code can be found in the examples subdirectory of the iperf3 source tree.
π AUTHORS π
A list of the contributors to iperf3 can be found within the documentation located at https://software.es.net/iperf/dev.html#authors.
β SEE ALSO β
and that's the whole page bestie, slay π
This was brought to you by ESnet, dated May 2024, and it's the LIBIPERF(3) manual page β periodt. πβ¨
π¦ where this page comes from
- arch rolling: iperf3 3.22-1 Β· BSD-3-Clause
- centos-stream 10: iperf3 3.21-2.el10 Β· BSD-3-Clause-LBNL AND MIT AND dtoa AND BSD-3-Clause AND NCSA AND LicenseRef-Fedora-Public-Domain
- fedora 43: iperf3 3.22-2.fc43 Β· BSD-3-Clause-LBNL AND MIT AND dtoa AND BSD-3-Clause AND NCSA AND LicenseRef-Fedora-Public-Domain
- fedora 43: iperf3 3.22-2.fc43 Β· BSD-3-Clause-LBNL AND MIT AND dtoa AND BSD-3-Clause AND NCSA AND LicenseRef-Fedora-Public-Domain
- fedora 44: iperf3 3.22-1.fc44 Β· BSD-3-Clause-LBNL AND MIT AND dtoa AND BSD-3-Clause AND NCSA AND LicenseRef-Fedora-Public-Domain
- fedora 44: iperf3 3.22-1.fc44 Β· BSD-3-Clause-LBNL AND MIT AND dtoa AND BSD-3-Clause AND NCSA AND LicenseRef-Fedora-Public-Domain
- nixpkgs unstable: iperf 3.21
- opensuse-leap 16.0: iperf-devel 3.21-160000.1.1 Β· BSD-3-Clause
- opensuse-leap 16.0: iperf-devel 3.21-160000.1.1 Β· BSD-3-Clause
- opensuse-leap 16.0: iperf-devel 3.21-160000.1.1 Β· BSD-3-Clause
- opensuse-leap 16.0: iperf-devel 3.21-160000.1.1 Β· BSD-3-Clause
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms