Maximum Packet Size According to MTU - KBA203312

Version: **

 

Question:

What is the maximum packet size according to MTU?

 

Answer:

The maximum transmission unit (MTU) is the maximum size of payload data, in octets, that the upper layer entity is capable of accepting. This value is used to respond to an Exchange MTU request from the GATT Client. If a server uses the MTU size, Server_MTU and a client uses the MTU size, Client_MTU, then the negotiated MTU is equal to the minimum of Server_MTU and Client_MTU. The valid range for the negotiated MTU size for a Cypress BLE connection is from 23 to 512 bytes.

Handle Value Notification and Indication:

A server can send a notification of an attribute’s value at any time. Also, the server can send an indication of an attribute’s value. The format for notification and indication is shown below. One byte is for opcode, 2 bytes for handle, and the remaining bytes are for data. Thus, the maximum size of an information payload for BLE notification is ATT_MTU minus 3 bytes. If you are using an MTU size of 23, then the maximum size for data is 20. If the attribute value is longer than (ATT_MTU) bytes, then only the first (ATT_MTU - 3) bytes of this attribute value can be sent in a notification or indication.

                      
Opcode (1 byte)Handle (2 bytes)Value (1 to ATT_MTU - 3)

 

Reading Attributes:

  1. Read Request
      This is used to request the server to read the value of an attribute and return its value in a ‘Read Response’. The format is as follows                                   
    Opcode (1 byte)Attribute Handle (2 byte)
     
      To get a long attribute, a client should use the Read Blob Request.
  2.  

    Read Response
       This is sent in reply to a ‘Read Request’ and contains the value of the attribute that has been read.
        

                                       
    Opcode (1 byte)Attribute Value (0 to ATT_MTU-1)
     
      If the attribute value is longer than (ATT_MTU - 1), then the first (ATT_MTU - 1) octet will be included in this response. 

Writing Attributes:

  1. Write Request
      This is used to request the server to write the value of an attribute and acknowledge that this has been achieved in a ‘Write Response’. The format is as follows. The attribute value field is the value to be written to the attribute.                                         
    Opcode (1 byte)Handle (2 byte)Attribute Value (0 to ATT_MTU-3)
  2.  

    Write Response
       This is sent in reply to a valid ‘Write Request’ and acknowledges that the attribute has been successfully written. The format of write response is as follows. The ‘Write Response’ will be sent after the attribute value is written.
        

                                 
    Attribute Opcode (1 byte)
  3.  

    Write Command
       This is used to request the server to write the value of an attribute, typically into a control-point attribute. The format is as follows.
        

                                             
    Opcode (1 byte)Handle (2 byte)Attribute Value (0 to ATT_MTU-3)