ArticlePDF Available

Blockchain based Secure, Efficient and Coordinated Energy Trading and Data Sharing between Electric Vehicles


Abstract and Figures

In this study, a secure and coordinated blockchain based energy trading system for Electric Vehicles (EVs) is presented. The major goals of this study are to provide secure and efficient energy trading between EVs and Charging Stations (CSs), and to ensure efficient coordination between EVs. In this study, a consortium blockchain based energy trading algorithm is presented that handles the essential energy requests, discards the redundant requests and calculates the distance between EVs and CSs. Moreover, Matching Pool (M-Pool) and Pairing Pool (P-Pool) are used to store energy and payment requests. Furthermore, a blockchain based mechanism is proposed for ensuring efficient coordination between EVs at the unsignalized crossroads and intersections. The scheme involves efficient communication between EVs and the timely sharing of important messages. In the proposed work, EVs are authenticated using a Registration Authority (RA) before they become part of a Vehicular Energy Network (VEN). The increase in the number of EVs results in an increase in the number of messages leading to data redundancy issue. To solve the issue, message filtration is performed. The delays incurred in the VEN are also mathematically formulated in this study. In addition, the range anxiety issue is discussed in the proposed work. Besides, a Local Aggregator (LAG) is used as an energy broker to manage energy trading events and transaction validation. To promote the users to take part in the proposed network, they are provided with incentives. The proposed model is tested against selfish mining attack and the security analysis is performed through Oyente tool. The simulation results show that the proposed study excels in providing a secure, efficient and coordinated energy trading and data sharing system for EVs. The results show that due to proper coordination, the risk factor is reduced by almost 25-30%. Moreover, almost 40-50% reduction in time is observed when storing less redundant data.
This content is subject to copyright. Terms and conditions apply.
Blockchain based Secure, Efficient and Coordinated
Energy Trading and Data Sharing between Electric
Muhammad Umar Javed1, Nadeem Javaid1,, Muhammad Waseem Malik1,
Mariam Akbar1,, Omaji Samuel1, Adamu Sani Yahaya1and Jalel Ben Othman2,3
1Department of Computer Science, COMSATS University Islamabad, Islamabad 44000, Pakistan
2Universit Paris-Saclay, CNRS, CentraleSuplec, Laboratoire des signaux et systmes, 91190, Gif-sur-Yvette, France
3Universit Sorbonne Paris Nord, France
*Corresponding author: mariam
Abstract—In this study, a secure and coordinated blockchain
based energy trading system for Electric Vehicles (EVs) is
presented. The major goals of this study are to provide
secure and efficient energy trading between EVs and Charging
Stations (CSs), and to ensure efficient coordination between
EVs. In this study, a consortium blockchain based energy
trading algorithm is presented that handles the essential energy
requests, discards the redundant requests and calculates the
distance between EVs and CSs. Moreover, Matching Pool (M-
Pool) and Pairing Pool (P-Pool) are used to store energy and
payment requests. Furthermore, a blockchain based mechanism
is proposed for ensuring efficient coordination between EVs
at the unsignalized crossroads and intersections. The scheme
involves efficient communication between EVs and the timely
sharing of important messages. In the proposed work, EVs
are authenticated using a Registration Authority (RA) before
they become part of a Vehicular Energy Network (VEN). The
increase in the number of EVs results in an increase in the
number of messages leading to data redundancy issue. To
solve the issue, message filtration is performed. The delays
incurred in the VEN are also mathematically formulated in this
study. In addition, the range anxiety issue is discussed in the
proposed work. Besides, a Local Aggregator (LAG) is used as an
energy broker to manage energy trading events and transaction
validation. To promote the users to take part in the proposed
network, they are provided with incentives. The proposed model
is tested against selfish mining attack and the security analysis
is performed through Oyente tool. The simulation results show
that the proposed study excels in providing a secure, efficient
and coordinated energy trading and data sharing system for
EVs. The results show that due to proper coordination, the risk
factor is reduced by almost 25-30%. Moreover, almost 40-50%
reduction in time is observed when storing less redundant data.
Index Terms—Consortium blockchain, energy trading,
vehicle-to-vehicle, vehicle-to-grid, coordination, data sharing
and filtration, incentive provisioning, range anxiety.
Over the past few years, the world has witnessed an
immense increase in the population and the migration of
people from rural to urban areas. This migration has pro-
vided people with many benefits. On the other side, it has
posed some serious threats as well. The scarcity of various
necessities like health facilities, employment opportunities,
and physiological and social needs are some of them. The
TABLE I: List of Abbreviations
Abbreviations Description
CS Charging Station
DAO Decentralized Autonomous Organization
DoS Denial-of-Service
ESC Energy Smart Contract
EV Electric Vehicle
IoT Internet of Things
G2V Grid-to-Vehicle
LAG Local Aggregator
MILP Mixed Integer Linear Programming
M-Pool Matching Pool
OBU On-Board Unit
PBFT Practical Byzantine Fault Tolerance
PoW Proof of Work
P-Pool Pairing Pool
PSC Payment Smart Contract
P2P Peer-to-Peer
RA Registration Authority
RES Renewable Energy Sources
RSU Road Side Unit
SDN Software Defined Networking
VANETs Vehicular Ad-hoc Network
VENs Vehicular Energy Networks
V2G Vehicle-to-Grid
V2I Vehicle-to-Infrastructure
V2R Vehicle-to-RSU
V2V Vehicle-to-Vehicle
WSNs Wireless Sensor Networks
outburst of population escalated the number of houses,
vehicles and industries. All these entities require a massive
amount of energy to power themselves. Moreover, electricity
is needed by the people to do their daily chores like washing
and ironing clothes, using cellular and multimedia devices,
running industrial plants and motors, and travelling from one
place to another place. This vast energy demand has led to an
imbalance between energy supply and demand [1]. It further
TABLE II: List of Variables
Variables Description
Bcap Battery Capacity
DijDistance between EV and CS
Eav Energy Available
kW h Energy Available in kWh
Epr Energy Present
kW h Energy Present in kWh
Erq Energy Required
kW h Energy Required in kWh
Eth Energy Threshold
end to enddelay End-to-end-delay
EV bBuyer EV
EV sSeller EV
Exrq Required Energy Expenses
ID Identity
Loccur Current Location
procdelay Processing delay
propdelay Propagation delay
P K Public Key
PsPrice for Traded Energy
nNumber of EVs present in a queue
quedelay Queuing delay
RRole of EV
SK Private Key
SoC pr Present State of Charge
SoC th Threshold State of Charge
Trq Time required to reach the CS
totaldelay Total delay
transdelay Transmission delay
directs the society towards the problems of irregular load
shedding, increased electricity bills and substantial financial
loss due to voltage fluctuation.
Consequently, a green and sustainable smart city has
become the need of the current times to tackle the above
mentioned issues [2]. Though, the concept of smart city is
not new, and many contributions have been made in making
the cities smarter, cleaner and greener over the past few
years. In a smart city, everything is transformed from old
conventional mode to intelligent and updated form. These
things include power grids, homes, hospitals, educational
institutes, industries and transportation. The scarcity of fossil
fuels is tackled by exploring Renewable Energy Sources
(RES) and utilizing them to their full potential. Examples
of RES include solar photovoltaic, wind and hydro. Despite
RES adding up to the energy generation and creating a
balance between energy demand and supply, some issues
like intermittent nature and unavailability of RES also exist
[3]. The emergence of smart cities has changed the global
transportation sector and introduced a smart transportation
system [4]. With the aid of communication and information
technologies, the smart transportation system provides vari-
ous automated services, such as traffic control, information
sharing, navigation, provisioning of parking lot information
to public transport like taxis, etc., [5], [6]. It also ensures
secure communication between Electric Vehicles (EVs) and
Road Side Units (RSUs), and the safety and privacy of
vehicles’ owners [7]. Moreover, the idea of EVs in the smart
transportation sector emerges in order to develop an eco-
friendly transportation system. Besides efficient transporta-
tion [8], EVs also provide numerous benefits, such as less
carbon emission, and less operation and maintenance cost as
compared to conventional vehicles [9].
The immense surge in the vehicles running on the high-
ways has provided many benefits to the people and have
made traveling easy. The IHS Markit estimated that the
sale of EVs could exceed 12 million by 2025 [10]. With
the introduction of state-of-the-art vehicles, large distances
are now covered in less time. However, the increase in
vehicles exhibits various issues like road congestion, road
accidents and increased amounts of pollution. To tackle these
issues, intelligent vehicles are proposed, which are able to
communicate with each other, share important information,
and avoid both road congestion and road accidents. Further-
more, these vehicles are powered using RES, which helps in
reducing the pollution and the gas emissions [11]. Despite of
these benefits, there still exist some issues like data storage
issue, lack of security and privacy, absence of trust between
vehicle users and unavailability of data transparency. In
Vehicular Energy Networks (VENs), the vehicles share im-
portant information with each other like road conditions and
weather conditions. This type of communication is known
as Vehicle-to-Vehicle (V2V) communication. Moreover, the
communication between vehicles and the Charging Stations
(CSs) takes place for fulfilling the energy requirements and
this kind of communication is termed as Vehicle-to-Grid
(V2G) and Grid-to-Vehicle (G2V) communication [12]. For
the storage of important information, which can be used for
later use, the vehicles communicate with RSUs and other in-
frastructure in Vehicle-to-Road Side Unit (V2R) and Vehicle-
to-Infrastructure (V2I) modes, respectively. No doubt, EVs
have benefited the human race in numerous ways. However,
they still exhibit some issues like lack of trust, security
and privacy, data redundancy [3], inefficient coordination
between EVs [13], delays in message propagation and range
anxiety [14]. In VENs, several other issues also arise, such
as selfish behavior of EVs and CSs, large distance between
nodes, cost of traveling incurred to reach the CSs, etc.
To overcome the issues, many different energy trading and
vehicle charging mechanisms are presented. However, the
conventional centralized energy trading mechanisms depend
on intermediary bodies to audit, verify and manage energy
transactions [16]. The inclusion of an intermediary body in
the network is a security threat, and causes issues like Denial-
of-Service (DoS) attack, a single point of failure and privacy
leakage [17]. Therefore, energy trading environment requires
a secure, reliable and distributed mechanism [18]. More-
over, an incentive mechanism, in terms of cryptocurrency
or reputation, is introduced to motivate nodes to perform
efficient energy trading. It also helps to avoid the selfish
behavior of nodes [19]. Furthermore, different solutions
present efficient distance measurement techniques. These
solutions also reduce the amount of traveling required to
reach the destination [20], [21].
In order to solve the aforementioned challenges in VENs,
blockchain technology is considered as an effective solution
that provides distributed, secure and efficient energy trading
[22]–[26]. The concept of blockchain technology was ini-
tially brought forward by Satoshi Nakamoto in 2008 [27].
Blockchain is a decentralized Peer-to-Peer (P2P) network
technology in which blocks are used to store the transactions.
The blocks are joined together in a chronological manner
using hashes. Hence, it is given the name blockchain, i.e.,
blocks linked together in a chain. The blocks comprise
of hashes, transaction data, timestamp, Merkle root and
nonce [25]. Blockchain was proposed to tackle the issues
related to the centralized networks like a single point of fail-
ure, increased transaction cost and vulnerability to security
breach. Furthermore, it also ensures security, transparency,
reliability, auditability and integrity of the transactions. It
also ensures privacy of the network nodes [28], [29]. Due
to its numerous benefits, it is widely used in many fields
like energy [30]–[32], cloud computing [33], Wireless Sensor
Networks (WSNs) [34], [35], Vehicular Ad-hoc Networks
(VANETs) [36]–[39], Internet of Things (IoT) [40]–[42], etc.
A. Contributions
In this study, a blockchain based secure and coordinated
energy trading system is presented to overcome the above
mentioned issues. The major contributions made in the
proposed work are summarized below.
A secure and efficient energy trading scheme is pro-
posed in this study. To provide security, blockchain
technology is used; while, Proof-of-Work (PoW) con-
sensus mechanism is implemented to verify energy
transactions and ensure transparency.
An algorithm is presented to perform optimal energy
trading, which prevents EVs to send multiple fake
energy requests for energy trading at the same time.
The algorithm also calculates the distance between EVs
and CSs along with the required time and expenses.
Afterwards, a list of the nearest CSs is given to the
requesting EVs.
Two memory pools are introduced to store transactions:
Matching Pool (M-Pool) and Pairing Pool (P-Pool). The
former stores the requests of energy trading temporarily;
while, the latter stores the matched pairs of CSs and
Three different smart contracts are presented in the
proposed work: EVs’ registration smart contract, Energy
Smart Contract (ESC) and Payment Smart Contract
(PSC). ESC handles CS related information like current
energy level and present number of EVs. Whereas, PSC
ensures secure payment transactions for energy trading
among energy nodes.
The authentication of vehicles is performed using a
Registration Authority (RA), which provides a unique
ID (ID) to each EV. Furthermore, coordination between
vehicles at the crossroads and the intersections is per-
formed. The range anxiety issue of the EV users is
discussed for both high level and low level users.
Mathematical formulation of the delays incurred in the
VENs, the amount of energy traded and the correspond-
ing payment charged, and the coordination between EVs
is performed.
Message credibility is checked and redundant data is re-
moved after filtration. The legitimate and authentic users
are provided with incentives. Moreover. the reputation
of nodes that provide energy to the requesting nodes
is increased. On the other hand, nodes who perform
malicious operations like sending fake and multiple
requests to the system are discarded.
Extensive simulations are performed that prove the
efficiency of the proposed work.
The proposed model is tested against selfish mining
attack. The attack is induced and the model is designed
in such a way to prevent it from the attack. Moreover,
security analysis of the proposed work is performed us-
ing Oyente tool, which tests the system against the well
known vulnerabilities incurred in the smart contracts.
The lists of abbreviations and variables used in this paper
are given in Tables I and II, respectively. The remaining
manuscript is organized as follows. The detailed literature
review is presented in Section II. Whereas, the problem
statement is provided in Section III. Furthermore, Section
IV is dedicated to the proposed system model. Whereas, the
mathematical formulation and the coordination scenario are
discussed in Section V. Moving ahead, message credibility
and incentive provisioning mechanisms are given in Sections
VI and VII, respectively. The simulation results are presented
in Section VIII;. The overview of security analysis is given in
Section IX; while attacker model and smart contract analysis
are given in Sections X and XI, respectively. Finally, the
paper is concluded in Section XII and the future perspectives
are provided.
In this section, literature review of existing systems and
schemes for VENs is presented in detail. The underlying
works are intended to perform efficient and secure energy
trading, provide optimum charging to EVs and perform
coordination between EVs in VENs.
A. Energy Trading in VENs
Efficient power allocation plays an important role in
energy trading environments [43]. Keeping this in mind,
different authors work on promoting energy trading in VENs.
The authors in [44] introduce contract theory in Internet
of EVs (IoEVs) using consortium blockchain. Similarly,
the authors in [45] develop an energy delivery scheme for
EVs in order to maximize the energy exchange process.
Furthermore, in [46], the authors examine the feasibility
study of the energy harvesting system in a vehicular energy
environment. In [47], the authors introduce a two phase
energy resource acquisition framework for shared relay se-
lection, power control and spectrum allocation in vehicular
heterogeneous networks. The authors in [48] propose a
P2P energy trading scheme for the Industrial Internet of
Things (IIoT) using blockchain. The main objective of this
scheme is to reduce the transaction confirmation latency,
which relies on a credit based payment strategy. In [49],
the authors present EnergyChain model using blockchain,
which enables secure energy trading between nodes. The
model handles the issues of miner selection, creation and
validation of transactions and blocks. However, the security
issues in these energy trading works are not fully addressed.
Furthermore, these works rely on a common understanding
that the information on the EV side is well known through
central authority, i.e., Local Aggregator (LAG). Similarly, the
authors in [50] propose a model to continuously verify the
transactions using real time data. Two platform independent
optimization techniques are proposed in the work to reduce
the operational cost and increase the benefits for the users.
The authors in [20] present a blockchain based framework
integrated with edge computing for secure energy trading in
Software Defined Networking (SDN). The issues resolved
are delay, network overhead, and security and privacy issues.
The authors in [51] highlight the benefits of using blockchain
and smart contracts in the energy sector. Moreover, the
scalability and decentralization in the P2P energy tading
model is tackled by the authors in [52]. The profitability of
the proposed system is also enhanced using reinforcement
learning. In addition, the scalability and security issues in
the centralized cyberphysical systems are discussed in [53].
The study provides the opportunities to tackle the issues
using blockchain technology, which makes the system decen-
tralized. The authors propose a privacy preserving payment
mechanism for V2G network using hyperledger blockchain
technology with Proof of Concept (PoC) mechanism in [54].
In [55], the authors develop an EV charging and discharging
mechanism, which is based on genetic algorithm. The main
objective is to reduce the cost of EV emission and penalty of
wind power imbalance. Furthermore, V2G energy trading is
improved through Stackelberg game based pricing scheme.
However, the local energy market structure in micro grids is
ignored in these works while energy trading. The authors in
[16] propose a secure environment for the vehicle users and
enable them to share the available resources with each other.
Similarly, the authors in [56] propose a secure environment
for ensuring the privacy of EV users’ data.
B. Charging Scheduling of EVs
Scheduling of vehicles’ charging is also brought under
consideration in different papers to avoid creating a huge
burden on charging entities. The authors in [22] discussed
about scheduling the charging of EVs in an efficient manner
to address the issue of imbalance between energy demand
and supply. Similarly, Zou et al. in [57] propose a charg-
ing scheduling mechanism based on game theory for EVs.
The auction and bidding mechanisms are also included in
the proposed work to create a sense of harmony between
charging entities and EVs. In [58], the authors propose
a blockchain based decentralized EV charging scheme. It
reduces the power grid’s fluctuations and EV charging costs
at the same time. Moving on, a multi coalition mechanism
for EVs is presented in [59]. The proposed mechanism helps
in cutting down both the energy provisioning and the vehicle
charging cost in a local network. Amini et al. propose a multi
layered model for the efficient charging of a large number of
vehicles running on the roads in [60]. The taxis are directed
towards optimally placed charging lots. The specific amount
of renewable energy is also designated to the taxis.
C. Authentication in VENs
The authors in [61] use cryptographic keys in the VEN to
secure the communication between the EVs. Furthermore,
the public key infrastructure is used in the proposed work
to ensure security and privacy. Similarly, authors in [62]
propose a decentralized model to ensure security of the
trading performed between EVs. The authors in [63] use zero
knowledge proofs to ensure the EVs’ privacy preservation
and their authentication. The anonymous authentication of
EVs is done using Pederson Commitment scheme. The
charging scheduling of EVs is also done in the proposed
work. Furthermore, the vehicles’ identity is concealed us-
ing pseudonyms in [64]. Authors in [65], [66] proposed
an authentication mechanism for IoT and a signcryption
system for the EVs to ensure that only authenticated nodes
and users become part of the networks, respectively. An
incentive-punishment scheme is also proposed in this work to
encourage the users for reporting of trustworthy information.
The manipulation of users’ data is avoided using Practical
Byzantine Fault Tolerance (PBFT) mechanism.
D. Coordination between EVs
The authors in [67] propose a scheduling mechanism for
the EVs in an urbanized traffic system. The proposed work
guarantees the collision avoidance between the vehicles at
the intersections. Similarly, the authors in [68] use a buffer
assignment mechanism to cooperate between vehicles and
assign a specific crossing span to each individual vehicle.
The intersection control problem is formulated in [69] and
specific rules are provided to the vehicles to pass through the
intersections. The authors in [70] handled the coordination
between the vehicles at intersections mathematically. A two
stage procedure is used to perform coordination between ve-
hicles. No doubt, a lot of work has been done in performing
coordination between the vehicles at the intersections. How-
ever, there still exists a room for using blockchain technology
to perform secure coordination between the vehicles. The
limitations identified after performing an intensive literature
review are provided in the form of a consolidated Problem
Statement in the next section.
The conventional energy trading schemes have several
limitations like lack of trust, privacy and security, illegit-
imate and malicious requests, etc., which need to be ad-
dressed. In [20], [54], the authors propose blockchain based
mechanisms to tackle delay, network overhead, security
and privacy issues. These mechanisms ensure secure and
efficient energy trading between EVs and CSs. However,
nodes generate multiple energy trading requests. There-
fore, fake and small trading transactions are also executed,
which results in an increased computational overhead of
the networks. Moreover, the authors in [19], [44] present
blockchain based systems to tackle the selfish behavior
of users using incentive mechanisms. The energy demand-
supply ratio is balanced as well. However, different security
attacks like sybil and re-entrancy are not tackled. Apart from
that, there are no efficient payment and reputation scoring
mechanisms. Furthermore, the rapid surge in the vehicles
leads to various problems, mainly the traffic congestion
and the roadside accidents. The main reason behind these
issues is the lack of coordination between vehicles [13].
If a proper coordination strategy is established and timely
credible information sharing is performed between vehicles,
these issues can be mitigated. Moreover, the inclusion of
unauthorized vehicles in the VENs causes hindrance in the
system’s performance [71]. It is because the unauthorized
vehicles tend to generate fake messages, which causes huge
burden on the RSUs. As a result, the amount of data being
generated is increased manifolds. In addition, simultaneous
generation and sharing of messages by vehicles lead to
loss of important information over time. This also includes
delay in sharing of important information, which needs to be
minimized so that important information regarding road side
accidents and road congestion should be broadcasted within
minimum time and without any data loss. To minimize the
data redundancy by filtering out the fake messages, proper
data filtration mechanism is required [3]. The mechanism
should also help in tackling the data flooding issue. The rapid
adoption of EVs by the masses leads to the need for efficient
knowledge about the batteries placed inside the vehicles.
People having less knowledge about the batteries installed
within their vehicles leads to range anxiety issue [14]. People
are always in constant fear of their batteries being drained off
at places where no charging entities exist. This requires that
the vehicle owners be informed and made well aware about
the batteries installed within their vehicles. To promote users’
participation in adopting the blockchain based VENs, they
should be provided with identity and location privacy along
with healthy incentives [72]. When users are ensured that
their privacy is protected and they will be awarded with good
incentives, they tend to participate in the designed VENs.
Section IV presents the solutions for the problems discussed
in this section.
The proposed blockchain based energy trading and co-
ordination model for EVs is described in detail in this
section and is shown in Figure 1. The proposed blockchain
based VEN consists of EVs running on the roads along
with other vehicles like simple vehicles, buses, etc. Ve-
hicles share information with each other and with RSUs.
The arrows of three different colors are observed in the
figure. The red color arrow shows the V2V communication
between vehicles. While, the blue color arrows are used for
V2R communication. Moreover, the yellow color arrows are
used for coordination between vehicles on the unsignalized
crossroads. While passing through such crossroads, proper
coordination between vehicles is necessary to avoid mishaps.
The authorization authority, also referred as RA, exists in
the network, which is necessary for the authorization of
vehicles. It also helps in the elimination of malicious vehicles
from the network. It further reduces the sharing of fake
messages and the burden on the RSUs. In the presence of
malicious vehicles, the amount of messages being generated
increases manifolds, which leads to the loss of important
information and causes delay in the sharing of credible
information. Different transactions performed between ve-
hicles are stored using blockchain technology, which helps
in promoting data transparency, immutability, security and
privacy. The blockchain technology is implemented on the
RSUs and only the important information is stored at RSUs
after data filtration. Moreover, the proposed work is intended
to ensure efficient energy trading between EVs and CSs. Fur-
thermore, the security and reliability of energy transactions
are maintained via consortium blockchain. The transactions’
validation is done using PoW consensus mechanism. The
proposed model consists of several entities: EVs, CSs, RSUs,
LAGs and RA. In the proposed energy trading model, LAGs
are interconnected in a P2P manner, and all energy trading
transactions are audited and verified by them. While, the
CS broadcasts energy selling requests with present state
of charge (SoCpr ), current location (Loccur) and present
number of EVs in a queue (Qev
n) in the network. Moreover,
the buyer EV (EV b) communicates with the LAG to find
the nearest CS along with energy present at CS (Epr
j) and
nfor energy trading; while, seller EV (EV s) requests the
LAG to sell energy. The entities mentioned above are further
elaborated below.
EVs: in the energy trading environment, EVs play
different roles as energy sellers, energy buyers and idle
nodes. EV sshare its surplus energy with other EVs that
are in need of it. EV scan also trade energy with CSs to
earn energy coins. Furthermore, EV bsends its energy
requests to the LAGs when it requires energy. The
idle EVs are neither energy buyers nor energy sellers.
However, their role can be changed upon requirements.
Each EV in the network chooses its role according to
its energy state and driving plan.
LAGs: they work as energy brokers that manage trading
events and provide wireless communication services to
EVs, CSs and RSUs. For energy trading, EVs and CSs
send their energy requests to the nearest LAGs. The
energy broker does a statistics of local energy demand
and announces this demand to CSs and EVs. When EVs
have surplus energy, they send energy selling request
to the LAG, which sets the energy selling price and
sends it to each energy node. For each request, LAG
verifies the ID of each node through the RA. LAG also
accesses the wallet addresses of the nodes using the
respective IDs. Afterwards, LAG temporarily places
energy trading requests into the M-Pool.
RA: in the energy trading model, the registration of
EVs, CSs and LAGs is done though RA. When any
entity wants to join the network, RA registers it and
provides a unique ID. The ID is generated by a pair of
Public Key (P K) and Private Key (SK). The authenti-
cation of nodes is maintained through the assigned ID.
Moreover, EVs and CSs also request for their wallet
addresses from the RA, which then generates a mapping
list based on the request and provides them with specific
wallet addresses.
Smart meter: it is used to record and calculate the
amount of energy that is traded between energy nodes.
The energy buyers pay the corresponding price to the
sellers, according to the records of smart meters.
A real time scenario is developed to describe the workflow
of the proposed scheme. The CSs and EVs are categorized
into two groups: energy sellers and energy buyers. They
are deployed at different locations in a particular region. In
the proposed work, the EVs are considered to be equipped
with Energy Storage Systems (ESSs) and have the ability
to save energy. The surplus energy means the energy that is
not usable for the EVs at a certain time. As all EVs are in
coordination with each other, so any EV that needs energy
and is far from the CS can buy energy from that EV. In
this case, energy will be traded between EVs efficiently and
at reduced rates. EVs can also supply some certain amount
of energy to the buildings when there is a burden on the
power grids, especially during peak hours. Moreover, the
purpose of selling energy to the charging station is to help
alleviate the burden on the station. Besides, by selling energy
to the charging station, EVs can also earn some incentive.
Furthermore, in G2V trading, CS trades its energy with the
EV. Initially, the CS sends an energy selling request to LAG
along with its ID,Loccur,SoCpr, battery capacity (Bcap)
and Qev
n. Afterwards, LAG verifies the authentication of CS
and determines the corresponding energy price. The price
is set after considering Bcap and SoC pr of CS. The LAG
temporarily places the request in the M-Pool. Whereas, in
V2G trading, EV s
ishares its surplus energy with CS. In
this case, EV s
isends a request to LAG for searching the
nearby CSs. The LAG provides a list of CSs by considering
EV s
i’s Loccur. Then EV s
iselects the CS, which is at
minimum distance (Dij) and requires less time to reach.
After matching, LAG makes a pair of EV s
iand CS, and
stores it in the P-Pool. Similarly, when EV b
isends energy
buying request to LAG, it is provided with a list of the nearest
CSs along with Dijand required energy expenses (Exrq ).
EV b
iselects a preferable CS for energy trading.
The energy selling process of a CS is explained in detail
in the following steps and is also illustrated in Figure 2.
Initially, CS is registered with the RA in order to take
part in energy trading. Then, CS sends an energy selling
request to the LAG that contains Loccur,SoCpr ,Bcap
and Qev
LAG executes the ESC, given in Algorithm 1, and stores
all information about the CS in the blockchain. In the
algorithm, the identity of each CS is verified. If CS is to
found to be verified, energy buying and selling requests
are entertained. If the CS is not verified, it is regarded
as invalid.
Algorithm 1: Algorithm of Energy Smart Contract
1: Initialization
2: Inputs: IDj, Locj, Bcap, SoC pr, Qev
3: Output: Identity validation
4: Verify identity (IDj) of each CS
5: if CS identity = Valid then
6: Save data block (IDj,Locj,Bcap ,SoCpr ,Qev
7: if CS energy buying (Ei
u, Qev
8: energyUnitj+ = Ei
9: Qev
n+ 1
10: end if
11: if CS energy selling (Ei
u, Qev
12: energyUnitj=Ei
13: Qev
n+ 1
14: end if
15: else
16: Send message “Identity is not valid”
17: end if
18: End
EV b
isends energy buying request to the LAG. The
LAG executes Algorithm 2 that starts the energy trading
process when the request is validated. For validation, the
request of EV b
imust contain ID,Loccur,Bcap, role
(R) and SoC pr . Moreover, LAG accepts or rejects the
request after comparing it with the requests stored in the
M-Pool. If the request is matched, the newly generated
request is discarded; otherwise, it is placed in M-Pool
for processing.
When a LAG receives an energy buying request, it starts
finding the nearest CSs according to the EV b
i’s Loccur
and gets information through the ESC. LAG calculates
Dijbetween EV b
iand CS along with Exrq. LAG
provides a list of nearest CSs to EV b
ialong with Dij,
kW h,Epr
kW h and Qev
EV b
iselects the CS that matches with its preferences
and sends the required number of energy units (EV rq
kW h)
to it. Thus, matching is done between EV and CS.
Afterwards, EV b
iand CS are paired and Qev
nof CS is
incremented by 1. The energy units of CS are subtracted
to match the energy demand of EV b
i. Once a pair is
made, LAG stores the new pair in P-Pool and sends
confirm pair notification to both EV b
iand CS.
After energy is traded among the paired EV b
iand CS,
PSC is executed. The energy coins are deducted from
the buyer’s account and added to the seller’s account.
The PSC is given in Algorithm 3. In the algorithm,
the payment mechanism is discussed. Once energy is
traded between registered EVs and CSs, payment is
to be initiated from the buyer side towards the seller
side. Before the payment is made, the wallets of both
S1: Delay calculation
S2: M-Pool and P-Pool
S3: Design ESC
S4: Design PSC
S5: Reputation score,
provisioning of incentives
S6: Vehicle registration,
certificate provisioning
S7: String and character
S8: Coordination strategy
L1: Computational overhead
L2: Charging time of EVs
L3: No secure energy trading
L4: No secure payment
L5: Reputation and credibility
L6: Lack of security and privacy
L7: Data redundancy
L8: Coordination at crossroads
L6, S6
L8, S8
L3, S3
L4, S4
L2, S2
L5, S5
L7, S7
Authority Road Side Unit
V2R Communication V2V Communication Coordination
Aggregator Smart Contracts Transaction Pools
Figure 1: Proposed System Model
buyer and seller are registered. If wallets are found
to be unregistered, payment would not be made and
energy trading would be stopped. Once registration is
performed, the amount payable in accordance with the
energy being traded is calculated and made. The energy
units are analyzed through the smart meter. After the
execution of smart contract, a decrement of 1 is made
in Qev
nof CS.
After completion of energy trading, LAG calculates the
reputation function and updates the number of total
completed requests.
The workflow of energy trading of EV s
iis explained in
the following steps and is also illustrated in Figure 3.
Initially, EV s
iis registered by the RA to maintain its
authentication. Then, EV s
isends energy selling request
to the LAG.
The LAG compares the selling request generated by
EV s
iwith the requests that are stored in M-Pool. The
reason is to discard the request, if it matches with any
of the existing requests. If the request does not exist in
M-Pool, the available energy (Eavi) of EV s
iis checked.
If Eaviof EV s
iis more than 10 units, the LAG finds
the nearest CS and calculates the specific details, such
as Dij,Exrq and required time (Trq) to reach the
CS. Afterwards, LAG provides a list of all the nearest
CSs to the EV s
EV s
iselects a preferable CS for energy trading and
notifies the LAG, which then forwards the energy
selling request of EV s
ito the CS.
In case, CS accepts the request of EV s
i, LAG creates a
pair of CS and EV s
i, and sends a pairing notification to
both CS and EV s
i. On the other hand, if the CS does
not accept the request, LAG stores it in the M-Pool.
LAG executes the ESC and increments the Qev
nby 1.
Once energy trading is performed between EV s
CS, LAG executes the PSC and decrements the Qev
Energy trading request along with Loc
, SoCprand Qev
Transaction stored in blockchain using ESC
Request to get CS's SoC
, Qenand Loc cur
Provide specific details
Check for existing request
No existing request found
Run ESC for a specific CS according to EV's request
Provide list of nearest CSs
Confirm pair notification
Find the nearest CS
according to EV's Loc
Create a pair of
CS and EV
Store request in M-Pool
Compare with
existing request
Confirm pair notification
Energy buying request
Select a preferable CS
Figure 2: Sequence Diagram for Buyer EV’s Energy Trading Scheme
The energy units and equivalent price are calculated
through the smart meter and PSC, respectively. The
energy coins are transferred from buyer to seller.
After successful energy trading, LAG calculates the
reputation function and updates the M-Pool according
to the requests.
In the proposed scheme, an EV can get information about
the Epr
kW h,Qev
nand total number of charging time slots
(Tslot) of a CS. Owing to this, EV can easily know that
how long the CS will remain busy. This information allows
the EV to choose the optimal charging time slot where it
can get the energy as per its demand and in due course. The
algorithm proposed for optimal energy trading is discussed
in Section IV-A.
A. Algorithm for Energy Trading
One of the main goals of the proposed work is to prevent
redundant energy requests that are repeatedly sent by the
energy seller. These requests are either fake or very small
and cause malfunctioning in the energy trading environment.
When an energy seller generates a new energy trading
request, LAG checks the seller’s authentication and matches
its request with the ones already present in the M-Pool. If the
new request is already stored in M-Pool for processing, it is
being discarded. Otherwise, it is placed in M-Pool according
to the steps given in Algorithm 2.
Initially, in the energy trading process, the node with
surplus energy sends request to the LAG. For instance, EV s
sends request to other nodes that contains IDi,R,Loccur,
SoC pr and Bcap. LAG calculates the Epr
kW h of the battery
with the help of SoC pr and Bcap that are provided by EV s
using Equation 1.
kW h =SoCpr
100 xBcap,(1)
LAG also calculates the amount of energy required by an
EV using Equation 2
kW h = (Bcap Epr
kW h).(2)
In the next step, LAG validates the EV s
i’s ID to ensure
authentication. Afterwards, LAG checks the energy request
in M-Pool via EV s
i’s ID. It stops the transaction process
and sends a notification to the EV s
iif the energy request
already exists. The request checking function of EV s
like a filter to avoid redundant requests to be placed in M-
Pool. Besides, LAG checks the role of EV s
ias a seller. For
this purpose, a selling function is executed. Before starting
energy trading process, the function first verifies the EV-
CS pairs present in the P-Pool. If EV s
iis not already paired
with any CS, a pair is being made to perform energy trading.
As a result, the reputation value of EV s
iis increased by 1.
In another case, if EV s
iis already paired with a CS, its
reputation value is decreased by 1 and its existing pair is
removed from the P-Pool.
Moreover, in the next step, a threshold value (Eth) for
SoC pr of EV s
iis calculated, which can be different in
practice. However, in our case, the threshold level is set to
be 30 percent of the Bcap. The threshold is calculated using
Request to get CS's SoCpr
, Qenand Loc cur
Provide specific detail
Check for existing
energy request
No existing request
Run ESC for a specific CS according to EV's request
Provide a list of nearest
CSs with Dist
i jExrq and Trq
Confirm pair notification
Confirm pair notification
Select a preferable CS
Check available
energy of EV
Find the nearest CS and
calculate specific details
Compare with the
existing request
Forward request to CS having required energy
Accept EV's request
Create a pair of
EV and CS
Energy selling request
Figure 3: Sequence Diagram for Seller EV’s Energy Trading Scheme
Equation 3.
Eth =30
In addition, the value of Eth is subtracted from Epr
kW h of
EV s
ito get the total available units of energy (Eav
kW h).
kW h = (Epr
kW h Eth).(4)
In the next step, Eav
kW h of EV s
iis checked. If it is more than
10 units of energy, the energy trading request is processed.
Otherwise, the process is stopped and a notification is sent to
EV s
ithat the present energy level is very low. Furthermore,
the Loccur
iof the EV s
iis assigned to variable Locbfor pro-
cessing. According to the Loccur
i, LAG finds the appropriate
CSs for the EV s
i. The energy trading is done between EV s
and the selected CS. Afterwards, the corresponding price for
traded energy is determined using Equation 5 as follows.
i=aSoC pr
SoC pr SoCth ,(5)
where SoC th is a threshold value. In this study, SoCth is
set to be 30 percent on the basis of SoC for each EV s
battery. ais used to calculate price value, which is equal to
$0.065. However, SoCth and acan be different in practice.
Equation 5 is used after taking motivation from [20]. De-
pending on the location of EV s
i, information of the nearest
CSs is provided that contains Ps
kW h and Qev
n. Moreover,
GPS is used to find the nearest CS and to measure the
distance between EV and CS. The purpose of GPS is to
provide an accurate measurement between two different
locations. On the basis of accurate distance, Exr q and Trq
are calculated to reach the CS. Furthermore, EV s
iselects a
CS from the list that is provided by LAG, which then sends
the trading request of EV s
ito the CS. If the CS accepts the
energy selling request, the LAG makes a pair of EV s
CS, and sends notification to both of them. Furthermore,
ESC is executed to perform energy trading process. After
the energy is successfully traded between a pair of EV s
CS, the payment transactions are handled by the PSC. The
energy selling price is defined initially when the request is
generated. However, the payment is made using PSC after
energy is successfully traded and coins are shared between
EVs and CSs.
The energy buying functionality of EV b
iis described as
follows. Pre-made pairs are checked according to the ID of
the EV b
ithat sends the energy buying request. When the pair
does not exist, the LAG takes the location of the EV b
gets request from the M-Pool with seller’s Loccur
jand Ps
It then measures the distance between EV b
iand CSs using
GPS. Afterwards, LAG provides the information of all the
nearest CSs to the EV, which includes the distance of CS, Ps
n,SoC pr
j,Trq and Exrq to reach the CS. The provided
list of CSs is shown in Table III. The EV selects one of the
CSs provided in the list. LAG makes pair of EV and CS, and
sends notification to both of them. In the next stage, ESC is
executed and the energy request is entertained. Afterwards,
PSC is processed. When PSC runs, it first verifies the IDs
of both CS and EV b
i. It then accesses their wallet addresses.
Algorithm 2: Algorithm of Request for Energy Trading
1: Initialization
2: Inputs: IDi, Ri, Loccur
i, SoC pr, Bcap
3: Output: Request status
4: Epr
kW h =SoC pr
100 xBcap
5: Erq
kW h = (Bcap Epr
kW h)
6: Check request (IDi)
7: if Request present (IDi)=0 then
8: if Rtype= Seller then
9: Check pair (IDi)
10: Eth =30
100 xBcap
11: Eav
kW h = (Epr
kW h Eth)
12: if Eav
kW h >10kW h then
13: Loccur
14: Ps
kW hEth
15: geocode(Loccur
16: for k = 1 to No. of nearest CSs do
17: Price announced to nearest CSs
18: end for
19: if CS selects EV’s Request then
20: Create pair (IDiwith IDj)
21: Send notification (IDi,j)
22: else
23: Request stored in M-Pool with Loccur
iand Ps
24: end if
25: else
26: Send message “Present energy is very low”
27: end if
28: else
29: Check pair (IDi)
30: Locb=Loccur
31: Get requests from M-Pool with seller’s Loccur
and Ps
32: for j=1 to last 10 requests do
33: Get Locs
jand Ps
34: Dij=gmaps.distance matrix(Locb
i, Locs
35: Exrq = (Dij/1000)x(Ps
36: end for
37: Announce Exrq, Dij, T rq and P s
jto EV b
38: if EV selects preferable CS or EV then
39: Buyer and seller pair is confirmed
40: Create pair (IDiwithIDj)
41: Pair is sent to ESC for energy trading
42: Run PSC
43: else
44: Request discarded
45: end if
46: end if
47: Reputation score (IDi)
48: else
49: Request exist (IDi)
50: end if
51: End
When verification is performed, PSC checks the balance in
the energy buyer’s wallet. If the energy buyer’s balance is
Algorithm 3: Algorithm of Payment Smart Contract
1: Initialization
2: Inputs: IDs
i, IDb
3: Output: Payment to be made
4: Verify (IDs
5: Verify (IDb
6: wallets= access wallet address according to I Ds
7: walletb= access wallet address according to I Db
8: Verify wallet address(wallets)
9: if wallets= false then
10: Stop energy trading
11: end if
12: Verify wallet address (walletb)
13: if walletb= false then
14: Stop energy trading
15: end if
16: Event Sent(f rom, to, amount)
17: Transfer energy coin
(wallets, walletb, P s
kW h, Ek W h)
18: amountpayable =Ps
kW h xEkW h
19: if amountpayable > balance[walletb]then
20: Send message “Insufficient balance, please buy coins
21: balance[walletb]=amountpayable
22: balance[wallets] + = amountpayable
23: Emit Sent(sender, receiver, amountpayable)
24: end if
25: End
TABLE III: Time and Expenses Required to cover the
Distance for Reaching the Nearest CSs
8.8 15 2 $0.97
1.9 4 3 $0.021
3.2 9 2 $0.035
13.1 19 3 $0.144
1.8 3 4 $0.02
less than the purchased energy coins, PSC stops the energy
trading. Otherwise, PSC withdraws money from the energy
buyer’s wallet and puts it in the energy seller’s wallet. As a
result, Qev
nof the respective CS is decremented by 1. After
EV b
icompletes the energy trading process, its reputation
score is increased.
The section comprises of the mathematical formulation of
the underlying work. In the first subsection, the mathematical
formulation of the delays involved in the VEN is given.
While in the next subsection, the mathematical formulation
of the coordination done between the vehicles at the cross-
roads is presented.
A. Delays in Vehicular Energy Network
There exist different types of delays in message sharing
between vehicles and the RSUs. The common delays include
the propagation delay, transmission delay, message process-
ing delay and queuing delay [73].
The delay caused while sending a message bit by bit from
one vehicle to other vehicles present in the network is known
as the propagation delay. It is denoted by propdelay and
depends upon the distance between source and destination
and the speed of sending the message. It is given in Equation
6 obtained from [73]. Transmission delay, on the other hand,
is the delay caused during the transmission of an entire
message between two vehicles. It is denoted by transdelay
and is given in Equation 7 [73]. It depends upon the total
message size and the data rate.
propdelay =distance
velocity (6)
transdelay =message size
data rate (7)
Furthermore, the message processing delay is the delay
caused in processing the message by the receiving vehicle.
It is denoted by procdelay and depends upon the message
size and the processing speed. The fourth type of delay is
encountered when there exists a large number of messages
in the queue that need to be processed. This delay is
significant at the RSUs because a great number of messages
are constantly broadcasted by the vehicles to the RSUs.
This delay is known as the queuing delay and is denoted
by quedelay . This delay is linked with transdelay using
Equation 8, taken from [74].
quedelay =transdelay queuelength (8)
All of the above mentioned delays are summed up to
provide the total delay occurred in the network. The total
delay, denoted as totaldelay, is given in Equation 9. This
delay can also be termed as end-to-end delay, denoted as
end to enddelay.
totaldelay =propdelay +transdelay +procdelay +quedelay
1) Objective Function: It is a very important function in
the mathematical formulation of any network. The objective
function of the proposed work is the minimization of the
total delay, given in Equation 10.
objective f unction =min(totaldelay)(10)
B. Coordination at the Crossroads
In VENs, the coordination between vehicles and the timely
sharing of information play important roles. To prevent both
the occurrence of mishaps between vehicles and the road
congestion, coordination between vehicles is necessary at
the crossroads. The vehicles have three choices to make
at the crossroads: 1) turn towards right side, 2) turn to-
wards left side and 3) proceed straight ahead. The proposed
coordination mechanism is designed keeping the real life
feasibility in mind. If multiple vehicles are present at the
intersections, the vehicles having high credibility and good
reputation are given the priority to cross the intersections.
Same prioritization mechanism is followed in the special
case where vehicles are mobile and various movements are
observed at the intersections. Figure 4 shows these options
and the coordination between vehicles.
Figure 4: Coordination at the Crossroads
1) Assumptions: Before discussing the options available
for the vehicles at the crossroads, it is necessary to provide
the assumptions made in this study. These assumptions are
given below.
The vehicles are right-hand driven, which means that
people drive on the left side of the roads.
The crossroads do not have traffic signals and the drivers
have to cross the intersections at their own risk.
Each vehicle has the option to either turn right, turn left
or go straight.
2) Coordination Types: There are two types of coordina-
tion available for the vehicles at the crossroads. These are
a) rule based and b) optimization based. The details of these
types are given below.
Rule based coordination: in this type of coordination,
the vehicles are bound to obey some given rules,
implemented through a predefined protocol. According
to these rules, each vehicle is assigned a specific zone
when it reaches the intersection. If no vehicle is coming
from the other three sides present in that zone, the
vehicle is allowed to pass through crossroads at a given
speed. On the contrary, if the vehicles are found present
in the coordination zone, the vehicle near the crossroads
is given the priority; while, the other vehicles are asked
to reduce their speed and let the other vehicle pass to
avoid any mishap.
Optimization based coordination: in this type of co-
ordination, the coordination between vehicles is formu-
lated as a mathematical function. Different algorithms
and tools are used to formulate the coordination.
In the proposed work, rule based coordination is used be-
cause it is easy to be followed by all the drivers. Moreover,
the aim of this work is the implementation of the proposed
scheme on a global scale and not confining to a specific
geographical area. If the optimization based coordination is
used, it would be targeted to a specific area. Furthermore, not
everyone is trained enough to implement specially designed
optimization algorithms. Therefore, keeping all the factors
in mind, rule based coordination is used in the underlying
3) Coordination Cases: Three different route selection
cases available for the vehicles present at the crossroads are
discussed below.
Case 1: when the vehicles intend to turn towards
the right side: when vehicles select to turn right at
the crossroads, then they have to communicate with
the vehicles coming from the opposite side wishing to
continue in the straight path. Moreover, they also have
to coordinate with the vehicles coming from the right
side wishing to turn either towards right or go in the
straight path. In this case, we have assigned probability
value of 0.5 to the vehicles turning towards right. While,
the other options are given probabilistic value of 0.25
Case 2: when the vehicles intend to turn towards
the left side: in this case, the vehicles turning left are
given the probabilistic value of 0.5; while, the other two
options are given the values of 0.25 each. The vehicles
are able to turn towards the left side without performing
any coordination as no vehicle from any other side is a
hindrance to their path.
Case 3: when the vehicles intend to go straight: in the
third case, the vehicles neither turn towards left side nor
towards the right side. Rather, they continue their course
and keep moving in the straight direction. In following
such a route, the vehicles must communicate with the
other vehicles coming from the right and left sides,
who wish to proceed straight. Furthermore, they must
also communicate with the vehicles coming from the
opposite and the left sides, who wish to turn towards the
right side. In this case, the vehicles proceeding straight
ahead are assigned probabilistic value of 0.5. While, the
vehicles turning left and right are given value of 0.25
Algorithm 4 provides the guidelines to be followed by the
vehicles while passing through the crossroads. In the algo-
rithm, all the cases available for the vehicles are discussed
one by one: vehicles coming from right side (Lines 13-22),
vehicles going straight (Lines 23-32) and vehicles turning
left (Lines 33-36). If the conditions are suitable, the vehicles
are allowed to move further. Else, it is stopped from moving
The shortage of energy and absence of an efficient energy
trading mechanism creates a sense of anxiety among the
drivers. The anxiety is because of the fact that energy
Algorithm 4: Algorithm of Coordination at Crossroads
1: Initialization
2: Inputs: Number of vehicles, T urnlef t,T urnr ight,
3: Output: Crossroad crossing
4: for Each vehicle, vehicle = 1, ..., n do
5: Check for the authorization of the vehicle
6: if Vehicle is authorized then
7: Check for its option of the route selection
8: else
9: Assign the vehicle as malicious
10: end if
11: end for
12: for The different options made by the vehicles do
13: if The vehicle opts for T urnright then
14: Check for the vehicles coming from right side and
from opposite side
15: if The vehicles are coming either from right side
or the opposite side then
16: Deny the vehicle from turning right
17: Send message “Do not turn right”
18: else
19: Allow the vehicle to turn right
20: Send message “Turn right”
21: end if
22: end if
23: if The vehicle opts for Gostraight then
24: Check for the vehicles coming from right side, left
side and opposite side
25: if The vehicles are coming from right side, left
side or opposite side then
26: Deny the vehicle from going straight
27: Send message “Do not go straight”
28: else
29: Allow the vehicle to go straight
30: Send message “Proceed forward”
31: end if
32: end if
33: if The vehicle opts for T urnlef t then
34: Allow the vehicle to turn left
35: Send message “Turn left”
36: end if
37: end for
38: End
consumption is more at lower speeds and vehicles are driven
at increased speeds to save energy. Moreover, when the
vehicles have to wait for a longer time at the intersections,
their energy is consumed, which reduces the energy stored
in the batteries. As a result, the anxious vehicle drivers
will try to cross the intersections hurriedly without per-
forming any coordination. It will lead to high chances of
accidents. To cater the anxiety issue and reduce the number
of accidents, an efficient energy trading mechanism and an
accident avoidance mechanism based on coordination are
proposed. The coordination between vehicles would result
in accident avoidance; while, energy trading would ensure
that the vehicles are able to get required amount of energy
from the nearby charging entities. Hence, both energy trading
and accident avoidance go side by side.
With the increase in the vehicles running on the roads, the
messages being generated and shared between vehicles are
also increased, which further leads to data storage issue. To
deal with this issue, message credibility is ensured. The mes-
sage credibility is defined as the extent to which a message is
believed to be true by the recipients. The sharing of credible
messages between the network participants ensures trustwor-
thiness, reliability, etc. In the proposed work, the storage of
credible messages ensures data redundancy as non or less
credible messages will be discarded. The messages generated
are compared with each other and only the important and
credible ones are saved. Message credibility is different from
the vehicle credibility. In the latter, the trustworthiness of a
vehicle is checked based upon the previous activities and a
vehicle is considered either to be trustable or malicious. If
the activities are found honest and transparent, the vehicle
is considered credible and vice versa. It further leads to the
belief in the authenticity of the messages being generated.
Algorithm 5 shows the mechanism used for checking the
credibility of the incoming messages. In the algorithm, each
new incoming message is checked for redundancy. If the
vehicle is authenticated, the message is accepted else it
is discarded (Lines 4-14). Once the message is accepted,
duplication in the message content is checked. If different
text is found, message is saved; else it is discarded (Lines
Range anxiety is the fear possessed by EV drivers that the
vehicles will run out of charge while going on long journeys.
This fear restricts the users from shifting to EVs from
conventional vehicles. The phenomenon of range anxiety
depends upon two factors: distance to cover and battery
capacity. It is directly proportional to the distance to be
covered; greater the distance, greater is the range anxiety. On
the contrary, battery capacity exhibits an inverse relation with
range anxiety; increased battery capacity yields decreased
range anxiety. Mathematically, range anxiety is calculated
using Equation 11.
rangeanxiety =distance to cover
battery capacity (11)
We have high and low range anxious users in the VEN.
The first type of range anxious users are highly anxious
about their batteries being drained off while going on long
distances. Such users are constantly looking for CSs to have
their vehicles charged at all times. On the other hand, low
range anxious users do not worry much about their batteries
being drained off and tend to recharge their batteries when
less than 20% charge is remaining. Moreover, the EV users
are also informed about the CSs’ locations on their ways
through RSUs. Knowing the exact location of the CSs helps
the drivers to select the optimal path to reach the destination.
Algorithm 5: Algorithm of Data Redundancy Removal
1: Initialization
2: Inputs: Number of vehicles, Incoming message
3: Output: Message storage
4: for Each vehicle, vehicle = 1, ..., n do
5: Check for the incoming message
6: if Message is received then
7: Check for message credibility
8: if Vehicle is authorized then
9: Accept the message
10: else
11: Discard the message
12: end if
13: end if
14: end for
15: for Each authorized message do
16: Check the message content and find duplicate text
17: if Duplicate message is found then
18: Discard the message
19: else
20: Save the message
21: end if
22: end for
23: End
To motivate the vehicle users to take part in the proposed
system, they are being provided with the incentives. The
incentives prevent the vehicle drivers from not following the
traffic rules and regulations. If any driver breaks the traffic
rules, he will be penalized and has to pay some amount as
penalty. The penalty rates are set by the traffic regulatory
authority. Furthermore, the users are also provided with
incentives on sharing the important and credible messages.
If the messages being shared are not credible, the vehicle is
given the negative rating. Algorithm 6 presents the incentive
provisioning mechanism used in the proposed work. In
the algorithm, the message coming from each vehicle is
initially checked from credibility perspective. If the message
is found credible and important, the vehicle is provided with
incentives (Lines 5-11) and vice versa. In the second part
of the algorithm, a vehicle is checked from the perspective
of traffic signals following. If a vehicle follows the traffic
signals, it is provided with incentives and vice versa (Lines
The simulations performed in the proposed work are
discussed in this section. The simulations are performed
on an HP 450 G4 Core-i5 7th Generation ProBook sys-
tem having 1 TB SATA, 8 GB DDR4 and Windows 10
Professional operating system. Solidity language is used to
write the smart contracts; while, Remix IDE is used for
providing an Integrated Development Environment (IDE).
Moreover, for assessing the virtual accounts, Ganache is
Algorithm 6: Algorithm of Incentive Provisioning
1: Initialization
2: Inputs: Number of vehicles, Incoming message
3: Output: Incentive provisioning
4: for Each vehicle, vehicle = 1, ..., n do
5: Checks for the incoming message
6: if Message received is credible and important then
7: Provide incentives to the vehicle
8: else
9: Does not provide the incentives
10: end if
11: end for
12: for Each authorized vehicle do
13: Check if the vehicle has followed the traffic rules
14: if Rules are followed then
15: Provide incentives to the vehicle
16: else
17: Penalize the vehicle
18: Generate a traffic challan
19: end if
20: end for
21: End
used; while, MetaMask is used for connectivity. Furthermore,
the experimental results are taken in Python 3.6.
In this study, we analyzed the performance of the proposed
scheme using real environment of a certain area in a city,
which is presented in Figure 5. In the given map, the red
marks indicate the CSs. The data of charging stations used in
the proposed work is taken from Oil and Gas Development
Corporation Limited, Pakistan. The traditional fuel pumps
are referred as the charging stations and their exact locations
are used for simulations. Furthermore, the values of risk
factor, network delays and energy available for selling are
the average values selected after performing multiple simu-
lations. Table IV presents the simulation parameters used in
the proposed work.
TABLE IV: Simulation Parameters’ Values
Simulation Parameters Values
Selected area 21.5km x 15.9km
Number of CSs 20
Number of EVs 50
Maximum number of generated
Energy selling price $0 - $0.3
Energy available for selling 0kWh - 60kWh
SoC value 0% - 100%
Risk factor 0% - 80%
Network delays 0ms - 60ms
The main purpose of considering real environment is to
check the accuracy of the obtained results on the real data.
The values are the measurement of distance between the
locations of EVs and CSs. The values of Trq and Exrq
are estimated according to accurate distance measurement.
Moreover, Loccur is calculated by executing Algorithm 2.
The algorithm provides the locations of the nearest CSs and
measures the distance along with Trq and Exrq, which are
shown in Table III.
Figure 5: Real time Distribution of CSs
The consumption cost of smart contracts is calculated in
terms of gas, which is a small unit of cryptocurrency. This
unit is deducted from the users’ accounts while performing
transactions. Gas consumption depends on the complexity
of the smart contract. The consumption cost of the smart
contracts is further divided into transaction cost and ex-
ecution cost. Transaction cost is defined as the cost of
smart contract deployment. It involves the cost of adding
transactions in the blockchain. The execution cost, on the
other hand, is defined as the computational cost of executing
each individual operation. The execution cost is always
less than the transaction cost. Figure 6a shows the gas
consumption of the EV registration smart contract in terms
of transaction cost and execution cost. It is observed that the
former is greater than the latter. This is due to the fact that
the transaction cost involves the function execution cost as
well. Four different functions are shown in Figure 6a. These
functions are (a) EV registration, (b) message broadcast, (c)
message retrieval and (d) authentication. Similarly, Figure
6b shows gas consumption cost of ESC. In ESC, five main
operations are performed: (a) energy trading request, (b)
energy selling request, (c) verify ID, (d) check S oCpr and
(e) check Qev
n. The event (a) is executed when the energy
node registers itself with RA. During the execution of the
event, the information of SoCpr,Bcap and Qev
nis stored in
the blockchain. As more computational tasks are performed
by event (a); therefore, its transaction and execution costs
are higher as compared to other events. On the other hand,
Figure 6c shows gas consumption cost of PSC. There are five
different functions in the PSC: (a) recharge wallet, (b) access
buyer’s wallet address, (c) access seller’s wallet address, (d)
transfer energy coin form one account to another account and
(e) check current balance in wallet. It is observed from the
figure that event (a) consumes more gas because it performs
more operations as compared to other events.
In Figure 7, the comparison between the number of mes-
sages generated using authentication of vehicles and without
authentication is given. It is observed that the presence of
a b c
Tra nsac tion Cost
Exec uti on Cost
Total Consumption (gas)
Gas Consumption of Main Smart Contract
ESC’s Gas Consumption Cost
PSC’s Gas Consumption Cost
Figure 6: Gas Consumption of Smart Contracts
authenticated vehicles lead to less messages generated over
time. Whereas, in the presence of unauthenticated vehicles,
fake messages are generated, which increases the total num-
ber of messages being generated by the vehicles and also
increases the data storage requirements.
5 10 1 5 20 25 3 0 35 4 0 45 50 5 5 60 6 5 70 7 5 80 85 9 0
Time (minutes)
Number of Messages Generated
Wit hou t Aut hen tica tion
Wit h Au then tic atio n
Figure 7: Authentication of Vehicles
Energy Required (kWh)
Figure 8: Energy Required to Recharge EVs’ Battery
The energy price in the proposed scheme is determined
using the formula taken from [20]. The formula uses the ex-
isting SoC pr and SoCth values to determine the appropriate
energy price. In case, the charge of battery is full, the price
would be $0.09, which is the current energy rate in USA
[75]. By using the price formula, it is assessed that the price
of energy increases as the level of charging decreases and
vise versa. Furthermore, the number of required and available
energy units are calculated to sell optimum energy using the
SoC pr value. The required and available energy units of EVs
are shown in Figures 8 and 9, respectively. It is depicted
from the figures that the value of energy changes for each
EV. The red bar in Figure 9 shows that the SoCpr of EV s
is very low, i.e., 10 units. It means that the EV s
icannot sell
its energy. Algorithm 2 checks the charging level of EV s
when it sends energy selling request. For instance, if the
present energy units of EV s
iare less than 10 units, it cannot
perform selling operation. The level of energy units might
be different; however, for simulations’ purpose, the minimum
Energy Available for Selling (kWh)
Figure 9: Energy Units Available for Selling by EVs
Figure 10: Energy Selling Price Announced by Multiple EVs
number of energy units used is 10. Furthermore, the selling
price of EV s0energy units is illustrated in Figure 10. It is
clear from the figure that the energy selling price is not fixed
and is based on the charging level of EVs. The peak factor
is not considered in this work. Moreover, the energy selling
price is calculated through the PSC. Additionally, in order to
test the working of energy price formula, an EV is selected
and the formula is executed with different SoCpr values.
It is depicted from Figure 11 that the energy selling price
increases as the time increases and vise versa. The increase
in price with respect to time is because when an EV needs
more energy for charging, it will have to spend more time at
the charging entity. When the time required for charging is
more, the energy selling and buying cost will also be more.
Hence, the analysis proves that the pricing formula, given in
Equation 5, shows accurate results. Also, the energy price
increases as the load on the CS increases. In the proposed
work, EVs’ current SoCpr value is recorded and is illustrated
Figure 11: Change in Energy Selling Price Announced by
an EV with respect to time
in Figure 12. The value is recorded during the execution
of Algorithm 2. Based on SoC pr , each EV selects its role,
either as a seller or a buyer. The change in SoCpr value with
respect to time is shown in Figure 13.
To tackle the issue of huge storage demand, and to
Figure 12: SoC pr Values of Multiple EVs
avoid storage of malicious and duplicate data, filtration of
data is required. The time taken to save both filtered and
redundant data is visualized from Figure 14. As the amount
of data increases, the difference between the time taken
for storage of filtered and redundant data is also increased.
Figure 15 shows the range anxiety probability in relation to
the time taken to travel the distance. Two types of range
anxieties are shown in the figure: high range anxiety and
low range anxiety. It is observed from the figure that as the
time increases, the high range anxious users become more
hesitant while traveling to reach the nearest CS as compared
to low range anxious users. The simulation results for the
coordination of the vehicles and the delays encountered in the
Figure 13: Change in SoC pr of an EV with respect to Time
VEN are presented and discussed further. Figure 16 shows
the delays incurred in the VENs over time. It is observed
from the figure that the rise in the number of vehicles
increases the delays in the VENs. It is observed from the
figure that as the number of EVs increases, the quedelay also
increases. It is because each message needs specific time to
be processed, which adds up and increases the total quedelay .
10 20 30 40 50 60 70 80 90 100
Redu ndan t Da ta
Filt ered Dat a
Size of Data (kB)
Figure 14: Filtration of Broadcasted Messages
Figure 17 shows the increase in the risk factor at the
crossroads with and without the coordination between the
vehicles. It is observed that using coordination between
vehicles, the risk factor of the vehicle drivers is almost
halved. It shows the necessity of the coordination between
the vehicles in the VEN. This coordination also reduces the
number of accidents occurring at the crossroads.
1) Comparison: The underlying work is compared with
the work done in [20]. The auction is performed according
to the buying prices from charging EVs and selling prices
5 1 0 15 2 0 25 30 3 5 40 4 5 50 5 5 60 6 5 70 7 5 80 8 5 90
Time (minutes)
Probability of Range Anxiety
Hig h Rang e Anx iet y
Low Range Anxi ety
Figure 15: Range Anxiety of Vehicle Users
10 20 30 40 50 60 70 80 90 100
Number of EVs
Delays (microseconds)
Prop agat ion D elay
Tra nsm issio n De lay
Proce ssing Dela y
Que uin g De lay
Figure 16: Delays in the Vehicular Energy Network
10 20 30 40 50 60 70 80 90 100
Number of EVs
Risk Factor (%)
Wit h Coo rdi nat ion
Wit hou t Coor dina tio n
Figure 17: Reduction in Risk Factor due to Coordination
from the discharging EVs. In this way, the accurate amount
of energy and its price are determined by the auctioneer.
Furthermore, the private information of EVs is not revealed
during energy trading. As energy nodes send more than one
request at a time, it is hard to determine that the request
is coming from one or more EVs. Therefore, a pairing of
nodes is done on the basis of buying and selling bid prices.
However, there is a chance that an EV is paired up with
multiple CSs at a time by sending multiple requests. Due
to which it is difficult to prevent malicious nodes from
sending multiple requests. On the other hand, the proposed
Algorithm 2 examines the application of EVs. In this study,
two pools are created such as M-Pool and P-Pool. In M-
Pool, energy requests of energy nodes are placed; whereas,
P-Pool maintains the pairs of energy nodes. The new requests
generated by EV and CS are compared with the existing
requests in M-Pool. If the new request is present in M-Pool,
it is discarded in order to avoid redundancy; otherwise, it is
stored in M-Pool and processed. Moreover, the EV chooses
a preferable CS and LAG makes their pair and places it in
the P-Pool.
In order to make comparison between existing and pro-
posed algorithms, five EVs and three CSs are considered.
Initially, CSs send their energy selling requests and EVs
generate energy buying requests. In this observation, a mali-
cious EV is considered that sends multiple fake requests too
frequently. As a result, the benchmark algorithm executes
each request and makes pairs of nodes, even including
the malicious node and its fake requests. However, the
proposed algorithm first examines each request and then
starts processing. The redundant or matching requests are
discarded. Afterwards, pairs of corresponding EVs and CSs
are made. If a paired node tries to make a new pair, its
request is canceled and its existing pair is removed as well.
It shows that the proposed algorithm is more efficient than
benchmark model in terms of its processing. The mapping of
identified limitations with proposed solutions and validation
results is given in Table V.
In this contribution, the consortium blockchain is used,
which ensures provisioning of security, privacy, data im-
mutability, transparency, etc. It comprises of the character-
istics of both public and private blockchain networks. It
requires prior permission, which makes the network more
secure and blocks the malicious nodes from joining the
network. Moreover, the energy network is protected from
attacks, such as sybil and re-entrancy attacks [76]. In this sec-
tion, security of the proposed scheme is analyzed in terms of
different possible vulnerabilities. The vulnerabilities include
data auditability, wallet security, transaction authentication,
double-spending and transaction tampering. Furthermore, the
proposed smart contracts are examined using Oyente security
analysis tool. Smart contracts are analyzed in terms of
different vulnerabilities, which are discussed below.
A. Data Auditability
The consortium blockchain is used in this study that
keeps records of energy trading requests and payments in
a verifiable, timestamped, and tamper proof manner. For this
reason, data records in the energy trading network cannot be
B. Wallet Security
In the proposed scheme, PSC is used to ensure secure
and fair payment. The smart contract accesses the wallet
addresses of buyer and seller through their IDs. Moreover,
LAG is authorized to execute smart contracts at energy
trading time. The wallet’s address is not shared publicly,
which prevents energy coins from being stolen.
C. Transaction Authentication
In the proposed scheme, the PoW consensus mechanism
and the consortium blockchain are used to empower the LAG
to validate transaction records and only the registered energy
nodes are included in the energy trading network. Therefore,
a malicious node finds it almost impossible to intrude the
network and make illegal transactions.
D. No Double-spending
The wallet address of each energy node relies on SK and
digital signatures to verify their ownership and transaction
history. In this way, the model is prevented from the double-
spending attack.
E. No Transaction Tampering
The blockchain technology stores the data in a tamper
proof manner. Therefore, it is impossible to change the
energy transaction records that are stored in the blockchain.
In the energy trading environment, nodes can cause finan-
cial loss and pose different security attacks to the system.
Some of the attacks are discussed below.
A. DoS
A kind of cyber attack in which the malicious node sends
too many requests and floods the network with unnecessary
traffic. In this attack, a target node is flooded with requests
and the information given to it triggers a crash. Due to this,
the network becomes inaccessible for the legitimate nodes
B. Refusing to Pay
In this attack, the malicious EV may pretend that it has not
received any energy from the seller CS or EV. The malicious
EV also refuses to pay for the received energy [19], [21].
C. Sybil Attack
In the energy trading environment, the malicious EV
makes sybil attacks by using multiple fake identities. In this
attack, malicious EV affects the reputation of other EVs by
executing fake energy transactions with the help of an energy
operator. Moreover, when reputation of the malicious node
is reduced due to its poor performance, it further influences
the network by creating new fake identities [19].