Introduction: HackerBox 0031: the Ether

This month, HackerBox Hackers are delving into Ethernet, router operating systems, network monitoring, and network analysis. This Instructable contains information for working with HackerBox #0031, which you can pick up here while supplies last. Also, if you would like to receive a HackerBox like this right in your mailbox each month, please subscribe at HackerBoxes.com and join the revolution!

Topics and Learning Objectives for HackerBox 0031:

  • Configure the WT3020 Ethernet router
  • Install the OpenWrt operating system on the WT3020 router
  • Assemble the HackerBoxes EtherTap Kit
  • Deploy the EtherTap to passively monitor network traffic
  • Configure the Arduino IDE for use with the Arduino Nano
  • Interface an ENC28J60 Ethernet controller to the Arduino Nano
  • Transmit and receive Ethernet packets from the Arduino Nano

HackerBoxes is the monthly subscription box service for DIY electronics and computer technology. We are hobbyists, makers, and experimenters. We are the dreamers of dreams. HACK THE PLANET!

Step 1: HackerBox 0031: Box Contents

  • HackerBoxes #0031 Collectable Reference Card
  • Nexx WT3020F Ethernet Router
  • Exclusive HackerBox EtherTap Kit
  • Arduino Nano 5V, 16MHz
  • ENC28J60 Ethernet Module
  • Red Crossover Adapter Plug
  • Female-to-Female Dupont Jumpers
  • Exclusive OpenWrt Decal

Some other things that will be helpful:

  • Soldering iron, solder, and basic soldering tools
  • Computer for running software tools

Most importantly, you will need a sense of adventure, DIY spirit, and hacker curiosity. Hardcore DIY electronics is not a trivial pursuit, and HackerBoxes are not watered down. The goal is progress, not perfection. When you persist and enjoy the adventure, a great deal of satisfaction can be derived from learning new technology and hopefully getting some projects working. We suggest taking each step slowly, minding the details, and don't be afraid to ask for help.

There is a wealth of information for current, and prospective, members in the HackerBoxes FAQ.

Step 2: The Ether

"The only thing that really worried me was the ether. There is nothing in the world more helpless and irresponsible and depraved than a man in the depths of an ether binge, and I knew we'd get into that rotten stuff pretty soon." - Hunter S. Thompson, "Fear and Loathing in Las Vegas"

Ethernet (Wikipedia) is a family of computer networking technologies commonly used in local area networks (LANs). Ethernet was commercially introduced in 1980 and first standardized in 1983 and has since been refined to support higher bit rates and longer link distances. The linked "Ethernet Hacks" video, while otherwise quite good, makes the absurd claim that wired Ethernet is becoming obsolete due to wireless technologies.

The original 10BASE5 Ethernet uses big, fat coaxial cable as a shared medium. Newer Ethernet variants use twisted pair and fiber optic links in conjunction with hubs or switches. Over the course of its history, Ethernet data transfer rates have been increased from the original 2.94 Mbps to hundreds of Gbps.

Ethernet provides services including the lowest two layers of the OSI model (physical layer and data link layer). If you want to know more about the seven-layer OSI network model (you do), check out Wikipedia and/or this video.

Step 3: Nexx WT3020F Ethernet Router and OpenWrt

The Nexx WT3020 series of Ethernet Routers are based on the MediaTek MT7620N (specs). These routers include two UTP Ethernet ports and a 802.11n 300Mbps wireless interface operating on 2.4 GHz.

OpenWrt is an open source project for embedded operating system based on Linux, primarily used on embedded routers. All components have been optimized to be small enough to fit into the limited storage and memory available in home routers. OpenWrt may be configured using a command-line interface (ash shell), or a web interface (LuCI).

There are several thousand packages available for installation via the opkg package management system to extend the functionality of your device. These packages include firewalls, telephony, VPNs, storage, messaging, routing, and email services among many, many others.

This OpenWrt Wiki entry covers installing OpenWrt onto the WT3020 router. Under the "Installation" heading there is a table of binaries. Don’t use these. Instead, click on the link for “LEDE firmware download” just under that table. These are the latest versions. Here is a nice tutorial on flashing the routers firmware. The OpenWrt HOWTOs can be quite helpful as well.

Step 4: EtherTap Kit

The EtherTap is a passive Ethernet tap. It is "passive" in that the EtherTap looks just like a piece of Ethernet cable to the network where it is deployed. The pass-through ports are connected inline within the Ethernet connection to be monitored. The two channels of the pass-through (one going in each direction) are physically "tapped" in the traced of PCB. The tapped signals are coupled out to the two tap ports. The two tap ports only have their receive channels wired up. According to this safety mechanism, neither of the tap ports can transmit into the pass-through.

The EtherTap Kit includes:

  • Exclusive HackerBoxes EtherTap PCB
  • Two Black RJ45 Jacks
  • Two Yellow RJ45 Jacks
  • Two 220pF Ceramic Capacitors

Assembly of the EtherTap Kit is fairly straightforward. The two differently colored RJ45 jacks are actually identical and can be placed anyway you like. We generally place the black RJ45 jacks on the pass-through ports and the yellow jacks on the tap ports. The two capacitors are not polarized and can been inserted either way.

Operation of the EtherTap involves hooking up the pass-through and then connecting one of the tap ports (depending upon which direction of traffic you are monitoring) to a computer running a packet capture/analysis program like Wireshark.

Shout Out: The EtherTap was inspired by Michael Ossmann's Throwing Star LAN Tap, so there are a lot of relevant details and history over at his site Great Scott Gadgets. Michael makes some other very cool toys worth checking out while you are there.

Step 5: Arduino Nano Microcontroller Platform

The included Arduino Nano module comes with header pins, but they are not soldered to the module. Leave the pins off for now. Perform these initial tests of the Arduino Nano module separately from the BioSense Board and PRIOR to soldering the header pins the Arduino Nano. All that is needed for the next couple of steps is a microUSB cable and the Nano module just as it comes out of the bag.

The Arduino Nano is a surface-mount, breadboard-friendly, miniaturized Arduino board with integrated USB. It is amazingly full-featured and easy to hack.

Features:

  • Microcontroller: Atmel ATmega328P
  • Voltage: 5V
  • Digital I/O Pins: 14 (6 PWM)
  • Analog Input Pins: 8
  • DC Current per I/O Pin: 40 mA
  • Flash Memory: 32 KB (2KB for bootloader)
  • SRAM: 2 KB
  • EEPROM: 1 KB
  • Clock Speed: 16 MHz
  • Dimensions: 17mm x 43mm

This particular variant of the Arduino Nano is the black Robotdyn design. The interface is by an on-board MicroUSB port that is compatible with the same MicroUSB cables used with many mobile phones and tablets.

Arduino Nanos feature a built-in USB/Serial bridge chip. On this particular variant, the bridge chip is the CH340G. Note that there are various other types of USB/Serial bridge chips used on the various types of Arduino boards. These chips allow you computer's USB port to communicate with the serial interface on the Arduino's processor chip.

A computer's operating system requires a Device Driver to communicate with the USB/Serial chip. The driver allows the IDE to communicate with the Arduino board. The specific device driver that is needed depends upon both the OS version and also the type of USB/Serial chip. For the CH340 USB/Serial chips, there are drivers available for many operating systems (UNIX, Mac OS X, or Windows). The maker of the CH340 supplies those drivers here.

When you first plug the Arduino Nano into a USB port of your computer, the green power light should come on and shortly after the blue LED should start to blink slowly. This happens because the Nano is pre-loaded with the BLINK program, which is running on the brand new Arduino Nano.

Step 6: Arduino Integrated Development Environment (IDE)

If you do not yet have the Arduino IDE installed, you can download it from Arduino.cc

If you would like additional introductory information for working in the Arduino ecosystem, we suggest checking out the instructions for the HackerBoxes Starter Workshop.

Plug the Nano into the MicroUSB cable and the other end of the cable into a USB port on the computer, launch the Arduino IDE software, select the appropriate USB port in the IDE under tools>port (likely a name with "wchusb" in it). Also select "Arduino Nano" in the IDE under tools>board.

Finally, load up a piece of example code:

File->Examples->Basics->Blink

This is actually the code that was preloaded onto the Nano and should be running right now to slowly blink the blue LED. Accordingly, if we load this example code, nothing will change. Instead, let's modify the code a little bit.

Looking closely, you can see that the program turns the LED on, waits 1000 milliseconds (one second), turns the LED off, waits another second, and then does it all again - forever.

Modify the code by changing both of the "delay(1000)" statements to "delay(100)". This modification will cause the LED to blink ten times faster, right?

Let's load the modified code into the Nano by clicking the UPLOAD button (the arrow icon) just above your modified code. Watch below the code for the status info: "compiling" and then "uploading". Eventually, the IDE should indicate "Uploading Complete" and your LED should be blinking faster.

If so, congratulations! You have just hacked your first piece of embedded code.

Once your fast-blink version is loaded and running, why not see if you can you change the code again to cause the LED to blink fast twice and then wait a couple of seconds before repeating? Give it a try! How about some other patterns? Once you succeed at visualizing a desired outcome, coding it, and observing it to work as planned, you have taken an enormous step toward becoming a competent hardware hacker.

Step 7: Arduino Nano Header Pins

Now that your development computer has been configured to load code to the Arduino Nano and the Nano has been tested, disconnect the USB cable from the Nano and get ready to solder.

If you new to soldering, there are a lot of great guides and videos online about soldering. Here is one example. If you feel that you need additional assistance, try to find a local makers group or hacker space in your area. Also, amateur radio clubs are always excellent sources of electronics experience.

Solder the two single row headers (fifteen pins each) to the Arduino Nano module. The six pin ICSP (in-circuit serial programming) connector will not be used in this project, so just leave those pins off.

Once the soldering is complete, check carefully for solder bridges and/or cold solder joints. Finally, hook the Arduino Nano back up to the USB cable and verify that everything still works properly.

Step 8: ENC28J60 Ethernet Module

The ENC28J60 (datasheet) is an Ethernet controller chip. Thanks to its SPI interface, it is reasonably easy to use with even the simplest microcontrollers.

Note that some versions of this module have an LDO voltage regulator allowing them to be driven by 5V even though the ENC28J60 chip is 3.3V. This version of the module DOES NOT have a voltage regulator and needs to be supplied with 3.3V externally.

The EtherCard Arduino Library performs low-level interfacing from your Arduino code to the network. The library comes with several examples. A nice one to start with is backSoon.ino which will let you access the sketch on the Arduino Nano from any web browser on the same LAN.

Step 9: Crossover Adapter Plug

An Ethernet crossover (Wikipedia) is a cable or adapter plug used to connect computing devices together directly. It is most often used to connect two devices of the same type, e.g. two computers (via their network interface controllers) or two switches to each other. By contrast, patch cables or straight through cables are used to connect devices of different types, such as a computer to a network switch or Ethernet hub.

Wiring within the crossover is intentionally crossed to connect the transmit signals at one end to the receive signals at the other end and vice versa.

Step 10: HACK THE PLANET

If you have enjoyed this Instrucable and would like to have a box of electronics and computer tech projects like this delivered right to your mailbox each month, please join the HackerBox revolution by SUBSCRIBING HERE.

Reach out and share your success in the comments below or on the HackerBoxes Facebook Page. Certainly let us know if you have any questions or need some help with anything. Thank you for being part of HackerBoxes. Please keep your suggestions and feedback coming. HackerBoxes are YOUR boxes. Let's make something great!