Discussion Board

Results 1 to 2 of 2
  1. #1
    Regular Contributor
    Join Date
    Aug 2005

    Is L2CAP worth the extra effort?

    I have a 2 player game running using RFComm. There is slight latency, depending on which devices you play. I was wondering by how much would L2CAP improve things. According to the documentation L2Cap is a lot more complicated because I have to "handle my own flow control" (whatever that means).
    My question is the small reduction of latency worth the extra complexity of the implementation?

  2. #2
    Regular Contributor
    Join Date
    Feb 2006

    Lightbulb Re: Is L2CAP worth the extra effort?

    Hello ed_welch,

    As I suppose you know, RFComm is above the L2CAP protocol in the Bluetooth stack. This means that RFComm packets will be included inside the L2CAP payloads, so RFComm will use more overhead than L2CAP.

    In other words, I don't know exactly if it is worth to use L2CAP instead of RFComm and if this change will improve your speed connections in your particular case, but I think that this change is feasible if you have a lot of Bluetooth connections simultaneously and in this case you will note a little difference.

    27.4.4 Logical Link Control and Adaptation Protocol (L2CAP)

    Logical Link Control and Adaptation Protocol (L2CAP) provides connection-oriented and connectionless data services to upper layer protocols with protocol multiplexing capability and segmentation and reassembly operation. L2CAP permits higher level protocols and applications to transmit and receive L2CAP data packets up to 64 kilobytes in length.

    L2CAP is based around the concept of channels. Channel is a logical connection on top of baseband connection. Each channel is bound to a single protocol in a many-to-one fashion. Multiple channels can be bound to the same protocol, but a channel cannot be bound to multiple protocols. Each L2CAP packet received on a channel is directed to the appropriate higher level protocol. Multiple channels can share the same baseband connection.

    A single Netgraph node of type l2cap is created for a single Bluetooth device. The L2CAP node is normally connected to the Bluetooth HCI node (downstream) and Bluetooth sockets nodes (upstream). Default name for the L2CAP node is “devicel2cap”. For more details refer to the ng_l2cap(4) manual page.

    A useful command is l2ping(8), which can be used to ping other devices. Some Bluetooth implementations might not return all of the data sent to them, so 0 bytes in the following example is normal.

    # l2ping -a 00:80:37:29:19:a4
    0 bytes from 0:80:37:29:19:a4 seq_no=0 time=48.633 ms result=0
    0 bytes from 0:80:37:29:19:a4 seq_no=1 time=37.551 ms result=0
    0 bytes from 0:80:37:29:19:a4 seq_no=2 time=28.324 ms result=0
    0 bytes from 0:80:37:29:19:a4 seq_no=3 time=46.150 ms result=0

    The l2control(8) utility is used to perform various operations on L2CAP nodes. This example shows how to obtain the list of logical connections (channels) and the list of baseband connections for the local device:

    % l2control -a 00:02:72:00:d4:1a read_channel_list
    L2CAP channels:
    00:07:e0:00:0b:ca 66/ 64 3 132/ 672 OPEN
    % l2control -a 00:02:72:00:d4:1a read_connection_list
    L2CAP connections:
    Remote BD_ADDR Handle Flags Pending State
    00:07:e0:00:0b:ca 41 O 0 OPEN

    Another diagnostic tool is btsockstat(1). It does a job similar to as netstat(1) does, but for Bluetooth network-related data structures. The example below shows the same logical connection as l2control(8) above.

    % btsockstat
    Active L2CAP sockets
    PCB Recv-Q Send-Q Local address/PSM Foreign address CID State
    c2afe900 0 0 00:02:72:00:d4:1a/3 00:07:e0:00:0b:ca 66 OPEN
    Active RFCOMM sessions
    L2PCB PCB Flag MTU Out-Q DLCs State
    c2afe900 c2b53380 1 127 0 Yes OPEN
    Active RFCOMM sockets
    PCB Recv-Q Send-Q Local address Foreign address Chan DLCI State
    c2e8bc80 0 250 00:02:72:00:d4:1a 00:07:e0:00:0b:ca 3 6 OPEN

    27.4.5 RFCOMM Protocol

    The RFCOMM protocol provides emulation of serial ports over the L2CAP protocol. The protocol is based on the ETSI standard TS 07.10. RFCOMM is a simple transport protocol, with additional provisions for emulating the 9 circuits of RS-232 (EIATIA-232-E) serial ports. The RFCOMM protocol supports up to 60 simultaneous connections (RFCOMM channels) between two Bluetooth devices.

    For the purposes of RFCOMM, a complete communication path involves two applications running on different devices (the communication endpoints) with a communication segment between them. RFCOMM is intended to cover applications that make use of the serial ports of the devices in which they reside. The communication segment is a Bluetooth link from one device to another (direct connect).

    RFCOMM is only concerned with the connection between the devices in the direct connect case, or between the device and a modem in the network case. RFCOMM can support other configurations, such as modules that communicate via Bluetooth wireless technology on one side and provide a wired interface on the other side.

    In FreeBSD the RFCOMM protocol is implemented at the Bluetooth sockets layer.
    I would make a worst case test in both cases, using RFCOMM and L2CAP protocols. Then, I would test the average jitter and compare both measures. Finally, I would choose the fastest option, although it would have been more complex to program!



Similar Threads

  1. BIP problem for nokia 6682
    By fafou in forum Bluetooth Technology
    Replies: 0
    Last Post: 2006-09-19, 14:11
  2. L2CAP socket not connecting
    By gpalvia in forum Bluetooth Technology
    Replies: 4
    Last Post: 2004-07-19, 09:20
  3. how to set the send/recv buffer size of L2CAP sockets in Bluetooth
    By gpalvia in forum Symbian User Interface
    Replies: 0
    Last Post: 2004-03-26, 07:01
  4. Send and Receive using L2CAP
    By viddunokia in forum Mobile Java General
    Replies: 1
    Last Post: 2003-09-12, 21:12
  5. Postfixing extra digits on SMS Messages
    By Talking in forum PC Suite API and PC Connectivity SDK
    Replies: 1
    Last Post: 2002-09-11, 22:40

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts