Need help with your equipment?
SomeJoe7777's profile

Expert

 • 

9.4K Messages

Monday, November 24th, 2008 4:20 AM

How To Measure Your Internet Usage Using VLANs and MRTG

With all the talk of the possible upcoming internet usage caps, I was wondering if there was a way that I could measure my own internet usage.  Although it looks like AT&T will provide us a usage meter that we can check to see the total usage on our own accounts, I wanted to see if I could measure my own usage myself as a cross-check on AT&T.

 

Some people have suggested downloading and installing a personal internet usage meter on your computer.  While this works well in single-computer environments, it doesn't solve the problem when there is more than one computer on your network.  You need a measurement system that can measure all internet traffic from all computers and internet devices.

 

A while back, I came up with a method that could measure the RG's total bandwidth usage using MRTG.  (See this thread over at UverseUsers).  However, this only showed total bandwidth, without regard to what bandwidth was being consumed by TV and what was being used by computers.  Since the proposed internet usage limits would be on computer use only, I needed a method to split the bandwidth usage statistics into IPTV and Internet.

 

To do this, I split up my network using VLAN-capable switches, and then used MRTG to measure only the computer bandwidth portion.

The switches I'm using are Netgear GS-108T switches, which can be had for only $79.00 each for an 8-port Gigabit managed switch -- a really good bargain.  The following is a diagram of my home network -- all connections throughout my network are Cat5e (no coax is used):

 

 

The trick is that the main switch (Switch 1) is uplinked to the RG twice.  Port 1 is a member of VLAN 1, which is carrying all Internet traffic, and port 2 is a member of VLAN 2, carrying IPTV traffic.  This enables MRTG to query port 1 of the switch to get traffic counters for only Internet traffic.  All IPTV traffic travels to/from the RG through port 2, so that traffic is not included in the port 1 counters.

 

The green lines on the diagram are Cat5e links that are carrying 802.1q VLAN-tagged frames.  These Ethernet frames have an additional header on them that tells the switch what VLAN they belong to.  When they get to the switch on the other end, that switch strips off the VLAN tag, and switches the packet only to the ports allowed by that VLAN.  What this essentially means is that the only place in the network where packets can go from VLAN 1 to VLAN 2 (or vice versa) is through the RG.  So, if Desktop 1 tries to ping the Office STB, the ping packet will travel all the way up to the RG and back to reach the Office STB.

 

The reason that switch 1 is uplinked to the RG twice is because the RG is not VLAN-aware.  To the RG, it looks like all 3 STBs are on port 2, and all computer hardware is on port 1.  The RG doesn't know that the network is actually mixed together.

 

The computer labeled as the video server actually runs MRTG.  It queries both the RG (for total VDSL statistics, error counts, and line sync rate/capacity) and switch 1 (to get traffic counters for IPTV and Internet off ports 1 and 2).  These parameters are graphed on the MRTG summary page (available here).

 

The final graph on that page, which shows the total Internet data transferred for the last 30 days, is generated on the fly from the MRTG log files.  If anyone is interested and wants to set this up themselves, I'll provide the source code for that (it's VBscript/ASP).

 

Here's some other examples of how data flows through the network for various functions:

 

1. Watching a live TV program on the Office STB.  Note that this traffic doesn't get counted as Internet traffic because it goes through port 2 of switch 1 (only traffic through port 1 of switch 1 gets counted by MRTG):

 

 

2. Watching a DVD from the Video Server on the Living Room XBox Media Center.  Note that this traffic doesn't get counted anywhere by MRTG because it doesn't traverse port 1 of switch 1:

 

 

3. Downloading a file from the Internet to Desktop 2.  This gets counted as Internet traffic since it flows through switch 1 port 1:

 

 

4. Now the really cool one. :smileyhappy:  Watching a recorded program from the DVR, using THDVR, from a remote location using the Slingbox.  This will get counted as Internet traffic in the upload direction as it traverses switch 1 port 1:

 

 

Now, here are some problems you may run into with the above setup:

 

1. Coax devices cannot get their traffic counted.  Now, this isn't a problem if you're only interested in counting Internet traffic.  However, if you have used the trick where you have an STB connected via coax, and then have used the Cat5e port on the STB as a bridge to a computing device, you won't be able to count the traffic from that computing device.

 

2. You cannot use the RG's built-in wireless if you want to count that traffic.  You must use an external 802.11g/n wireless access point connected to the Internet VLAN to get wireless devices' traffic counted.  This is why I have shown a wireless access point in my diagrams (I haven't installed that yet).

 

3. MRTG runs as a service, so it's required to be installed on a computer that runs 24/7. 

 

I know this setup goes beyond what many people may want to do, but I hope it gives you some ideas of what you might want to try with your network.

 

Message Edited by SomeJoe7777 on 11-24-2008 11:27 AM

Expert

 • 

9.4K Messages

13 years ago

Lowest priced D-Link I could find with VLAN capability was the DGS-1210-10P, around $250.00.

 

Dell also has the PowerConnect 2808 8-port gigabit switches for $119.

 

Mentor

 • 

71 Messages

13 years ago

Joe - 

 

I got MRTG up and running, and have all internet traffic coming off Port4 of the RG. I setup a quick and dirty index page and it's got data starting to populate.

 

http://dale.versatechnetworks.net/mrtg/

 

I'd like to add a "Total Monthly Usage" that will calculate a data count... is it possible to do that with MRTG? All my internet facing devices are off 1 switch on port 4, no other port has a non-AT&T device on it. 

 

Thanks!

 

 

Expert

 • 

9.4K Messages

13 years ago

You can get total cumulative data with MRTG with a helper app.  One that I just so happen to have written. Smiley Happy

 

MRTG Integrator will take an MRTG log file full of data rates and integrate it over time, producing a time-integrated total.

 

Download it from the above link, unzip, and put the .exe in the MRTG bin folder (usually, C:\mrtg\bin, which is the same directory where 2WireMRTG.exe is).

 

Example configuration in the mrtg.cfg file:

 

 

Target[192.168.1.11_9]: `C:\mrtg\bin\MRTGIntegrator.exe /q /m "C:\Inetpub\MRTG\192.168.1.11_1.log"`
SetEnv[192.168.1.11_9]: MRTG_INT_IP="192.168.1.11" MRTG_INT_DESCR="Total Cumulative Internet Traffic"
MaxBytes[192.168.1.11_9]: 250000000000
AbsMax[192.168.1.11_9]: 4000000000000
Options[192.168.1.11_9]: withzeroes, gauge
YLegend[192.168.1.11_9]: Total Data (B)
ShortLegend[192.168.1.11_9]: B
Title[192.168.1.11_9]: Total Cumulative Internet Traffic
LegendI[192.168.1.11_9]: Total Downloaded Data (B)
LegendO[192.168.1.11_9]: Total Uploaded Data (B)
AddHead[192.168.1.11_9]: 
 
  
PageTop[192.168.1.11_9]: 
  

Total Cumulative Internet Traffic

System: Total Cumulative Internet Traffic
Maintainer: SomeJoe7777
Description: Total Cumulative Internet Traffic
ifType: 100Mbps Ethernet
ifName: Ethernet 4
Maximum: 250 GB

 

 

Change the Target line to point to your MRTG log file for the Ethernet 4 interface.

 

The program will reset the totals to 0 on the 1st of the month when the /m parameter is used.

 

Mentor

 • 

71 Messages

13 years ago

This is great, thank you man! I truly love your work, if you ever need a tester, just let me know, I'd be more than happy. And, if you ever need some bandwidth, let me know, I have some unmetered servers I'd be happy to share.

 

So Looking at the Daily Graph:

day

http://dale.versatechnetworks.net/mrtg/192.168.1.254_3-day.png

 

Am I correct in assuming this will show the last 24 hours, consistently growing? I'd imagine this would look something like a perfect stock market, slowly rising, by the end of the first 24 hour period?

 

Is there a way to draw a 3rd plot on this graph, showing the totals of up and down?

 

Thanks again!

 

Expert

 • 

9.4K Messages

13 years ago

 


@doctorisham wrote:

 

Am I correct in assuming this will show the last 24 hours, consistently growing? I'd imagine this would look something like a perfect stock market, slowly rising, by the end of the first 24 hour period?

 

Is there a way to draw a 3rd plot on this graph, showing the totals of up and down?


 

Yes, this graph will slowly grow and reset on the 1st of the next month.  You are showing the daily graph there, but I find the monthly graph gives you a great snapshot of the data.

 

Unfortunately, there is no way to draw a 3rd plot on a graph with MRTG.  The MRTG scripts are hard-coded to work with only 2 parameters per graph.

 

You could theoretically do another helper app that would return the total and then have MRTG graph that.  Now that you mention it, I might add that functionality to the Integrator with a /t switch.  Then you could just make another entry block in the MRTG.cfg file that called the integrator with the /t switch and get another graph that represents the up+down total.

 

Mentor

 • 

71 Messages

13 years ago

That would be great, let me know if you find the time to add that ability... would be more than happy to help test it. 

 

Same goes with your next rev. of UVRT 🙂

Contributor

 • 

1 Message

13 years ago

Dude, you are so my new god.

I have dreamed the impossible dream about such a setup for so many years, and to see it not only in operation, but diagrammed and explained for the masses, it's... such a pleasure to know that someone is enjoying the wonderousness of XBMCs, slingboxen, etc...

And I'm willing to be dollars to donuts you don't have a single exposed cat5e, either... just the wires running from units to runners to switches to wall plates...

Expert

 • 

9.4K Messages

13 years ago

I have one other tool I cooked up this weekend that's useful for network monitoring:

 

MRTGPing is an executable that can return max and average round-trip ping times to MRTG for graphing.  This is useful to see if your ping time has changed due to a routing change in AT&T's network or if a router in your area is overloaded.

 

Download it from the above link, unzip, and put the .exe in the MRTG bin folder (usually, C:\mrtg\bin, which is the same directory where 2WireMRTG.exe and MRTGIntegrator.exe are).

 

Example configuration in the mrtg.cfg file:

 

 

Target[www.google.com_ping4]: `C:\mrtg\bin\MRTGPing.exe /q www.google.com`
SetEnv[www.google.com_ping4]: MRTG_INT_IP="" MRTG_INT_DESCR="Google IPv4 Ping Times"
MaxBytes[www.google.com_ping4]: 100
AbsMax[www.google.com_ping4]: 200
Options[www.google.com_ping4]: withzeroes, gauge
YLegend[www.google.com_ping4]: Ping Time (msec)
ShortLegend[www.google.com_ping4]: msec
Title[www.google.com_ping4]: Google IPv4 Ping Time
LegendI[www.google.com_ping4]: Max Ping Time (msec)
LegendO[www.google.com_ping4]: Avg Ping Time (msec)
AddHead[www.google.com_ping4]: 
PageTop[www.google.com_ping4]: 

Google IPv4 Ping Time

System: Google IPv4 Ping Time
Maintainer: SomeJoe7777
Description: Google IPv4 Ping Time
ifType: Gigabit Ethernet
ifName: G0
Maximum: 100 msec

 

 

A couple of notes on this tool:

 

• This tool is written in .Net Framework 4.0, so you need to have the 4.0 framework installed on the MRTG computer for it to work.

• On the command line, you can use a DNS name (www.google.com) or an IP address.

• The tool is fully compatible with IPv6 if you are using it on an operating system with IPv6 installed.  Example command line to test IPv6 ping times: MRTGPing.exe /q ipv6.google.com

 

On the output lines, the first line (MRTG considers that the input) is the Max ping time (out of 10 attempted pings).  The second line (MRTG considered that the output) is the Avg ping time (out of 10 attempted pings).  Pings that are lost are not considered in the average.

 

Tutor

 • 

5 Messages

12 years ago

Dan,

 

I had a question on your network setup.  I know you have two physical connections from your main/core switch running to the RG to monitor/measure your utilization with MRTG.  However metering aside, could you conceivably just used one connection since everything is VLAN tagged?  Does bandwidth utilization get too saturated if you just used one connection?

 

Thanks for your help.

Expert

 • 

9.4K Messages

12 years ago

You cannot use only one connection because the RG does not support VLAN tagging. There would be no way to differentiate what traffic coming from the RG belonged to which VLAN.
Not finding what you're looking for?
New to AT&T Community?
New to the AT&T Community? Start by visiting the Community How-To.
New to the AT&T Community?
Visit the Community How-To.