Monitoring USB utilization on Raspberry Pi

I recently researched monitoring the USB utilization on a Raspberry Pi to help determine in theory if it was possible to run multiple Dongles and dump1090 instances on a Pi2. Wireshark is a GUI app, so you will need a monitor, keyboard, and mouse. (works with X11 tunneling if you understand how to do that too) If you would like to do similar monitoring on your own gear, here are the steps to set up USB monitoring for wireshark running on raspian.

First thing you need to do is install wireshark on your pi
sudo apt-get update
sudo apt-get install wireshark

Next you need to enable usbmon in the linux kernel. I created a quickie script to do it for me since it will need to be done each time the OS is rebooted:

vi mountusbmon.sh


#/bin/sh
sudo mount -t debugfs none_debugs /sys/kernel/debug
sudo modprobe usbmon
sudo chmod 755 /sys/kernel/debug
sudo chmod 644 /sys/kernel/debug/usb/usbmon/*

execute the script after making it executable:
chmod 750 mountusbmon.sh
./mountusbmon.sh

Get a list of your USB devices so you can identify traffic by device
lsusb
Bus 001 Device 002: ID 0424:9514 Standard Microsystems Corp.
Bus 001 Device 001: ID 1d6b:0002 Linux Foundation 2.0 root hub
Bus 001 Device 003: ID 0424:ec00 Standard Microsystems Corp.
Bus 001 Device 004: ID 0bda:2832 Realtek Semiconductor Corp. RTL2832U DVB-T

Start wireshark:
wireshark


Select the usbmon1 device and then click start. The capture will begin and you should see data flowing on the screen. You can let the capture run while you play around with the features of wireshark, but I prefer to capture for a period and then stop the capture. (ie 60 seconds)

To see a pretty graph, click [statistics] → [IO Graph]


After the graph window pops up, make some adjustments to the filters and x/y access parameters
Graph 1 set to my RTL-SDR dongle usb.device_address == 4
Graph 2 set to my wired network jack usb.device_address = = 3
X axis – Tick interval 1 sec – Pixels per tic ** 1**
Y axis – Unit: Bytes/tick – scale auto


With 1 second samples, you see the USB dongle is “averaging” 10MB/sec and network is about 1MB/sec

If you crank up the sample detail (tick interval), you can see the data is bursty:


Zoomed in the sample detail even more (.01/sec)

Have fun and enjoy !
Cheers!
LitterBug

great tutorial, thanks – Wireshark and nmap are some of my favourite tools…

From the looks of things, supporting a pair of SDRs running dump1090-mutability and PiAware won’t be an issue from a computational or an I/O bandwidth standpoint; power is easily addressed using a powered USB hub. As long as the Ethernet traffic is managed, things look good!

bob k6rtm

What’s your process and ram utilization running full-blast?

An alternative note, I just downgraded to an A+ I had lying around unused. I’m only running one instance, hooked up to to a hub to power the Pi and connect to the wifi and SDR, everything chugging away happily with plenty of CPU and memory to spare.