Ubuntu – Virtual USB bus using TCP

usbwindows

I have a router that a printer can be attached to to print wirelessly to. It appears that the software for Windows uses a virtual USB bus using TCP. This allows the printer to appear as if it was plugged directly into the computer.

Windows device driver

Is it possible to create a virtual USB bus using TCP on Ubuntu or is this a custom protocol used by the router and Windows software?

Best Answer

This is potentially a custom/proprietary protocol used by your router and the software designed by the manufacturer.

However, USB over IP is a thing and it can be used on Ubuntu. Assuming your router is using the standard USB over IP and not a custom protocol, this page (paraphrased below for anyone who finds this through google) should help you set it up.

  1. Install usbip

    sudo apt-get install usbip

  2. Load the vhci-hcd kernel module

    modprobe vhci-hcd

  3. Check if it really got loaded

    lsmod | grep vhci_hcd

    (Your out should be similar to below)

    root@client1:~# lsmod | grep vhci_hcd
    vhci_hcd               19800  0
    usbip_common_mod       13605  1 vhci_hcd
    root@client1:~#
    
  4. (optional) Add module to load on boot

    sudo echo vhci-hcd >> /etc/modules

  5. Connect to the server (your router) and get a list of devices.

    usbip -l serverip

    Replace serverip with the IP address of your router.

    Example output:

    root@client1:~# usbip -l 192.168.0.100
    - 192.168.0.100
         1-1: SanDisk Corp. : Cruzer Micro Flash Drive (0781:5151)
            : /sys/devices/pci0000:00/0000:00:07.2/usb1/1-1
            : (Defined at Interface level) (00/00/00)
            :  0 - Mass Storage / SCSI / Bulk (Zip) (08/06/50)
    

    Note the designation of the USB device you want to use (1-1 in this example).

  6. Attach the remote device to the local computer.

    usbip -a serverip designation
    

    e.g.

    usbip -a 192.168.12.34 1-1
    

    The remote device should now be attached locally to your computer. You should see it listed if you execute lsusb from the terminal.

Related Question