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.
Open Server A1: Flash [ Text:Opening. Long:Off ] A2: Wake Device [ Configuration:Device|1|pc Timeout (Seconds):0 ] A3: Wait [ MS:0 Seconds:5 Minutes:0 Hours:0 Days:0 ] A4: AutoRemote Message [ Configuration:Recipient: Desktop Message: serveropen Timeout (Seconds):200 ]
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.
Close Server A1: Flash [ Text:Closing Long:Off ] A2: AutoRemote Message [ Configuration:Recipient: Desktop Message: serverclose Timeout (Seconds):200 ] A3: AutoNotification Cancel [ Configuration:Id: iperf Timeout (Seconds):0 ] A4: Status Bar [ Set:Collapsed ] A5: Go Home [ Page:0 ]
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.
Profile: Server Commands Event: AutoNotification [ Configuration:Event Behaviour Filter: server (case ins) ] Enter: Server options (28) A1: Perform Task [ Name:Open Server Priority:%priority Parameter 1 (%par1): Parameter 2 (%par2): Return Value Variable: Stop:Off ] If [ %anmessage ~ Server restart ] A2: Perform Task [ Name:Close Server Priority:%priority Parameter 1 (%par1): Parameter 2 (%par2): Return Value Variable: Stop:Off ] If [ %anmessage ~ Server close ] A3: If [ %anmessage ~ Server iperf ] A4: Launch App [ App:Magic iPerf Data: Exclude From Recent Apps:Off Always Start New Copy:Off ] A5: Status Bar [ Set:Collapsed ] A6: End If
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. As usual, you can find the files to download in the video description.
A lot of time and effort goes into researching, prototyping projects and creating articles. All that knowledge has been nicely compressed into a few minutes long article and sometimes a video. If you want to put a monetary value on the time I saved you – Take a look at Patreon page! I appreciate your support!