【发布时间】:2022-01-04 16:54:52
【问题描述】:
我正在尝试通过分析 Wireshark 在我的键盘上嗅探的输出来了解 USB 协议。例如,考虑这个框架:
Frame 29335: 72 bytes on wire (576 bits), 72 bytes captured (576 bits) on interface usbmon1, id 0
Interface id: 0 (usbmon1)
Encapsulation type: USB packets with Linux header and padding (115)
Arrival Time: Jan 4, 2022 17:44:50.003878000 CET
[Time shift for this packet: 0.000000000 seconds]
Epoch Time: 1641314690.003878000 seconds
[Time delta from previous captured frame: 0.205081000 seconds]
[Time delta from previous displayed frame: 3.343982000 seconds]
[Time since reference or first frame: 342.817999000 seconds]
Frame Number: 29335
Frame Length: 72 bytes (576 bits)
Capture Length: 72 bytes (576 bits)
[Frame is marked: False]
[Frame is ignored: False]
[Protocols in frame: usb]
USB URB
[Source: 1.5.1]
[Destination: host]
URB id: 0xffff8cbe330fba80
URB type: URB_COMPLETE ('C')
URB transfer type: URB_INTERRUPT (0x01)
Endpoint: 0x81, Direction: IN
Device: 5
URB bus id: 1
Device setup request: not relevant ('-')
Data: present (0)
URB sec: 1641314690
URB usec: 3878
URB status: Success (0)
URB length [bytes]: 8
Data length [bytes]: 8
[Request in: 29167]
[Time from request: 3.343946000 seconds]
[bInterfaceClass: Unknown (0xffff)]
Unused Setup Header
Interval: 16
Start frame: 0
Copy of Transfer Flags: 0x00000204, No transfer DMA map, Dir IN
Number of ISO descriptors: 0
Leftover Capture Data: 0000290000000000
这里是相关的 lsusb 输出:
> sudo lsusb -s 001:005 -vvvvv
Bus 001 Device 005: ID 046d:c312 Logitech, Inc. DeLuxe 250 Keyboard
Device Descriptor:
bLength 18
bDescriptorType 1
bcdUSB 1.10
bDeviceClass 0
bDeviceSubClass 0
bDeviceProtocol 0
bMaxPacketSize0 8
idVendor 0x046d Logitech, Inc.
idProduct 0xc312 DeLuxe 250 Keyboard
bcdDevice 1.01
iManufacturer 1 LITEON Technology
iProduct 2 USB Multimedia Keyboard
iSerial 0
bNumConfigurations 1
Configuration Descriptor:
bLength 9
bDescriptorType 2
wTotalLength 0x0022
bNumInterfaces 1
bConfigurationValue 1
iConfiguration 0
bmAttributes 0xa0
(Bus Powered)
Remote Wakeup
MaxPower 70mA
Interface Descriptor:
bLength 9
bDescriptorType 4
bInterfaceNumber 0
bAlternateSetting 0
bNumEndpoints 1
bInterfaceClass 3 Human Interface Device
bInterfaceSubClass 1 Boot Interface Subclass
bInterfaceProtocol 1 Keyboard
iInterface 0
HID Device Descriptor:
bLength 9
bDescriptorType 33
bcdHID 1.10
bCountryCode 0 Not supported
bNumDescriptors 1
bDescriptorType 34 Report
wDescriptorLength 65
Report Descriptors:
** UNAVAILABLE **
Endpoint Descriptor:
bLength 7
bDescriptorType 5
bEndpointAddress 0x81 EP 1 IN
bmAttributes 3
Transfer Type Interrupt
Synch Type None
Usage Type Data
wMaxPacketSize 0x0008 1x 8 bytes
bInterval 24
can't get debug descriptor: Resource temporarily unavailable
Device Status: 0x0000
(Bus Powered)
“29”根据我按下的键而有所不同。如何将其映射回特定键?是否需要更多上下文来解释这个框架?
【问题讨论】:
-
您是否在 x86-64 CPU 架构上进行测试?
-
@user123 是的。这些有效载荷的解释是否会因此而有所不同?
-
我不这么认为,但 USB 控制器可能不同。在 x86-64 上,您会发现 xHC,而在 ARM 上,与硬件的标准化接口较少,因此每个主板都有自己的芯片组需要支持。它可以改变数据的解释,但我不确定具体如何。可以肯定的是,使用 xHC 而不是使用主板制造商为 ARM 制造的随机芯片组更容易解释事情是如何工作的。
-
但是,我在这里和那里阅读,xHCI 似乎也用于许多 ARM 计算机。