If you follow me on social media, you probably know, that my recent period of silence has been caused by a holiday far, far away. Prior to my big trip to Hong Kong and Sydney, I came up with an idea to see how different VPN providers would behave across the continents. One of my tests was iperf (transfer speed test) to a server located back home. To make my life easier I used Tasker to automate some of that! I know, this may not be the most popular Tasker project, but hey, why not!
Automating iperf internet speed test with Tasker
I needed a task which would wake up my PC (if needed) and started an iperf server. I also wanted to have some sort of confirmation that the process has been completed successfully.
Iperf is a command line tool that measures the internet transfer speeds between the server and client. The tool is available on many platforms including Windows and Android. I’m going to open I’m going to run it on a Windows 10 OS, as I was able to clock higher speeds there, comparing to the Raspberry Pi.
To use the tool, simply download the iperf for your platform and run a command line or PowerShell from the folder containing the files:
.\iperf3.exe -s -p 5202
Where -s starts it as a server and -p assigns a port (5202 in my case – be sure to forward the port in your router). To run the PowerShell in Windows 10, press shift and right click in the folder to bring up the menu with the PowerShell option. EventGhost will automatically do this for me later.
Client side, I’m going to use Android app which is called Magic Iperf. I need the iperf3 support, and the app comes with it. To connect to the server you will need the IP of the server or DNS.
-c [your_ip or DNS] -p 5202
Make sure the iperf3 is selected.
I need the EventGhost to handle 3 tasks. Starting and closing the server, notifying the Android (Tasker) that everything has been done correctly. I have created a feedback loop where EG is letting me know if the server has started correctly.
To pass the information and to create the push notification message, I’m going to use the Near-Perfect AutoNotification system I created previously. If you not sure what it does, the string below allows you to create a full push notification with AutoRemote or AutoApps command. No more single ‘show notification’ actions.
When AR message is received, EG will start the PowerShell.exe from the correct location, and run the iperf3 as a server. Next, I used EG to look for the PowerShell window. If this is successful, a message confirmation is sent, otherwise, a prompt is issued to restart the server.
Once again, I’m using find the window to bring the window with the PowerShell to the front and close it.
Server is running/not running
These two messages contain the AutoRemote message to display feedback as an AutoNotification message. If the server has been started successfully, EG sends:
NOTIFICATION=:=Iperf server is running=:=The server is ready for testing=:=iperf=:=#0B974C=:=2=:=vpnserver=:=vpnserver=:=Restart=:=Server Restart=:=Close=:=Server close=:=Start Iperf=:=Server iperf
NOTIFICATION=:=Server Failed=:=Please restart the server=:=iperf=:=#F51D1D=:=2=:=vpnfail=:=vpnfail=:=Restart=:=Server restart
The notification profile is downloaded from the Near Perfect AutoNotification, so I got this covered already (new icons has to be placed in the icon folder of your choice). I need to set up the action for each button and create a task to start the server.
There is no an easy way to ping a device from WAN, so I’m just blindly running a WOL wake up message using Wake On Lan app (I talked about it before) with Tasker support.
There is no disadvantage to doing so, other than waiting few extra seconds for the PC to be up and connected. After a short wait, I’m sending the AR message to start the server.
Once more, AR message is sent to the EG on my PC to close the window, then Tasker cancels the notification, collapses the status bar and returns to the home screen.
Because I used AutoNotification buttons to restart/close the server and to start the iperf, I have to link the commands to tasks that will handle it. The message has a simple format:
and performs tasks created earlier or launches the iperf app.
It’s a nerdy and probably not the most important profile in my collection, but you can learn few things from this setup. It also shows you how much work you can save by using universal notification system.