# RESEMBLE: A Real-Time Stack for Synchronized Mesh Mobile Bluetooth Low Energy Networks
## 3 Overview of the Bluetooth Mesh Architecture  
The Bluetooth Mesh Profile specifications [22] define a layered architecture that operates on top of the BLE stack. The layers of this architecture are shown in Figure 1.  
At the bottom layer of the protocol stack, there is the BLE Core Specification (lower layer in Figure 1). The Bluetooth Mesh architecture operates on top of this layer.  
**The Bearer Layer** interfaces BLE with the layers of the mesh network architecture. The specifications provide two kinds of bearers:  
* Advertising Bearer. This uses the advertisement, i.e., messages that are periodically broadcast.
* GATT Bearer. This operates on top of the Generic Attribute Profile (GATT) Layer of BLE. The GATT defines a connection-oriented application protocol for BLE. The GATT Bearer was defined to maintain the backward compatibility with the devices that support connection-oriented transmissions only.  
**The Network Layer** is in charge of the encryption/decryption, authentication and forwarding to the upper layers of the received messages and their retransmission to the other nodes. The routing algorithm is based on flooding, i.e., a node that receives a message addressed to another node and retransmits the message. In order to avoid loops and unlimited retransmissions, the Network Layer adopts two mechanisms. The first mechanism is based on a cache that stores the received messages, while the second is based on the message time-to-live (TTL), i.e., the number of hops that have been traversed. The cache mechanism avoids forwarding messages that have already been received by storing a copy of each message in a cache maintained at the Network Layer. When a new message is received, the Network Layer inspects the cache to check whether the message has already been received. If this is the case, the new message is dropped; otherwise, it is stored in the cache and then processed. Moreover, every Network Layer message maintains a TTL field to limit the number of times the message can be forwarded.  
**The Lower Transport Layer** segments the messages received from the upper layer to allow for their transmission on the network and reassembles the segments received from the Network Layer. To increase the communication reliability, this layer adopts a segment acknowledgement and retransmission mechanism.  
**The Upper Transport Layer** is mainly in charge of encrypting and decrypting the messages received from (or addressed to) the upper layer.  
**The Access Layer** interfaces the Upper Transport Layer with the Foundation Model Layer and the Model Layer for the transmission of data messages. The Access Layer supports both reliable (through an acknowledgement & retransmission mechanism) and non-reliable message transmissions and provides a \"Publish and Subscribe\" communication mechanism.  
**The Foundation Model Layer** defines the states, the messages and the models to configure and manage the mesh network, such as the configuration of the communication  
Figure 1: Bluetooth Mesh Profile stack.  
models for the Model Layer, the management of the health status of the network nodes or service, etc.  
**The Model Layer** defines the communication models to standardize the operations of specific user scenarios, such as light management, sensor data acquisition, etc.