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 zero
  • void 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 address
  • void iperf_set_test_bind_dev( struct iperf_test *t, char *bind_dev ); β€” or pin it to a bind device
  • void 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 tho
  • void iperf_set_test_duration( struct iperf_test *t, int duration ); β€” how long we running this
  • void iperf_set_test_blksize( struct iperf_test *t, int blksize ); β€” block size, the classic
  • void iperf_set_test_num_streams( struct iperf_test *t, int num_streams ); β€” how many streams, go off
  • void 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 toggle
  • int 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/off
  • void 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, bestie
  • void 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 client
  • int iperf_run_server(struct iperf_test *); β€” run the server
  • void 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 handle
  • char* 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 style
  • char *iperf_strerror(int); β€” turn an error number into a human string
  • extern 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