-
Notifications
You must be signed in to change notification settings - Fork 305
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
MTU exchange takes affect under windows but not under linux #1227
Comments
Thanks @dlech. Do you see anything out of the ordinary in the connection and MTU exchange packets that may hint why the device fragments the packets? (Trying to find a hint, how to approach here. On the device, the BLE stack reports to the app an MTU update event with value of 247 as expected). |
I would look into the Bluetooth stack on the remote device to see how it works. |
I tested the same bleak test program but with a very different device and BLE stack (Nordic nRF52, vs ESP32) and am getting same results. With bleak/linux the device fragments. Here is the packets capture. |
On Windows, the remote device is sending a remote Connection Parameter Update Request which results in PDUs exchanged every 40ms after this. I'm not seeing the same on Linux. On Windows, the central is sending the MTU exchange first while on Linux the peripheral is initiating the exchange. So I'm guessing there is some sort of timing difference or hardware difference between Windows and Linux that triggers a different behavoir on the remote device. |
Thanks @dlech . I also tested the ESP32 device with a Nordic phone app as a client and no fragmentation. Considering that the exact same problem exist with both ESP32 stack and nRF stack suggests that it's not the device but something on the linux side. Are you aware of any BLE related forum where I can post the packets and ask for another set of eyes to look at it? I will also try the zephyr forums since the nRF device is zephyr based. They have a few BLE experts there. |
I think I found the answer now. On Linux, the adapter does not have the "LE Data Packet Length Extension" feature flag But the adapter on Windows does. This flags controls whether data has to be fragmented or not according to https://stackoverflow.com/a/71512081/1976323.
(the other flags also explain the other differences I noted) |
I'm pretty sure anything starting with "LL" (link layer) is something that is manged by the radio itself and not generally controlled by the host, at least not directly. |
I found this Contacts page for Bluez, so I will try to ask there and see
what comes back. I presume that this is what Bleak/Linux uses (?).
http://www.bluez.org/contact/
…On Sat, Feb 18, 2023 at 11:37 AM David Lechner ***@***.***> wrote:
I'm pretty sure anything starting with "LL" (link layer) is something that
is manged by the radio itself and not generally controlled by the host, at
least not directly.
—
Reply to this email directly, view it on GitHub
<#1227 (comment)>, or
unsubscribe
<https://github.com/notifications/unsubscribe-auth/AAQVMQKXKMIL3BDAGBYEFZTWYEQGFANCNFSM6AAAAAAVAE7P3I>
.
You are receiving this because you authored the thread.Message ID:
***@***.***>
|
Yes. BlueZ also has a github page. However, I already look in the BlueZ source code and |
Thanks @dlech. I just filed this bluez issue bluez/bluez#480 |
Digging more brought up the hciconfig -a Linux commands. The Features line may indicate the capabilities of linux interface. Bits may correspond to the 8 bytes that are sent in the LL_FEATURE_REQ but I am not sure. $ hciconfig -a This is the feature bit specification from BLE 4.2. Version 5.x uses more bits. |
Apparently the issue is the builtin BT controller in my computer which doesn't support the Data Packet Length Extension feature. It's an old controller. I plugged in this adapter https://www.amazon.com/dp/B08M1VJHVD and, disabled the internal one, packets are not fragmented anymore. Thanks for the help @dlech. NOTE: to disable the builtin interface I followed the answer here https://unix.stackexchange.com/questions/242937/i-have-two-usb-bluetooth-adapters-one-doesnt-work-hci1-but-seems-to-be-the-de |
bleak version: 0.19.5
Python version: 3.10.6
Operating System: Ubuntu 22.04.1 LTS
BlueZ version (bluetoothctl -v) in case of Linux: bluetoothctl: 5.64
Description
I encountered another difference between windows and linux. The test program below runs against a device that is supposed to set MTU to 247. The setting works well when I run the bleak test program on windows and I can see packets at size > 200, but when the bleak test program runs on linux, against the same device, the MTU increase doesn't take affect and the device fragments the packets into smaller ones. I don't not understand the BLE protocol well enough to pinpoint what exactly causes that difference in behavior.
What I Did
Test program
Logs
Logs when running the test program on linux. MTU doesn't take affect and packets are fragmented.
mtu_linux.zip
mtu_linux.txt
Logs when running the test program on windows. Packets are not fragmented (good).
mtu_windows.zip
The text was updated successfully, but these errors were encountered: