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|pattern>

PARAMETERS

-i, --interval=INTERVAL
    Ping interval in seconds (min 0.2s, default 1s)

-s, --size=SIZE
    Data packet size in bytes (default 23, max 65535)

-c, --count=COUNT
    Packets to send (default infinite)

-d, --discover
    Discover remote BDADDR via inquiry

-F, --follow
    Follow remote device during page scans

-f, --no-fork
    Foreground mode, no daemonizing

-n, --numeric
    Show numeric BDADDRs only

-H, --help
    Display help information

-V, --version
    Print version and exit

DESCRIPTION

l2ping is a command-line tool from the BlueZ Linux Bluetooth stack. It sends L2CAP (Logical Link Control and Adaptation Protocol) echo requests to a Bluetooth device's BDADDR, akin to ping(8) for IP networks but at the Bluetooth L2CAP layer. This measures round-trip time (RTT), detects packet loss, and tests connectivity.

Primarily used for debugging Bluetooth links, verifying device responsiveness, performance benchmarking, and ensuring L2CAP support. Packets are sent periodically with configurable size, count, and interval. Upon stopping (Ctrl+C), it displays statistics: packets transmitted/received, loss percentage, min/avg/max RTT.

Requires an active HCI Bluetooth adapter (hciconfig hci0 up). Supports device discovery and following mobile devices. Default behavior: 23-byte packets every 1 second indefinitely. Maximum packet size is 65535 bytes; minimum interval 0.2s.

Ideal for developers testing Bluetooth peripherals, IoT devices, or audio equipment in Linux environments.

CAVEATS

Requires root privileges for some operations like discovery; Bluetooth adapter must be up and L2CAP enabled. Not all devices respond to L2CAP pings. High packet sizes may fail on low-MTU links. Deprecated in favor of newer BlueZ tools like btmgmt.

EXAMPLE USAGE

l2ping AA:BB:CC:DD:EE:FF
Pings device with defaults.

l2ping -d -s 1024 -c 5 AA:BB:CC:DD:EE:FF
Discovers, sends 5 large packets.

OUTPUT SAMPLE

PING: AA:BB:CC:DD:EE:FF from AA:BB:CC:DD:EE:FF (data size 23)
23 bytes from AA:BB:CC:DD:EE:FF id 0 time 12.34 ms
--- AA:BB:CC:DD:EE:FF l2ping statistics ---
5 packets transmitted, 5 received, 0% loss
min/avg/max = 10.1/12.3/15.2 ms

HISTORY

Introduced in early BlueZ releases (circa 2000s) as part of Linux Bluetooth protocol stack tools. Maintained by BlueZ project under kernel.org; evolved with Bluetooth spec versions (1.1 to 5.x). Usage peaked in development/debugging before modern tools like bluetoothctl.

SEE ALSO

Copied to clipboard