Content uploaded by Abdullah Bin Masood
Author content
All content in this area was uploaded by Abdullah Bin Masood on Dec 26, 2019
Content may be subject to copyright.
Realizing an Implementation Platform for Closed
Loop Cyber-Physical Systems using Blockchain
Abdullah Bin Masood∗† , Hassaan Khaliq Qureshi∗, Syed Muhammad Danish∗, Marios Lestas†
∗National University of Sciences and Technology (NUST), Islamabad, Pakistan
Email: ∗(amasood.msee17seecs, hassaan.khaliq, sdanish.msee16seecs)@seecs.edu.pk
†Frederick University, Nicosia, Cyprus. Email: †eng.lm@frederick.ac.cy
Abstract—Cyber-physical Systems (CPS) comprise of a net-
work of physically distributed embedded sensors and actuators
equipped with computational and communication capability.
In CPS, Internet of Things (IoT) devices communicate in a
trustless environment as the data can be compromised due
to the centralized database, limited power and computational
constraints. At the same time, reliability and resiliency are key
concerns in CPS in the face of unforeseen circumstances, often
emanating from disaster based failures. In this paper, critical
issues of centralized database security in CPS are addressed via
a distributed blockchain based solution. The proposed system
encompasses a smart contract based framework in Ethereum
blockchain. It further explores the potential of blockchain in se-
curing and offering a distributed network for the CPS in a closed
loop manner. To demonstrate the realizability of the proposed
framework, a testbed implementation for the proposed idea is
provided. A desktop computer, a laptop, a simple temperature
sensor and a Light Emitting Diode (LED) are interfaced in a Peer-
to-Peer (P2P) network using Ethereum. The speedy transaction
of sensor data in the blockchain at various difficulty levels and
actuation through smart contracts enhance the usability of the
platform for CPS and various IoT applications.
Index Terms—Cyber-Physical Systems, Internet of Things,
Peer-to-Peer, Blockchain
I. INTRODUCTION
CPS is becoming a cornerstone technology in many im-
portant applications such as renewable energy, smart grids,
smart cities, intelligent transportation systems, large process
plants, distributed robotic systems etc. Modern technologies
and protocols are being developed to offer higher bandwidth
and reliable fast networks to communicate with each other us-
ing Internet of Things (IoT) devices. However, in many cases,
CPS is characterized by security deficiencies and lack of trust.
Multiple stakeholders countering communication noise and
updating system to current protocols pose major challenges in
CPS security and performance. Designing CPS for operation
in proximity to humans means that current safety regulations
need to be updated so that individuals are not harmed and
the desired benefits surpass the potential unintended conse-
quences.
A typical CPS system, which currently works largely in an
open loop fashion is Intelligent Transportation Systems. The
system gradually shifts from the open loop operation to closed
loop operation as the gathered data is processed and used to
issue command signals to the traffic actuation units which may
include traffic light signals, ramp metering signals, rerouting
instructions, variable speed limits etc. Closed loop CPS greatly
improve efficiency, however, they suffer from major security
challenges and lack of trust mostly on the data acquisition
side [1]. In addition, IoT devices are replacing modern sensors
in CPS as they offer interconnection and intelligence by
providing sensing and actuating with ubiquitous networking
and computing abilities. These devices are evaluated in terms
of their performance, load and number of users they can handle
efficiently. In many compelling application areas, the security
of communication channels is of primary importance [2].
Recently, blockchain has been considered to address open
problems in applications beyond cryptocurrencies including
IoTs [3]. This work explores the potential of blockchain to
offer an implementation platform for closed-loop CPS. The
blockchain platform has attractive security features which can
be offered to all elements of a cyber-physical system; sensing,
processing and actuation/control. Blockchain can store sensed
data in the form of verified hashed blocks and use smart con-
tracts to process the data, generate appropriate control signals
and actuate relevant devices in a distributed fashion. In this
work, a blockchain based management system is considered,
which combines the aforementioned functionalities to offer an
implementation platform for closed loop CPS. A testbed has
been implemented which serves as a proof of concept (POC)
for the proposed solution and is used to estimate the delay that
is crucial in closed loop systems as it may lead to instability.
The proposed management system implements a protocol via a
smart contract that turns a permissioned Ethereum blockchain
into an automated access-control manager. The automated
access-control manager helps to enhance user controllability
over data and does not require trust in a third party. Only users
have access rights over data and can define access policies for
IoT devices [4].
The ability to implement the envisioned system is demon-
strated by a simple testbed incorporating a temperature sensor
and an actuator. The readings from the temperature sensor
are stored on the blockchain and are utilized by a smart
contract to send activation signals to a LED which serves as
the actuator. The activation signals are generated by the smart
contract according to a simple control algorithm. Delay of the
sensor data transactions and output from the smart contract
is calculated at different difficulty hash levels and block sizes
with respect to time. The proposed system architecture for a
closed loop CPS incorporating blockchain is shown in Fig. 1.
Fig. 1: Proposed closed loop CPS architecture incorporating blockchain
The rest of this paper is organized as follows. Section
II presents relevant previous work and constraints in the
approaches therein. The proposed system architecture is then
described in section III. A working prototype of the proposed
solution is presented in section IV and concluding remarks are
offered in Section V.
II. BACKGROU ND A ND LITERATURE REVIEW
In various applications, IoT devices usually store actuated
data in centralized cloud storage. However centralized systems
are often inadequate and create a single point of failure. For
improving the security and control over CPS systems, users
wish to own their data and personalized services without
compromising security. Hence, a consensus-based secure com-
munication network is required for CPS in which nodes can
trust, interact and share information without worrying about
data tempering.
Blockchain has been recently considered for applications
beyond cryptocurrencies due to its ability to build trust among
various entities. The distributed nature of blockchain implies
that no single entity controls the ledger but rather the par-
ticipating peers together validate the authenticity of records.
Blockchain was designed to operate in a trustless environment
where Bitcoin and Ethereum are the most celebrated examples
of permissioned blockchain and hyperledger is an example
of a private blockchain. The most celebrated alternative to
the cryptocurrency application is the smart contract paradigm
where Bitcoin and Ethereum were originally deployed to serve
as cryptocurrencies [5]-[7]. The smart contract is defined as
”A computerized transaction protocol that executes the terms
of a contract” [8]. Ethereum is the first platform to provide
a blockchain with a built-in turing complete programming
language called Solidity. Physical systems in CPS typically
consist of IoT devices. As the interaction between these
devices and cyber systems increases, they become increasingly
more vulnerable due to constraints as indicated below:
1) Device Accessibility: Users are required to grant a set
of permissions to their devices upon sign-up. These
access rights are granted indefinitely and the only way
to alter them is by opting-out. Third-party applications
constantly collect high-resolution personal data without
the user’s knowledge or control [9].
2) Batteries: The size of IoT devices is decreasing day
by day to become more user-friendly and accessible.
Security is an issue in such devices due to their low
resource availability. A great challenge for the CPS is
to satisfy the ever-increasing energy demands of IoT
applications, while IoT nodes continue to grow in both
numbers and performance requirements.
3) Database: As we are installing more IoT devices
for gathering information to make our processes more
efficient and intelligent, securing the obtained data is
becoming a challenge. Providing large functionality and
high computations of data on a small battery driven IoT
means increased deployment and maintenance cost [2].
Blockchain has been used by researchers to solve diverse
problems. In [10], various options for blockchain directed
acyclic graph based distributed consensus systems have been
considered and compared to support Fog computing for IoT.
Similarly, distributed authorized control access over the mas-
sive IoT database is another problem which has been addressed
using blockchain in [11]. Access control and authorization
are co-designed and a decentralized scheme was proposed
focusing on streaming data. However, the data is assumed
to be off-chain. Another notable attempt is the work in
[12], which enables data exchange through smart contracts
and uses a signature-based approach to resolve the dilemma
between data indexing and information leakage. Finally, in the
recent work of [13], data management is again realized using
smart contracts, in an architecture where users connect to the
blockchain through management hubs. The main advantage
is that a POC implementation supports the proposal with
demonstrated effectiveness. A number of blockchain based
solutions also have been proposed for the issue of secure
device access control. A recent work [14], examines the use
of multiple smart contracts (access control contract, judge
contract, and register contract) to provide access control to IoT
devices. This is one of the few works which adopts the smart
contract approach for access control and supports the proposed
approach with POC hardware/software implementation.
III. SYS TE M ARCHITECTURE
The considered system architecture is illustrated in Fig.
2. A temperature sensor here is a representative of an IoT
device and data obtained from it is stored in Ethereum, while
actuation of the sensor is done via a smart contract. Node
one is interfaced with a LED and the temperature sensor, is
connected to Node two in a Peer-to-Peer (P2P) manner. The
Fig. 2: System architecture
architecture is divided into two parts whose functionalities are
explained below:
A. Hardware Components
•Sensor: DHT11 is a digital temperature and humidity
sensor. In this architecture, it is used to measure temper-
ature.
•Actuating Device: Arduino Uno board is used here to
interface DHT 11 sensor. It reads the value from a sensor
and serially sends it to Node one on the computer using
pySerial. Baud rate for this communication is set at 9600
bps. Two LEDs are also interfaced with the Uno board
to display the actuation process. Green LED blinks if the
temperature value transmitted to the computer is equal or
less than 30°C while the red LED blinks when the value
is above than 30°C. The specification of the devices used
in this architecture is shown in Table I.
B. Ethereum Platform
•Proof of Authority: Clique Proof of Authority (PoA)
protocol has been opted in this architecture. PoA is
a modified form of Proof of Stake (PoS) where users
identity performs the role of stake instead of monetary
value. This protocol is an upgraded version of PoS and
has only one identity per person. It is lightweight and
can perform thousands of transactions per second. On the
other hand, Proof of Work (PoW) is costly, inefficient and
involves many computational resources. PoS has benefits
over PoW in terms of required computation, cost, and
hardware. No reward for mining, nothing at stake and
little prevention from a miner to mine numerous PoS
chains make it less fascinating. On the other hand, PoA
is efficient and can be deployed with IoT devices.
•Ethereum Blockchain: Ethereum private testnet
blockchain has been opted for this system. Go Ethereum
TABLE I: Specification of devices.
Device CPU Operating
System Memory Hard
Disk
Dell Optiplex
990
Intel Core
i3, 3.10GHz Ubuntu 16.04 8 GB 500 GB
Lenovo
V310
Intel Core
i5, 2.30GHz Ubuntu 16.04 4 GB 1 TB
TABLE II: Genesis file parameters.
Parameter Value
eip150Block 2
eip155Block 3
Gas Limit 0x8000000
Hash Difficulty 0x1
(Geth) is the official golang implementation of Ethereum
network, used for creating Ethereum blockchain and its
nodes. Two nodes each having one account in them are
created using Geth. Ethereum private testnet blockchain
is initialized using the genesis file. Puppeth prevents the
operator from going through scratch to create genesis
file. Main parameters from this architecture’s genesis
file are shown in Table II. Network ID for the whole
blockchain network is 1515. Block size is set to 5
seconds for smooth sensing of temperature, storing and
transacting its value in the blockchain.
Ethereum blockchain is a P2P network and nodes can
have dynamic Internet Protocol (IP) address. Each ac-
count is allocated a bunch of Ethers through the genesis
file paying for transactions, as PoA does not have mining
rewards. However, bootnode usually works over static
IP addresses and its only purpose is to help nodes in
discovering each other. A uniquely defined value called
Enode is created by initializing bootnode and it is stored
in the boot.key file. Node one is running on a laptop,
having an IP address of 10.3.81.15 while Node two is
running on a desktop PC with IP address 10.3.81.16.
Sync mode is ON preventing the Nodes from having
an error of “discarded bad propagated block”. Node one
and Node two have Remote Procedure Call (RPC) port
numbers 8051 and 8052, respectively. The gas price,
while the Nodes are alive, is set at value 1. JavaScript
Object Notation-Remote Procedure Call (JSON-RPC),
web3py protocols and the request library are used for
communication between the python script and Node one.
•Smart Contract: Solidity is used to write and develop
smart contracts for the Ethereum blockchain. A simple
smart contract having two functions is stored in this
blockchain. The first function named Sensor takes and
stores incoming sensor data values while the second
function, which is a Get function compares the stored
value in the Sensor function with defined conditions and
returns a specific value. For example, if the incoming
temperature sensor value is below or equal to 30°C, it
returns a value 0 and if it is above 30°C then it returns
a value 1. The temperature above 30°C in the system
architecture is pre-defined to turn on the red LED while
(a) Temperature sensor connected to Node one running on a Laptop. (b) Node two running on the desktop PC.
Fig. 3: Nodes of ethereum blockchain connected in P2P network
TABLE III: Address specification of accounts.
Node Account No Machine Public Address
1 1 Laptop 0x0337518b10d11Ff8c475ab2508eA120e3d7F41e7
2 2 Desktop PC 0xcEc646349D71e34c0c128eEa6B88dDFa0E60431b
Sensor 3 Laptop 0x29a86118C1Ff89d474E9497D8B3FA890D9F7e30C
1 4 (Smart Contract) Laptop 0x1F9eB9f5C0C94603f6fB1aCF19f99dDd76600AF7
values equal to or below 30°C turn on the green LED for
three seconds.
IV. TES TB ED IMPLEMENTATION
For the implementation of the system testbed, two machines
are connected in a P2P network. Node one, which is running
on a laptop interfaced to Arduino UNO is shown in Fig. 3a,
while the Desktop PC running Node two is shown in Fig.
3b. The system starts by running both Nodes on terminal
windows of their respective operating system. In the initial
time, a small period is required for building DApps, mining
some blocks and syncing on both nodes. A third account is
created using web3py and stored in the Genesis file for the
transaction of sensor data to the account stored on Node one. A
smart contract is deployed on Node one using the truffle suite.
Contract and accounts’ addresses of testbed implementation
are shown in Table III. Serial transmission of sensor data is
started by running a python script in the terminal window. This
python script holds the Node one URL, the path to the genesis
file, a public and private key of the third account, the chain ID
of the network, the gas limit and contract address. The python
script takes the incoming sensor data, directs it in the Sensor
function and then creates the method-ID of the function using
SHA3-hash. The whole hash is used as a parameter in creating
a valid transaction signature. This data then transact from the
third account to the contract address using the JSON-RPC
protocol. The output conditions are requested by reading the
Get function and their respective values are then transmitted
to the Arduino board.
The effectiveness of the proposed method has been demon-
strated by the ability of the system to switch ON and OFF
the LEDs based on the temperature measurements. The trans-
actions of sensor data at different temperatures below and
above 30°C with the resulting output from the smart contract
are shown in Fig. 4a and Fig. 4b respectively. The main
performance metric evaluated in this study is the delay of per-
forming the sensing and actuation actions i.e. upon receiving
a sensed reading, the time required for data processing via
the blockchain for the actuator to be activated. The delay is a
very important parameter which affects the stability properties
of any closed loop system. Evaluating the magnitude of the
delays as a result of the blockchain implementation reveals
fundamental limitations of the proposed approach and at the
same time helps to identify the class of systems for which such
an implementation will be applicable. Applications with fast
response and stringent delay requirements are not amenable for
implementing large delay structures. So, a major contribution
of this study is to characterize the delays as various system
parameters change.
Delay is defined as the time required for a sensor data
transmission to lead to an output from the smart contract
based on the sensor value. Different hash difficulty levels
are set while keeping the block size at 5 seconds. Ethereum
blockchain has a consensus algorithm for the relation between
the hash difficulty level and the block size. It will adjust
the difficulty level to keep the transaction time close to the
block size. The delay graph shown in Fig. 5a illustrates this
consensus algorithm phenomenon where mean and variance
are calculated from 50 consecutive transactions at different
difficulty level. Delay graph in Fig. 5b at difficulty level 10 and
block size 20 seconds further verifies the consensus algorithm
concept.
V. CONCLUSION
In this paper, a blockchain based framework to implement
a trustworthy and distributed management system for closed
loop CPS is proposed and a proof of concept implementa-
tion is developed. The framework includes a sensor, inter-
faced serially to a computer, transacting its data on nodes
of Ethereum blockchain and LEDs are blinked in return
through simple conditions programmed in a smart contract.
The developed testbed was used to characterize the overall
delay, including transactions, processing and actuation. Such
delay characterizations are crucial for closed loop CPS as
(a) Transactions in safe range. (b) Transactions in dangerous range.
Fig. 4: Sensor’s data transactions on blockchain at different temperatures.
4.4 4.6 4.8 5 5.2 5.4 5.6
Time (s)
0
1
2
3
4
5
6
7
f(x)
Normal Distribution Graph
Difficulty Level 1
Difficulty Level 10
Difficulty Level 50
Difficulty Level 200
(a) Delay graph at block size 5 seconds & different difficulty levels.
19.2 19.4 19.6 19.8 20 20.2 20.4
Time (s)
0
1
2
3
4
5
f(x)
Normal Distribution Graph for block size 20s & difficulty level 10
(b) Delay graph at block size 20 seconds & difficulty level 10.
Fig. 5: Delay graphs.
they are known to significantly affect stability. The proposed
system can potentially serve systems such as the smart grid,
Intelligent Transportation, industrial robots and medical moni-
toring/operations and such applications will be investigated in
the future.
ACKNOWLEDGMENT
This article is based upon work from COST Action
CA15127 (“Resilient communication services protecting end-
user applications from disaster-based failures – RECODIS”)
supported by COST (European Cooperation in Science and
Technology).
REFERENCES
[1] Lu, G. Qu and Z. Liu, ”A Survey on Recent Advances in Vehicular Net-
work Security, Trust, and Privacy,” in IEEE Transactions on Intelligent
Transportation Systems, vol. 20, no. 2, pp. 760-776, Feb. 2019
[2] S. Sen, J. Koo and S. Bagchi, ”TRIFECTA: Security, Energy Efficiency,
and Communication Capacity Comparison for Wireless IoT Devices,”
in IEEE Internet Computing, vol. 22, no. 1, pp. 74-81, Jan./Feb. 2018.
[3] T. M. Fern´
andez-Caram´
es and P. Fraga-Lamas, ”A Review on the Use
of Blockchain for the Internet of Things,” in IEEE Access, vol. 6, pp.
32979-33001, 2018.
[4] G. Zyskind, O. Nathan and A. ’. Pentland, ”Decentralizing Privacy:
Using Blockchain to Protect Personal Data,” in IEEE Security and
Privacy Workshops, San Jose, CA, pp. 180-184, 2015.
[5] T. T. A. Dinh, R. Liu, M. Zhang, G. Chen, B. C. Ooi and J. Wang, ”Un-
tangling Blockchain: A Data Processing View of Blockchain Systems,”
in IEEE Transactions on Knowledge and Data Engineering, vol. 30, no.
7, pp. 1366-1385, 1 July 2018.
[6] Zhang, Kaiwen, Roman Vitenberg, and Hans-Arno Jacobsen. ”Decon-
structing Blockchains: Concepts, Systems, and Insights.” Proceedings of
the 12th ACM International Conference on Distributed and Event-based
Systems. ACM, pp. 187-190, 2018.
[7] Bacon, Jean and Michels, Johan David and Millard, Christopher and
Singh, Jatinder, Blockchain Demystified (December 20, 2017). Queen
Mary School of Law Legal Studies Research Paper No. 268/2017.
[8] Reyna, Ana, et al. ”On blockchain and its integration with IoT. Chal-
lenges and opportunities.” Future Generation Computer Systems, vol 88,
pp. 173-190, 2018.
[9] S. Singh and N. Singh, ”Blockchain: Future of financial and cyber
security,” in 2nd International Conference on Contemporary Computing
and Informatics (IC3I), Noida, pp. 463-467, 2016.
[10] K. Yeow, A. Gani, R. W. Ahmad, J. J. P. C. Rodrigues and K.
Ko, ”Decentralized Consensus for Edge-Centric Internet of Things: A
Review, Taxonomy, and Research Issues,” in IEEE Access, vol. 6, pp.
1513-1524, 2018.
[11] Shafagh, Hossein, et al. ”Droplet: Decentralized Authorization for IoT
Data Streams.” arXiv preprint arXiv:1806.02057(2018).
[12] Zhou, Jiayu, et al. ”Distributed Data Vending on Blockchain.” arXiv
preprint arXiv:1803.05871 (2018).
[13] O. Novo, ”Blockchain Meets IoT: An Architecture for Scalable Access
Management in IoT,” in IEEE Internet of Things Journal, vol. 5, no. 2,
pp. 1184-1195, April 2018.
[14] Zhang, Yuanyu, et al. ”Smart Contract-Based Access Control for the
Internet of Things.” arXiv preprint arXiv:1802.04410(2018).