๐Ÿ“ฆ cyrozap / usbtop-ebpf

A top-like tool for monitoring USB traffic using eBPF, inspired by usbtop.

โ˜… 8 stars โ‘‚ 1 forks ๐Ÿ‘ 8 watching โš–๏ธ BSD Zero Clause License
๐Ÿ“ฅ Clone https://github.com/cyrozap/usbtop-ebpf.git
HTTPS git clone https://github.com/cyrozap/usbtop-ebpf.git
SSH git clone git@github.com:cyrozap/usbtop-ebpf.git
CLI gh repo clone cyrozap/usbtop-ebpf
cyrozap cyrozap Use defined transfer type instead of magic number 71916d9 3 months ago ๐Ÿ“ History
๐Ÿ“‚ master View all commits โ†’
๐Ÿ“„ LICENSE.txt
๐Ÿ“„ perf.c
๐Ÿ“„ pyproject.toml
๐Ÿ“„ README.md
๐Ÿ“„ usbtop.py
๐Ÿ“„ README.md

usbtop-ebpf

A top-like tool for monitoring USB traffic using eBPF, inspired by usbtop.

Unlike usbtop, which captures packets from usbmon and performs bus traffic calculations on URBs at the userspace level, this program uses an eBPF kprobe to collect USB traffic stats directly from URBs in the kernel.

Example output

Below is an example of the output from usbtop.py, showing a very fast read from a USB SSD connected to a 5 Gbps port and a much slower read from an RTL-SDR dongle.

Bus 6:
  Device   6.12  [0bda:9210]:
    0x81 (BULK, IN ):       3.38 Gbps    402.55 MiB/s
    0x83 (BULK, IN ):     104.88 Kbps     12.80 KiB/s
    0x04 (BULK, OUT):     209.77 Kbps     25.61 KiB/s
Bus 9:
  Device   9.30  [0bda:2838]:
    0x81 (BULK, IN ):       4.19 Mbps    512.00 KiB/s

Quick start

Software dependencies

  • On Arch Linux, run sudo pacman -S python-bcc.
  • On Debian, run sudo apt-get install python3-bpfcc

Procedure

  • Install dependencies.
  • Run sudo ./usbtop.py.

License

Except where stated otherwise, the contents of this repository are made available under the Zero-Clause BSD (0BSD) license.