HomeTaskerAutomating iperf internet speed testing with Tasker

Automating iperf internet speed testing with Tasker

A nerdy tutorial, because I can!

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 internet transfer speeds between the server and the 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 start the server I will use the EventGhost, while AutoRemote will handle the communication between devices.

Iperf3

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 the 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.

EventGhost Setup

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.


Open Iperf

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.

Close Iperf

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

otherwise:

NOTIFICATION=:=Server Failed=:=Please restart the server=:=iperf=:=#F51D1D=:=2=:=vpnfail=:=vpnfail=:=Restart=:=Server restart

Tasker setup

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
TASK: Open 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 a 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
TASK: Close 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.

Server Commands
PROFILE: Server Commands
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:

Server open/close/iperf

and performs tasks created earlier or launches the iperf app.

Conclusion

It’s a nerdy and probably not the most important profile in my collection, but you can learn a few things from this setup. It also shows you how much work you can save by using a universal notification system.

Project Download

Download project files here. Bear in mind that Patreon supporters have early access to project files and videos.

PayPal

Nothing says "Thank you" better than keeping my coffee jar topped up!

Patreon

Support me on Patreon and get an early access to tutorial files and videos.

image/svg+xml

Bitcoin (BTC)

Use this QR to keep me caffeinated with BTC: 1FwFqqh71mUTENcRe9q4s9AWFgoc8BA9ZU

New to Tasker?

Tasker Quick Start – Getting started with Tasker

0
From newb to not so newbie in 10 min

Best Tasker Projects

How to use Raspberry PI as WOL (wake on lan) server

0
While you could wake up your PC from a mobile directly, having a dedicated server capable of doing so is the best solution. The reason is simple. You can hook up as many devices as you wish with a single endpoint. This is why Raspberry Pi is perfect for this.

How to wake on LAN computers and put it to sleep with Power Menu,...

0
How to Wake on LAN properly via Android, Alexa, Google Assistant and Web

7 awesome Bluetooth keyboard shortcuts for Android

0
7 unique Android shortcuts that you can add to any Bluetooth keyboard.

Smart overnight charging with Tasker

0
Still keeping your phone plugged in overnight? Try smarter overnight charging with this profile

One thing that Join app can’t do and how to fix it with Tasker

0
It's not possible to share the clipboard automatically between join accounts registered to 2 different emails. But you can fix this with tasker.

Essential Guides

Tasker: Seconds into DD:HH:MM:SS (dynamic)

0
It's time to.... ok it's a pun, but I will show you how to master time and convert seconds to DD:HH:MM:SS dynamically

4 ways to organise Tasker projects

0
Keep your Tasker tidy!

A better way to store Tasker credentials

0
The more clever way of managing credentials

Annoyed with dozens of AutoApps populating your app drawer? Here is a fix!

0
Clear your app drawer from the clutter in seconds

Putting AutoTools pie chart to a good use – SSID logger

0
Who wants a piece of the pie (chart)?