igorskh / iperf-swift

An easy to use Swift wrapper for iPerf3
6 stars 5 forks source link

is there any way to save the output to a log file. #6

Open manmohan777 opened 2 years ago

manmohan777 commented 2 years ago

Is there any way to save the output to a log file and apply different options like iperf.exe -s -u -i1 -fm -w32M -p5206? I am trying to save the log file using the following function of the iperf_api file named

let path = FileManager.default.urls(for: .documentDirectory, in: .userDomainMask)[0].appendingPathComponent("IperfResults.txt") print("logfile path: (path)") iperf_set_test_logfile(currentTest, "(path)") but everything is working fine without using the above function.

and is there any way to pass options like iperf.exe -s -u -i1 -fm -w32M -p5206. so far i have found a function in iperf-api file named iperf_parse_arguments(struct iperf_test *test, int argc, char **argv) but I don't know how to use that to achieve the required functionality. can you please share an example for the same?

thanks in advance

igorskh commented 2 years ago

Hi @manmohan777,

Not all functionality of the original iPerf library is implemented by this Swift wrapper, I'm afraid you cannot achieve what you describe without extending the package. See my comments below.

Is there any way to save the output to a log file and apply different options like iperf.exe -s -u -i1 -fm -w32M -p5206? I am trying to save the log file using the following function of the iperf_api file named

let path = FileManager.default.urls(for: .documentDirectory, in: .userDomainMask)[0].appendingPathComponent("IperfResults.txt") print("logfile path: (path)") iperf_set_test_logfile(currentTest, "(path)") but everything is working fine without using the above function.

What you can do is to access interval results from the onResultReceived callback, where you periodically (by default every second) receive IperfIntervalResult structure and you can save it to file. Alternatively you could monitor onRunnerState callback to monitor when test is finished to save all results at once.

Just keep in mind that IperfIntervalResult structure is not Codable, you would need to copy data to some Codable structure or extend IperfIntervalResult to conform to Codable if you want to encode it to JSON.

and is there any way to pass options like iperf.exe -s -u -i1 -fm -w32M -p5206. so far i have found a function in iperf-api file named iperf_parse_arguments(struct iperf_test *test, int argc, char **argv) but I don't know how to use that to achieve the required functionality. can you please share an example for the same?

thanks in advance

Port is configurable, for other parameters you would need to extend IperfConfiguration and add corresponding code to the IperfRunner to parse those properties.

I could have a look later for adding those arguments, if you do extend my package I would appreciate a pull request.