CID (Channel ID) 在L2CAP层的很重要。
其中有一些固定的CID,比如在ACL_U逻辑链路上,
如下图所示,基本的信道主要是三种:
待补充
Length: 2 bytes
Channel ID : 2 bytes
Information payload: 65535 bytes (由长度的决定)
Length: 2 bytes
CID: 2 bytes,固定是0x0002
PSM(Protocol/Service Multiplexer) : >= 2bytes 最小是两个字节 eg:SDP, Refcommon
Information payload: 65535 bytes
The Control Field identifies whether the frame is an S-frame or I-frame and contains various information about the frame.
用来控制数据帧是否重传。
S-frames are used to acknowledge I-frames and request retransmission of Iframes.
Each S-frame has an ReqSeq sequence number which may acknowledge additional I-frames received by the data Link Layer entity.
Each S-frame with a Standard Control Field has a retransmission bit (R bit) that affects whether I-frames are retransmitted.
Each S-frame with an Enhanced Control field or an Extended Control Field has a Poll bit (P-bit) and a Final bit (F-bit) and does not have an R-bit.
Defined types of S-frames are RR (Receiver Ready), REJ (Reject), RNR(Receiver Not Ready) and SREJ (Selective Reject).
主要用来传输L2CAP的数据。
The I-frames are used to transfer information between L2CAP entities.
Each I-frame has a TxSeq(Send sequence number), ReqSeq(Receive sequence number) which can acknowledge additional I-frames received by the dataLink Layer entity.
Each I-frame with a Standard Control field has a retransmission bit (R bit) that affects whether I-frames are retransmitted.
Each I-frame with an Enhanced Control Field or an Extended Control Field has an F-bit that is used in Poll/Final bit functions.
//(SAR segmentation and reassembly)
The SAR field in the I-frame is used for segmentation and reassembly control. The L2CAP SDU Length field specifies the length of an SDU, including the aggregate length across all segments if segmented.
是S-Frame还是I-Frame 由 Control 字段中最低位决定的。
Information and Supervisory frames types are distinguished by the least significant bit in the Control Field.
Type
The type bit shall be 0 for an I-frame and 1 for an S-frame.
Send Sequence Number - TxSeq
The send sequence number is used to number each I-frame, to enable sequencing and retransmission.
Receive Sequence Number - ReqSeq
The receive sequence number is used by the receiver side to acknowledge I-frames, and in the REJ and SREJ frames to request the retransmission of an I-frame with a specific send sequence number.
Retransmission Disable Bit - R
R=0: Normal operation. Sender uses the RetransmissionTimer to control retransmission of I-frames. Sender does not use the MonitorTimer.
R=1: Receiver side requests sender to postpone retransmission of I-frames. Sender monitors signaling with the MonitorTimer. Sender does not use the RetransmissionTimer.
Segmentation and Reassembly - SAR
The SAR bits define whether an L2CAP SDU is segmented。
Supervisory function - S
The S-bits mark the type of S-frame
Poll - P
The P-bit is set to 1 to solicit a response from the receiver. The receiver shall respond immediately with a frame with the F-bit set to 1.
Final - F
The F-bit is set to 1 in response to an S-frame with the P bit set to 1.
0x0001 information payload 可以包含多条指令。 0x0005只能包含一条指令
Multiple commands may be sent in a single C-frame over fixed channel CID 0x0001 while only one command per C-frame shall be sent over fixed channel CID 0x0005.
C-Frame不能超过MTU中定义的长度。如果超过,接受端会立即发L2CAP_COMMAND_REJECT_RSP包含支持的最大的长度。同时C-Frame 最小长度如下表。
Note: The name of a signalling packet has a suffix indicating its type: _REQ for requests, _RSP for responses, and _IND for indications.
连续的命令,需要使用不同的Identifier。
Within each signaling channel a different Identifier shall be used for each successive command.
同时0x00不可以使用,会被当做无效signaling抛弃。
Signaling identifier 0x00 is an illegal identifier and shall never be used in any command.