L2CAP LAYER

圖片發(fā)自簡書App

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.

圖片發(fā)自簡書App

如圖將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

最后編輯于
?著作權歸作者所有,轉(zhuǎn)載或內(nèi)容合作請聯(lián)系作者
  • 序言:七十年代末双妨,一起剝皮案震驚了整個濱河市淮阐,隨后出現(xiàn)的幾起案子,更是在濱河造成了極大的恐慌刁品,老刑警劉巖泣特,帶你破解...
    沈念sama閱讀 212,454評論 6 493
  • 序言:濱河連續(xù)發(fā)生了三起死亡事件,死亡現(xiàn)場離奇詭異挑随,居然都是意外死亡状您,警方通過查閱死者的電腦和手機,發(fā)現(xiàn)死者居然都...
    沈念sama閱讀 90,553評論 3 385
  • 文/潘曉璐 我一進店門镀裤,熙熙樓的掌柜王于貴愁眉苦臉地迎上來竞阐,“玉大人,你說我怎么就攤上這事暑劝。” “怎么了颗搂?”我有些...
    開封第一講書人閱讀 157,921評論 0 348
  • 文/不壞的土叔 我叫張陵担猛,是天一觀的道長。 經(jīng)常有香客問我丢氢,道長傅联,這世上最難降的妖魔是什么? 我笑而不...
    開封第一講書人閱讀 56,648評論 1 284
  • 正文 為了忘掉前任疚察,我火速辦了婚禮蒸走,結果婚禮上,老公的妹妹穿的比我還像新娘貌嫡。我一直安慰自己比驻,他們只是感情好该溯,可當我...
    茶點故事閱讀 65,770評論 6 386
  • 文/花漫 我一把揭開白布。 她就那樣靜靜地躺著别惦,像睡著了一般狈茉。 火紅的嫁衣襯著肌膚如雪。 梳的紋絲不亂的頭發(fā)上掸掸,一...
    開封第一講書人閱讀 49,950評論 1 291
  • 那天氯庆,我揣著相機與錄音,去河邊找鬼扰付。 笑死堤撵,一個胖子當著我的面吹牛,可吹牛的內(nèi)容都是我干的羽莺。 我是一名探鬼主播实昨,決...
    沈念sama閱讀 39,090評論 3 410
  • 文/蒼蘭香墨 我猛地睜開眼,長吁一口氣:“原來是場噩夢啊……” “哼禽翼!你這毒婦竟也來了屠橄?” 一聲冷哼從身側響起,我...
    開封第一講書人閱讀 37,817評論 0 268
  • 序言:老撾萬榮一對情侶失蹤闰挡,失蹤者是張志新(化名)和其女友劉穎锐墙,沒想到半個月后,有當?shù)厝嗽跇淞掷锇l(fā)現(xiàn)了一具尸體长酗,經(jīng)...
    沈念sama閱讀 44,275評論 1 303
  • 正文 獨居荒郊野嶺守林人離奇死亡溪北,尸身上長有42處帶血的膿包…… 初始之章·張勛 以下內(nèi)容為張勛視角 年9月15日...
    茶點故事閱讀 36,592評論 2 327
  • 正文 我和宋清朗相戀三年,在試婚紗的時候發(fā)現(xiàn)自己被綠了夺脾。 大學時的朋友給我發(fā)了我未婚夫和他白月光在一起吃飯的照片之拨。...
    茶點故事閱讀 38,724評論 1 341
  • 序言:一個原本活蹦亂跳的男人離奇死亡,死狀恐怖咧叭,靈堂內(nèi)的尸體忽然破棺而出蚀乔,到底是詐尸還是另有隱情,我是刑警寧澤菲茬,帶...
    沈念sama閱讀 34,409評論 4 333
  • 正文 年R本政府宣布吉挣,位于F島的核電站,受9級特大地震影響婉弹,放射性物質(zhì)發(fā)生泄漏睬魂。R本人自食惡果不足惜,卻給世界環(huán)境...
    茶點故事閱讀 40,052評論 3 316
  • 文/蒙蒙 一镀赌、第九天 我趴在偏房一處隱蔽的房頂上張望氯哮。 院中可真熱鬧,春花似錦商佛、人聲如沸喉钢。這莊子的主人今日做“春日...
    開封第一講書人閱讀 30,815評論 0 21
  • 文/蒼蘭香墨 我抬頭看了看天上的太陽出牧。三九已至穴肘,卻和暖如春,著一層夾襖步出監(jiān)牢的瞬間舔痕,已是汗流浹背评抚。 一陣腳步聲響...
    開封第一講書人閱讀 32,043評論 1 266
  • 我被黑心中介騙來泰國打工, 沒想到剛下飛機就差點兒被人妖公主榨干…… 1. 我叫王不留伯复,地道東北人慨代。 一個月前我還...
    沈念sama閱讀 46,503評論 2 361
  • 正文 我出身青樓,卻偏偏與公主長得像啸如,于是被迫代替她去往敵國和親侍匙。 傳聞我的和親對象是個殘疾皇子,可洞房花燭夜當晚...
    茶點故事閱讀 43,627評論 2 350