Finding your Network Interface for SysInfo and Net
Tip by JSMorley
As of Rainmeter 4.5, Rainmeter has changed how the SysInfo measure network options and Net (NetIn/NetOut/NetTotal) measures find the correct network interface / adapter to measure. This was done to make things more logical and consistent between the SysInfo and Net functionality, consolidate some internal coding for network functions, and increase efficiency of the code.
If you simply want to measure information about the currently active network interface on your system, it's very simple:
For SysInfo measures:
Use: SysInfoData=Best
[MeasureLAN] |
For Net measures:
Use: Interface=Best
[MeasureNetIn] |
The option value of "Best" will detect and measure the currently active interface. For almost all cases, this is what you want.
Note: There are cases where the meaning of "Best" can change while the skin is running. Most commonly this will be if you have a system, like a laptop, that has both wired (Ethernet) and wireless (WiFi) connections, and you switch between them. Another common case is if you have VPN software, that creates a "tunnel adapter" when running. In order to have your skin react to these changes, you must set DynamicVariables=1
on the measures.
Setting DynamicVariables=1
on the measures is recommended if you intend to "distribute" your skin, as while you might only have one network adapter, this may not be true of all your end-users.
Note that "Best" is now the default for both SysInfo and Net measures.
If you have two or more network interfaces that can be active at once:
In this case you are going to want to create separate SysInfo and / or Net measures to measure each of the interfaces. You certainly are going to want to at least be specific about which interface to measure. The recommended way to do this is to use the name (Description) of the actual network adapter in the measures.
There are many ways in Windows to find the Description of the network adapters, two ways are:
- Turn on
Debug mode
andLog to file
in the Settings panel in Rainmeter, and restart the application. - Perhaps a bit less cumbersome a way is to open a PowerShell (Windows Terminal) window and enter the following
Get-NetAdapter
command:
The information about all your network interfaces will be in the log that is created. Be sure to turn both of these off when you are done with them.
DBUG (08:04:32.360) : 46: Name: Intel(R) Dual Band Wireless-AC 7265 |
Just copy and paste that "Name" information for use in the SysInfoData and / or Interface options.
[MeasureLAN] |
Get-NetAdapter | format-table -property "InterfaceDescription", "InterfaceIndex" -HideTableHeaders
Windows PowerShell |
There are other ways to format this PowerShell command to show more or less information as you like:
Get-NetAdapter -Name * -IncludeHidden | format-list -property "Name", "InterfaceDescription", "InterfaceIndex"
Windows PowerShell |
Or if you want a full firehose of information about each interface:
Get-NetAdapter -Name * -IncludeHidden | format-list -property *
Using the network interface / adapter "index" number:
There is an interface index number that is created by Windows for each of your network interfaces. You can use this index number in the options for SysInfo and / or Net measures, but caution! These numbers are pretty dynamic in Windows and can change if you enable/disable networks. There is just no certainty that these numbers will remain constant over time.
Getting these numbers is the same as getting the name (Description) shown above, just use the number found as IfIndex
in the Rainmeter log, or InterfaceIndex
in the PowerShell output.
A backwards compatibility concern:
As originally written, the Net (NetIn/NetOut/NetTotal) measures will see an explicit index value of "0" as meaning "all". For systems with only one active interface, this sorta works well enough, and there may be skins out there that have Interface=0 or SysInfoData=0 on them. Those skins should be changed going forward. In most cases, it is recommended that they be changed to Interface=Best
and SysInfoData=Best
. If you have SysInfoData=0 on any measure, Rainmeter is going to automatically change it to "Best", but will bark at you in the log...