My new place in Austin came with a huge perk for a tech geek like me – it came pre-wired for ethernet in every room. (Well, technically not every room is wired. The laundry room, bathrooms, and garage are not, an understandable oversight.)
After installing a new D-Link Gigabit Ethernet Switch, I wanted to check the throughput to see if I was actually getting gigabit speeds – particularly because the house is wired with CAT-5e cable (and not the recommended CAT-6).
There are many ways to measure network throughput. In the past I have usually copied a file across the network and used a stopwatch to get a relative sense of speed. However, due to file sharing protocol overhead I always got disappointing results and never knew maximum capability of my network.
This time, based on the advice of a more network-savvy friend, I decided to use a command-line tool called iperf.
iperf is a command-line tool to measure network performance. It is very powerful, but also easy to use for simple tests. For a more complete overview of what iperf is and what it can be used for, check out this tutorial or the iperf page on Wikipedia. iperf has a lot of options, and I won’t cover the majority of them here. For more usage information, consult the iperf manual.
If you run Debian or Ubuntu (Linux), iperf can be installed by executing
sudo apt-get install iperf
I did these tests with OS X on the Mac since both of my Macs have gigabit ethernet ports and my older PCs don’t. A package for iperf is conveniently available from Macports. It can be installed via the graphical package manager Porticus or opening a Terminal window and typing
sudo port install iperf
In my case, all I wanted was a quick test of TCP/IP network performance. This is easy to do, but it requires two computers, a client and a server, both connected to the network under test. Ideally, there should be no other network traffic during the test, as this will affect the results.
On the first computer, launch the iperf server by executing
You should see something like this:
Server listening on TCP port 5001
TCP window size: 64.0 KByte (default)
On the 2nd computer (the client), open a Terminal window and run
iperf -c <IP address or hostname of server> -i 1
Within a few seconds, you should start to see reports coming in on both the client and server terminal windows:
The last report (for the interval 0.0-10.0 sec) is the average throughput for the entire test. I’m more than happy with 854 Mbits (927 Mbits/sec peak!) given my fairly long runs of CAT-5e cable and other machines using the network. Contrast this with my results over 802.11g wireless:
This is the third part of an ongoing series about building a low cost, open source streaming internet radio. If you haven’t already, check out part one and part two for some background about the project.
Hacking the Asus WL-520GU Wireless Router:
In the last part of this series, I selected the Asus WL-520GU wireless router as a suitable embedded platform for my Wifi Radio project. I have since posted some detailed specs on this impressive low-cost router, revealing it’s powerful Broadcom BCM5354 core, 4MB flash, and 16MB SRAM. Granted, there are many more powerful routers out there that have USB support, will run Linux in various forms, and have built-in WiFi. However, the WL-520GU does almost everything we need to build a streaming internet radio and costs under $50 (I have seen them for as little as $26 after rebate), which is very impressive indeed.
To convert this router into a powerful embedded system, we need to make a couple modifications. First, we need to throw out the stock firmware. It turns out that this router, like many others, runs Linux from the factory. However, because it was designed to be a wireless router and not much else, the stock firmware doesn’t include a very wide set of features (and certainly was not intended to be accessed by the customer). Thankfully, there are several open source Linux distributions available that support this router, including my favorite, OpenWrt. In addition, Asus has made it fairly straightforward replace the stock firmware with our own custom Linux build which can include all the programs, drivers, and utilities we can cram into 4MB of flash.
Before we start hacking the router, there are a couple things I should mention:
From this point onward, your warranty is toast. Don’t even THINK about trying to send a modified router back to Asus for warranty service. In the end it hurts people like us, because Asus will try to make it harder for people to perform the same modifications in future products.
You may inadvertently destroy your router. If you are not comfortable with the fact that a misstep during the reflash or a stray solder bridge could ruin your hardware, stop now. Sorry. If you really take a wrong turn, you could damage your PC as well, but this is extremely unlikely. If you do somehow damage your router or PC doing these modifications, I assume no responsibility for any damages!
This tutorial assumes that you have already established the router is basically working by assembling it, plugging it in and checking for it’s wireless signal and internal webserver. The user manual does a good job of leading you through this process, but don’t use the supplied CD – follow the advanced/manual instructions instead.
Accessing the internal serial port:
The OpenWrt install will be easier if we can find a way to access the internal serial port of the router. The built-in serial port gives us a way to view Linux boot and status messages and get shell access as well. The serial port will also come in handy later when we want to add a user interface to the radio.
You will need:
A desktop or laptop computer with an open USB and Ethernet port.
Your shiny new ASUS WL-520GU wireless router (R1.02)
A basic electronics workbench with ample light, a temperature controlled soldering iron, a solder sucker, solderbraid, wirecutters, and pliers. Servo Magazine recently held a contest to see who could build the best electronics workbench for under $100, the results should be helpful for anyone just starting out. If you’re uncomfortable soldering, find someone else to help you with this part at your local hackerspace.
Step 1 – Open the router
Remove the power cord and antenna (the base unscrews). Flip the router over and look at the bottom. You should see something like this:
Note there are four screws that hold the router together, two are hidden underneath the rubber feet. The feet are stuck on really well, but persistent prying with a fingernail will get them off eventually. Remove the four screws and set them aside. The top cover should come off without too much trouble.
Now that the router is open, you should see something like this:
Step 2 – Add a serial port header
Remove the PCB from the plastic enclosure by gently pulling it up and towards you (ethernet ports facing away).
Just to the left of the ASUS logo in the photo below, you will see a 4-pin header that I have installed to access the internal serial port of the router, the router ships without this header. Instead, you will see four solder filled vias in a row in the same spot.
You will need to use your soldering iron and a solder sucker to remove most of the solder so that the header can be installed. A higher power soldering iron will help with removing solder from the first via on the left (mine is a 60W Weller WTCPT). This via connects to a ground plane which sucks heat away from the iron and makes the job more difficult. Be patient and persistent and you should be able to wick any remaining solder away with some soldering braid if necessary.
Break a 4-pin chunk of male header off the strip. Pop the header into the board and carefully solder it into place. If it doesn’t fit, chances are there is still some solder left in the vias. You should end up with something like this:
The pin functions are, from left to right in the photo:
GND TX RX 3.3V
Step 3 – Connect your PC
The FTDI-232-3V3 USB to serial adapter cable provides a handy way to add a 3.3V TTL level serial port to a PC or laptop. The cable has a flat connector on the serial end that can plug directly onto 0.1″ male headers like the one we are using on the router. Unfortunately, the pinout of the FTDI cable (given in the datasheet) does not match that of the router. To resolve this, you have two options:
Use a tiny screwdriver to pull out the pins from the housing at the cable and rearrange them. Do not connect anything to the 3.3V pin on the router, and swap the TX/RX so that the TX on the router feeds RX on the cable, and vice-versa. Don’t forget to connect the grounds! The downside of this is that now you can’t use the FTDI cable for things like the Boarduino without swapping the pins back.
Fabricate an adapter board using a small piece of perfboard and some headers, shown below (click for a larger version):
Here is a schematic of the adapter board:
Shown here are the cable and adapter installed on the router. Make sure the ground side of the cable is connected to the pin on the header that is opposite from the fat angled trace (the 3.3V line). Ground is the black wire, on my adapter I marked this with a black dot so I won’t forget and plug it in backwards.
Step 4 – Test the connection
Plug the cable into your PC (you may need some drivers) and open your favorite terminal program. (I like Zterm for the Mac or Hyperterminal on the PC.) Using the terminal program, open the serial port corresponding to the FTDI cable (something like usbserial-FTDQ23LB on the Mac or COM3 on the PC, but your setup may be different.) Set the port options to 115200 baud, 8N1.
Connect the antenna and power supply to the router and plug it in. You should see something like this appear in your terminal program:
CFE version 1.0.37 for BCM947XX (32bit,SP,LE)
Build Date: Thu Mar 6 10:05:04 CST 2008 (email@example.com)
If you do, congratulations, your serial port is working!
The lines that scroll by are boot messages from the Linux kernel of the stock firmware on the router. These messages give you a lot of information about the hardware in addition to information about the operating system and software drivers. Here is a complete transcript of the boot log from my router. If you wait a couple minutes for the router to finish booting and hit enter, you should see a command prompt. From here you can explore and play around with the stock firmware, there is really not much to do here until we reflash the router with OpenWrt.
That’s it for part three. In part four, I’ll talk about installing OpenWrt and connecting the router to your wireless network.
In my previous post about the Wifi Radio project I’m working on, I concluded that the Asus WL-520GU wireless router was the perfect choice for an embedded wireless platform, thanks to its builtin 802.11g WiFi, Linux support, and extremely low cost. (In fact, the price after rebate has dropped since my last post – now would probably be a good time to buy one if you’re thinking about hacking it into something eventually).
Here are the specs on this router, based on an inspection of the hardware and the stock firmware Linux kernel boot log (the complete log is here).
One external TX/RX whip antenna (RPSMA), internal diversity RX antenna on PCB
Internal 3.3V DC-DC converter
PCB Dimensions: 4.0″ x 5.6″
Supply: 5V @ <2A
Here are some images of the PCB, click for a larger version.
Here’s a closeup of the Broadcom BCM5354 SoC – the brains of the router. It is surrounded by a 4MB MX flash chip above and a Samsung 4MB SRAM chip on the right.
Overall this is a great little router and an even better platform to build an embedded Linux system, provided you don’t need USB 2.0 support. If you do, look at the WL-500gP v2 instead, it has two working USB 2.0 ports (in addition to much more flash storage and RAM).