l2test
Test layer 2 (MAC) Ethernet connections
SYNOPSIS
l2test [options] [bdaddr] [psm]
PARAMETERS
-i, --device <dev>
Local Bluetooth device (default hci0)
-s, --server
Act as L2CAP server (listen mode)
-c, --client
Act as L2CAP client (default)
-P, --psm <psm>
Local PSM value (default 1)
-p, --peer-psm <psm>
Remote PSM value (default 1)
-b, --backlog <num>
Listen backlog queue length (default 1)
-r, --reliable
Use reliable (retransmission) L2CAP mode
-S, --streaming
Use streaming L2CAP mode (default)
-f, --frame [<size>]
Fixed frame size (default 1024 bytes)
-F, --flushable
Use flushable data channel
-E, --ertm
Use Enhanced Retransmission Mode (default)
-A, --auto [<size>]
Auto-tune Tx window (optional size)
-w, --wtime <timeout>
Monitor inactivity timeout in seconds
-m, --mtu <size>
Set L2CAP MTU size
-d, --detach
Detach from controlling terminal
-D, --dump
Dump data packets for debugging
DESCRIPTION
l2test is a command-line utility from the BlueZ Bluetooth protocol stack designed for testing L2CAP (Logical Link Control Adaptation Protocol) sockets. It enables users to establish connections between Bluetooth devices, send and receive data interactively, and verify L2CAP functionality including connection setup, data transfer, and error conditions.
This tool is invaluable for developers debugging Bluetooth applications, simulating client-server interactions, and testing channel modes such as basic L2CAP, reliable (retransmission), or streaming modes. It supports customizable parameters like Protocol/Service Multiplexer (PSM) values, frame sizes, timeouts, and backlog for listening sockets.
In server mode, it listens for incoming connections; in client mode (default), it initiates connections to a remote device's BDADDR and PSM. Interactive mode allows typing data to send (with Ctrl+D to close) or hex/continuous input modes for advanced testing. Primarily used on Linux systems with Bluetooth hardware.
CAVEATS
Requires root privileges or CAP_NET_RAW capability. Bluetooth interface must be up and not blocked (hciconfig hci0 up). Not for production use; testing only. May interfere with other Bluetooth services.
USAGE EXAMPLE
Server: l2test -i hci0 -s 1
Client: l2test -i hci0 AA:BB:CC:DD:EE:FF 1
Type data and press Enter to send; Ctrl+D to close.
INTERACTIVE MODES
Supports line mode (default), hex dump (-x not listed but implied), continuous echo. Use for PSM 1 (SDP) or custom services.
HISTORY
Developed as part of BlueZ Bluetooth stack around 2002 (BlueZ 2.x era). Maintained for testing in BlueZ 5.x/6.x versions. Focuses on legacy L2CAP testing; modern BLE uses tools like btmgmt or gatttool.
SEE ALSO
l2ping(1), rfcomm(1), sdptool(1), hciconfig(8), bluetoothd(8)


