Protocols

Networking Over USB Protocol Comparisons

This will provide a short overview of the different Networking over USB Protocols showing their primary differences and features.

Overview

Networking over USB Protocols allow a USB Device that either provides access to a network to a USB Host or requires network access via a USB Host to transfer Network Frames across the USB.

The primary protocols that are available for this are:
  • Simple 
  • CDC-ECM 
  • CDC-EEM 
  • CDC-NCM 
  • RNDIS 
The following table outlines some of the primary characteristics of the protocols and provides a starting point for comparison.



SimpleCDC ECMCDC EEMCDC NCMRNDIS
Endpoints
BULK IN/OUT
yes
yes
yes
yes
yes
INTERRUPT
optional
yes
yes
yes
Interfaces
Communications with INTERRUPT Endpoint
yes
yes
yes
Data default with BULK Endpoints
yes
yes
yes
Data default with no Endpoints
yes
yes
Data alternate with BULK Endpoints
yes
yes
Device Requests
Set Interface
yes
yes
Send Encapsulated Command
yes
Get Encapsulated Response
yes
Notifications
Network Notification
yes
yes
Speed Change Notification
yes
yes
Response Available
no
yes
Configuration
MAC Address for Host via USB String Descriptor
yes
no
yes
MAC Address for Host via Control message
yes
Transfers
Maximum IN Transfer
1510
1510
not defined
configurable
configurable
Maximum OUT Transfer
1510
1510
not defined
configurable
configurable
Maximum Network Frames per IN Transfer
1
1
not defined
configurable
not defined
Maximum Network Frames per OUT Transfer
1
1
not defined
configurable
configurable
Throughputs (MBytes/s)
Typical one way TCP stream
10
10
16
16
16
Typical two way TCP stream
2x6
2x6
2x8
2x8
2x8
Best observed one TCP stream
10
10
28
28
28
Best observed two TCP stream
2x6
2x6
2x15
2x15
2x15


Glossary

bus transport - A bus mechanism that is used to transport bits between the host and device such as USB.

channel - An independent communications method using the bus transport between the host and device on the USB.

class driver - A vendor independent driver on the host operating system that supports a device that conforms to the device interface for the host operating system and the specific protocols used by the device.

control channel - A communications channel used to control the device.

control message - A message used to control a device.

data channel - A communications channel used to transfer networking data between the host and device.


Networking Glossary

datagram - a Protocol Data Unit used to transfer network data at the Network Layer. This is a subset of Network Packets usually associated with specific (unreliable) protocols such as UDP.

multi-frame - the ability to transfer multiple network frames in single USB Bulk data transfer

NDIS - Windows implementation of TCP/IP networking

network device - A device that can provide access to a network for a host.

network frame - a Protocol Data Unit for sending data at the Link Layer, N.B. this is not the same as a USB Frame.

network stack - the operating systems implementation of TCP/IP networking

packet - a Protocol Data Unit for sending data at the Network Layer

USB Glossary

bulk endpoint - an endpoint that provides low priority bulk data transfers

bulk data transfer - a method for transferring a large amount of data between a device and host.

device - A computer or hardware capable of acting as a device on a Universal Serial Bus.

device request - A control message sent to the device to change (set) something or query (get) information.

endpoint - USB term for a source or sink for data.

frame - a period of time on the USB deliniated with Start of Frame tokens, at milli-second intervals. N.B. this is not the same as a network frame.

host - A computer system capable of acting as a host on a Universal Serial Bus.

interrupt endpoint - an endpoint that has higher priority but limited data

interface - USB term for a collection of endpoints and their characteristics.

null byte packet - a USB data packet with a single NULL (zero) byte, this qualifies as a short data packet.

packet - data sent across the USB between two endpoints

short data packet - a USB data packet that is less than the packetsize

zero length packet - a USB data packet with zero data bytes, this qualifies as a short data packet


Network Overview

The following chart shows the OSI Network Model, with its classic 7 layers, described in Wikipeda or in Andrew Tanenbaum’s classic textbook Computer Networks. The OSI model also introduced the notions of Service Data Unit (SDU) and Protocol Data Unit (PDU). Briefly,

Layer
Protocol Data Unit
Linux
Windows
7
Application
message
6
Presentation
message
5
Session
message
4
Transport
message
3
Network
packets
Network Stack
NDIS
2
Data Link
Frames
Network Card Driver
Network Card Driver
1
Physical Layer
Varied



In the context of Networking over USB, the protocols all deal with transferring Network Frames. Network Packets are encapsulated within a Network Frame, with the USB providing the physical transport of the Network Frames between the host and device.

Network Datagrams are a sub-set of Network Packets associated with some protocols such as UDP.

For sending over USB the Network Frames are either transferred as a BULK Data transfer (Simple and ECM) or with further encapsulation sent via a BULK Data transfer.

The rules of BULK Data transfers are observed which means that transfers must always end in a Short Data Packet unless the total size of the transfer is exactly the same as the expected maximum transfer size.

Some of the protocols (EEM, NCM and Rndis) support aggregation of Network Frames. This is generally referred to as Multi-Frame support. Given the overhead on the USB this can increase throughput.

N.B. The maximum transfer size is fixed for ECM (3x512), not configurable or preset for EEM (therefore all transfers must be terminated with a short packet) and configurable for both directions during setup for NCM (via NCM specific device requests) and RNDIS (via encapsulated RNDIS control messages.)

 Simple

The simple configuration is a simpler variant of the CDC-ECM protocol that removes the requirements for the Interrupt endpoint and places the data endpoints into the default data interface. This eliminates the requirement for the host to send a Set Interface device request to enable data flow.
CDC-ECM

This is the first standardized protocol. It was designed to allow for optimal use of a Full Speed USB on older USB Host systems with minimal USB Ports. This mandated the requirement for being able to enable and disable the data endpoints so that they would only be used when the network was configured (polling of the BULK endpoints consumed bandwidth.)

ECM uses the INTERRUPT endpoint to send Network and Speed Change notifications to the host when a change to the network is observed. This allows the host to determine when and if the device network connection is available. Typically this is used to set the media connected status in the network stack.

Some operating systems use the speed in the speed change notification. For example to set the route metric.

CDC-EEM

This was the second standardised protocol.

The primary features of this protocol where to first simplify the configuration and second to allow multiple Network Frames to be sent in a single USB Bulk Transfer.

The EEM protocol did not define maximum or expected sizes for the Bulk Transfers. This makes it complex to implement the multiple frames capability. This has limited the number of implementations that use the multiple Network Frames capability.

Without implementing multiple frames the EEM protocol the throughput is effectively the same as ECM and Simple.

If multiple frame support is implemented EEM throughput is similar to NCM and Belcarra's RNDIS.


CDC-NCM

NCM is the logical successor to the ECM protocol. It retains all of the features of the ECM configuration and adds a new network frame encapsulation method. This allows for multiple network frames to be sent in a single USB Bulk Transfer.

NCM also mandates additional Device Requests that are used to query the device about its configuration and capabilities and change its operating behavior.

NCM Hosts and Devices know the exact behaviour expected for the maximum size of transfers and maximum number of Network Frames per transfer. This simplifies the implementation of the protocol.

NCM configuration also allows the device to request specific alignment and padding of the network frames within the BULK Data transfer. For certain types of devices this can increase throughput by allowing DMA to be used on correctly aligned memory boundaries.

RNDIS

RNDIS predates most of the other protocols. It was designed by Microsoft to allow implementation of networking devices that could use a common Class driver. To this end the protocol requires a series of Windows specific NDIS protocol elements. The host Class driver effectively forwards NDIS queries to the device and sends the responses back the NDIS layer.

The device must support the CDC Encapsulated Command model (send command and get response, and the Response Available notification.)

The protocol allows for multiple Network Frames in a single Bulk Transfer. Configuration of operational characteristics such as maximum transfer size and maximum Network frames per transfer is done as part of the initial sequence of RNDIS Control Messages.

The RNDIS initialization allows the device to specify some alignment of the RNDIS Data Messages (and therefore indirectly the network frames) within the BULK Data transfers.

Multiple Frame Support
Some of the Networking over USB protocols support network frame aggregation. This allows multiple network frames to be transferred in a single Bulk Data transfer.

USB Bulk Data transfers have overheads. Both at the bus level where individual transfers must be terminated with a short data packet. And at the OS level where the USB controller drivers must setup and tear down each transfer. And finally in the communication between the protocol driver (class driver on host systems and matching function driver on devices) and the low level controller drivers. These add latency to the time it takes for each transfer to take place.

Aggregating multiple network frames into a single Bulk Data transfer allows the overheads and associated latencies to be absorbed across multiple network frames.

Care must be taken in the use of this feature though. Additional latency is induced as the entire Bulk Transfer must be received before any of the network frames it contains can be forwarded. This places a bound on effective number of frames that should be aggregated. The actual number is best determined by using simple heuristics at runtime to ensure that the use of available bandwidth is optimized with only minimal latency added.

Effective multi-frame support can provide close to 100% improvement in throughput.


----------------------------------

BLAN MDLM – Belcarra Local Area Network protocol, a custom protocol for IP packet transfer across a USB connection. This protocol was developed by Belcarra as an alternative to CDC-ECM. BLAN streamlines and extends ECM for the case of personal area networks (PANs).

CDC ACM - a virtual serial port, Abstract Control Model refers to the fact that the serial device may in fact be a modem, requiring a control phase (dialing) followed by a data transfer phase. This protocol implements a virtual serial port or serial-controlled modem (using AT commands). The ACM protocol defines two USB interfaces to allow for this rarely used possibility. Contained inside the document PSTN120.pdf


CDC – A core communication Device Class for all Communications Device Class devices, together with subclass definitions matching several models (types of Communications device). These specifications were originally issued in one very large specification known as CDC1.1 (no longer available), but later broken down into a suite of documents available from usb.org. The Communications Device Class suite of protocols were created by the USB Implementers Forum to define access via USB to pre-USB communications devices such as Ethernet controllers, ISDN, ATM, and others. (http://www.usb.org/developers/devclass_docs)

Device Subclass -- A USB specification to support a sub-category of Devices of a larger Device Class. Examples of Device Classes with many Subclasses are Communication Device Class (CDC, see above) and Mass Storage (many types of disk-like devices).

Favourites