Friday, November 4, 2011

Part 3 — Bluetooth Logical Transports

 Content Index:

Introduction : Bluetooth
Part 1: Bluetooth Framework
Part 2: Physical Layer
Part 3: Logical Transports (Link Layer)

 

Physical links are eventually managed by a combination of master – slave relationship and the time slots within the medium. The most cogent way to grasp how these slots are used for transferring data is to explore this within the context of the popular BT use cases given below.

  • Hands free
    &
  • Music Playback (A2DP)
Hands free
Hands free use case is a critical one, this has to be full duplex and real time too which mandates a minimum guaranteed bandwidth otherwise the voice quality will take a hit. For achieving this circuit switched connection like behavior we need to reserve over the air slots for transmitting voice. The following two types of logical transports cater to this very stringent requirement.
  • SCO (Synchronous Connection Oriented) &
  • eSCO (Extended Synchronous Connection Oriented)
When link manager sets up above types of logical links it will make sure that a certain number of slots are reserved for its use, for more clarity please refer to the following figure.
eSCO Window
The above diagram illustrates an eSCO connection with the following attributes.
  • Total six slots are reserved for eSCO.
  • Out of the six slots one slot is for master to slave Tx and one for slave to master.
  • Four slots are reserved for retransmissions
  • There are two unreserved slots between each eSCO window.
During the connection set up phase itself the devices will negotiate the above eSCO connection parameters. There may be multiple unreserved slots between two eSCO windows which may be used for other types of data transfers. eSCO connections and SCO connections work in a similar fashion but in case of SCO there are no re-transmissions and it does not support EDR modulation schemes. Hopefully this has explained how hands free profile is working.
Music Playback (A2DP)
Music play back involves streaming of music files from a device to BT enabled head set. This music data is usually encoded in some form during transfer and later it is decoded and played by the headset, this use case implements a Asynchronous connection oriented transport(ACL). There are no slots reserved for this type of a logical transport, in case of A2DP we can have the headset to be the master or the device to be the master but in either of the case only master can trigger the data transfer. An ACL link is established by exchanging ACL control packets and during the connection establishment the ACL link parameters are negotiated, this will also determine the frequency of the music data transfer, its encoding, the type of packets and this transmission will be frequent enough to guarantee a clear playback.
In case where SCO/eSCO and ACL transports are coexisting between two BT devices, it will make sure that the reserved SCO/eSCO slots are honored and ACL uses only the intermittent unreserved ones.
Now the crux of this logical transports lie in the packet types used, which is given in the table below.
Baseband Packet Types

As you can see above eSCO support more than 1 MBPS rates, this in turn means that EDR (Extended Data Rate) modulation scheme will be used for eSCO but not for SCO, similarly for ACL there are BDR and EDR modulations supported, usage of the packet type will determine the modulation scheme and vice versa is also true.

ACL transport is also used for other profiles like FTP, DUN, SAP etc. One an ACL connection is established to a device then all these application profiles will share this ACL link, multiplexing all these profiles over one link is responsibility of the L2CAP layer.

Part 2 – Bluetooth Physical Layer

Content Index:

Introduction : Bluetooth
Part 1: Bluetooth Framework
Part 2: Physical Layer
Part 3: Logical Transports (Link Layer)

 
A bottom up approach is ideal for understanding BT, grasping the aspects of physical medium will clarify how data bits are transmitted over the air and how various abstractions can be enforced over this elementary framework. Two primary attributes which defines the physical layer are explained below:

1. Frequency Usage

BT employs frequency ranging from 2400MHz to 2483.4 MHz, the Unlicensed 2.4GHz ISM, in a typical wireless communication scenario there could be other devices in the vicinity operating with the same frequency and this can cause interference on the BT channel. To overcomes such noise BT articulates a frequency hopping scheme where the particular frequency of communication is switched every 625uS (but it can never switch outside of the 2.4GHz unlicensed spectrum), this unique pattern of hopping is mutually agreed by the devices during the connection establishment.

2. Modulation 

Across all the possible frequencies there are multiple modulation schemes, and this determines the speed of the transmission over the air. For example BT supports following types of modulations.

  • BDR scheme (Basic Data Rate Scheme has over the air speed of 1MBPS) and  
  • EDR Scheme (Enhanced Data Rate Scheme has over the air speed of 2 and 3 MBPS).

Packets transmitted over the air could belong to any one of these two modulation schemes and the header tells the receiver about the scheme used, note that header is always send in BDR scheme.

Physical Channel Transmission

We know how frequency and modulation schemes are used for encoding data over the air but there has to be an efficient way for utilizing the medium too. With Ethernet we have CSMA but BT works in a slightly different manner.

  1.  Similar to wired protocols like SPI and I2C we have a master slave relationship between the BT devices, its pure hegemony wherein the master controls the medium and decides when a slave can transmit.
  2. The physical medium is also divided into time slots of 625 uS and each slot is reserved for either the master or the slave, an illustration is done in the diagram below.
BT Time Slots
BT Time Slots

Master Tx always happens over a even numbered slot and slave Tx over an odd one. In the above graphical illustration we can see the following transmissions

  1. Master and slave exchange single slot packets in the first 3 slots.
  2. After which slave sends a three slot packet for which master sends a five slot packet response.
  3. Finally the slave sends another three slot packet.

Each BT device will have a 28 bit clock running in its controller which can identify the 625uS boundaries and initiate a Transmission (Tx) or a Reception (Rx). Data transmission happen using different packet structures, some of these packet types occupy more than one slot and needless to say every packet needs to be acknowledged by the receiving device. It is critical to note that the packet transmission will always occupy odd number of slots, this means that the slot immediately following the last packet will be reserved for the response from the receiver. Understanding the whole protocol stack is simpler if we start by studying its genetic constitution, in other words the physical layer which elaborates the strengths and the weakness in the most absolutely elementary form.

Part 1 – Bluetooth Framework

Content Index:

Introduction : Bluetooth
Part 1: Bluetooth Framework
Part 2: Physical Layer
Part 3: Logical Transports (Link Layer)

 

Bluetooth Protocol Layers
Bluetooth Protocol Layers

The core protocol stack of Bluetooth has the above three main layers:

Physical Layer: Decides how the bits are transmitted over the air, like the modulation schemes and the packet structures to be used for communication.

Logical Layer : Bluetooth is a connection oriented protocol, this means that there is a connection set up, maintenance and tear down. This layer handles these activities. Each type of connection has its own set of associated packets and each connection type is tailored for different purposes like music playback, hands free etc.

L2CAP : L2CAP multiplexes data of various applications (or BT profiles) over the lower layer logical links and connections.

Bluetooth System
Bluetooth System

A typical Bluetooth architecture will look like above diagram, L2CAP and above layers will sit on the host while Logical and Physical layers will sit on the controller. “Host” usually means the main processor, and the controller is a small BT chip sold by guys like Broadcom and CSR. “Host” processors in Laptops are usually Intel CPUs running Windows/Linux, in hand held market the host is usually an ARM SoC which may be running Android/iOS/WP7 or any other embedded OS.

There is usually a transport layer which connects the host to the BT controller, usually this is a high speed UART interface. There is one more hardware which is the lowest and below all the layers, this is the analog RF which actually transmits the bits over the air, receives the response and passes it to the physical layer, this analog logic is usually outside of the BT controller chip. An interesting aspect is that the main consumer of power or current in this system will be the RF, better the RF more optimized will be the power consumption.


No comments:

Post a Comment