In April, John Cosgrove (@rtr_man) posted the following way to monitor your WLAN association statistics that I have been using and playing with since:
Once you paste from :loop to goto loop into notepad and save as a .bat file, you will see this little icon:
Double-click that and it will open up your command line and it will look like this:
If you’ve been working in WiFi for at least a little while, then you should know what most of these mean. Really important ones to pay attention to are BSSID (mac address of the radio of the AP you are connecting to) and Signal (received signal strength from AP).
As you can see, the signal strength is in a percentage. If you want to convert this percentage to dBm, use the following formula (quality=Signal %):
quality = 2 * (dBm + 100) where dBm: [-100 to -50]
dBm = (quality / 2) – 100 where quality: [0 to 100]
So a 50% would be a -75 dBm. A 70% would be -65 dBm. 100% is -50 dBm or better. Those are the markers I keep in my head when looking at it.
This is great for real time monitoring of how your client is behaving, but what if you want to record the output? Maybe you want to save the output in a text file? Well, my good WiFi buddy, you are in luck. You would then edit the batch file to look like this:
netsh WLAN show interfaces >>WLANstat.txt
timeout /t 5
You can replace “WLANstat” with whatever you want to name the file.
Now when you run it, the output in the command line will look like this:
Now you’re probably saying “What the heck, Matt?!? Now it’s not showing me any of the statistics! What a dumb blog.”
Take a chill pill, friend, and look at your desktop. Notice anything different? Like maybe a text file that wasn’t there before? You should see a text file appear after you ran the batch file:
Open the text file and now there is the output:
Starting to trust me yet?
OK, so now we have our output being saved in a text file to review later. We’re done here, right? Wrong, good sir, wrong. Wouldn’t it be nice to have some sort of timeline to reference? It would, right? That’s what I thought as well. So, after an hour or so of furious googling, playing, scripting, cursing, googling more, scripting more, cursing more, and having a beer I found a way to get the timestamp in there. Now I am posting it here to hopefully help my WiFi brethren not have to endure what I did.
Edit your batch file to now look like this (by the way, Notepad++ is great for this because you can just right click the file then click “Edit in Notepad++”):
if %time_hh% lss 10 (set time_hh=0%time:~1,1%)
echo %time_hh%:%time_mn%:%time_ss%.%time_ms% >> WLANstat_%date:~-4,4%%date:~-7,2%%date:~-10,2%.txt
netsh WLAN show interfaces >>WLANstat_%date:~-4,4%%date:~-7,2%%date:~-10,2%.txt
timeout /t 5
The string after the filename will append the date in the filename…..just for extra awesomeness….
Now you should see a text file appear on your desktop with the date in the filename (YearDayMonth – you can play with the string if you want this different):
When you open the text file, you should see the time above each output (Hour:Minute:Second.Millisecond – you can delete the “set time_ms” line if you don’t want the milliseconds):
So, if you want to document the roaming behavior and perceived signal strength of a Windows client on the network without having to login to the network and look through logs, just open the batch file and walk around and close it when you are done. It’s super quick and easy and gives you some pretty valuable information.
Comment below or tweet me @mattbfrederick with any feedback/questions.
Thanks for reading!
Edit: I found John’s original blog post on this: