LLDPi - Raspberry Pi Network Tool

The LLDPi project is an embedded system made from a Raspberry Pi and screen that can retrieve LLDP (Link Layer Discovery Protocol) information from neighboring devices on a network such as the system name and description, port name and description, VLAN names, and IP management address. In this tutorial we will go over the necessary steps to put together a LLDPi system made up of the following parts.

Raspberry Pi 2 B (Or newer) + microSD memory card

https://www.amazon.com/Raspberry-Pi-Barebones-Kit-...

Elecrow 5-inch TFT LCD HDMI Display

https://www.amazon.com/Elecrow-RPA05010R-800x480-...

6000 mah Portable Power Supply (should be enough capacity to last about 4 hours) https://www.amazon.com/myCharge-RazorMax-6000mAh-...

Spool of 3-D printing filament to print an enclosure for the LLDPi *(You will need access to a 3-D printer)

4 x 2" machine screws (to hold the case together)

microSD adapter to read/write from PC with Monitor, HDMI cable, Keyboard & Mouse to setup Raspberry Pi

Step 1: 3D Print Case

After you have found your favorite color of printing filament that is compatible with the 3-D printer you are going to use, then download these 4 files and start printing them. These files are slightly modified from the original version of this case from thingiverse which can be found at the following link,

https://makerware.thingiverse.com/thing:2428673

Step 2: Install Raspbian on SD Card

You will need to have a firm understanding of Linux to be able to make an LLDPi.

Go to the link below and download the latest version of Raspbian with Desktop.

https://www.raspberrypi.org/downloads/raspbian/

Use your computer to write the OS image onto the microSD card. Unzip the Raspbian file and go to the following link to view instructions specific to the OS you are currently using to install the image.

https://learn.sparkfun.com/tutorials/sd-cards-and-...

Now we should be able to plug the microSD card into the Raspberry Pi 3 and boot it up. Make sure the raspberry pi is hooked up to a monitor and keyboard and has an internet connection when going through this guide.

Step 3: Setup Raspbian on the Raspberry Pi

First we will make sure that the keyboard works properly by specifying which locale to use. Run the following command, where $ is the command line prompt, don't type it in.

$ sudo raspi-config

This should now take us to a screen where we can edit the Localisation Options, it should be the fourth on the list. Now we want to select Change Locale, go down the list and hit space bar on the locale named en_US.UTF-8 UTF-8 and set it to default on the next screen. We also need to change the timezone by going back into the Localisation Options and select Change Timezone and set it to America / Denver

Now we need to go into Boot Options, Desktop / CLIDesktop Autologin in order for the pi to autologin when booting up. Let's go into the Advanced Options and select Expand Filesystem to use the entire SDcard. We might also want to change the user password by selecting the first option, Change User Password. It is highly recommended to write the password down, don't forget it! The default password is raspberry. Then hit Finish to exit. The Raspberry Pi might need to reboot for the changes to take effect. Now open a terminal and run the following command and select this set of options when prompted,

$ sudo dpkg-reconfigure keyboard-configuration

Generic 105-Key (Intl) PC

Other ->then-> English (US)

The default for the keyboard layout

No compose key

No

Our next step is to update and upgrade Raspbian to the latest version. To do this simply open a terminal and type,

$ sudo apt-get -y update && sudo apt-get -y upgrade

If the last command doesn't finish properly or gives a message about a broken package, then we might need to reboot and re-run the command. Wait until that finishes running and then execute the following the commands,

$ sudo apt-get -y update

$ sudo apt-get install -y vim tshark tcpdump ethtool gawk

When asked "Should non-superusers be able to capture packets?", hit Yes.

Step 4: Configuring the LCD Display

The next steps will be to configure the LCD display to work with the Raspberry Pi. Turn off the Raspberry Pi, mount the LCD display and power it back on so that it matches the pictures above. Make sure the HDMI ports line up like shown in the picture and plug in the HDMI connector.

Next, we need to execute the following commands to download and install the driver for the LCD display.

$ git clone https://github.com/Elecrow-keen/Elecrow-LCD5.git

$ cd Elecrow-LCD5

$ sudo ./Elecrow-LCD5

and type y to reboot. After the device finishes rebooting, we will also need to make changes to the display orientation.

$ sudo vim /boot/config.txt

and look towards the end of a file for a line like

display_rotate=0

and change it to

display_rotate=3

Reboot the Raspberry Pi, wait until the Raspberry Pi boots up again and open up a terminal. And run the following command to install a way to calibrate the touch screen.

$ sudo reboot

$ sudo apt-get install -y xinput-calibrator xinput xserver-xorg-input-evdev

The X and Y axis of the touch screen need to be swapped so we perform the following changes to finish orienting the screen.

$ xinput --set-prop 'ADS7846 Touchscreen' 'Evdev Axes Swap' 1

$ xinput --set-prop 'ADS7846 Touchscreen' 'Evdev Axis Inversion' 1 0 #################################################################

If there ARE errors after executing the commands above then you can try making these changes to the driver files used by the Raspberry Pi. Depending on which Raspberry Pi you are using for this LLDPi there might be some slight differences with setting up the LCD drivers and/or other settings. When setting this up with a Raspberry Pi 3, there was a problem with the LCD using the following config file

/usr/share/X11/xorg.conf.d/40-libinput.conf

When it should have been using this config file for another driver evdev

/usr/share/X11/xorg.conf.d/10-evdev.conf

To fix this run the following commands,

$ sudo mv /usr/share/X11/xorg.conf.d/10-evdev.conf /usr/share/X11/xorg.conf.d/45-evdev.conf

$ sudo reboot

Then try running the commands to swap the X and Y axis again.

$ xinput --set-prop 'ADS7846 Touchscreen' 'Evdev Axes Swap' 1

$ xinput --set-prop 'ADS7846 Touchscreen' 'Evdev Axis Inversion' 1 0

If this still does not work then you will need to look for another way of getting the touchscreen configured properly.

###############################################################

If the commands DO work and the touchscreen works properly then proceed to edit the following file to have these 3 lines of code.
$ vim /home/pi/.config/lxsession/LXDE-pi/swapAxis.sh

#!/bin/bash

xinput --set-prop 'ADS7846 Touchscreen' 'Evdev Axes Swap' 1

xinput --set-prop 'ADS7846 Touchscreen' 'Evdev Axis Inversion' 1 0

exit 0


Don't forget to give the script the appropriate file permissions.
$ sudo chmod 755 /home/pi/.config/lxsession/LXDE-pi/swapAxis.sh

The next command will ensure the app starts and axis are swapped correctly every time the Pi boots up.

$ sudo vim /home/pi/.config/lxsession/LXDE-pi/autostart

Append the following 2 lines,

@/home/pi/.config/lxsession/LXDE-pi/swapAxis.sh

@lxterminal

Step 5: Coding the LLDPi Application

Now that we have configured the hardware we can proceed to work out the code that will create a GUI and gather all the information we need. The files with the code necessary for this application are located at the bottom of the page. You should download them and make sure they are in their correct respective directory paths, as shown below.

$ mkdir /home/pi/LLDPi

$ cd /home/pi/LLDPi

$ touch /home/pi/LLDPi/lldp

$ touch /home/pi/LLDPi/getSWITCHinfo

$ touch /home/pi/LLDPi/getVLANinfo

$ touch /home/pi/LLDPi/LLDPiGUI.py

$ touch /home/pi/LLDPi/reset

***Might need to run this to make the scripts above executable

$ chmod 755 filename

$ touch tshark.cap

$ sudo chown root:root tshark.cap

$ touch tcpdump.cap

$ touch displayLLDP.txt

$ touch progess

This will make a convenient icon at the Desktop screen that the user can double-click to start the LLDPi Application. Edit the following file to create the icon and make sure it has the following contents.

$ vim /home/pi/Desktop/LLDPi.desktop

[Desktop Entry]
Name=LLDPi

Comment=RUN LLDPi Script

Exec=/home/pi/LLDPi/LLDPiGUI.py

Terminal=true

Type=Application


If you have a picture to use as an icon then add a line to the LLDPi.desktop file that reflects the directory path to the picture,

Icon=/absolute/path/to/picture/file

Give the scripts a test run by checking the output of ./LLDPiGUI.py or by clicking the icon on the main screen

$ vim ~/.bashrc

Add a line like the one below at the end of ~/.bashrc to start the LLDPi app at boot time. /home/pi/LLDPi/LLDPiGUI.py


And that should be it, the LLDPi should be complete and ready to try out.

Share

    Recommendations

    • Optics Contest

      Optics Contest
    • Make it Glow Contest 2018

      Make it Glow Contest 2018
    • Plastics Contest

      Plastics Contest

    Discussions

    0
    None
    slowthumbs

    Question 3 months ago

    Can the files for step 5 be re-posted? The only one that's available for download in the LLDPPiGUI python script, the rest come back 403 forbidden.