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為上層提供了面向連接和無連接的服務數(shù)據(jù)及其復用能力,分段和重組操作.
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允許高層協(xié)議和應用程序去發(fā)送和接收高達64K 字節(jié)聪蘸,同時也允許每個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 內(nèi)部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的建立過程中,復用能力用于將連接導向正確的上層協(xié)議.
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.
在數(shù)據(jù)傳輸階段审洞,邏輯鏈路復用去要區(qū)分多個上層的實體.可以有多個上層實體使用相同協(xié)議(如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)分段允許應用程序數(shù)據(jù)單元的交替以滿足延遲的需求.(分段后的數(shù)據(jù)比較小亲雪,這樣l2cap便可以實現(xiàn)給每條鏈路的延遲需求:如A2DP會要求盡快吞吐以免引起聲音卡頓(丟包或延遲.而OPP則應滿足盡量快速完成的傳輸要求,這就是不同的應用有不同的延遲要求啃勉,分片后使得每種應用都滿足其基本延遲的傳輸需要)
b) Memory and buffer management is easier when L2CAP controls the packet size.
l2cap控制包大小更利于內(nèi)存緩沖管理
c) Error correction by retransmission can be made more efficient.
重傳實現(xiàn)的錯誤矯正可以變得更高效
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被污染或丟棄所造成的數(shù)據(jù)總量的毀壞比應用程序的數(shù)據(jù)單元更小
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.?
幾個數(shù)據(jù)流在相同的控制器上使用不用的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