Is it possible to programmatically query for current USB controller bandwidth usage?

4

I am using three Logitech C920 webcams with mjpg-streamer. The setup works extremely well, but I just realised that it doesn't scale. I began encountering bandwidth issues when bumping the frame rate up from my usual favourite of 5 FPS to 10 FPS and higher (which should be more-or-less equivalent to adding another webcam.) Basically, I didn't realise the 480Mbit/s theoretical limit was per USB 2.0 controller; I thought it was per port. It made me think that advertising theoretical USB 2.0 speeds as 480Mbit/s is misleading, but considering I haven't read the USB specifications I'll settle with the fact that it was purely a naïve assumption on my part.

I know that the board I have set this up on, the Intel DN2800MT, has only one USB 2.0 controller:

gw1 ~ # lsusb -t | grep ehci
/:  Bus 01.Port 1: Dev 1, Class=root_hub, Driver=ehci-pci/8p, 480M

But I also know that my Logitech C920 webcams support hardware-accelerated h264 decoding:

gw1 ~ # v4l2-ctl --list-formats
ioctl: VIDIOC_ENUM_FMT
Index       : 0
Type        : Video Capture
Pixel Format: 'YUYV'
Name        : YUV 4:2:2 (YUYV)

Index       : 1
Type        : Video Capture
Pixel Format: 'H264' (compressed)
Name        : H.264

Index       : 2
Type        : Video Capture
Pixel Format: 'MJPG' (compressed)
Name        : MJPEG

So, I should be able to create a workaround by switching the webcams to h264 mode as I believe that would use less bandwidth (and then of course use a different program to fetch the imagery, but leave that to me for later.)

Given all of this, is there any way to find out how much of a USB controller's total available bandwidth is presently being consumed? It would simply help me put some numbers to my experience with this setup. My gut feeling is probably-but-it's-not-that-easy. If anyone can shed some light on this, I'd love to know.

Milos Ivanovic

Posted 2013-10-18T14:35:13.340

Reputation: 580

It's correct that it is 480mbps per bus and you will have mobo vendors occasionally "cheat" by sharing a single bus with multiple ports. It's usually done to lower cost, as you may find on the Raspberry Pi - it's USB bus bandwidth shares both two USB ports and an onboard ethernet controller. – Hengjie – 2013-10-19T08:37:58.623

Answers

0

There is a tool 'pv' that you could download if you don't have it.

$ cat /dev/zero | pv > /media/your_usb/tmpfile

will give you the speed in which the file 'tmpfile' is written through your usb controller.

$ cat /media/your_usb/tmpfile | pv > /dev/null

will give you the speed in which the same file is read.

Paul Bergström

Posted 2013-10-18T14:35:13.340

Reputation: 352