https://docs.microsoft.
com/en-us/windows-hardware/drivers/network/overview
https://learn.microsoft.com/en-us/windows-hardware/drivers/network/remote-ndis-to-usb-mapping
USB Remote NDIS overview
A USB Remote NDIS device is implemented as a USB Communication Device
Class (CDC) device with two interfaces. A Communication Class interface, of
type Abstract Control, and a Data Class interface combine to form a single
functional unit representing the USB Remote NDIS device. The
Communication Class interface includes a single endpoint for event
notification and uses the shared bidirectional Control endpoint for control
messages. The Data Class interface includes two bulk endpoints for data
traffic.
USB-Level Initialization
The host issues standard USB requests to obtain a set of standard USB
descriptors for the device. The relevant portions of those descriptors are
given below. See the USB Specification for generic USB device initialization.
USB Device Descriptor
The device returns a USB Device Descriptor as defined in the USB
Specification. The following table defines the prominent fields of the USB
Device Descriptor.
TABLE 1
Offset Field Size Valu Description
(bytes) (bytes) e
4 bDeviceClass 1 02h Communication Device Class code.
5 bDeviceSubClass 1 00h Communication Device Subclass code,
unused at this time.
6 bDeviceProtocol 1 00h Communication Device Protocol code,
unused at this time.
USB Configuration Descriptor
The device returns a Configuration Descriptor as defined in the USB Specification.
See the USB Specification for details.
Communication Class Interface
The Communication Class interface is described by a USB interface descriptor, three
class-specific descriptors, and an endpoint descriptor for the notification endpoint.
The notification endpoint descriptor is a standard USB Interrupt-type IN endpoint
descriptor whose wMaxPacketSize field is 8 bytes. The following table defines the
prominent fields of the Communication Class interface descriptor.
Offset Field Size Valu Description
(bytes) (bytes) e
5 bInterfaceClass 1 02h Communication Interface Class code.
6 bInterfaceSubCl 1 02h Communication Interface Class
ass SubClass code for Abstract Control
Model.
7 bInterfaceProtoc 1 FFh Communication Interface Class
ol Protocol code for vendor specific
protocol.
Data Class Interface
The Data Class interface is described by a standard USB Interface Descriptor
followed by two endpoint descriptors. The two endpoint descriptors in the Data
Class interface define standard USB Bulk-type endpoints: one Bulk-IN and one Bulk-
OUT. The following table defines the prominent fields of the Data Class Interface
Descriptor.
USB-Level Termination
See the USB Specification for a description of generic USB bus-level termination.
Control Channel Characteristics
The Control channel for the device is its USB Control endpoint. A control
message from the host to the device is sent as a
SEND_ENCAPSULATED_COMMAND transfer. This transfer is defined in the
following table.
TABLE 1
BmRequestType bRequest wValue wIndex wLength Data
0x21 0x00 0x0000 bInterfaceNumber field of Byte length of Control
Communication Class interface control message
descriptor message block block
The host does not continuously poll the USB Control endpoint for input
control messages. Upon placing a control message on its Control endpoint,
the device must return a notification on the Communication Class interface's
Interrupt IN endpoint, which is polled by the host whenever the device can
return control messages. The transfer from the device's interrupt IN endpoint
to the host is a standard USB Interrupt IN transfer. The only defined device
notification is the RESPONSE_AVAILABLE notification, defined in the following
table.
TABLE 2
Offset (bytes) Length (bytes) Field Data
0 4 Notification RESPONSE_AVAILABLE (0x00000001)
4 4 Reserved 0
Upon receiving the RESPONSE_AVAILABLE notification, the host reads the
control message from the Control endpoint using a
GET_ENCAPSULATED_RESPONSE transfer, defined in the following table.
TABLE 3
bmRequestType bReques wValue wIndex wLength Data
t
0xA1 0x01 0x0000 bInterfaceNumber field of 0x0400 (this is Control
Communication Class the minimum message
interface descriptor byte length of the block
buffer posted by
host)
If for some reason the device receives a GET_ENCAPSULATED_RESPONSE and
is unable to respond with a valid data on the Control endpoint, then it should
return a one-byte packet set to 0x00, rather than stalling the Control
endpoint.
Data Channel Characteristics
The data channel for the device consists of the Bulk IN and OUT endpoints in
the Data Class interface.
A single USB data transfer in either direction may consist of a
single REMOTE_NDIS_PACKET_MSG or a longer multipacket message.
The USB transfer to send a data message from the host to the device is a
standard USB bulk transfer to the Bulk OUT endpoint of the Data Class
interface.
The USB transfer to send a data message from the device to the host is a
standard USB bulk transfer from the Bulk IN endpoint of the Data Class
interface. The host will read up to the number of bytes indicated by
the MaxTransferSize field of REMOTE_NDIS_INITIALIZE_MSG, which will be no
greater than 0x4000 bytes for a USB 1.1 device.
USB Short Packets
USB passes data over the wire in the form of USB packets, which should not
be confused with NDIS or networking packets. The maximum length of a USB
packet to or from a USB endpoint is limited to the value of
the wMaxPacketSize field of the endpoint's descriptor. For bulk pipes the
maximum packet size is 64 bytes. Due to constraints of certain USB host
controllers, there is a penalty associated with using short USB packets (for
example, those of less then 64 bytes, when streaming data).
To work around this limitation, Remote NDIS USB devices may append zero-
byte padding to data messages so that a short packet will not occur (within
the constraints of the MaxTransferSize field
of REMOTE_NDIS_INITIALIZE_MSG). The MessageLength field of the
final REMOTE_NDIS_PACKET_MSG does not include these appended padding
bytes.
If the device has transmitted its last available REMOTE_NDIS_PACKET_MSG
(so no more are left in the device's queue), then it is acceptable to send a
short USB packet.
If the last REMOTE_NDIS_PACKET_MSG of a device-send Remote NDIS data
message (without any zero-byte padding) ends with a USB packet whose
length is exactly the wMaxPacketSize for that endpoint, then the device
may send an additional one-byte zero packet as an appended part of the
transfer. Some device implementations are simplified by this allowance.
Similarly, some device-side USB chipsets do not detect the end of a received
USB transfer that ends with a USB packet whose length is
the wMaxPacketSize for that endpoint. For this reason, the host must
append a one-byte zero packet to a data transfer that otherwise would have
a length that is a multiple of the wMaxPacketSize of the receiving
endpoint. USB Remote NDIS devices must tolerate the appended byte.
The MessageLength field of the final REMOTE_NDIS_PACKET_MSG does not
include this appended byte.
Flow Control
Flow control for a USB Remote NDIS device is defined by the USB
Specification.
Since all communication on USB is based on a host to device transaction, all
the host must do to slow the flow of data is stop issuing IN tokens to the
device on the bulk pipe. If the device needs to assert flow control, then it
should NAK data transfers from the host until it is able to process data again.
For a detailed explanation of this process, review Section 8.4.4 in the USB
Specification, version 1.1.
USB Remote NDIS power
management
A USB Remote NDIS device must support the Power Management OIDs as well as
Network wake-up OIDs that are listed in the Microsoft Windows 2000 Driver
Development Kit (DDK) under NDIS OIDs. See the USB specification for a description
of USB bus-level power management.
Timer Constants
The ControlTimeoutPeriod for a USB Remote NDIS device is 10 seconds.
The KeepAliveTimeoutPeriod for a USB Remote NDIS device is 5 seconds.
USB 802.3 Device Sample
The following is a sample set of descriptors for a USB Remote NDIS Ethernet
Device. It includes a CDC Communication Class interface and a CDC Data
Class interface. The Device Descriptor is returned independently. The
Configuration descriptor and all following descriptors are returned as a single
block in the order shown.
Control messages are sent on the Control endpoint. Notification messages
are sent on the Interrupt In endpoint in the CDC Communication Class
interface. Data messages are sent on the Bulk In and Bulk Out endpoints in
the CDC Data Class interface. String descriptors are not shown.
The Remote NDIS implementation in Windows Millennium Edition assumes
that the Communication Class interface precedes the Data Class interface.
Vendors should choose this descriptor ordering so that devices initialize
correctly on Windows Millennium Edition.
If any portion of this sample contradicts a controlling specification, follow the
specification.