How to Know the Mtu Size of Android Smartphone

Android Ble MTU size

As M. Kotzjan indicated, this is related to the MTU supported by the other device. From the Bluetooth Specification v5.2, Vol 3, Part G, Section 4.3.1 (Exchange MTU):-

This sub-procedure is used by the client to set the ATT_MTU to the
maximum possible value that can be supported by both devices when the
client supports a value greater than the default ATT_MTU for the
Attribute protocol. This sub- procedure shall only be initiated once
during a connection.

In other words, if you request an MTU of 512 and the remote device replies with 23 (the minimum MTU value), the connection's MTU will be 23. If you request 512 and the remote device replies with 100, the connection's MTU will be 100. If you request 200 and the remote device replies with 512, the connection's MTU will be 200.

Have a look at the following link for more information:-

  • Maximising BLE Throughput Using Larger MTU
  • The Ultimate Guide to Android BLE

Android BLE MTU size, has anyone sniffed it?

I couldnt get the MTU exchange packet while sniffing. But i have found in code :

#define GATT_MAX_MTU_SIZE 517

https://github.com/tieto/external-bluetooth-bluedroid/blob/master/stack/include/gatt_api.h

Change the MTU or Packet Size for Bluetooth in Android?

Yes, You are right - it is not possible in Android API. You can only get MTU value for an interface with networkInterface.getMTU() method.

Based on sources for the NetworkInterface class

public int getMTU() throws SocketException {
return readIntFile("/sys/class/net/" + name + "/mtu");
}

You probably can change MTU value (for rooted devices) - You need to write new int MTU value to "/sys/class/net/" + networkInterface.getName() + "/mtu" file.

But I'm not sure if it is reliable solution for You.



Related Topics



Leave a reply



Submit