USB调试笔记
+ -

UAC扬声器同步传输URB数据结构USBD_ISO_PACKET_DESCRIPTOR成员StartFrame

2022-08-26 20 0

凡是USB的数据设备的数据传输,都是通过URB实现的。
在Windows系统中,凡是同步传输,都是通过URB_ISOCH_TRANSFER实现的。
当然,本站也提供了一个USB同步传输X64 URB数据在线分析工具:https://www.usbzh.com/tool/urb-iso.html

URB_ISOCH_TRANSFER的结构体定义如下:

struct _URB_ISOCH_TRANSFER {
  struct _URB_HEADER         Hdr;
  USBD_PIPE_HANDLE           PipeHandle;
  ULONG                      TransferFlags;
  ULONG                      TransferBufferLength;
  PVOID                      TransferBuffer;
  PMDL                       TransferBufferMDL;
  struct _URB                *UrbLink;
  struct _URB_HCD_AREA       hca;
  ULONG                      StartFrame;
  ULONG                      NumberOfPackets;
  ULONG                      ErrorCount;
  USBD_ISO_PACKET_DESCRIPTOR IsoPacket[1];
};

这个对构体的成员相对来说,都比较容易理解。但StartFrame成员总有一个模糊不清。
StartFrame官方的解释如下:

Specifies the frame number that the transfer should begin on. This variable must be within a system-defined range of the current frame. The range is specified by the constant USBD_ISO_START_FRAME_RANGE.

If START_ISO_TRANSFER_ASAP is set in TransferFlags, this member contains the frame number that the transfer began on, when the request is returned by the host controller driver. Otherwise, this member must contain the frame number that this transfer begins on.

可见StartFrame指定了数据传输开始的frame numbe,前且必须当前帧的系统定义范围内。数据范围在USBD_ISO_START_FRAME_RANGE之内。

#define USBD_ISO_START_FRAME_RANGE            1024

另外,如果TransferFlags中设置了START_ISO_TRANSFER_ASAP,那么表示的是传输的开始编号。https://docs.microsoft.com/en-us/windows-hardware/drivers/usbcon/transfer-data-to-isochronous-endpoints

#define USBD_SHORT_TRANSFER_OK                0x00000002
#define USBD_START_ISO_TRANSFER_ASAP          0x00000004
#define USBD_DEFAULT_PIPE_TRANSFER            0x00000008

这里我们通过BUSHOUND来抓包进行原始数据分析:

27.0            URB    88 00 08 00  00 00 00 00  98 f3 d4 14  fd 3e 00 00  00 00 00 00  00 00 00 00  c0 4c 98 f2  02 c1 ff ff
                       0a 00 00 00  03 00 00 00  38 6b ff 9b  03 f5 ff ff  00 00 00 00  00 00 00 00  00 00 00 00  00 00 00 00
                       04 00 00 00  00 00 00 00  00 00 00 00  00 00 00 00  02 00 00 00  01 00 00 00  a8 8a a0 fa  02 c1 ff ff
                       a8 8a a0 fa  02 c1 ff ff  88 53 4f ec  02 c1 ff ff  18 8a a0 fa  02 c1 ff ff  00 00 00 00  00 00 00 00
                       22 01 00 01  02 00 03 00                                                                              
27.2       192  ISOC   00 00 00 00  00 00 00 00  00 00 00 00  00 00 00 00  00 00 00 00  00 00 00 00  00 00 00 00  00 00 00 00
                       00 00 00 00  00 00 00 00  00 00 00 00  00 00 00 00  00 00 00 00  00 00 00 00  00 00 00 00  00 00 00 00
                       00 00 00 00  00 00 00 00  00 00 00 00  00 00 00 00  00 00 00 00  00 00 00 00  00 00 00 00  00 00 00 00
                       00 00 00 00  00 00 00 00  00 00 00 00  00 00 00 00  00 00 00 00  00 00 00 00  00 00 00 00  00 00 00 00
                       00 00 00 00  00 00 00 00  00 00 00 00                                                                 
27.2            URB    a4 00 0a 00  00 00 00 00  98 f3 d4 14  fd 3e 00 00  00 00 00 00  00 00 00 00  90 8c 29 ed  02 c1 ff ff
                       04 00 00 00  c0 00 00 00  30 9a 34 ef  02 c1 ff ff  00 00 00 00  00 00 00 00  00 00 00 00  00 00 00 00
                       02 00 00 00  00 00 00 00  00 00 00 00  00 00 00 00  00 00 00 00  00 00 00 00  00 00 00 00  00 00 00 00
                       00 00 00 00  00 00 00 00  00 00 00 00  00 00 00 00  00 00 00 00  00 00 00 00  00 00 00 00  00 00 00 00
                       53 b0 3c 01  01 00 00 00  00 00 00 00                                                                 
27.2      1920  ISOC   00 00 00 00  00 00 00 00  00 00 00 00  00 00 00 00  00 00 00 00  00 00 00 00  00 00 00 00  00 00 00 00
                       00 00 00 00  00 00 00 00  00 00 00 00  00 00 00 00  00 00 00 00  00 00 00 00  00 00 00 00  00 00 00 00
                       00 00 00 00  00 00 00 00  00 00 00 00  00 00 00 00  00 00 00 00  00 00 00 00  00 00 00 00  00 00 00 00
                       00 00 00 00  00 00 00 00  00 00 00 00  00 00 00 00  00 00 00 00  00 00 00 00  00 00 00 00  00 00 00 00
                       00 00 00 00  00 00 00 00  00 00 00 00                                                                 
27.2            URB    10 01 0a 00  00 00 00 00  98 f3 d4 14  fd 3e 00 00  00 00 00 00  00 00 00 00  90 8c 29 ed  02 c1 ff ff
                       04 00 00 00  80 07 00 00  90 f0 78 72  81 95 ff ff  00 00 00 00  00 00 00 00  00 00 00 00  00 00 00 00
                       02 00 00 00  00 00 00 00  00 00 00 00  00 00 00 00  00 00 00 00  00 00 00 00  00 00 00 00  00 00 00 00
                       00 00 00 00  00 00 00 00  00 00 00 00  00 00 00 00  00 00 00 00  00 00 00 00  00 00 00 00  00 00 00 00
                       54 b0 3c 01  0a 00 00 00  00 00 00 00                                                                 
27.2      1920  ISOC   00 00 00 00  00 00 00 00  00 00 00 00  00 00 00 00  00 00 00 00  00 00 00 00  00 00 00 00  00 00 00 00
                       00 00 00 00  00 00 00 00  00 00 00 00  00 00 00 00  00 00 00 00  00 00 00 00  00 00 00 00  00 00 00 00
                       00 00 00 00  00 00 00 00  00 00 00 00  00 00 00 00  00 00 00 00  00 00 00 00  00 00 00 00  00 00 00 00
                       00 00 00 00  00 00 00 00  00 00 00 00  00 00 00 00  00 00 00 00  00 00 00 00  00 00 00 00  00 00 00 00
                       00 00 00 00  00 00 00 00  00 00 00 00

从一个USB扬声器来看,其打开的时候,第一个音频数据的长度为192字节,其只有1ms的数据量,其StartFrame为53 b0 3c 01。我们做个表格来分析:

数据长度 StartFrame
1 192 53 b0 3c 01
2 1920 54 b0 3c 01
3 920 5e b0 3c 01
4 920 68 b0 3c 01
5 1920 72 b0 3c 01

可以看到,这个StatFrame变成了NumberOfPackets的计数了。

而过一段时间之后。我们停止该扬声器的工作,过一段时间之间,再次打开,发现StartFrame又从另一个计数:
f9 25 42 01开始计数。
所以从这里来看,StartFrame又像是一个系统的时间计数。

其实我在虚拟MIC的时候,重新打开MIC的时候,将第一包的StartFrame清0开始,也是可以的。所以最后我想说的是,我信你个鬼,你个糟老头子坏地很。

0 篇笔记 写笔记

UVC 等时传输中的URB_ISOCH_TRANSFER
通过UVC规范可知,视频图像数据的读取可使用两种端点传输方式,分别为:BULK 块/批量传输方式ISO 等时/同步传输方式在Windows内核中,USB数据的读取是通过URB来进行传输的,其结构体是一个大大的共用体,根据数据传输的方式对应其不同的结构体,其内容如下:typedef _Struct_s......
UVC等时传输中的dwMaxPayloadTransferSize
UVC的视频流接口控制请求的数据大小可为26字节,34字节和48字节,其分别对应的是UVC的1.0,1,1和UVC1.5版本。在其整个视频流控制接口参数偏移地址22处的字段为一4字节的dwMaxPayloadTransferSize,根据其字段解释为“指定设备在单个有效负载传输中可以传输或接收的最大......
USB 等时/同步传输、块传输与转换设置在UVC摄像头驱动中的探讨
最近在Windows10 x64环境下,开发了一个虚拟UVC摄像头驱动。确切的来说这不是摄像头驱动,而是一个虚拟USB总线驱动。使用该虚拟总线驱动使用应用软件通过IOCTL控制总线子设备的创建与卸载。框架设计驱动安装完成后,是一个单纯的USB虚拟总线。应用软件通过发送自定义IOCTL码IOCTL......
USB 同步/等时传输方式
USB协议规定了四种传输类型:控制传输、批量传输、同步传输、中断传输。等时传输也有“同步传输”的叫法,一般用于要求数据连续、实时且数据量大的场合,其对传输延时十分敏感,类似用于USB摄像设备,USB语音设备等等。同步事务没有握手包。当一个同步传输中有多个事务时,最后一个事务之前的事务的数据长......
USB超高速 同步传输
正如USB2.0一样,超速同步传输类型是用来支持想要能容忍错误,周期性的轮询服务的传输流。超速跟USB2.0一样不发送起始帧,但是时序信息要通过同步时间戳包(ITP)被发送给设备。这个规格的协议层章详细描述了用来完成同步传输的包,总线事务和事务处理流程。也描述了怎么样传送时序信息给设备。超速同步传输......
Windows下USB驱动同步URB转IRP请求函数代码
URB和IRP类似,只不过一个应用于通用的Windows驱动,一个专职于USB。USB的URB的负载是IRP,其通过负载到IRP时,然后使用通用的Windows IRP请求发向下层目标USB设备。USB与IRP的关联是通过IRP的IO_STACK_LOCATION的 IoStack->Para......
Windows下USB驱动异步URB转IRP请求函数代码
URB有同步请求,也有异步请求。这里微软官方提供了一个异步请求URB的代码示例// The SubmitUrbASync routine submits an URB asynchronously.//// Parameters://// Parameters:// Devic......
Windows下USB驱动同步URB转IRP请求函数代码-改进版
URB的同步调用一般使用:Windows下USB驱动同步URB转IRP请求函数代码 http://www.usbzh.com/article/detail-547.html但是,在某些特定的情况下,有时会因为下底设备并没有完成而挂死。这里提供一种超时取消IRP的方法,同时考虑到了线和切换的情况。这里......
Windows下虚拟USB设备数据的读写请求调试笔记
到现在为止,本人已经在Windows下确切来说是Windows10 x64下开发了以下USB虚拟USB设备:USB虚拟UVC摄像头设备USB虚拟UAC麦克风设备USB虚拟HID键盘设备USB虚拟HID鼠标设备USB虚拟HID键盘鼠标复合设备USB虚拟HID单点触摸屏设备USB虚拟HID多点触摸屏......
基于UVC规范的USB摄像头数据传输模式的总结
根据UVC(USB VIDEO CLASS)规范,UVC视频数据传输方式支持:同步传输即ISO传输批量传输即BULK传输但是不同的操作系统对UVC规范的支持不一定是全量支持的:Windows操作系统对于windows操作系统,对UVC版本的支持情况如下:UVC 版本Windows ......
手动分析使用BUSHOUND抓取同步传输URB
BUSHOUND大家太熟了,使用它来进行数据抓包那不太太方便。但在BUSHOUND的抓取配置项中,有一个叫了URB的东西,我相信大家都没有选中过,因为一般来说,对WINDOWS USB驱动开发人员来说都不一定有用,更何况大家也只是用来抓取一下几个数据的输入输出,更没有必要进行USB的分析了。本人今天......
USB 同步传输端点的数据包PID序列及额外传输端点大小
对于同步传输:如果输入端点提供的负载数据小于端点描述符指定的最大负载数据,则主机端将不再该端点提供进一步的输入事务。这是因为所对USB设备来说,所有的数据传输都是由主机发起的。对于数据输入IN事务,虽然数据的传输方向为设备端到主机,但是该事务却是由主机发起。由于设备的输入端点提供的负载数据小于该......
使用BUSHOUND手动分析USB控制传输的URB
USB的控制传输是最基本的传输类型,控制传输适用于设备的枚举和设备的状态控制。我里我们使用BUSHOUND来抓取USB控制传输的URB。同样的,我们使用的操作系统是Windows10 x64,和同步传输URB抓包一样,我们先抓取数据,然后再分析数据结构。这里我插入电脑的U盘的枚举以获取设备描述符为......
使用BUSHOUND手动分析USB批量传输的URB
使用BUSHOUND抓取U盘的批量传输的URB数据,我们对其其进行数据分析:13 IN 55 53 42 53 40 0b ac 57 00 00 00 00 00 URB80 00 09 00 00 00 00 00 d8 f2 75 a0 77 7f 00 00 ......
作者信息
USB中文网
B站搜索 站长漫谈 看视频。
pnpon内核开网,USB中文网,
busrom硬核技术网站长
取消
感谢您的支持,我会继续努力的!
扫码支持
扫码打赏,你说多少就多少

打开支付宝扫一扫,即可进行扫码打赏哦

您的支持,是我们前进的动力!