Friday 30 December 2022

Internet Speed test Application for Windows

Introduction

I like to write software as a bit of a hobby. I use Microsoft C#  Visual Studio and have written a small  number of (Windows) applications for my own use. These are always a "work in progress" and each application uses code from previous applications

My latest application is a Windows application wrapper around the Ookla Speedtest CLI application (I know there is an official Ookla Windows application here) but where's the fun in that? Has mixed reviews on the Windows Store as well to be honest.

Ookla (here) do the internet speed tester. The reason for this was that recently we moved from ADSL (copper wire) broadband (at typically 30-50Mbps) to BT full fibre at 500Mbps and I obviously wanted to check I was getting what I paid for

The initial tests using the web page version showed that at times I was getting 500Mbps download but this was very variable (I was not rigorous enough to test whilst ensuring no other devices were using the internet). Upload speeds were very consistent at about 70Mbps.

Here's an example:

What I could not tell reliably was how did this vary and by what amount. I decided that what I'd do was put a Windows wrapper wound the Ookla CLI version

This can be downloaded from here:


This page describes the software that I wrote

The Code

In this case I also took some time to prepare a proper class library - I have quite a few classes that I re-use (these are: an SQL database class, an application logger class, a general utilities class, a DataTable handling class, a Process Class and a few other miscellaneous classes). I realised that my existing method of copying the last version of the class to the new project did not work and I never copied the updates back. Now that I have a Class Library, this is a much better solution and I used it on a 2nd project at the same time (this was to address some database creation issues I had) and the code worked for both projects.

It took some effort to work out how to do this - for example I had not realised that it was a "code only" class and and Windows  forms (for example) could not be included. I am assuming that I can create a Windows forms class library. In terms of the SQL code I spent a lot of time trying to simplify the code and break up into smaller classes with some inherited behaviour. This has improved the code but it needs more work

I run the speed test by spawning it as a Process, intercepting the STDOUT and parsing it (this

I also wanted the application to be responsive during the speed test - once the Process class started the execution the application hung until the test was completed - for up to 25-30 seconds. This was not good. To fix this I used a background worker thread (actually I used 2 - one for the speed test and the other to monitor completion and allow aborting the test). This was a new area of code for me. Using these background worker threads showed another issue that this was a sperate thread so I could not get results or interact - this was fixed with creating some delegates to update a DataGridview, update progress bars etc. Not quite sure what delegates do (I need to do some more reading) but it works. Thanks to Stackoverflow for all this.

Installing the software

Before you install this application you need to down load the Ookla Windows CLI file from here. Download and extract the exe file to a location of your choice

You can test the code manually if you like. Open a Command prompt, change directory to the location of speedtest.exe and type speedtest.exe.


Note that the first time you run the Ookla CLI application it asks you to accept the licence terms and GPDR terms. My application checks if this has been already done. If it has it moves on, if it has not it accepts them on your behalf.

My application is here on my Google drive. Download and extract the zip file to get the installer:


Double click on Setup. You'll get the unsigned warning


I have not signed the code but from my drive it should be "safe". Here's the file info at the point I uploaded it:


Running the Application

When the application first runs it needs to know where the Ookla Speedtest cli exe file is. A standard File Open dialog box will appear to allow you to set the path for this. The title of the dialog box is "Locate the Speedtest.exe file"




Double clicking the file or selecting it and pressing "Open" registers the path. It also checks that it is called "speedtest.exe".

It will then create an SQL database to hold the results (in C:\Users\<User>\AppData\Local\Speed_Test) where <User> is your user account.

It creates an ini file for settings in the Application's Environment.SpecialFolder.ApplicationData folder. This is really hard to find so there is a means to get this easily from the application itself (see below). It also creates a log file (appliocation.txt) in the same folder

Assuming this is successful the main form will open:


To look at the database folder use the Miscellaneous menu:


You can select "Show Application folder" for the log file and the ini file or "Show database folder" for the database files

Finally select "Show Application messages" to look at application messages:


To get a speed test press the "Do a Speed test" Button:


At the end of the test you'll see some Stats data (best, worst, average results etc) and the individual results:


Until you have 3 results there will only be a line chart. Once there are 3 results or more there are also some histograms for upload and download:


You can run an automated Speedtest every 2 minutes using the "Start Auto Speed test" button.

Note that there is a 30 second timeout for the Speedtest to complete within. If your machine is timing out you will need to edit the setting in the ini file. Open the folder (Miscellaneous Settings, Show Application Folder) and double click on Speed_test.ini:


You'll see this:

[Database_Properties]
Database_Path=C:\Users\<User>\AppData\Local\Speed_Test
Database_Name=Speed_Test
[Executable_Properties]
Executable_Path=L:\Visual Studio\Speed_Test\Speed_Test\bin\Debug
Executable_Name=speedtest.exe
[Log_Properties]
Log_Path=C:\Users\<User>\AppData\Local\Speed_Test
Log_Name=log.txt
[Timer_Properties]
Timer_Value=30000

Change Timer_Value to a longer value if needed. Note that this is seconds x 1000, so if you want 45 seconds enter:
Timer_Value=45000

You'll also have your User name instead of <User>

Save the file and restart the application

These graphs look better with more results:



There are tooltips on the graphs. On the line graph hovering a mouse over a point will give the speed and date/time of the result:




Right clicking on the lower DataGridview will allow you to export the results as tsv (Tab Separated Values - because some Server names contain a "," symbol):


Here's an example output of the export:



If there are issues you can review the application.txt file and send it to me via this Blog:

This file is appended which each run of the application so can get large. If there are no issues it can be deleted (as long as the application is not running at the time) and it will be recre4ated next time the application starts.

Sunday 20 November 2022

Changing Bottom Bracket Bearings with an FSA Gossamer Chainset

After about 10,000 miles of use (outside and indoors on the Turbo) the bottom bracket bearings on my FSA Gossamer chain set were worn and needed replacement. I had a lot of issues with FSA Mega Exo Bottom Brackets on another bike that never seemed to last more than a few 1000 miles but this design had lasted a lot longer

It was quite hard to read that part number from the bike:



Some internet trawling showed that you needed to replace with a like-for-like unit - namely the FSA BB-6200, this is partly due to the pre-loading design of this (Shimano Hollow-Tech BB have a manual pre-load adjustment

This is the part:



Here's the video I made showing how to do it 



Apologies as it was a bit of a last minute decision to make the video so it's a combination of phone photographs and video




Saturday 18 June 2022

Lower Gears on My Giant Propel

When I bought my Giant Propel in 2016 it came with a 52-36 chain set and 11-28 cassette. Whilst I am reasonably fit I found that the 36/28 lowest gear was a bit to high for me for some of the hills around the Midlands (UK) and I changed it out for a 50/34 which was a much better compromise (and matched my other bike for the front chain set - although I run an 11/32 cassette on this other bike as well)

I still found 34/28 a bit high for some of the hills round where I live and this actually meant that I was choosing to leave the Giant in the garage if I wanted to climb some of the bigger hills more easily. The biggest climbs I have from my house are Dovers Hill, Saintbury Hill and Larkstoke Hill, all about 30 miles away. These are not huge hills and 34-28 is do-able but it's then a long drag back home and it always felt a lot easier on the other bike.

Once the cassette on the Giant got to around 9000 miles and I was coming up for the 4th chain swap I decided that perhaps it was time to get a new cassette as the original was getting worn. I thought about getting an 11-34 but without even trying felt that this was just going to be too big for the medium length derailleur so opted for an 11-30. I don't plan on going Alp hunting on the Giant to be honest as it is heavier than my other bike

The original cassette is an Ultegra 6800 model but I just could not bring myself to pay Ultegra prices for a few grams of weight saving, so I bought a 105 7000 series 11-30 cassette. At the time of writing this the 105 cassette is typically £54 and the Ultegra £90

The gear ratios are:

  • 11-28: 11-12-13-14-15-17-19-21-23-25-28
  • 11-30: 11-12-13-14-15-17-19-21-24-27-30

The only difference between the 2 cassettes is the lowest 3 gears 

The Ultegra 11-28 weighed in at 247 gram whilst the 105 11-30 weighed in at 297 gram. Accepting that the 105 unit will be a little heavier just because it has a few bigger rings shows that actually there's not a lot of extra weight going to 105 to worry about.

Here's the 11-28 Ultegra cassette weight:


And here's the new 11-30 105 cassette weight:


I didn't let my wife know that I used her kitchen scales to do this!

I didn't want to put on a longer chain for the sake of 2 cassette teeth as the 34-11 combination was already at the practical limit of length so I fitted the 11-30 cassette and left the chain the original length. Here's a photo of the chain in 50-28 combination (i.e as it was with the original set up):

And here it is in the new 50-30 gear combination



The rear derailleur is a medium cage unit and it just about manages it.

I am not going to consciously ride in the 50-30 gear but I needed to be sure that it it was selected by mistake there would be no issues - it's probably on the absolute limit but shifts up and down fine 

I have since put on about 500 miles on the Giant with this new cassette fitted. It's been great to have that slightly lower gear when needed and I have not really noticed the slightly bigger gaps in the lowest 3 gears

So in brief summary - makes the bike slightly easier to ride when you need a lower gear and if the chain is the correct length for 50-28 it'll just about be OK with the same chain for 50-30