Tuesday, March 14, 2017

Arduino port analyzer using CDP

At work, I occasionally get the question of what section of the network a wall jack is connected to. To answer that question, I used to carry around a big-ole laptop and do manual port traces.  However, the port tracing procedure isn't particularly fast and it's also difficult to delegate.  Fortunately, I work in an environment where we can use the Cisco Discovery Protocol to show what switch port a given device is attached to.  Due to this, it is possible to build a relatively inexpensive scanner from an Arduino UNO and a HanRun Ethernet shield.  Just plug in the device and power it on. It will then grab a DHCP address and then do a scan for CDP packets.  Once found, it will then report a bunch of useful information as seen above. Although it's not as small as could be made, it was relatively inexpensive to build and it's layout seems to be rugged enough to toss into the tool bag.

The housing was  printed in HIPS plastic. The design is not the most glamorous case in the world, but it should be printable on most any printer.  When it comes to servicing, all components can be easily removed if needed.   The STL files below allow printing of all case parts.  As you wire-wrap connections, print out the box.  Then manually drill out the side holes and screw together!

Operating the device is very simple and relatively quick.  Just plug in an Ethernet cord to the port being tested, then turn on the recessed DC slider switch on (upper left hole).  The on-board 9V battery works for quite a while.  However, if that happens to be drained, the device can also be powered from a USB cable or by attaching a 12v transformer to the barrel plug.

When it comes to performance, grabbing a DHCP is pretty quick but waiting for a CDP packet may take up to a minute depending on CDP settings of the equipment.  In testing, I found ports configured in access mode are detected reliably as are ports with no config. However, the parsing routine isn't quite smart enough to deal with voice settings yet. Once I adjust, I’ll release it as v0.9.  

Parts used for this project:
  • HanRun Ethernet shield HR911105A ver 11/16 (shown above, may be hard to get now)
  • Adafruit 1.44 color TFTP LCD display with MicroSD breakout
  • Arduino UNO 
  • 9v battery clip, micro switch, wire-wrap and some tiny screws I had laying about.
  • XP professional sp3 (not required, just what I happened to have)
  • Arduino software ver 1.0.3 (available at the Arduino site) 
Other downloads are available on this site:
Wiring is rather simple. Put on the Ethernet shield. Then follow the steps from Adafruit for the LCD to get the sample display routine working. They have much nicer pictures & diagrams than I can draw. Then, once graphics demo works,  replace that code with the code from this site. If you prefer, wiring is also noted in the pin out section within the code. There is one small addition not noted. It is to power the Arduino from battery. If this is desired, connect 9V positive (with an inline switch) from battery to Vin pin.  Battery ground goes to any of the grounding pins.  Since power can be by USB or barrel plug, the 9v battery feature Is nice, but can be considered optional.

 

Code is based on the work of Quistoph, Kirstain and many others!
If you found this posting helpful, please comment!