Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

How to use the iperf library to obtain bandwidth information in real-time at intervals? #1711

Open
QingshuangZhu opened this issue Jun 5, 2024 · 4 comments

Comments

@QingshuangZhu
Copy link

I compiled iperf into a library and then used it in my code. I want to obtain the bandwidth information once every interval.
What should I do? Thank you.

@davidBar-On
Copy link
Contributor

As far as I am aware there is no such capability in iperf3. One iperf_run_client(() is called, there is practically no interaction with the library, except for the possibility to view the output (stdout or the iperf_set_test_logfile(() file).

@QingshuangZhu
Copy link
Author

QingshuangZhu commented Jun 10, 2024

Thank you very much for your answer. I took a brief look at the iperf3 source code and it indeed does not support this feature.

Currently, I am doing it like this: first, I set the JSON streaming output with iperf_set_test_json_output(test, 1) and iperf_set_test_json_stream(test, 1); And I set logfile and outfile through iperf_set_test_logfile("./iperf3.log"); then I execute iperf_run_client(test) in one thread, and another thread waits for 2 seconds before reading the JSON data from iperf3.log and parsing out the bandwidth information.

I look forward to iperf3 supporting this feature through a callback function. Thank you again.

@davidBar-On
Copy link
Contributor

Thanks for the detailed explanation. Not sure how easy/difficult it is to implement that, but Just to make sure. Are you looking for a callback at the end of the test, so there will be no need to wait the 2 seconds, something like the function bellow that will set JSON file output and will define the callback at the end of the test, something like:

void end_of_test_callback(struct iperf_test *test);
int iperf_set_test_json_end_of_test_callback(
    struct iperf_test,
    (*json_callback)(struct iperf_test *),
    char *logfile_name
);

Or, something else?

@QingshuangZhu
Copy link
Author

QingshuangZhu commented Jun 12, 2024

Thank you very much for your reply. I hope to obtain bandwidth information in real-time at each time interval, rather than at the end of the test. The 2 seconds wait is to ensure that the test data is written into the logfile file. I think an interval event callback function should be added, but I feel it might not be easy to implement (I am not familiar with the iperf3 source code).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants