Network Skin


One of the things folks like to have on their desktop is a skin to monitor the behavior and traffic of their network.

The NetIn / NetOut / NetTotal measures in Rainmeter can be used to monitor all traffic in and out of the NIC (Network Interface Card) on your computer.

However, there are a few considerations you should keep in mind to have a skin that is useful, accurate and informative.

The Interface option

One of the options that can be set on the Net measures is Interface. It will almost always be correct to set this to Interface=Best.

Smoothing out the traffic values

The network measures in Rainmeter measure the average number of Bytes sent through the interface every second. However, the nature of network traffic is that it can be very "spiky". Many people find that a network skin has a more useful behavior if we "smooth out" these spikes a bit. So the traffic values "ramp up" and "ramp down" as the values change, rather than having a very jerky behavior.

This can be done by using the AverageSize option on the measure(s). This will cause the measure(s) to average the returned values over the number of skin updates specified in the AverageSize option.

e.g: AverageSize=5

Using Network values as a percentage

While it is simple enough to just display the number of Bytes / kBytes / MBytes from the measures in a String meter using AutoScale to format the numbers, you may want to display the traffic in a meter that requires a percentage. This would include the Bar, Bitmap, Histogram, Line, Rotator and Roundline meters.

As discussed in the percentage manual entry, these meters will require that a "range" of values is provided, so the meter knows where in the scale of 0% to 100% the current value of the measure lies.

Some measures, like FreeDiskSpace for instance, automatically set this "range", based on examining the resource being measured. The Network measures also attempt to do this, but with some serious limitations. What the measures do is dynamically set the maximum value for the range to the highest value the measure has been since the skin was loaded or refreshed. This can cause really undesirable behavior on these "percentage" meters until your skin has been running for a while and you have done things to use a large percentage of your total bandwidth.

Note: The Net measures internally measure the traffic data in bits per second. The measures automatically divide both this internal measurement, and any MinValue / MaxValue options by 8, in order to use and display the values as bytes in meters. This means that any MinValue and MaxValue options should be set in bits, not bytes. Rainmeter will do the conversion to bytes automatically when the value(s) are used.

Setting the MinValue / MaxValue options:

The way to correct this behavior is to manually set the MinValue and MaxValue options on the network measure(s). This will explicitly set the possible "range" of values for the measure so that meters requiring a percentage will immediately and correctly know where in the range of 0% to 100% the current value lies.

Finding your maximum download and upload bandwidth:

What we want to do is find and enter the maximum bandwidth your network connection supports. There are a couple of things to keep in mind:

  • The maximum bandwidth your ISP told you is a baldfaced lie.
  • Rainmeter measures network traffic in bytes per second, while most descriptions of network traffic in other contexts (Wikipedia articles about network traffic, the amount your ISP advertises, many online testing sites, etc.) describe network traffic in bits, or generally Megabits / Mbps per second. A byte is 8 bits. The good news is that Rainmeter will handle this conversion for you.

speedtest.net

One of the better places to get a reasonably accurate measurement of your maximum download and upload bandwidth is the SpeedTest site. Simply go to this site, click on Begin Test, and wait. In less than a minute, you will be given the maximum speeds the site sees for your computer.

An alternative, so you can test at more than one place and compare is speedof.me.

As you can see from the image, the values returned by SpeedTest are in Mbps or Megabits per second. This is just what we need for Rainmeter.

So to use these values in your skin, you simply need to plug them into the MaxValue options for your measures.

There is one more little calculation you need to do though. Remember that Rainmeter measures network traffic in bytes, and although it will handle any conversion from bits (the Mbps from SpeedTest) to bytes, we are talking about Mega or million bits/bytes. Simple enough, a Megabyte is 1048576 bytes.

Let's put it together:

I set my Interface to "Best", my maximum download speed from SpeedTest is "33.12" and my maximum upload speed is "11.71" I want to smooth out the traffic by averaging the results every "5" skin updates:

[MeasureNetIn]
Measure=NetIn
Interface=Best
MinValue=0
MaxValue=(33.12 * 1048576)
AverageSize=5

[MeasureNetOut]
Measure=NetOut
Interface=Best
MinValue=0
MaxValue=(11.71 * 1048576)
AverageSize=5

Sample Skin:

I have put all this together in a reasonably simple little skin that:

  • Tests your network connection to be sure it is active.
  • Gets and displays both your LAN (local) IP address and WAN (Internet) IP address. Simply move the mouse over the skin to toggle the value between them. Click the skin to copy your WAN IP address to the Windows clipboard.
  • Displays an image that dynamically indicates Downloading/Uploading/Both/Neither/Error as appropriate.
  • Displays the current download and upload traffic in bytes/kbytes/Mbytes, scaling automatically.
  • Displays a Bar meter for download and upload values, as a percentage of the total bandwidth your connection supports.

I have put some things in [Variables] to make them easy to change. Be SURE to change the values for your maximum download and upload bandwidth. Feel free to either use this skin as is, or tear it apart to make it your own.

[Rainmeter]
Update=1000
AccurateText=1
LeftMouseUpAction=[!SetClip "[MeasureIPWeb]"][Play "#@#Sounds\Copy.wav"]
MouseOverAction=[!SetOption MeterWANIPText Text "[MeasureIPLan]"][!UpdateMeter MeterWANIPText][!Redraw]
MouseLeaveAction=[!SetOption MeterWANIPText Text ""][!UpdateMeter MeterWANIPText][!Redraw]

[Metadata]
Name=NetTraffic
Author=JSMorley
Information=Description:|Network Information
Version=Aug 31, 2013
License=Creative Commons Attribution-Non-Commercial-Share Alike 3.0

[Variables]
;Set these for sure
;https://speedtest.net
MaxDownloadMbits=33.82
MaxUploadMbits=4.85

;Set this if needed
Interface=Best

Font=Trebuchet MS
LabelColor=220,220,220
ValueColor=255,254,222,255
ImagePath=#@#Images\

[MeterAllBackground]
Meter=Image
W=170
H=78
SolidColor=20,20,20,255
SolidColor2=23,46,29,255

;[GATHER Network]=================================

[MeasureNetwork]
Measure=Plugin
Plugin=WebParser.dll
Url=http://www.msftncsi.com/ncsi.txt
RegExp="^(.*)$"
UpdateRate=30
ForceReload=1
StringIndex=1
FinishAction=!EnableMeasure MeasureNetworkLua #CURRENTCONFIG#

[MeasureNetIn]
Measure=NetIn
Interface=#Interface#
MinValue=0
MaxValue=(#MaxDownloadMbits# * 1048576)
AverageSize=5

[MeasureInDelay]
Measure=Calc
Formula=MeasureNetIn

[MeasureNetOut]
Measure=NetOut
Interface=#Interface#
MinValue=0
MaxValue=(#MaxUploadMbits# * 1048576)
AverageSize=5

[MeasureOutDelay]
Measure=Calc
Formula=MeasureNetOut

;[Network WEB IP]=================================

[MeasureIPLan]
Measure=Plugin
Plugin=Plugins\SysInfo.dll
SysInfoType=IP_ADDRESS
SysInfoData=Best

[MeasureIPWeb]
Measure=Plugin
Plugin=Plugins\WebParser.dll
Url=http://checkip.dyndns.org
RegExp="(?siU)Address: (.*)</body>"
StringIndex=1
UpdateRate=-1

[MeterIPLabel]
Meter=String
X=10
Y=7
FontFace=#Font#
FontColor=#LabelColor#
FontSize=11
StringStyle=Normal
StringAlign=Left
AntiAlias=1
Text="IP:"

[MeterWANIPText]
Meter=String
MeasureName=MeasureIPWeb
X=160
Y=0r
FontFace=#Font#
FontColor=#ValueColor#
SolidColor=0,0,0,1
FontSize=11
StringStyle=Normal
StringAlign=Right
AntiAlias=1

;[Network TRAFFIC IMAGE]========================

[MeterNetworkImage]
Meter=IMAGE
ImageName=#ImagePath#NetworkError.png
X=10
Y=26r
W=30
H=30
AntiAlias=1

[MeasureNetworkLua]
Measure=Script
ScriptFile=NetTraffic.lua
Disabled=1

;[Network INBOUND TRAFFIC]========================

[MeterNetInPre]
Meter=String
X=50
Y=-6r
FontFace=#Font#
FontColor=#LabelColor#
FontSize=11
StringStyle=Normal
StringAlign=Left
AntiAlias=1
Text="DN:"

[MeterNetInText]
MeasureName=MeasureInDelay
Meter=String
X=160
Y=0r
FontFace=#Font#
FontColor=#ValueColor#
FontSize=11
StringStyle=Normal
StringAlign=Right
AntiAlias=1
AutoScale=1
NumOfDecimals=1
Text="%1B"

[MeterNetInBar]
Meter=Bar
MeasureName=MeasureNetIn
X=50
Y=0R
W=110
H=2
BarColor=104,199,128,255
SolidColor=60,60,60,255
BarOrientation=Horizontal

;[Network OUTBOUND TRAFFIC]=======================

[MeterNetOUTPre]
Meter=String
X=50
Y=5r
FontFace=#Font#
FontColor=#LabelColor#
FontSize=11
StringStyle=Normal
StringAlign=Left
AntiAlias=1
Text="UP:"

[MeterNetOutText]
MeasureName=MeasureOutDelay
Meter=String
X=160
Y=0r
FontFace=#Font#
FontColor=#ValueColor#
FontSize=11
StringStyle=Normal
StringAlign=Right
AntiAlias=1
AutoScale=1
NumOfDecimals=1
Text="%1B"

[MeterNetOutBar]
Meter=Bar
MeasureName=MeasureNetOut
X=50
Y=0R
W=110
H=2
BarColor=104,199,128,255
SolidColor=60,60,60,255
BarOrientation=Horizontal