As a geek, I like to know my bandwidth usage when I'm gaming/streaming/bored (okay, all the time!). I wanted a device that would sit between my router and cable modem and provide upload / download rates (Mbps) in real time. I wanted to create a standalone device that could be plugged into any 10/100Base-T network and work without any user configuration or complicated installation.
I also wanted my device to not interrupt normal network operations. For example, if the device lost power or its software crashed, the network should continue to functional as usual. For this, I decided that a passive network tap was the best solution. There are a few concerns with passive taps, such as extra noise/loading on the line and incompatibility with gigabit connections. As most home connections are well under 100Mbps (except maybe FIOS?), gigabit compatibility isn't a big deal. To mitigate noise/loading issues, cables/board traces are kept as short as possible.
I created a prototype passive network tap out of female RJ-45 push down sockets. Under normal conditions, data is transmitted on TX and recieved on RX, however when sniffing traffic on a line, the listening device must treat each direction as seperate receive channels. To handle two RX channels, two NICs are required.
I ran into Mike Ossman at a GNU Radio conference and received one of his Throwing Star LAN Tap. He uses them as business cards, how cool is that? If I ever get around to populating the board, it will certainly clean up my protyping efforts a bit.
The bandwidth meter operates at the ethernet frame level, counting bytes transmitted and received (including headers). As such, I looked for a MAC + PHY chip with a large receive buffer and the ability to handle raw ethernet frames. I first looked at the WIZnet module, but found it's raw ethernet support lacking. The interface could only store one raw ethernet frame at a time and block any incoming packets until the first frame is read. For this application, the blocked packets would lead to an incorrect byte count and defeat the purpose of the meter.
I ultimately selected the ENC624J600 chip. Unlike the WIZnet module, the ENC624J600 does not have a built in TCP/IP stack, but had a much better raw ethernet interface. I ordered a single Olimex breakout module from Mouser to get going. I planned on making a PCB with two ENC624J600 chips and some flavor of Atmel to keep track of the packet count and drive the display.
The SPI IO pins on the ENC624J600 are 5v tolerant and the Atmega128 recognized ~3.3v as high, so the level shifters weren't needed.
I originally planned to use the parallel interface, but I decided to test the module with the SPI interface first, to ensure it was functional. I had to do some research on SPI and was delighted to see how similar it is to JTAG (in fact I believe JTAG is a subset of SPI). These are a few links that proved helpful.The ENC624J600 datasheet provided configuration information for the interface:
"The SPI port on ENC424J600/624J600 devices operates as a slave port only. The host controller must be configured as an SPI master that generates the Serial Clock (SCK) signal. This implementation supports SPI Mode 0,0, which requires: SCK is Idle at a logic low state, Data is clocked in on rising clock edges and changes on falling clock edges"
I initially hooked up the SPI interface to an Arduino Uno in an attempt to verify the module worked correctly.
After many painstaking hours of debugging with the Arduino Uno, I switched to an Atmega128 in the form of the BDMicro Maveric IIB from a previous project. The JTAG debugger proved quite valuable in the finding several coding mistakes (not to mention the fact that I confused CS and SPISel for about two days).
After I completed the initial tests with the SPI interface, I began searching for a microprocessor with a parallel interface with sufficient data rates for my needs. I found the PIC24F to be a suitable candidate and began laying out a pcb to interface with ENC624J600 breakout board I purchased.
Having verified the functionality of version 1.1, I will begin working on version 1.2 which will incorporate the MAC and PHY chip as well as the passive tap into the main PCB. Until then, behold the working prototype below.
I designed a front plate and back plate and had them laser cut out of 3mm clear acrylic. I didn't have any standoffs on hand, so I made some out of cut down pens and zip ties.