# A Secure IoT-Based Irrigation System for Precision Agriculture Using the Expeditious Cipher
## 3 Results
### Simulation Scenario  
Table 3 presents the simulation packages used in the performance evaluation of the X-cipher. A Windows 10 virtual machine runs the Raspberry Pi emulator that was selected. An Ubuntu 20.1 virtual machine is used for the subscriber. The DHT-11 sensors are connected directly to the Raspberry Pi Emulator. Figure 4 illustrates selected parts of the Python code used to obtain humidity and temperature reading from DHTT-11 sensors. The Adafruit_DHT Python library is available for reading the DHT series of humidity and temperature sensors on a Raspberry Pi. First, the sensor type and the pin that the DHT-11 is connected through to Raspberry Pi must be specified. Then, the function Adafruit_DHT.read_retry is used to read from the specified pin. As can be noticed, the humidity and temperature readings are encrypted using the lightweight class function encrypt, which is our class implementation for the X-cipher protocol. Moreover, Figure 5 depicts a selected part of the MQTT client code for the Raspberry Pi emulator. The paho.mqtt.client Python library is deployed to provide a client class with support for MQTT protocol, and it also provides some helper functions that facilitate publishing messages to an MQTT server. Figure 6 highlights selected parts of the python code used to calculate memory usage. Calculations of memory usage rely on the process.memory_info and choosing the \"rss\" option returns the actual physical memory the process is using. Figure 7 illustrated selected parts of the Python code used to calculate power consumption. The pyRAPL Python library is utilized to measure the energy footprint of a host machine along with the execution of a piece of Python code. Three performance metrics were used to evaluate and compare the Expeditious Cipher (X-cipher) and the AES cipher [32]: power consumption, execution time, and memory usage for a file of 10,000 message comma separated of total size 20 MB.  
import paho.mqtt.client as paho.  def on_connect(self, mosq, obj, rc):  self.subscribe(\"Fan\", 0)  def on_message(mosq, obj, msg):  print(msg.topic + \" \" + str(msg.qos) + \" \" + str(msg.payload))  # Give 5 second delay  def on_publish(mosq, obj, mid):  print(\"mid: \" + str(mid))  def on_subscribe(mosq, obj, mid, granted_qos):  print(\"Subscribed: \" + str(mid) + \" \" + str(granted_qos))  
mqttc = paho.client() # object declaration # Assign event callbacks  matttc.on_message = on_message # called as callback  matttc.on_connect = on_connect  matttc.on_publish = on_publish  matttc.on_subscribe = on_subscribe  url_str = os.environ.get(\"MQTT_URL\", 'tcp://192.168.10.5:1883')  url = urlparse.urlparse(url_str)  mqttc.connect(url.hostname, url.port)  import os, sys .  # inner psutil function  def process_memory():  process = psutil.Process(os.getpid())  mem_info = process.memory_info()  return mem_info.rss  # decorator function  def profile(func):  def wrapper(\"args, \"\"kwargs):  mem_before = process_memory()  result = func(\"args, \"\"kwargs)  mem_after = process_memory()  print(\"{}:consumed memory: {;}\".format(  func._name,  mem_before, mem_after, mem_after - mem_before))  return result  return wrapper