This section of the Bluetooth Specification defines the Logical Link Control and Adaptation Layer Protocol, referred to as L2CAP. L2CAP provides connection- oriented and connectionless data services to upper layer protocols with protocol multiplexing capability and segmentation and reassembly operation.
l2cap为上层提供了面向连接和无连接的服务数据及其复用能力,分段和重组操作.
L2CAP permits higher level protocols and applications to transmit and receive upper layer data packets (L2CAP Service Data Units, SDU) up to 64 kilobytes in length. L2CAP also permits per-channel flow control and retransmission.
l2cap允许高层协议和应用程序去发送和接收高达64K 字节,同时也允许每个channel进行流程控制和重传.
The L2CAP layer provides logical channels, named L2CAP channels, which are multiplexed over one or more logical links.
如图将l2cap break down into 架构性部件:
1.channel mgr:提供控制平台功能,即负责(be responsible for)all 内部signaling,端到端的signaling以及上下层的signaling.
2.The Retransmission and Flow Control block provides per-channel flow control and error recovery using packet retransmission.
3.The Resource Manager is responsible for providing a frame relay service to the Channel Manager, the Retransmission and Flow Control block and those application data streams that do not require Retransmission and Flow Control services
Protocol/channel multiplexing L2CAP supports multiplexing over individual Controllers and across multiple controllers. An L2CAP channel shall operate over one Controller at a time. 不重要.
During channel setup, protocol multiplexing capability is used to route the connection to the correct upper layer protocol.
在channel的建立过程中,复用能力用于将连接导向正确的上层协议.
For data transfer, logical channel multiplexing is needed to distinguish between multiple upper layer entities. There may be more than one upper layer entity using the same protocol.
在数据传输阶段,逻辑链路复用去要区分多个上层的实体.可以有多个上层实体使用相同协议(如rfcomm)
• Segmentation and reassembly With the frame relay service offered by the Resource Manager, the length of transport frames is controlled by the individual applications running over L2CAP. Many multiplexed applications are better served if L2CAP has control over the PDU length. This provides the following benefits: a) Segmentation will allow the interleaving of application data units in order to satisfy latency requirements.
帧的分段和重组依赖于RM提供的服务.
帧的传输长度受到运行于l2cap之上的应用程序.l2cap控制pdu长度可以更好得服务于多路复用的应用程序并带来以下好处:
a)分段允许应用程序数据单元的交替以满足延迟的需求.(分段后的数据比较小,这样l2cap便可以实现给每条链路的延迟需求:如A2DP会要求尽快吞吐以免引起声音卡顿(丢包或延迟.而OPP则应满足尽量快速完成的传输要求,这就是不同的应用有不同的延迟要求,分片后使得每种应用都满足其基本延迟的传输需要)
b) Memory and buffer management is easier when L2CAP controls the packet size.
l2cap控制包大小更利于内存缓冲管理
c) Error correction by retransmission can be made more efficient.
重传实现的错误矫正可以变得更高效
d) The amount of data that is destroyed when an L2CAP PDU is corrupted or lost can be made smaller than the application's data unit.
当一个l2cap pdu被污染或丢弃所造成的数据总量的毁坏比应用程序的数据单元更小
e) The application is decoupled from the segmentation required to map the application packets into the lower layer packets.
应用程序从分段中分离出来被要求去映射到底层的包
Flow control per L2CAP channel Controllers provide error and flow control for data going over the air and HCI flow control exists for data going over an HCI transport. When several data streams run over the same Controller using separate L2CAP channels, each channel requires individual flow control. A window based flow control scheme is provided.
几个数据流在相同的控制器上使用不用的l2cap channel,每个channel要求独立的流控.流程的窗口将被提供.
• Error control and retransmissions When L2CAP channels are moved from one Controller to another data can be lost. Also, some applications require a residual error rate much smaller than some Controllers can deliver. L2CAP provides error checks and retransmissions of L2CAP PDUs. The error checking in L2CAP protects against errors due to Controllers falsely accepting packets that contain errors but pass Controller-based integrity checks. L2CAP error checking and retransmission also protect against loss of packets due to flushing by the Controller. The error control works in conjunction with flow control in the sense that the flow control mechanism will throttle retransmissions as well as first transmissions.
• Support for Streaming Streaming applications such as audio set up an L2CAP channel with an agreed-upon data rate and do not want flow control mechanisms, including those in the Controller, to alter(改变) the flow of data. A flush timeout is used to keep data flowing(使流动) on the transmit side. Streaming mode is used to stop HCI and Controller based flow control from being applied on the receiving side.
• Fragmentation and Recombination Some Controllers may have limited transmission capabilities and may require fragment sizes different from those created by L2CAP segmentation.
Therefore layers below L2CAP may further fragment and recombine L2CAP PDUs to create fragments which fit each layer’s capabilities. During transmission of an L2CAP PDU, many different levels of fragmentation and recombination may occur in both peer devices.
The HCI driver or controller may fragment L2CAP PDUs to honor packet size constraints of a host controller interface transport scheme. This results in HCI data packet payloads carrying start and continuation fragments of the L2CAP PDU. Similarly the Controller may fragment L2CAP PDUs to map them into Controller packets. This may result in Controller packet payloads carrying start and continuation fragments of the L2CAP PDU.
Each layer of the protocol stack may pass on different sized fragments of L2CAP PDUs, and the size of fragments created by a layer may be different in each peer device. However the PDU is fragmented within the stack, the receiving L2CAP entity still recombines the fragments to obtain the original L2CAP PDU.
• Quality of Service The L2CAP connection establishment process allows the exchange of information regarding the quality of service (QoS) expected between two Bluetooth devices. Each L2CAP implementation monitors the resources used by the protocol and ensures that QoS contracts are honored.
For a BR/EDR or BR/EDR/LE Controller, L2CAP may support both isochronous (Guaranteed) and asynchronous (Best Effort) data flows over the same ACL logical link by marking packets as automatically-flushable or non-automatically-flushable by setting the appropriate value for the Packet_Boundary_Flag in the HCI ACL Data Packet (see [vol.2, part E] Section 5.4.2 on page 472). Automatically-flushable L2CAP packets are flushed according to the automatic flush timeout set for the ACL logical link on which the L2CAP channels are mapped (see [vol.2, part E] Section 6.19 on page 486). Non-automatically-flushable L2CAP packets are not affected by the automatic flush timeout and will not be flushed. All L2CAP packets can be flushed by using the HCI Flush command (see [vol.2, part E] Section 7.3.4 on page 652).
For AMP Controllers, L2CAP places all asynchronous data flows going to the same remote device over a single logical link (aggregation). L2CAP places each isochronous data flow over its own logical