Bluetooth protocol stack summary

Bluetooth protocol stack

radio frequency

  • Responsible for data transmission and reception
  • Omni-directional antenna is used to support point-to-multipoint communication, so that multiple Bluetooth devices can share network resources;
  • Modulation method: Gaussian filtered binary frequency shift keying (GFSK) Three available power levels:
power level Maximum output power normal output power Minimum output power
1 100 mW - 1 mW
2 2.5 mW 1 mW 0.25 mW
3 1 mW - -

Frequency band: 2400-2483.5MHz, divided into 79 frequency hopping channels, each channel bandwidth is 1MHz, the upper guard bandwidth is 3.51MHz, and the lower guard bandwidth is 2MHz.

The modification of the packet modulation method in the Bluetooth 2.0 EDR mode:

  • Packet header and access code use GFSK modulation at a rate of 1 Mb/s
  • Sync sequence, payload and tail sequence use PSK modulation at enhanced data rates, supporting RF data rates of 2 Mb/s and 3 Mb/s

Baseband

  • Together with the radio frequency, it forms the physical layer of the Bluetooth protocol stack
  • When sending data, it is responsible for encoding the data of the high-level protocol. When receiving data, it is responsible for decoding the data from the radio frequency.
  • Networking (piconet, scatternet)
  • Combines the functions of circuit switching and packet switching

Bluetooth address (BD_ADDR)

All bluetooth devices in the world have unique addresses

Company Assignment Number Company ID Company ID
Low address LAP(24bit) High address UAP(8bit) Nonsense address NAP (16bit)

link management

LM (link manager) converts upper layer commands into baseband layer operations.

basic skills:

  • Handling and negotiating the size of baseband packets to meet a specific quality of service;
  • Link management and security management, including the establishment and shutdown of ACL and SCO links.
  • Manage device power.

LMP protocol data unit

  • The LMP message is called LMP_PDU, which is mainly used for link management, security and control. High priority, which can be superior to SCO packet transmission.
  • The LMP_PDU is the payload of the ACL packet, and is used as a single-slot packet to transmit information on the link management logical channel.

L2CAP

Logical link control and adaptation.

  • Split the large packets used by the upper layer into small packets that can be transmitted by the baseband, and complete the assembly at the receiving stage

  • Supports multiplexing of different high-level protocols, allowing high-level protocols to share the underlying link.

  • L2CAP only supports ACL, the maximum rate is 64KBytes. Only transmit data packets, not Bluetooth audio

RFCOMM

Cable Replacement Agreement

  • The earliest purpose of Bluetooth development is to cancel the connection between electrical appliances, replacing cables is the most basic and main application method
  • Emulate RS232 control and data signals on the Bluetooth baseband to provide transmission capabilities for advanced services that use serial cables as a transmission mechanism
  • The role is similar to TCP in TCP/IP, providing interfaces for various high-level applications to achieve end-to-end communication
  • Relying on the baseband to provide a reliable and orderly bit stream, it has no error correction capability, and flow control also depends on the baseband

Service Discovery Protocol

The bluetooth scene has ad-hoc characteristics and strong dynamics

Help devices and services in the network to easily discover, negotiate and configure each other

SDP is a protocol for client-server architecture

  • A server is a device that provides services to other bluetooth devices
  • A client is a device within an effective communication range that wants to find a service

Service Inquiry Process

  1. Establish L2CAP remote connection
  2. Search for the specified service type on the SDP server, or browse the list of services
  3. Get the property values ​​needed to connect to the specified service
  4. Establish a separate connection using the service

SDP database

Attribute identifier ID Attribute value (variable type and length)
Service attribute 1
Service attribute 2
service attribute n

mandatory attribute

  • Service type, the attribute identifier is 0x0001
  • Service handle, a 32bit unsigned certificate, is a pointer to a service record, uniquely marking an SDP service record

Universally Unique Identifier UUID

  • Logo service type
  • Assign unique UUIDs to service classes developed by developers themselves to avoid naming conflicts.
  • Distributed generation, no duplication
  • The traditional UUID is 128bit, which can be reduced to 16bit or 32bit.
    • 128_bit_value = 16_bit_value * 296 + Base_UUID
    • 128_bit_value = 32_bit_value * 296 + Base_UUID

SDP message

Design goal: simple and easy to implement, well compatible with L2CAP

message browsing mode

  • Browse all available services in the server to find the required service (find the service list, return all UUIDs in the list)
  • According to find a specific service (by UUID)

Profile

GAP

  • Describes the basic operations necessary to establish communication between two Bluetooth devices, including device discovery, link establishment and configuration, and security aspects.
  • device role
    • Broadcaster (Broadcaster): Periodically send broadcast information
    • Observer (Observer): Listen to the channel and receive broadcast information
    • Central device (Central): the party that initiates the connection
    • Peripheral: The party that receives the connection

Link between master and slave

SCO link (circuit switched)

  • Symmetrical, point-to-point synchronous link between the master device and the slave device;

  • Mainly used to transmit voice packets with high real-time requirements

  • Continuously transmit information through pre-reserved time slots, which can be regarded as circuit switching

  • Packet retransmission is not allowed (no parity bit), ensuring real-time performance

  • SCO packets use forward error correction FEC (Forward Error Correction)

    • Packet header: 1/3 FEC (each bit repeated three times)
    • Load: 2:3 FEC (2:3 Brief Hamming Code)
  • Regardless of whether data is sent or not, the system will reserve a fixed interval time limit for the master device and the slave device, and other slave devices cannot use the time slot on this connection to send data

ACL link (asynchronous packet switching)

  • Packet switching only transmits packets of data.
  • After the master device reserves time slots for SCO transmission, it allocates asynchronous ACL transmission in the remaining time slots
  • ACL has lower priority than SCO. Once the system wants to transmit SCO, ACL must automatically give up the reserved time slot.
  • Support broadcasting, the master device can send messages to all slave devices in the piconet.
  • ACL adopts CRC check, and the receiving error will be retransmitted

Bluetooth networking

The ad hoc feature of Bluetooth personal area network

  • Independent networking: automatically form an independent network in a short time
  • Multi-hop routing: Nodes outside the communication range need to go through multiple hops
  • Topology dynamic changes: Some nodes move, power off and on, causing changes in the number and distribution of nodes and links
  • Special channel characteristics: Affected by wireless channel conflicts, etc., the actual bandwidth of the link is much smaller than the theoretical bandwidth, and it changes dynamically
  • Node energy consumption is limited
  • Security: Vulnerable to eavesdropping, active intrusion, denial of service and other attacks

piconet

  • The master device that first puts forward the communication requirement, and the device that passively communicates is the slave device (only in the baseband)
  • 1 master and up to 7 slaves in a piconet
  • The clock of the master device is transmitted to the slave device, and the slave device adds the offset

Piconet Internal Scheduling

  • If the master device has no data for the slave device, it sends a POLL packet
  • If the slave has no data for the master, send NULL
  • Reducing the ratio of POLL and NULL packets is fundamental to improving scheduling efficiency

clock

  • Each Bluetooth device has an independent 28bit internal system clock with a frequency of 3.2kHz
  • Determining Transceiver Timing and Frequency Hopping
  • Add an offset to the local clock when synchronizing with the other device

Scatternet

Multiple piconets can exist in the same area at the same time. If a Bluetooth device enters such a network and acts as a bridging device, it connects the spatially overlapping piconets to form a scatternet.

An Improved Method for Loop Polling

  • full cycle polling

    • The next device is not polled until the master device and the slave device have sent the information; (what's the problem?)
    • Fairness issues, some nodes may always have data to send, making it impossible for other devices to send data
  • limited round robin polling

  • Limit the number of data transfers per connection

  • Rely on polling of master and slave status

    • Prioritize each pair of MS
    • 1 means data is sent, 0 means no data is sent.
    • 1-1 has the highest priority, followed by 1-0 and 0-1, and the lowest is 0-0
      ring polling
    • The next device is not polled until the master device and the slave device have sent the information; (what's the problem?)
    • Fairness issues, some nodes may always have data to send, making it impossible for other devices to send data
  • limited round robin polling

  • Limit the number of data transfers per connection

  • Rely on polling of master and slave status

    • Prioritize each pair of MS
    • 1 means data is sent, 0 means no data is sent.
    • 1-1 has the highest priority, followed by 1-0 and 0-1, and the lowest is 0-0

Guess you like

Origin blog.csdn.net/interval_package/article/details/125118625