LinuxCommandLibrary

l2ping

Test Bluetooth device connectivity

TLDR

Ping a Bluetooth device

$ sudo l2ping [mac_address]
copy

Reverse ping a Bluetooth device
$ sudo l2ping -r [mac_address]
copy

Ping a Bluetooth device from a specified interface
$ sudo l2ping -i [hci0] [mac_address]
copy

Ping Bluetooth device with a specified sized data package
$ sudo l2ping -s [byte_count] [mac_address]
copy

Ping flood a Bluetooth device
$ sudo l2ping -f [mac_address]
copy

Ping a Bluetooth device a specified amount of times
$ sudo l2ping -c [amount] [mac_address]
copy

Ping a Bluetooth device with a specified delay between requests
$ sudo l2ping -d [seconds] [mac_address]
copy

SYNOPSIS

l2ping [ options ] bdaddr

PARAMETERS

-s, --size
    Specifies the size of the L2CAP echo request packets in bytes.

-c, --count
    Sets the number of L2CAP echo request packets to send.

-i, --interval
    Defines the delay in seconds between sending each packet.

-t, --timeout
    Specifies the timeout in seconds to wait for an echo reply.

-f, --flood
    Sends packets as fast as possible without waiting for replies or adhering to intervals.

-a, --adapter
    Specifies the local Bluetooth adapter's address to use for sending packets.

-d, --debug
    Enables debug output, showing more detailed information about the L2CAP connection.

-h, --help
    Displays the help message and exits.


    The mandatory Bluetooth address of the target device to ping (e.g., 00:1A:2B:3C:4D:5E).

DESCRIPTION

l2ping is a utility for diagnosing and testing Bluetooth L2CAP (Logical Link Control and Adaptation Protocol) connections. Analogous to the ping command for IP networks, l2ping sends L2CAP echo request packets to a specified Bluetooth device address (BD_ADDR) and listens for echo replies.

This tool is essential for verifying basic Bluetooth connectivity, measuring round-trip time (RTT) between two Bluetooth devices, and assessing packet loss. It helps identify if a remote Bluetooth device is reachable and responsive at the L2CAP layer. l2ping is part of the BlueZ utilities, the official Linux Bluetooth protocol stack, and is widely used by developers and system administrators to troubleshoot Bluetooth issues on Linux systems. It supports various options to control packet size, count, interval, and source adapter, providing flexibility for different testing scenarios.

l2ping operates at a low level of the Bluetooth stack, providing insights into the fundamental link quality, making it a valuable first step in debugging more complex Bluetooth profile problems.

CAVEATS

l2ping typically requires root privileges (or being run with sudo) because it interacts directly with the Bluetooth HCI (Host Controller Interface) layer.

The target Bluetooth device must be powered on and in a state where it can respond to L2CAP echo requests. While it tests basic reachability, it does not guarantee higher-level Bluetooth profile (e.g., A2DP, SPP) functionality.

Performance measurements can be affected by factors like power saving modes on the devices, distance, interference, and the overall load on the Bluetooth adapter.

USAGE PRIVILEGES

Due to its direct interaction with the Bluetooth hardware and low-level stack, l2ping requires elevated privileges to run. This means it must be executed as the root user or by using the sudo command. For example:
sudo l2ping 00:1A:2B:3C:4D:5E

TYPICAL USE CASES

l2ping is commonly used for:
- Verifying if a remote Bluetooth device is discoverable and responsive at the L2CAP level.
- Measuring latency (round-trip time) between a local adapter and a remote device.
- Troubleshooting basic connectivity issues when devices fail to pair or connect.
- Assessing the quality of a Bluetooth link in a given environment.

HISTORY

l2ping is an integral part of the BlueZ project, the official Linux Bluetooth protocol stack. BlueZ began development in 2001, aiming to provide a robust and open-source implementation of Bluetooth for Linux. l2ping was developed early on as a fundamental diagnostic tool, mirroring the utility of ping for IP networks, adapted for the Bluetooth L2CAP layer.

Its consistent inclusion across various BlueZ releases underscores its importance as a go-to command-line tool for basic Bluetooth connectivity testing and troubleshooting on Linux systems for over two decades. Its design has remained largely consistent due to its effective simplicity.

SEE ALSO

Copied to clipboard