MAC Address Reader

Published on 2021-01-15 by molzy

One day, while in the process of organising some stock for a project at work, I noticed an issue which I later discovered had been wasting some people's time.

Namely, it turns out that some manufacturers ship networked devices without including the MAC address of the Ethernet NIC on the packaging.


Streamlining Tedium

Identifying A Problem

Since many networks these days use DHCP servers with static leases, and some even use MAC address filtering as a security-by-obscurity measure to filter traffic from unknown addresses, creating a list of device MAC addresses in advance of delivery and installation is often required.

Many useful pieces of product information are regularly included as a sticker on the outer packaging, including serial numbers, batch numbers, date of manufacture, and so on. Missing out on the MAC address left us with no alternative but to crack open the boxes, one by one, and take a look at the products.

In most cases, we are able to find a sticker on the product itself, with the MAC address included - usually in a font no more than 2mm tall. That's a lot of squinting, but still somewhat manageable, though more time consuming to remove all of the packaging.

Not Always Trivial

However, for some very special products, there is no sticker at all! The only method of finding the MAC address is to power on the device, and dig through some manufacturer-specific menus...

Which sometimes don't contain the MAC address either! Fantastic! Now what?

Of course, dear reader, you know just what to do. You quickly download WireShark onto the Windows Vista warehouse laptop with all of the tracking spreadsheets, you know the one. It even has a built in Ethernet port, right next to the DVD drive, and the PCMCIA slot. You start listening to traffic on the port, apply power to the product, and plug in the laptop with a lengthy CAT6 cable.

Some packets flood in, and by carefully ensuring that you pick a peck of pickled packets which did not originate from your device, you can find the MAC address!

Editor's note: Some very strange devices with multiple Ethernet ports may require reading a provided manual to determine which of the ports is intended to connect to a network. Other ports may be used for proprietary streaming protocols, or as serial / console access ports.

Why That Won't Do

In my opinion, the above procedure sucks. Most of the steps are easy to document on a sticky note, but that last Wireshark step in particular is a stinker, particularly if a non-technical person is expected to complete the procedure irregularly.

I had some free time, some spare parts, and a desire to solve this problem. That was more than sufficient for me to start building a tool to make this data collection more efficient.


Building A Reader

Parts & Problems

I took the following spare parts out of storage, and started measurements.

Note that the links provided above are for reference only. A cheaper supplier was used to provide the ENC28J60 Ethernet module; I would recommend shopping around.

The first thing to do is to figure out how to fit the items into the enclosure. To determine this, we will need to think about the wiring between the modules.

First problem - the ENC28J60 needs to be connected via the SPI bus to the Arduino, and this particular device is built into a cute little plastic enclosure of its own, with SPI vias on the internal PCB! As seen in this picture, numbers 11, 12, and 13.

Microview SPI Pins

So, I deconstructed the Microview to reach these pins, and as a bonus, regained some space within the larger enclosure.

Spatial Arrangement

The Ethernet module board was going to monopolise the top of the enclosure, so the Microview would have to be positioned at the lower end. I measured the devices and enclosure, and laid out the internals in a test fit, before cutting holes in the top, side and front of the enclosure. My tools of choice, a drill and a stanley knife, were imprecise enough to end up producing some wavy lines. However, the end result was accurate enough to be usable.

I proceeded to connect the Microview to the ENC28J60, and the power source, with small wires and a soldering iron. After completing this task and placing all components inside the case with some additional padding, the prototype had taken shape!

Prototype internals after completion

The Ethernet module board was secured to the enclosure using some nuts and bolts, and the Microview display was protected from finger jabs by using a cut-out from an unused screen protector as a window for the front of the enclosure.

The reader requires 5v power, which can easily be supplied by a USB battery bank! I connected a USB cable to the unit for this purpose. Ethernet is a power-hungry protocol which was never intended to be used by small, battery-powered devices, so I have also included a power toggle switch to ensure that the prototype can be switched off when not in use.

Parsing Code

Before completing this task, I had written and deployed some proof-of-concept code, which had been tested on a breadboard before commencing the build.

This code reads the first packet it finds in the receive buffer of the ENC28J60, and picks out the particular bytes in the standard Ethernet frame header which usually correspond to the source device MAC address. Those bytes are then displayed to the screen, while a small Space Invader wiggles to inform you that the process is complete.

The most faulty assumption made by this code, as shown on the linked page, is that all received frames will be Standard IEEE 802.3 Ethernet frames. An Ethernet II frame would produce incorrect results, due to the differing header structure.

In practice, I have not encountered a device that has sent a packet large enough to require the Ethernet II standard (greater than 1500 bytes) among the first dozen packets. This may be worth parsing in future, when a more complete prototype is created.


Summary

The completed prototype can be seen in the below image, displaying a device MAC address which was read within a few seconds of applying power to the reader!

Completed prototype, displaying MAC address

At the end of the day, this is the manufacturer's problem to solve. Some of them offer to send a list of product MAC addresses paired with serial numbers, as long as you send them a polite email with the order number. Others eventually see reason, and start stickering their products and packaging. But this is merely one of those minor annoyances caused by indifference, so I would argue that it will never be fully solved.