MTP Over BT Profile Specification
MTP Over BT Profile Specification
MTP Over BT Profile Specification
Specification
Abstract
This document specifies the manner in which the Media Transport Protocol (MTP) is
to be transported within the Bluetooth wireless networking environment. This
information enables a Bluetooth aware MTP Initiator and MTP Responder to carry on
a standard MTP conversation over Bluetooth similar to USB and TCP/IP.
This document is preliminary and will be updated prior to the final release of
Windows.
BLUETOOTH SPECIFICATION Page 2 of 40
MTP over Bluetooth
Disclaimer: This is a preliminary document and may be changed substantially prior to final commercial release of the software
described herein.
The information contained in this document represents the current view of Microsoft Corporation on the issues discussed as of the
date of publication. Because Microsoft must respond to changing market conditions, it should not be interpreted to be a commitment
on the part of Microsoft, and Microsoft cannot guarantee the accuracy of any information presented after the date of publication.
This White Paper is for informational purposes only. MICROSOFT MAKES NO WARRANTIES, EXPRESS, IMPLIED OR
STATUTORY, AS TO THE INFORMATION IN THIS DOCUMENT.
Complying with all applicable copyright laws is the responsibility of the user. Without limiting the rights under copyright, no part of
this document may be reproduced, stored in or introduced into a retrieval system, or transmitted in any form or by any means
(electronic, mechanical, photocopying, recording, or otherwise), or for any purpose, without the express written permission of
Microsoft Corporation.
Microsoft may have patents, patent applications, trademarks, copyrights, or other intellectual property rights covering subject matter
in this document. Except as expressly provided in any written license agreement from Microsoft, the furnishing of this document
does not give you any license to these patents, trademarks, copyrights, or other intellectual property.
Unless otherwise noted, the example companies, organizations, products, domain names, e-mail addresses, logos, people, places
and events depicted herein are fictitious, and no association with any real company, organization, product, domain name, email
address, logo, person, place or event is intended or should be inferred.
Microsoft, Windows, Windows NT, Windows Server, and Windows Vista are either registered trademarks or trademarks of Microsoft
Corporation in the United States and/or other countries.
The names of actual companies and products mentioned herein may be the trademarks of their respective owners.
Revision History
Revision Date Comments
0.9 31 March 2008 Initial draft
0.91 27 May 2008 Updated for correct ordering of
PacketType and Sequence ID. Added
TransportID as well. Additional
clarifications around TransportError
handling including the addition of the
TransportReady packet.
0.92 22 October 2008 Added MTU information. Moved L2CAP
Basic Mode operation to its own section
and added more details on how it
operates.
Contributors
Name Company
Darren Davis Microsoft Corporation
E-Zu Wu Microsoft Corporation
John Felkins Microsoft Corporation
Table of Contents
1 Overview.............................................................................................................. 6
1.1 Scope............................................................................................................. 6
1.2 Key MTP Concepts.......................................................................................... 6
1.3 Conformance with MTP/USB and MTP/IP........................................................7
1.4 RFC 2119 Compliance.................................................................................... 8
2 MTP implementation over Bluetooth....................................................................9
2.1 L2CAP Transport............................................................................................. 9
2.2 Transport Model............................................................................................. 9
2.2.1 Maximum Transmission Unit (MTU) Requirements...................................9
2.2.2 SDP Records.......................................................................................... 10
2.2.3 Role Determination................................................................................ 10
2.2.4 Connections........................................................................................... 10
2.2.5 Security................................................................................................. 11
2.2.6 L2CAP Flow Control and Retransmission Support..................................11
2.3 MTP Bluetooth Service Definitions...............................................................11
2.3.1 MTP Initiator Service Definition Record..................................................12
2.3.2 MTP Responder Service Definition Record.............................................12
2.4 Transport Channel Management..................................................................13
2.4.1 Bluetooth Pairing................................................................................... 13
2.4.2 Initiator Driven Link Establishment........................................................13
2.4.3 Responder Driven Link Establishment...................................................14
2.4.4 Race Conditions in Link Establishment..................................................15
2.4.5 MTP Bluetooth Link Power Management................................................16
2.4.6 Shutdown of MTP Bluetooth Link...........................................................16
2.5 Transfer Packet Types................................................................................... 17
2.5.1 Packet Header and Identifiers................................................................17
2.5.2 Parameter Optimizations.......................................................................18
2.5.3 Link Fail Packet...................................................................................... 19
2.6 Length.......................................................................................................... 19
2.7 4................................................................................................................... 19
2.8 UINT32......................................................................................................... 19
2.9 Total size of the packet, in bytes, including the header...............................19
2.9.1 Operation Request Packet......................................................................19
2.9.2 Operation Response Packet...................................................................20
2.9.3 Event Packet.......................................................................................... 21
2.9.4 Start Data Packet...................................................................................21
2.9.5 Cancel Packet........................................................................................ 22
2.9.6 Probe Request Packet............................................................................23
2.9.7 Probe Response Packet..........................................................................23
2.9.8 Init Command Request Packet...............................................................24
2.9.9 Init Event Request Packet......................................................................25
2.9.10 Init Link Acknowledgement Packet........................................................26
2.9.11 End Data Packet.................................................................................... 26
2.9.12 Transport Error Packet............................................................................27
2.9.13 Transport Ready Packet.........................................................................28
2.9.14 Request Link Destroy Packet..................................................................29
2.9.15 Data Packet........................................................................................... 30
2.10 L2CAP Basic Mode Support..........................................................................31
2.10.1 Error Handling........................................................................................ 31
2.10.2 Error Detection Fields............................................................................ 33
1 Overview
1.1 Scope
This document assumes familiarity with the MTP specification and is targeted at
Bluetooth wireless device developers who would like to implement Media Transport
Protocol (MTP) - based data exchange. Since MTP is transport agnostic, this
document does not enhance or otherwise add new MTP functionality. It only serves
to formalize how the MTP specification is handled over Bluetooth transport. The
functional components of MTP referenced in this document are specified in the MTP
1.0 specification hosted by the USB Implementers Forum 1.
For optimum reliability, the MTP Profile for Bluetooth is dependent on the presence
of a Bluetooth 1.2 compatible Logical Link Control and Adaptation Protocol (L2CAP)
implementation. Allowance is made for support under Bluetooth 1.1 but the
reliability of such interactions may be limited by the underlying L2CAP limitations.
As such this document describes the issues concerning the reliability and
robustness of the Bluetooth link, the packetization of MTP data over Bluetooth, and
the role of MTP hosts (Initiators) and MTP clients (Responders).
Concept Definition
Initiator The controlling, or host, device in an MTP protocol
interaction. It is responsible for initiating operations
with the attached client. All behavior during an MTP
interaction is under the control of the Initiator. The role
of Responder //Initiator?// is determined at the point the
MTP protocol interaction is established and cannot
change without the current interaction being
disconnected or an additional interaction being
established.
Responder The answering, or client, device in an MTP protocol
interaction. It is responsible for responding to
operations and requests from the attached host. The
role of Responder is determined at the point the MTP
protocol interaction is established and cannot change
without the current interaction being disconnected or an
1
Media Transfer Protocol 1.0 - http://www.usb.org/developers/devclass_docs/MTP_1.0.zip
2008 Microsoft Corporation. All rights reserved.
By using or providing feedback on these materials, you agree to the attached
license agreement.
BLUETOOTH SPECIFICATION Page 9 of 40
MTP over Bluetooth
later than the actual time the device went out of range. To accommodate a
more active connect/disconnect behavior, MTP Bluetooth implementations
are encouraged to take advantage of Initiator- or Responder-driven
disconnect operations (defined later in this document).
2. Reliable, Error Free Channel: Bluetooth 1.2 and above, optionally support
reliable, error-free channels at the L2CAP layer through optional L2CAP
extensions for flow control and packet retransmission. Additions have been
made at the MTP Bluetooth packet model level to account for the limitations
of pre-Bluetooth 1.2 environments or L2CAP Basic Mode environments
where the optional reliable, error-free channels are not supported. It should
be understood that these additions are intended to meet the spirit, if not the
letter of this MTP-compliance requirement and may not guarantee the best
MTP experience. Where a reliable, error-free channel is available, the MTP
Bluetooth specifies that it must be used.
3. Asynchronous Event Support: The definition of MTP over Bluetooth is a
two-channel model in order to provide asynchronous, out-of-band delivery of
MTP events.
4. Device Discovery and Enumeration: The definition of MTP over Bluetooth
defines standard Session Description Protocol (SDP)-based methods by which
the presence of both an MTP-compliant Bluetooth Initiator and MTP-compliant
Bluetooth Responder may be discovered.
5. Specific Transports: This document defines how MTP interactions are to
occur over Bluetooth wireless links.
The minimum MTU value required is 48 bytes. However given the fact that MTP is
frequently used to transmit large binary objects initiators the default L2CAP MTU of
768 bytes tends to introduce significant performance penalties given the number of
2
The key protocols evaluated were L2CAP, RFCOMM, and MTP/IP carried over a Bluetooth
PAN connection. Given the channel requirements of MTP in combination with the drive for
greater simplicity and better future adaptation in the Bluetooth implementation, RFCOMM
was excluded. While carrying MTP/IP over the top of PAN was a reasonable approach, some
PII concerns arise that may have required an additional layer of security. The combination of
performance and the security requirement excluded PAN from selection.
3
The MTP Bluetooth model is similar to the MTP/IP specification in its use of channel
allocation and packet formats. Due to slightly different requirements and reliability issues
with L2CAP some changes have been introduced.
2008 Microsoft Corporation. All rights reserved.
By using or providing feedback on these materials, you agree to the attached
license agreement.
BLUETOOTH SPECIFICATION Page 12 of 40
MTP over Bluetooth
packets required to send these objects. It has been found that packet sizes of
around 8 KB are the most efficient.
More powerful MTP Initiators (with more memory, higher CPU performance) are
encouraged to let the MTP Responder establish the packet sizes.
An MTP link may only be established when either the MTP Initiator or the MTP
Responder Service record is present on at least one device.
Devices which desire to serve as both an Initiator and a Responder may publish
both the MTP Initiator and MTP Responder Service records.
4
In USB transports the Initiator is always the USB host while the responder is always the USB
client. In TCP transports the host initiates both the command/data and event connections.
2008 Microsoft Corporation. All rights reserved.
By using or providing feedback on these materials, you agree to the attached
license agreement.
BLUETOOTH SPECIFICATION Page 13 of 40
MTP over Bluetooth
case, the service selected by the remote endpoint determines the role of the device
with respect to that connection.
2.2.4 Connections
MTP Bluetooth requires two active connections between the MTP Initiator and the
MTP Responder. An MTP Bluetooth Link is not considered established until both of
these connections have been made. Both of these connections MUST be
maintained for the lifetime of the MTP Bluetooth link. If either of these connections
is lost for any reason, the entire link is considered broken and the standard MTP
unexpected disconnect behaviors MUST be employed.
2.2.4.1Command/Data Channel
The command/data channel is always created by the MTP Initiator to the MTP
Responder. This channel carries the core MTP command and data operations for
each transaction. The connection is made to a published SDP Responder endpoint
on the Responder device.
2.2.4.2Event Channel
The event channel is always created by the MTP Responder to the MTP Initiator.
This channel carries asynchronous event data from the Responder to the Initiator.
The connection is made to a published SDP Initiator endpoint on the Initiator device.
The amount of information on the Event Channel is expected to be low. Therefore
power or servicing optimizations MAY be made provided that the connection itself is
maintained.
2.2.5 Security
MTP is intended to be a generic object exchange protocol. As such it is reasonable
to expect that sensitive information including Personally Identifiable Information
(PII) will be exchanged over this link. For this purpose all MTP Bluetooth
connections MUST support authorization, authentication, and encryption:
Additional parameters such as Provider Name and Service Name are optional.
7
MTP Bluetooth is expected to use a dynamic PSM assigned by the particular device
implementation. As appropriate, a standard PSM MAY be adopted during formalization
through the BT SIG.
2008 Microsoft Corporation. All rights reserved.
By using or providing feedback on these materials, you agree to the attached
license agreement.
BLUETOOTH SPECIFICATION Page 16 of 40
MTP over Bluetooth
af4843cfcf9
8}
Profile0SpecificParamete Version UInt16 0x0100
r0
Additional parameters such as Provider Name and Service Name are optional.
Errors which occur during any phase of the link establishment MUST be
acknowledged by sending a LinkFail packet first over the link being established
and then over any previously established link. For example, if the MTP Responder is
unable to establish a local dynamic endpoint to use for the Event Connection, it
must respond to the InitCommandRequest with a LinkFail packet. No additional
LinkFail packets should be sent. However, if the MTP Initiator rejects the
InitEventRequest, the LinkFail packet must first be sent over the just established
Event connection and then over the previously established Command/Data
connection.
Errors which occur during any phase of the link establishment MUST be
acknowledged by sending a LinkFail packet first over the link being established
and then over any previously established link. For example, if the MTP Initiator is
unable to establish a local dynamic endpoint to use for the Command/Data
Connection, it must respond to the InitEventRequest with a LinkFail packet. No
additional LinkFail packets should be sent. However, if the MTP Responder rejects
the InitCommandRequest, the LinkFail packet must first be sent over the just
established Command/Data connection and then over the previously established
Event connection.
link establishments which contain an unknown LinkID and validate that a pending
request to the same device is not already in process. If such a pending request is
located, the Initiator MUST respond to the device with a LinkFail packet and specify
FAIL_PENDING_REQUEST as the reason.
An Initiator MUST:
1. Support entering into SNIFF mode when no MTP transactions are pending.
2. Throttle to the lowest power transmission mode for all command and event
transmissions.
3. Elevate to the highest power transmission mode for all data transmissions
A Responder MUST:
1. Support entering into SNIFF mode when no MTP transactions are pending
2. Throttle to the lowest power transmission mode for all response and event
transmissions
3. Elevate to the highest power transmission mode for all data transmissions
1. The Initiator determines that the link should be closed in response to some
MTP application request, a timeout determination, or a specific request from
the Responder via a RequestLinkDestroy packet arriving on the Event
connection.
2. The Initiator closes the Command/Data L2CAP connection to the Responder to
indicate that the link should be destroyed.
In the event that either device receives an unexpected notification that the
Command/Data or Event connection is closed, it should assume that the devices are
no longer within Bluetooth range and forcibly close the current MTP Session as well
as close any L2CAP link associated with the link that is still active. It should be
understood that the formal and unexpected disconnect appears the same from the
Responders perspective and, given the transactional nature of MTP, it is safe to
assume that an incomplete transaction or unclosed session is an indication that the
link was unexpectedly disconnected.
PacketType Description
0x00 Invalid Value
0x0C Reserved
0x0F Reserved
8
Implementers familiar with the MTP/IP specification will appreciate that the packet types
described here align with the standard MTP/IP types. However, the size of the packet type
field has been reduced from a UINT32 to a UINT8 to accommodate both the TransportID
and SequenceID fields. Ordering of the fields accommodates the Big Endian ordering of
the MTP/IP UINT32 PacketType value. To use a similar header structure for MTP/IP parsing
the TransportID for MTP/IP MUST be 0 and the SequenceID must also be 0.
2008 Microsoft Corporation. All rights reserved.
By using or providing feedback on these materials, you agree to the attached
license agreement.
BLUETOOTH SPECIFICATION Page 22 of 40
MTP over Bluetooth
Packet
The operation only requires 3 parameters and space is available for 5. Only
the first 3 parameters need to be sent.
The operation requires 5 parameters, space is available for 5, but all
parameters are zero. All parameters may be omitted.
The operation requires 4 parameters. The first and third parameters are zero,
the second and forth parameters are non-zero. All of the first 4 parameters
need to be sent, the fifth parameter may be omitted.
2.6 Length 2.7 4 2.8 UINT3 2.9 Total size of the packet, in
2 bytes, including the header
0x01.
9
See MTP/IP specification for more details about how data phase MUST be set.
2008 Microsoft Corporation. All rights reserved.
By using or providing feedback on these materials, you agree to the attached
license agreement.
BLUETOOTH SPECIFICATION Page 24 of 40
MTP over Bluetooth
or Data In)
Operation 2 UINT16 MTP Operation Code
Code
Transaction ID 4 UINT32 Current Transaction ID
Parameter1 4 UINT32 First operation parameter
Parameter2 4 UINT32 Second operation parameter
Parameter3 4 UINT32 Third operation parameter
Parameter4 4 UINT32 Fourth operation parameter
Parameter5 4 UINT32 Fifth operation parameter
(Bytes)
Length 4 UINT32 Total size of the packet, in bytes,
including the header
transport reliability.
Special care must be taken to ensure that the Cancel packet is retrieved from both
the Command/Data and Event channel when it is detected. All packets associated
with the specified TransactionID MAY be removed and discarded from either data
channel in response to receiving this packet.
MTP link.
In the event that no data needs to be transferred during the data phase, the
StartData packet will be followed immediately by the EndData packet.
10
This is a significant difference from MTP/IP. In order to better support streaming
implementations operating in Basic L2CAP Mode, it was necessary to remove the data from
the EndData packet so that the CRC-32 could be transmitted without having to go back to
the top of the packet to update data.
2008 Microsoft Corporation. All rights reserved.
By using or providing feedback on these materials, you agree to the attached
license agreement.
BLUETOOTH SPECIFICATION Page 32 of 40
MTP over Bluetooth
used. The TransportError packet is always sent by the device detecting the error
on both the Command/Data and Event channel.
SHOULD not send an Operation Response packet indicating that the transaction was
cancelled. As with a normal cancellation request, the Responder MUST halt sending
of additional data and also flush all data on the Command/Data channel. All
information on the Event channel MUST also be flushed. Upon completion of these
operations, the Responder MUST send a TransportReady packet to resume normal
operation. As with the standard cancel operation, there is no requirement for a MTP
Responder to cache data associated with the current transaction in order to fully roll
back from a cancelled transaction.
Upon receipt of a TransportReady packet the Initiator MAY resume normal MTP
operations. After sending a TransportReady packet in response to the Initiator,
the Responder MUST enter the wait for next operation state.
transport reliability.
If the data phase is zero bytes in length, no Data packet should be sent. Only an
EndData packet should be sent.
terminated and both the Initiator and Responder return to their wait for next
command states. The exact mechanics of how Initiators and Responders forward
the cancel request to applications and how they respond is outside the scope of this
specification.
In general when the L2CAP Basic Mode Support is in effect the underlying MTP/BT
transport, it generates a cancel operation on behalf of the transport whenever an
error is detected. For example when the Initiators MTP/BT stack detects a transport
error it behaves as if it has just received a cancel event from the device and
forwards that notification up its stack. Similarly when a Responder detects a
transport error it forwards a cancel operation up its stack just as if a cancel packet
had been received from the Initiator. In both cases a TransportError packet is also
sent, triggering similar error recovery behaviors by the other end of the Link
whether as an Initiator or Responder The receipt of a TransportError packet
causes a cancel request to be forwarded up the stack.
A key aspect of the error handling protocol is the use of the TransportReady
acknowledgement between Initiator and Responder before regular MTP operations
are restarted. The protocol is designed in such a way that regardless of where the
error was detected, by the Initiator or Responder, the flush and restart mode are
identical to simplify implementation.
8. When ready to begin normal MTP operations again, the Initiator sends a
TransportReady packet on both the Command and Event channels
containing the LinkID of the link being reset.
9. The Initiatorss MTP/BT transport flushes all pending data received from the
Initiator until a TransportReady packet with the appropriate LinkID is
received on both the Command and Event channels.
10.The Responders MTP/BT transport resets the incoming Sequence ID for both
the Command and Event channels based on the Sequence ID present in the
TransportReady packet.
11.The Responders MTP/BT transport sends a TransportReady packet with the
associated LinkID on both the Command and Event Channels and returns to
the wait for next command state.
12.Upon receipt of the TransportReady packet with the correct LinkID on both
Command and Event channels, the Initiators MTP/BT transport re-initializes
the Sequence ID for both the Command and Event channels based on the
Sequence ID present in the TransportReady packet.
13.The Initiator resumes standard MTP operation.
2.10.2.1 Sequence ID
The general MTP/BT packet header contains both a Transport Identifier and
additional transport specific data. MTP over Bluetooth defines that the UINT16
format reserved for transport specific data to contain a SequenceID. A
monotonically increasing UINT16 value, the SequenceID is incremented for every
packet header that originates from a particular MTP Bluetooth device. The value 0
is illegal and the value 0xffff is reserved to indicate that SequenceID is disabled
because L2CAP Flow Control and Retransmission is in use. Upon exhausting all
SequenceID values by incrementing to 0xFFFE, the SequenceID value should be
reset to 0x0001 and continue incrementing. Care needs to be taken when
evaluating SequenceID progression to account for rollover.
2008 Microsoft Corporation. All rights reserved.
By using or providing feedback on these materials, you agree to the attached
license agreement.
BLUETOOTH SPECIFICATION Page 39 of 40
MTP over Bluetooth
The sending device may choose to initialize SequenceID to any starting value other
than 0x0 and 0xFFFF. Receiving devices are encouraged to initialize internal
tracking values to 0x0 upon startup or following any discontinuity in SequenceID
and assign them to the first SequenceID received. All packets following this initial
packet must resume standard progression requirements for SequenceID values.
Note that a sending device does not increment SequenceID upon receipt of a
packet; it is only incremented when it sends a packet.
1. Keep track of the last received SequenceID from the sending device in
LastSequenceID
2. Compare the SequenceID of the current packet to LastSequenceID + 1
taking into account rollover.
a. If the values match, the packet is OK and is accepted. No further work
is done.
b. If the values do not match, the receiving device initiates transaction
cancel behavior and transmits a TransportError packet on the
Command/Data and Event channel in accordance with the Transport
Error Handling section.
The CRC-32 fields in the Data packet and the EndData packet are subtly different.
The Running CRC-32 field in the Data packet takes into account all data
previously transmitted but not the data in the current packet. It is also not a final
CRC- it is the current intermediate value as calculated by the update_crc call in
the ANSI C implementation referenced above. The value of the CRC-32 in the
EndData packet takes into account all data transferred and is the full, complete
CRC-32 as defined by the crc function in the ANSI C implementation referenced.