## 5 Proposed IoT Layered Models
### Discussion and Analysis  
We made a simple scenario by making two IoT enabled devices to communicate with each other through our edge. The IoT devices were configured as virtual machines, created in AWS, and added to the Greengrass core, as shown in Figure 5 below. During the creation, a specific certificate, public and private keys are generated for each device to authenticate them with the AWS and with the Greengrass Core device. The communication between these two devices was done through a secure mechanism using the MQTT protocol called a message broker [34]. Finally, Figure 6 shows both IoT nodes and Edge node communicated successfully and data exchanges completed at specific times. The following are main points to observe about our AWS working environment and our implemented model:  
* In the general model, the IoT devices connect with each other or with the cloud through AWS IoT Core. * In our model we added the edge concept by utilizing the Greengrass IoT core concept in AWS, and represent it using Pi, so we can imagine it as an added mediator between the IoT devices and the AWS IoT Core then the cloud. * Each device needs its certificate, private key, and CA Root certificate (this is the AWS IoT certificate). There are different types of the CA Root certificate depending on the IoT device types. Figure 4: Certificate, private and public keys. * Each device needs a policy, this policy determines which operations this device can perform (connect/receive/publish/subscribe, etc.). Therefore, we created a device, policy, and certificate. Then we attached the policy to the certificate, then attached the certificate to the device. A default policy is shown Figure 7 below:  
Figure 5: IoT-enabled nodes. Figure 6: Successful communication and data exchange between nodes. The x-axis represents days of the month, and the y-axis the number of connections. * The default policy implies the device can perform all actions (Action: iot: *) from and to all other devices (Resource: *). * In our model, we created a modified policy to handle the added Greengrass layer. * Additionally, action: greengrass:
* means the device in the Greengrass group can perform all actions from and to other devices in the same Greengrass group (Resource: *). The modified policy for our model is shown in Figure 8. In our scenario, the communication is done using the MQTT protocol which is a machine to machine protocol. MQTT is used because it is lightweight (small size messages and need low power), so it is suitable for a constrained environment (sensors as an example in the real applications). Moreover, it is important to know that the IoT devices in the AWS are emulated as MQTT clients (if it is virtual--as it is in our scenario), and the MQTT clients communicate through an MQTT Topic. The connection can be imagined as a secure channel between the clients, it is created, then clients can subscribe to it, and other clients publish messages to it. Figure 8: Modified device policy to include the edge layer in the proposed model. Figure 7: Default device policy in Amazon Web Service (AWS). Now, the setup process for the Raspberry Pi includes installing JAVA JDK8, the Greengrass files, in addition to a suitable Core software (depending on the used device--in our case, it is a Raspberry Pi 4). All these files were transferred to the Raspberry Pi 4 as shown in Figure 9 below. After the transfer of necessary files to the Raspberry Pi 4, we needed to extract them and make some changes on some configuration files, to match the generated certificates and keys. Finally, we started the Greengrass core device. Figure 10 below shows that our Raspberry device successfully worked as an Edge. After setting up the environment and making sure it is ready, we created an MQTT topic in our scenario and named it (my/topic). Then, we created a device to be subscribed in my/topic and created another device to be a publisher to my/topic. All devices can perform all actions with all other devices (default policy), and all messages are exchanged successfully.