CDP Sniffing with an Arduino

Firstly full credit to Chris van Marle for his work on his CDPSniffino code, of which I have butchered (to be honest) to get it to work with ENC28J60 ethernet controllers. The packet info that is captured is slightly different, so it took a while debugging. This is also my first Arduino project (not including 3D printers). It has  been a while since I have written C code… Enough excuses…

Anyway, I use a lot of Cisco equipment and I have found on many occasion that network wall ports are either not labeled or the labels have worn off. When that port needs to be reconfigured it can take time to work out which network cabinet it goes back too, then which switch, and then which switch port. Most of the information can be obtained from CDP (Cisco Discovery Protocol):

  • The switch name gives a good indication of which cabinet and switch.
  • Model: Helps when the hostname has no indications of what the device is.
  • IP address: You can try to remotely access the switch (SSH/Telnet/Web interface).
  • The switch port is given (E.g; FastEthernet0/1).
  • VLAN: Good to know because it often determines what DHCP range is offered – I’m still working out if it’s the VLAN of the port or the “switch”.

The original code for CDPSniffino compiled fine on an Uno with a W5100 network shield (kudos again to Chris). I had always planned to make a few network enabled devices, and cost cuts are in effect. The ENC28J60 is significantly cheaper than the W5100, and the Arduino Mini Pro compatible boards have enough capacity to be a good substitute. Arduino Uno R3 + Wiznet W5100 shield >$20. Arduino Mini Pro + ENC28J60 = can be < $5 (shop around).

The ENC28J60 works with the Ethercard library. It took a while to find now to get the NIC to switch to promiscuous mode. When enabled the controller will process all packets it sees, and not filter multicast and broadcast packets.

To make it faster and easier to obtain the info, it needs a screen. The alternative is plugging it in and dragging out a laptop to read the info through a serial port. I tried a few no name LCD’s, but found (as many others have), that without correct information (datasheets or a driver name) it’s a huge time waster. Also most had 3.3v VCC and data lines (not 5v). Luckily I found a cheap supplier that did (after 3 failures). These have been pretty good, they can output text with basic commands using the Adafruit_ST7735 library. I mistakenly had 5V running to the LED line for a while (should be 3.3V) , after the LEDs cooled down, the blue tinge disappeared and all was fine.

The two test rigs shown below are both using ENC28J60 controllers, the larger on has a character LCD and Arduino Uno R3 board. The smaller one has an Arduino Mini Pro (compatible), and an ST7735 based color graphical LCD. During testing the larger one drained a 9V battery after about an hour of use. A goal was to make it small enough to  join to this and use the phone charger battery for power.

What I found when testing:

  • CDP is enabled by default on most Cisco devices.
  • The default schedule for sending CDP packets is every 60 seconds – Although this can be changed or disabled.
  • Wireless Access Points also have CDP enabled by default, which is good when tracing which WAP connects to which power injector (what out for POE!).
  • Un-managed consumer grade switches will pass CDP packets, so the switch you see may not be the one that is connected directly to the port. Also the heavier the traffic on an un-managed switch, the longer it takes to detect the packets. I believe this is because the ENC28J60 doesn’t not have a lot of processing power, and the Arduino Mini can’t keep up, so it drops packets when under heavy load.

All code and STL’s for the case will be published when I’m happy with the smaller test unit.

UPDATE: Reprinted case in green and crudely added it too the wireless serial device. Time for a field test.

UPDATE [24-06-14]: I’ve reduced the overall size of the case by about 10% by using a smaller ENC28J60 PCB, and started working on extra features. One of the features I’m working on is getting it to check for open ports (80, 22, and 23) on the detected equipment (if it’s IP can be obtained). If the switch accepts a connection on any of those ports you can gain access to the remote switch using network rather than using a serial cable.


ENC28J60 Ethernet controller with Arduino

This is a notes post for future reference
Description: Cheap/cheapest ethernet controller
Speed: 10MB/s (half duplex I believe)
POE: noOperating voltage: 5 or 3.3v
Libraries: EtherCard (My prefered).



Add the following to: enc28j60.cpp to enable promiscuous mode (disable ip filters), can be used for packet sniffing.

void ENC28J60::enablePromiscuous () {
writeRegByte(ERXFCON, 0);



#include <EtherCard.h>
byte Ethernet::buffer[500];
ether.begin(sizeof Ethernet::buffer, mymac,10);

if (!ether.dhcpSetup())
tft.print(“DHCP failed.”);


Controller -> UNO/Micro/Mini Pro (Compatible)
INT -> D2
SO -> D12
SI -> D11
SCK -> D13
CS -> D10 (or D8)
VCC -> 5V

ST7735 LCD 128×64 with Arduino

This is a notes post for future reference
Description: Cheap eBay color LCD display
Resolution: 128×160.
Size: 1.8″
Driver: ST7735
Colors: 18bit ?


Libraries: Adafruit_GFX, Adafruit_ST7735, SPI.



#define sclk 13
#define mosi 11
#define cs   4
#define dc   8
#define rst  -1
Adafruit_ST7735 tft = Adafruit_ST7735(cs, dc, rst);



Display -> UNO

SCLK -> 13
MOSI (SDA) -> 11
CS -> 4
DC (AO) -> 8
VCC -> 5V
LED -> 3.3v

SSD1306 OLED 128×64 with Arduino

This is a notes post for future reference
Description: Cheap eBay monochrome OLED display
Resolution: 128×64.
Size: 0.96″
Driver: SSD1306 ?

SSD1306 128x64 OLED







Libraries: U8glib (trying to get it to work with Adafruit_SSD1306.h).




//Uncomment this line from the examples:
U8GLIB_SSD1306_128X64 u8g(U8G_I2C_OPT_NONE);    // I2C / TWI


Display -> UNO
SDA -> A4
SCK -> A5
VCC -> VCC (5V)

Basic MK802ii Wall/Desk Mount

To celebrate getting new batteries for both of my digital calipers, I made a quick and easy wall or desk mount for a MK802ii, which I’m using Debian and motion to stream the webcams on my 3D printers (1 each and 1 for the room = 3). The HDMI cover was made by inverting an already existing HDMI plug in Sketchup online library. Although I haven’t used it for very long, I figured having the MK802ii vents (2x sets of air holes) facing out would be the best way to dissipate heat. If heat is still an issue I’d add a bracket for a 5v 40mm fan, and use part of the 5v USB.

Here’s the STL file: mk802_ii

Serial to Bluetooth Convertor

This is a far better version of this wireless serial port. Why bother? I use them for configuring Cisco equipment for work. If you have ever been standing on a chair, balancing your laptop, trying to program a managed switch, you’ll appreciate being able to sit comfortably at a desk close by, while doing it wirelessly. Just screw the console cable onto the RS-232 and turn it on.

  • New: 2-3 Seconds boot time.
    • Old: 20-30 seconds.
  • New: Battery life lasts around 48hrs when continuously transmitting. If you double tap the charge button on the battery it turns on an excellent flash light. Good for finding your way around the back of network racks.
    • Old: About 3-4hrs.
  • New: Auto turns off when inactive
    • Old: Stays on until dead battery.
  • New: Smaller, and easier to manufacture – minor soldering required.
    • Old: bigger and now requires hardware hack, then firmware mod, etc…

This newer version was also made modular; If the Bluetooth module, or battery fail, you can easily replace it. You can also design different modules to fit on the reverse side to the Bluetooth or replace it all together. The model below is the second iteration where I added an on/off switch to the Bluetooth module.

At the heart of the Bluetooth module is a JY-MCU soldered to a daughter board with 2 RS-232 connectors, 1 for programming the device, the other one is a pass through serial port. Do a search on eBay for “DB9 RS232 Wireless Bluetooth Module Slave” – Their about $15.

In the Sketchup screenshots below the battery has been left out.

These are the STL files: serial 2 Bluetooth. The portable phone charger used is a Romoss 2000mAh, you can get them for about $15 on eBay. I printed it using natural PLA so the photos look pretty terrible. It’s also printed as 4 pieces: Battery case, battery cap, Bluetooth module, and Bluetooth module lid. You also need a male USB cable, slide switch, 2 screws (40-50mm M3) and nuts.



Bluetooth Speakers and Squeezeslave

The setup serving audio in our kitchen was pretty conviluded and had a few too many cables jammed into a cupboard: A thin-client with powered speakers, attached to a wireless access point set to client mode. I picked up a newer set of powered speakers that came with a 30 pin iPod/iPad dock – so I looked online and found an attachment for the iPod dock that converts it to a Bluetooth audio receiver (similar to this), so you can connect with any Bluetooth enabled music device (phone, laptop, etc.). I have a laptop (Media Director for LinuxMCE) hooked up to a TV in a close room that’s on most of the time anyway, so I paired the Bluetooth receiver to a laptop and setup squeezeslave to pass audio to the speakers.

In summary: Before – Thin-client, wireless access point and speakers. Now – Speakers with a bluetooth adapter. I pulled 2 power packs, 4-5 cables and 2 devices from the cupboard. Not only am I saving power (+ money), it’s a cleaner looking setup.

To setup the bluetooth audio in LinuxMCE (12.04) I did the following:

  • Check to make sure a bluetooth dongle in laptop is detected correctly:

# hcitool dev
hci0    xx:xx:xx:xx:xx:xx <– Built in device wouldn’t connect successfully. I’m also pretty sure it was integrated into the wireless chipset.
hci1    xx:xx:xx:xx:xx:xx  <– USB bluetooth dongle which worked fine.

  • Scan for Bluetooth devices (it must be in discoverable mode): hcitool scan
  • Connect to speakers: bt-device –adapter=hci1 -c xx:xx:xx:xx:xx:xx

“hci1″ is the USB dongle, “xx:xx:xx:xx:xx:xx” is the MAC address from the above scan.

  • Check to make sure it joined correctly:

# bt-device -l
Added devices:
H168C (xx:xx:xx:xx:xx:xx)

  • Connect the Bluetooth audio service: bt-audio –adapter=hci1 -c xx:xx:xx:xx:xx:xx
  • Added device to the trusted list: bt-device –set H168C Trusted 1

“H168C” is the name of the audio device.

  • Edit /etc/bluetooth/audio.conf


# If we want to disable support for specific services
# Defaults to supporting all implemented services

# SCO routing. Either PCM or HCI (in which case audio is routed to/from ALSA)
# Defaults to HCI

# Automatically connect both A2DP and HFP/HSP profiles for incoming
# connections. Some headsets that support both profiles will only connect the
# other one automatically so the default setting of true is usually a good
# idea.


  • Restart Bluetooth servive: service bluetooth restart
  • Install squeezeslave:  apt-get install squeezeslave
  • List available audio devices squeezeslave detects: squeezeslave -L
    Output devices:
    0: (ALSA) HDA Intel: CONEXANT Analog (hw:0,0) (11/46)
    1: (ALSA) sysdefault (42/46)
    2: (ALSA) front (11/46)
    3: (ALSA) surround40 (11/46)
    4: (ALSA) surround51 (11/46)
    5: (ALSA) surround71 (11/46)
      6: (ALSA) rawbluetooth (139/139)
    7: (ALSA) analog_playback (42/46)
    8: (ALSA) asym_analog (42/46)
    9: (ALSA) dmix (42/42)
    *10: (ALSA) default (42/46)
  • Test run of audio device: squeezeslave –retry -o6 <IPAddress of Server>
  • Edit /etc/rc.local

bt-audio –adapter=hci1 -c xx:xx:xx:xx:xx:xx
squeezeslave –retry -o6 <IPAddress of Server> -M -Y /var/log/squeeze.log

  • On DCERouter change the Media Director’s sound settings to manual.
  • Always reboot to make sure the settings are all working

So far it looks pretty good, although it’s having issues starting at boot time, but it shouldnt be too hard.



Control LimitlessLED Globes With an Arduino

This is a quick post so please consider it a work in progress. I’ve purchased some Limitless RGB LED globes and a wireless controller for them. The wireless controller,  you can send it small UDP packets to make the paired globes change. By referencing their API, it’s pretty easy to write your own programs.

In this example I used an Arduino with a network shield and a PIR sensor. The goal was to get the PIR sensor to detect someone in the room and turn a desk lamp on.

Part Specifics: PIR Sensor – HC-SR501 Motion Sensor Module, Network Shield – Ethernet Shield W5100, Arduino UNO, Limitless v2 wireless controller, 2 RGB Globes

This is the program written for the Arduino. DISCLAIMER: The code is pretty dirty with no comments. It also needs some refining and cleaning up: LimitlessLED_Arduino

What the program does: Turns the lamp on, cycle down the disco modes to reach white, turn off, wait for the sensor to detect movement, turn on the lamp, and keep checking to see if there is any further movement before turning off again after a few seconds.

In future revisions of the code I hope to implement other features; Maybe beat/noise detection, and custom color animations.

Custom 5.25 Drive Bay Name Covers

Painted white, then black around the outside

When you buy a new computer or phone you often customize it to make it look and feel just the way you want. I’ve not really done a PC case mod in ages so I spent a short time finding the standard CDROM drive bay specifications (dimensions and screw hole placement), page 9. Created a template in Sketchup, printed face down, then face front. Face down looked better but face front was stronger. Changed the design to have removable legs so they can be printed separately, then screwed together. the images below were done for my gaming PC. As you can see my naming scheme is Transformers based.

The textured lines in the engraved text is where the bridging has failed. I kinda like it. Eventually I would like to fill the letter space with color, and try some aged effects, etc..

The STL File used for my LinuxMCE box is here: linuxmce3


Altec Lansing ACS48 Finished

I was out clearing some space in the shed and found these speakers.  I figured I’d do a quick case for the controls and speaker outputs. It’s pretty basic, and took longer to print than design. It was only supposed to be a quick fix, and as you can see from below, the text did not turn out at all, but the rest is OK. Perhaps next time I’ll use symbols instead of letters.

The STL files are here: bassbox.


Copyright © All Rights Reserved · Green Hope Theme by Sivan & schiy · Proudly powered by WordPress