## 5 Simulations and Results
### Cost Consumption
#### 5.2.2 **Functions Cost**  
Each smart contract contains various functions to manage access control among IoT devices. In this system, both transaction and execution cost for the functions of each smart contract are calculated. The costs are calculated to show the number of gas units consumed by each function of smart contracts. The cost consumption rate of each function is discussed below. **Functions of ACC:** The transaction cost and execution cost for each function of ACC are shown in Figure 5. It contains more function calls as compare to other two smart contracts, because ACC manages the access control of whole system. However, the gas consumption is calculated for main  
Figure 4: Smart Contracts Cost. functions of the smart contract. The functions of ACC that perform several operations include user registration, generating permission levels for the subject, and data access function. The transaction and execution costs of the functions are given below. Transaction cost: As it is illustrated in the aforementioned figure, transaction cost of the user registration function is higher than other functions. The user register function consumes 89,000 gas units, which are equal to 0.00178 eth value. All users are registered in the network for authentication. Furthermore, the data access function consumes 30,000 gas units, which are equal to 0.0006 eth values. In the access control function, requests of subjects are passed by ACC to the corresponding objects. After that, gas consumed by permission level function is 25,000 gas units, which is 0.0005 eth. This function is called after judging behavior of the users. The privileges are checked for users to access the required service, for this reason, it consumed very less cost. Execution cost: The execution cost of ACC functions is also given in the above-mentioned figure. The execution cost of user register function is 65,000 gas units and its ether value is 0.0013 eth. The registration function also consumes more execution cost. Furthermore, the function that grants data access to the users consumes 9,000 gas units that are equal to 0.00018 eth value. Moreover, the function for setting permission levels for the users consumes very less cost, i.e., 5,000 gas units that are equal to 0.0001 eth. Hence, the functions with high cost consumption are executed more than the functions that cost less. **Functions of RC:** The transaction and execution costs of RC functions are shown in Figure 6. The objective of RC is to manage the registration of users in the network, and to maintain a registration table to record the users' information. The functions of RC are user registration and registration table creation. Figure 5: ACC Function Cost. Transaction cost: The transaction cost of RC functions shows that user registration function consumes more transaction cost. The cost consumed is 130,000 gas units that is equal to 0.0026 eth. The function registers the users in the network. Furthermore, the registration table is maintained by the register table function. The cost of registration table function is 45,000 gas units, which is equal to 0.0009 eth values. Execution cost: Furthermore, the execution cost of RC functions is also calculated. The cost of registration function is 130,000 gas units that is equal to 0.0026 eth. The registration table consumes 23,000 gas units, which are equal to 0.00046 eth value. **Functions of JC:** In Figure 7, the transaction and execution costs of JC functions are given. The JC is used to maintain trustworthiness of the system by checking behavior of each user. The behavior judging method is implemented by JC, which checks if any misbehavior is conducted by the subjects or not. After that, the penalty is determined for subject. The functions of JC are misbehavior calculation function and misbehavior judge function. Figure 6: RC Function Cost. Transaction cost: The aforementioned figure illustrated the transaction cost for functions of JC. The cost of misbehavior judging function is more than other functions, which is 195,000 gas units.