Peer to Peer Distributed Energy Trading in Smart Grids: A Survey

: Due to the expansion of distributed renewable energy resources, peer to peer energy trading (P2P DET) is expected to be one of the key elements of next generation power systems. P2P DET can provide various beneﬁts such as creating a competitive energy market, reducing power outages, increasing overall efﬁciency of power systems and supplementing alternative sources of energy according to user preferences. Because of these promising advantages, P2P DET has attracted the attention of several researchers. Current research related to P2P DET include demand response optimization, power routing, network communication, security and privacy. This paper presents a review of the main research topics revolving around P2P DET. Particularly, we present a comprehensive survey of existing demand response optimization models, power routing devices and power routing algorithms. We also identify some key challenges faced in realizing P2P DET. Furthermore, we discuss state of the art enabling technologies such as Energy Internet, Blockchain and Software Deﬁned Networking (SDN) and we provide insights into future research directions.


Background and Motivation
Traditionally, non-renewable energy sources such as coal, oil and natural gas have been the main sources of energy.However, non-renewable energy sources are being depleted and becoming more expensive from time to time which indicates that the energy from these sources will not be able to support the increasing demand caused by a growing population [1].Moreover, non-renewable energy sources are not environmental friendly as they cause high level of carbon emissions.All these factors have motivated the emergence of various kinds of renewable energy sources (RES) such as solar panels and wind turbines.RES cause less pollution and are also more economical than their counter parts as they reduce transmission cost [1].In addition, RES help reduce the burden imposed on the main grid by supplying a proportion of the demand through locally produced and consumed energy.The expansion of renewable energy resources opened the door for a competitive P2P DET between small scale prosumers and end customers.Consequently, it is expected that P2P DET will be one of the most important element of next generation power systems.
P2P DET trading enables everyone to engage in energy exchange without relying on a central utility company.Distributed energy exchange can create a competitive energy market that is not monopolized by few utility companies bringing profit to small scale energy producers and consumers [2].Moreover, distributed energy trading can also reduce power outages by providing alternative local energy sources during a power outage from the central utility provider.P2P DET also allows customers to have access to a wide range of alternative sources of energy according to their preferences.Furthermore, energy trading also brings various benefits to utility companies such as increasing the overall efficiency of the grid and reducing operation cost [1].However, the realization of P2P DET depends on the availability of several important aspects such as demand response optimization, power routing, public energy market, money transaction mechanisms and efficient communication networks.

Issues Related To P2P DET
Maintaining the balance between supply and demand is an important criterion for the security and reliability of power systems.Mismatch between supply and demand may lead to system instability and failure [3].In existing systems, demand response optimization is usually performed though load scheduling and price optimization mechanisms under the control of one central entity [3][4][5].In P2P DET, power is generated in a distributed manner and is controlled by several producers.Moreover, power generation is highly unpredictable as it depends on RES that are affected by weather conditions.Therefore, achieving demand response optimization is more difficult for P2P DET as compared to existing systems.As a result, new methods of energy scheduling and price optimization algorithms based on game theory, collaboration, incentives and centrally controlled models have been proposed by several studies [6][7][8][9][10][11][12][13][14][15][16].
The other essential service required for P2P DET is power routing [17,18].This is a mechanism that allows energy routing between prosumers and consumers residing in different geographical locations.However, existing systems do not provide this functionality.Moreover, power routing in distributed systems is more challenging due to integration problems as it might require power conversion from one form to another.Power routing has gained considerable attention from the research community.Existing work related to this topic involves development of power routing devices and power routing algorithms.In [17][18][19] the authors proposed power routing devices and algorithms for routing power similar to data packets.However, requirements for power routing are different from data packet routing as best effort delivery is not suitable for power routing since lost power signals cannot be resent.
Future energy trading is expected to include all types of energy other than electrical energy.This requirement has led to a new research area known as Energy Internet.Energy Internet [20] is a new concept that aims to provide an energy trading platform that integrates all types of energy sources.In short, Energy Internet is the Internet of energy systems.Power routers are believed to be the core elements of the Energy Internet providing two-way communication and bi-directional power flow.Power routers need to exchange information and cooperate with each other to achieve global stability in the power system.This requires effective management of networked power routers, dynamic routing configurations and efficient communication and coordination among power routers.Earlier studies proposed SDN as a good solution to manage the complex networking architecture of existing smart grids systems.SDN is an emerging networking technology that provides greater flexibility for dynamically configuring and managing communication networks by using a centralized software controller via open application programming interfaces.However, integration of SDN with power routers and Energy Internet has not been fully investigated.
There are additional key challenges which need to be addressed to support P2P DET.First, as P2P DET is based on a two-way communication network, this might expose the system to various types of security and privacy threats which can harm the confidentiality, integrity and reliability of the system [21][22][23][24][25].Furthermore, P2P DET can take place in a public market where energy contracts are posted publicly to allow everyone to participate in the market.Plug-in electric vehicles (PEVs) are also one of the main challenges to P2P DET.PEVs are mobile entities which are not situated in a fixed location.Hence, they dynamically enter the market for a short period of time and leave as they move from one place to the other.An appropriate authentication method and power flow control mechanism is required to allow PEVs to securely participate in the market dynamically [26][27][28].
To this end, Blockchain [29] is believed to be the most promising technology to provide security and privacy in distributed energy trading.Blockchain is an emerging technology that allows making public contracts and transactions over peer to peer distributed networks without compromising the security and privacy of users.

Contribution
Even though there is a rich source of literature on various topics revolving around energy trading as mentioned earlier, a comprehensive literature survey that covers many of these topics has not been done so far.Therefore, in this paper, we provide an extensive literature survey that brings together the various research topics surrounding P2P DET.We cover topics including demand response optimization models, power routing, PEVs and security and privacy.A classification diagram that briefly illustrates the topics covered in this survey paper is shown in Figure 1.In addition, we also discuss state of the art enabling technologies and give insights into future directions.
The rest of the paper is organized as follows: Section 2 presents the architecture of P2P DET.Section 3 discusses demand response optimization models.Power routing is explained in Section 4. Section 5 reviews challenges in P2P DET.State of the art enabling technologies are presented in Section 6. Section 7 provides a discussion of past works and future directions.Section 8 summarizes and concludes the paper.
Energies 2018, 11, x FOR PEER REVIEW 3 of 21 public contracts and transactions over peer to peer distributed networks without compromising the security and privacy of users.

Contribution
Even though there is a rich source of literature on various topics revolving around energy trading as mentioned earlier, a comprehensive literature survey that covers many of these topics has not been done so far.Therefore, in this paper, we provide an extensive literature survey that brings together the various research topics surrounding P2P DET.We cover topics including demand response optimization models, power routing, PEVs and security and privacy.A classification diagram that briefly illustrates the topics covered in this survey paper is shown in Figure 1.In addition, we also discuss state of the art enabling technologies and give insights into future directions.
The rest of the paper is organized as follows: Section 2 presents the architecture of P2P DET.Section 3 discusses demand response optimization models.Power routing is explained in Section 4. Section 5 reviews challenges in P2P DET.State of the art enabling technologies are presented in Section 6. Section 7 provides a discussion of past works and future directions.Section 8 summarizes and concludes the paper.

Related Work
Several published papers discussed various aspects of P2P DET [1,[30][31][32][33].The authors in [1] provided a high level overview while not covering most recent research problems.The article in [30] presented a review of current industry level energy trading projects.However, the paper was not intended to discuss research papers but rather to give information about current related industrial projects.Another review paper [31] discussed peer-to-peer (P2P) communication architectures for prosumers' energy trading and sharing.They compared the performance of the structured and unstructured P2P architectural models for P2P DET.The paper also evaluated the performance of common P2P protocols considering the stringent communication requirements of energy networks to determine their suitability for P2P DET networks in various situations.Research done in [32] performed a comparison of five P2P DET projects based on their business models including both recently commercialized services and pilot services.The study identified the potential development and future challenges based on the business model characteristics of each case.
A recent and more detailed existing paper on P2P DET is [33].The authors provided an overview of the use of game theoretic approaches for P2P energy trading as a feasible and effective means of energy management.The study first provided an explanation to the key features of P2P trading network and also presented a review of existing P2P DET testbeds.The paper then presented specific game and auction theoretic models which have recently been used in P2P DET.The main goal of the article was to provide the reader with an understanding of how to use game theory in P2P energy trading paradigm and its potential benefits.The paper focused on the application of game theoretic models for P2P DET but did not address several other related topics as discussed in this paper.The work done in this paper covers several topics which have not been considered by others papers including demand response optimization models, power routing, architecture models, PEVs and security and privacy.

P2P DET Architecture
P2P DET is an energy trading system in which entities in the power system can exchange power with each other in a peer to peer mode without the involvement of central entity such as utility companies [32,33].The P2P DET system consists of various entities such as consumers, prosumers, microgrids and the utility grid itself.Prosumers are consumers who can also produce their own energy in small scale.They are equipped with small scale RES such as rooftop solar panels and wind turbines.When prosumers have surplus energy, they can sell it to other parties in the power grid.To make up for any shortage, they can buy electrical energy from neighboring prosumers or micrgrids or the utility company.Similarly, microgrids could do the same with consumers, prosumers or other microgrids and the utility company.
It is quite challenging to define a standardized model for P2P electrical energy trading as it made up of a complex set of technologies and infrastructures.Different types of P2P DET architectures have been devised by various studies [30,[34][35][36][37][38].The studies [30,34] suggested a hierarchical P2P DET model.Power systems are hierarchically arranged in such a way that microgrids consisting of several end customers are connected to a distribution system and multiple distribution systems are connected to a transmission network.Because of this hierarchical nature, P2P DET is expected to be carried out in three hierarchical levels [30,34].A typical P2P DET architecture that shows the different levels of energy trading is presented in Figure 2. Level 1 P2P DET takes place between peers in the same microgrid (within microgrid or intra microgrid).A microgrid consists of different customers (e.g., home users, industry users, PEVs etc.), power generating units such as wind and solar power and power storage units.A microgrid can also consist of prosumers.Level 2 energy trading is carried out between multiple microgrids in the same distribution network (also known as within a cell or inter microgrid).The papers [30] and [34] define a group of microgrids within the same distribution network as a cell.Energy trading can also take place at the distribution system level (between multiple cells) i.e., among users or microgrids in different distribution networks.The three levels of energy trading are further illustrated in Figure 2.For example, energy trading between customer C 6 and prosumer P 3 is an example of an intra microgrid trading.On the other hand, if this takes place between C 4 and P 1 or MG 11 and MG 1K , it is called inter microgrid.Examples of distribution level trading include: P 4 vs.C 3 , C 4 vs.MG N1 , MG 11 vs. MG N1 etc. P2P DET is considered to be at an early stage and is being investigated currently only at the microgrid level.Inter microgrid and distribution level P2P trading has not been discussed or implemented so far.Existing industrial projects on P2P energy trading are also at the microgrid level as discussed in details in [30].
Energies 2018, 11, x FOR PEER REVIEW 5 of 21 between C4 and P1 or MG11 and MG1K, it is called inter microgrid.Examples of distribution level trading include: P4 vs. C3, C4 vs. MGN1, MG11 vs. MGN1 etc. P2P DET is considered to be at an early stage and is being investigated currently only at the microgrid level.Inter microgrid and distribution level P2P trading has not been discussed or implemented so far.Existing industrial projects on P2P energy trading are also at the microgrid level as discussed in details in [30].The authors in [35] and [36] proposed a four-layer model of P2P DET to explain the design and interoperability aspects for the components of P2P DET.The hierarchical process of P2P DET is categorized into four interoperability layers that include business layer, control layer, Information and Communication Technologies (ICT) layer, and power grid layer.The paper [37] proposed a distributed business model that gives solutions to P2P electricity trading, P2P grid control and distributed ICT.The model divides the power system into three planes (trading plane, control plane and market plane) that provide services of electricity trading, grid control and wireless communication enabling the proposed P2P operation.

Demand Response Optimization Models
In power systems, consumer demand varies from time to time.If this variation in demand is not balanced by an equivalent supply response, peak hour load can cause frequency deviation from nominal values which may lead to a system failure.Different techniques are implemented by utility companies to alleviate peak loads and maintain this balance.The straight forward approach is to either use stored energy that was collected during off-peak hours to alleviate peak demands or to adjust the operation of power generating units so as to generate extra power or absorb power depending on the situation.However, this approach usually results in huge operational cost and low efficiency due to underutilization [3].Therefore, power companies usually try to keep the balance The authors in [35] and [36] proposed a four-layer model of P2P DET to explain the design and interoperability aspects for the components of P2P DET.The hierarchical process of P2P DET is categorized into four interoperability layers that include business layer, control layer, Information and Communication Technologies (ICT) layer, and power grid layer.The paper [37] proposed a distributed business model that gives solutions to P2P electricity trading, P2P grid control and distributed ICT.The model divides the power system into three planes (trading plane, control plane and market plane) that provide services of electricity trading, grid control and wireless communication enabling the proposed P2P operation.

Demand Response Optimization Models
In power systems, consumer demand varies from time to time.If this variation in demand is not balanced by an equivalent supply response, peak hour load can cause frequency deviation from nominal values which may lead to a system failure.Different techniques are implemented by utility companies to alleviate peak loads and maintain this balance.The straight forward approach is to either use stored energy that was collected during off-peak hours to alleviate peak demands or to adjust the operation of power generating units so as to generate extra power or absorb power depending on the situation.However, this approach usually results in huge operational cost and low efficiency due to underutilization [3].Therefore, power companies usually try to keep the balance between supply and demand through load scheduling and price based optimization [3][4][5].Load scheduling refers to planning customers' power consumption times according to the required demand and available supply.It can be performed either by the utility operator or by the customer itself.In existing systems, load scheduling is achieved through various methods including interruptible load, direct load control (DLR) which allows the power company to manipulate customer appliances and demand side bidding (DSB) where the customer is allowed to prepare a bid [4].In most cases, the customer is incentivized based on predefined rules.In price optimization methods, the utility company tries to indirectly force the user to postpone peak time demands to off-peak hours by imposing a high price rate for peak time consumption.
In traditional power systems, load scheduling is managed by a single centralized entity.Accomplishing this task gets harder with a distributed power system as power is generated and injected into the system in a decentralized manner by several distributed energy sources including mobile PEVs.Moreover, power generation from distributed renewable energy sources such as wind and solar is highly unpredictable as it depends on factors such as weather conditions [39].In such kind of system, it is difficult to predict who will produce what amount of energy and the percentage of energy to be consumed or sold to others.Therefore, achieving demand response optimization is more difficult for P2P DET as compared to existing centralized system.Understanding this gap, researchers have tried to come up with better methods of energy scheduling and price optimization algorithms such as: game theoretic based, collaborative based, and incentive based in addition to centrally controlled models.The centralized approach requires customers' information to be sent to the central controller leading to privacy concerns.The following subsections are dedicated to explaining these various models.

Centrally Controlled Models
Centrally controlled models rely on central entity that acts as mediator between different producers and consumers.The authors in [6] proposed an optimization model that optimizes energy trading between two islanded microgrids (microgrids which are disconnected from the main grid) based on a central controller.The model aims to satisfy the local power demand of each microgrid while minimizing energy generation and transportation cost.The model also proposed a distributed approach.However, it works only for two microgrids.The paper in [7] suggested pricing based optimization algorithm for local smart micro-grid energy trading that is controlled by a local trading manager (LTM).The LTM sets a local price that is different from the price given by the utility company in order to benefit local prosumers, consumers as well as itself.The model proposed two optimization algorithms.The first one models how producers and consumers adjust their energy demand schedules in response to price changes made by the LTM and the second one models how the LTM finds optimal prices that maximizes the profits of all stakeholders including energy producers, consumers and itself.The same authors extended this idea in an article [8] proposing a price optimization algorithm for a hybrid energy trading market that consists of a utility company and a local trading market controlled by a local trading center (LTC).In the extended model, two types of LTC are considered: a nonprofit-oriented LTC which only works to benefit local producers and consumers and a profit-oriented LTC which aims at maximizing its own profit as well as the profit for all other participating entities.An algorithm that allows finding the optimal energy scheduling for each producer and consumers as well as the optimal price for the LTC is proposed for both cases.

Incentive-Driven Models
Incentive-driven models encourage users by providing them with incentives for their continuous participation and contribution to the demand response optimization process.The authors in [9] proposed an incentive based renewable energy sharing mechanism to enable users with surplus energy to share their energy with other users who need it at the current time and vice versa so that the total utilization of surplus green energy is maximized.The method allows energy trading among several users simultaneously.The grid operator coordinates energy sharing by matching supply and demand between sellers and buyers as well as by providing the infrastructure for energy routing.Moreover, the grid also acts as a middle man for communication so that users can engage in energy sharing without revealing their identities to each other for privacy reasons.The model provides fair energy sharing among users.
However, the benefit of the smart grid operator, which provides the platform for users to sell and buy their surplus energy, is not explicitly mentioned.Fairness is an important criterion for effective energy trading.In [10], it has been shown that fairness leads to higher happiness of users and higher energy efficiency.A survey of incentive based energy management schemes adopted for energy trading was performed in [11].The authors classify incentive based demand side management into four categories: pricing, bargain, auction and contract theories.The authors also proposed a cloud-based vehicle-to-vehicle energy exchange framework and an optimal contract based electricity purchase scheme to provide efficient electric vehicle charging service and to reduce electricity transmission cost.The proposed theoretical scheme was verified through simulations.

Cooperative Based Models
Cooperative based models involve many producers and consumers working together for their mutual benefit.Researchers in [12] proposed a cooperative distributed energy generation and trading system that allows a group of prosumers having the capabilities of energy generation and energy storage to trade energy in a cooperative manner with the objective of minimizing their total energy-provisioning cost while ensuring the local demand of each individual prosumer.Two different optimization algorithms are proposed; one for energy scheduling and the other for calculating transaction cost (optimal charges and payments) associated with energy trading.The model first finds the optimal energy schedule that minimizes the total energy-provisioning cost for all prosumers.Next, the optimal transaction cost for each prosumer is determined such that each user gets appropriate benefit from its cooperative generation and energy trading.
The paper [13] suggested a cooperative energy trading scheme that allows a base station (BS) having local renewable energy to perform energy trading with the main grid based on coordinated multi-point (CoMP) communication powered by smart grids.The proposed model attempts to minimize the energy cost of cellular systems by providing an algorithm that allows the BS and the smart grid to jointly manage the two-way energy trading.The demand from BS varies over time due to the fluctuation in power generated from renewable energy sources.The proposed model allows the BS to sell electricity to the grid when the power generated from renewable energy sources is excess and to buy power from the grid when the production is low.

Game Theoretic Models
Game theoretic approaches are the most widely employed techniques for demand response management in energy trading.The problem of energy trading is modeled as a Multileader multi-follower Stackelberg game in several studies such as [14][15][16].The study in [14] proposed a multi-leader multi follower non-cooperative Stackelberg game based energy trading scheme for energy trading between multiple plugin hybrid electric vehicles (PHEVs) and microgrids.The model decides the optimal amount of energy to be consumed by the PHEVs and the price per unit energy to be charged by the micro-grids.The PHEVs act as a leader and decide the energy demand whereas the micro-grids act as follower and decide the price of energy.The model achieves a generalized optimal Nash equilibrium as verified theoretically and evaluated by simulations.However, the model does not account for mobility of PEVs as well as security and privacy.A Non-cooperative multi-leader multi-follower Stackelberg game model was proposed by [15] to manage distributed energy trading for multiple interconnected microgrids.Microgrids which want to sell energy lead the competition by deciding the amount of energy to sell based on the profit gained if the energy is sold at that time or stored for later use.Buyers follow the sellers by independently submitting a price bid to the sellers.Energy and revenues are shared among buyers and sellers respectively according to the proportion of their contributions.Analysis result showed that the model is guaranteed to converge to equilibrium that can maximize the payoff for all participating microgrids.
A study by [16] proposed an energy trading framework for finding the Nash equilibrium for energy trading among several microgrids which are connected together through a central entity that mediates the process of energy trading decision.The approach assumes that the trading strategy of each microgrid is hidden from others and no information concerning the distribution of payoffs is available a priori.Therefore, microgrids exchange information through the central entity so as to protect their private trading strategy.The model is based on reinforcement learning and multi-leaders and multi-followers Stackelberg game to model energy trading interactions between microgrids.Seller microgrids take the role of leaders while buyer microgrids follow the sellers.The sellers randomly select an arbitrary strategy and send their decision to the central entity.The central entity collects energy information from all sellers and sends messages to all buyers.Each buyer chooses its price action using the learning algorithm and sends it to the central entity.The central entity calculates the payoffs and allocates the amount of energy from each seller to all buyers according to the proportion of their offered bids.
The study in [40] suggested a coalitional game to derive the optimal price of electricity for energy trading between small scale energy producers and consumers where the Shapley value is used as a means for deriving the price of electricity that achieves a fair division of revenue.In the model, it is assumed that an independent agent manages the electricity trading between small scale sellers and buyers.The agent determines real time electricity pricing and announces it to all participants.The demand and supply information of each individual participant is not required to determine the price; rather the price is determined based on statistical demand and supply information and the number of participants in the market.The demand and supply of each participant is modeled as random variable by using statistical information.The agent also manages trading between the local participants and utility power suppliers.The income gained from trading between local participants and the utility company will be shared among all participants.Simulation results showed that a fair distribution of profit can be achieved among participants according to their contribution.
The authors of [41,42] proposed a game theory based distributed energy trading algorithm that allows consumers to buy energy from neighboring producers at a lower price than that of the utility company.Each seller may decide its selling price and set its preferences.Consumers play a game to select the best sellers to minimize their energy bill.The selection is performed based on the energy price and the transmission cost incurred for transporting the energy through the grid network.The transmission cost depends on the geographical location of the sellers and buyers and the capacity of the transmission links between them.Simulation results were performed and the results showed that the proposed algorithm can minimize energy bills of consumers and increase profits of sellers.Performance results showed that the proposed algorithm gives a near optimal solution.Moreover, the algorithm converges after few number of iterations.
The study in [43] proposed a non-cooperative game theory based algorithm for energy trading between multiple prosumers and a power company.Prosumers play the game to fulfill their energy demands at a minimum cost by optimally utilizing their storage units and renewable (wind) energy sources.Prosumers have to declare the amount of energy they wish to purchase or sell to the power grid at the start of the day.There is a tradeoff between the profit gained from selling energy and the penalty incurred by failure to meet the declared amount of energy because of uncertainties in energy generation from wind turbines.Uncertainty in energy generation was modeled using Gaussian probability distribution.
In [44], a contract game theory energy trading model is proposed for several sellers and a single consumer in the presence of (asymmetric information) i.e., buyers and sellers do not have full information about each other.Getting sellers related information is important for energy trading because the decision whether to buy or not depends on factors such as reliability and transmission cost.In the model, the consumer prepares a contract that describes the amount of electricity demanded and the associated payment.Sellers are stimulated to select the contract that best fits their production types in order to get maximal benefits.The model can get the optimal contract for deterministic generation where the supply of RESs is deterministic i.e., sellers know the exact amount of energy they can supply ahead of time.The authors also extended their work to the case where the supply by sellers faces uncertainty due to the unpredictable nature of renewable energy sources.In this case, an optimal contract is not achieved.
Another game theoretic approach is proposed by [45] to model the interaction between local prosumers that compete to sell their energy to other users.Each prosumer aims to maximize its revenue by appropriately selecting the price offered by buyers and the generation capacity.The generation capacity and the selected price depends on the marginal cost of the prosumer and the offered price.The consuming user on the other hand acquires a lower price compared to the price advertised by the utility company as a result of the competition between multiple local producers.The problem of selecting the offered price and deciding on the generation capacity is formulated as a linear mixed-integer program.Simulation results showed that prosumers are able to sell their excess energy to local users at a higher price than the buying price of the utility company.Moreover, consuming users could also buy energy from prosumers at a price lower than the selling price of the utility company.
A recent work by [46] proposed a retail electricity market based on game theory for the optimal operation of home microgrids within active distribution networks.A non-cooperative gaming approach which uses the Nikaido-Isoda Relaxation Algorithm is utilized to achieve an optimal solution.This model supports any number of traders and it considers three different types of players (generator, consumer, and retailer).Moreover, the authors tackled the problem of uncertainty of generation and demand using statistical models.A simulation study showed that the proposed method is able to lower the market clearing price by 4%, increase consumption responsive by a factor of two, and promote local generation by a factor of three.The summary of existing work on demand response optimization models is shown in Table 1.The table shows the references, the specific techniques employed, the level of energy trading, privacy and mobility considerations.

Power Routing
P2P DET involves transporting power from a source (seller) to a destination (buyer) which may be geographically located far away from each other.To accomplish this task, power routing devices should have the capability to understand location addresses and support bi-directional routing functions that switch power from one location to another.Moreover, power routers should be able to convert power from one form to another as future power systems will incorporate distributed heterogeneous power sources (e.g., wind, solar, existing system etc.) that generate power having different characteristics (e.g., frequency, phases, voltage level etc.).Furthermore, the requirement for power routing algorithms could be more as compared to traditional data packet routing.Data packet routing algorithms work on best effort delivery basis where packets can be resent if not successfully delivered.However, this does not work for power routing as power signals cannot be recovered once lost.In addition, long transmission leads to loss of energy.The existing power system does not support these functionalities.Thus, a number of researchers have been recently working to address these problems.The papers [47,48] studied the feasibility of power packet dispatching where electric energy is treated like data packets.These two studies found that switching power in the form of packets is possible.Most of the other studies conducted on this area include power routers [17,[49][50][51], power routing algorithms [19,[52][53][54][55][56][57][58] and architectures [59][60][61].The next two subsections discuss power routers and power routing algorithms in details.

Power Routers
Recent studies that have been concerned with power routers include [17,[49][50][51].Abe et al. [17] proposed a power router that segments the synchronized wide-area power grid into smaller asynchronous grids which are connected together using multiple IP addressed ACs/DC/ACs converters called Digital Grid Routers.The existing power grid works in a synchronous manner where the power flow depends on the impedance within the grid.The integration of distributed renewable energy sources to the main grid increases the complexity of fluctuating impedance as the generated energy fluctuates dynamically.The current smart grid system attempts to resolve these problems by performing synchronization between the RESs and the main grid.
As more RESs are penetrating the market, new high capacity transmission lines are being added to support grid synchronization and improve reliability through redundancy.However, these additional transmission lines are not only very costly but also increase the grid's short circuit capacity leading to the risk of wide area failures [17].This makes the management of power flow increasingly difficult.Thus, Reference [17] proposed a digital grid scheme where the traditional power system is subdivided into small asynchronous mini-grids called cells by using the concept of a Digital-Grid-Router (DGR).
The DGR isolates each cell from the main grid and allows each cell to have its own frequency that is different from the main grid which provides the flexibility to operate the RESs independently without worrying about synchronization with the main grid.Moreover, a DRG can send energy signals as power packets over transmission lines to any location similar to that of data packets.It achieves this function by using back to back AC-DC-AC bidirectional digital converters, with high frequency modulation, combined with IP address information.Within the subdivided cells, digital grid controllers (DGC) coordinate with DGRs to absorb, consume and generate the discrete power packets.The power packets through DGRs and DGCs can be identified by using attributes such as location, time, generation source, price etc.Digital grids are a promising solution to solve power routing.However, there are only few studies conducted on digital grids from the context of distributed energy trading [62].
The authors of [49] proposed a power router to be used in an active distribution network (ADN) based on multi agent system (MAS) technology.ADN is defined as a flexible distribution system that can handle challenges of distributed generation which demand a horizontal control structure as opposed to the traditional power system which employs vertical control hierarchically.The proposed power router is applicable to distribution level only and does not support IP addresses.Another paper [51], proposed an architecture and load flow model for power flow routers (PFRs).The load flow model captures the operating principle of PFRs and the optimal power flow (OPF).The performance of the PFR such as decoupled branch power flows and enlarged flow regions are analyzed based on the load flow model.Similar to that of [49], the proposed router does not support digital power packet transmission and IP addresses.The paper in [63] performed simulation and experimental analysis to prove the validity of the concept of a single phase intelligent power router similar to that proposed by [17].However, unlike that of [17], the router used in this experimental study works for smaller cells focused on distribution networks only.The experimental results showed that the concept is valid and applicable.

Power Routing Algorithms
In P2P DET, an efficient power routing algorithm is necessary to deliver energy from the source to the destination in a cost effective manner [18].The paper [53], proposed a secure energy routing mechanism for houses in smart microgrids that are interconnected with each other with energy routers.Information and energy flows from one house to another through these energy routers.The proposed mechanism enables energy routers to exchange end users' energy information securely to prevent attacks such as spoofed route signaling and fabricated routing messages.Moreover, the approach provides a method that finds an energy efficient path through which energy is shared among houses.
Power routing could cause congestion in the power grid due to uncertainties in renewable power generation, bidirectional power flow, and dynamic changes in the demands from customers.Therefore, the power flow inside power systems needs to be controlled to avoid congestion.This problem of power flow management is known as the optimal power flow (OPF) problem.The study in [52] suggested a distributed power routing algorithm based on successive shortest path and cost-scaling push-relabel (SPR) algorithms to address the OPF problem in an active distribution network.The algorithm supports self-stabilizing and self-healing functions in response to variations in demand/supply, cost or topology.The same authors proposed a power routing function to solve the optimal power flow and achieve maximization of transmission reliability, minimization of the operating cost and maximization of services for priority customers [54].The SPR algorithm is used to find the minimum cost flow.The algorithm assumes a MAS environment considering each power router in the distributed power system as implementing an agent software.The performance of the algorithm is evaluated using simulation and the results showed that the proposed system is flexible in dealing with load demand increases and network topology changes.
The paper [55], discussed the concept of an ad hoc nanogrid model managed by a distributed power routing algorithm.A nanogrid is considered as an isolated microgrid that is able to operate independent from a central utility company.The nanogrid consists of power generators, loads and intelligent power routing nodes known as smart nodes that manage the power routing in the nanogrid using a distributed routing algorithm.The smart nodes communicate and cooperate with each other using an ad hoc wireless network to ensure that all connected loads receive the required amount of power and power sources are not overloaded.The power packet structure developed by earlier studies includes header and footer bits to be used for distributing the packet through the network.However, the footer in the packet had extra load which could be reduced to increase efficiency of the system [19].The authors in [19], proposed an improved power packet format and power routing algorithm that can transfer power packets with less footer as compared to previous studies.The proposed method aims to reduce transitional switching loss which can improve the utilization of transmission and can reduce the capacitor size.
The article in [56] suggested a game theory-based energy routing algorithm for a smart microgrid network.The proposed algorithm applies a two-step method to enable efficient energy routing.First, a stock exchange pricing scheme is used to determine an optimal transaction price based on supply and demand information of each node to maximize the profit of each participant.Next, the algorithm utilizes an optimization scheme to find the shortest route using a similar approach used to solve transportation problems by treating the energy sale and purchase quantities as transportation supply and demand.Simulation test showed that the algorithm achieves desired functions.However, no performance comparison is performed with other methods.A power dispatching protocol that divides the operation of a packetized router into three different functions including subscriber matching, transmission scheduling and power packet transmission is proposed by [57].Subscriber matching involves matching between energy producers and consumer based on power requirements of consumers and generation capacity of producers to maximize their mutual benefits.The authors proposed a matching theory based deferred acceptance algorithm to achieve a stable matching and a heuristic transmission scheduling algorithm to optimally balance the supply and demand.The effectiveness of the proposed algorithm in subscriber matching and fair scheduling has been shown through simulations.However, the proposed algorithm only works for local energy network.
A graph-theory based energy routing algorithm is proposed by the research in [58] for energy local area network (e-LAN).The method adopts the concept of the Open Shortest Path First (OSPF) protocol and virtual circuit switching for designing a lowest cost routing selection algorithm.According to the article, energy routers cannot store lowest cost path routing tables as that of Internet routers as energy transmission is demand driven and the source of energy is not specified ahead.Instead, routers are required to store power information tables about all the devices, energy routers, and power links.Hence, each time a load is connected to the network, information about its power demand is sent to the nearby energy router.Therefore, the paper suggests dynamic routing algorithm based on OSPF to adapt to the change of the network topology and frequent connect/disconnect of devices.The algorithm determines the lowest cost route according to the features of power transmission and the power sources selected.Virtual circuit has been suggested as a better choice for energy transmission than datagram mode.In datagram mode, the routing path for each packet could be different from the other.This requires that power converters along the old path to shut down and the converters along the new path to start up.Such frequent shutdowns and startups could lead to power losses and deterioration in the reliability of the system.Hence, virtual circuit mode which does not require frequent path change has been selected as a promising method than the datagram mode.

Key Challenges in P2P DET
The two most important challenges in P2P DET are security and privacy of involved entities, and mobility issues related to integrating PEVs into the power grid system.In this section, we discuss these two main challenges.

Security and Privacy Challenges
The deployment of distributed energy exchange system based on the existing smart grid architecture suffers from various security and privacy problems.Entities participating in distributed energy trading need to communicate with each other for various reasons including demand response optimization, negotiation of energy prices, publishing/invoking energy contracts and performing payment transactions.This exposes the system and users to various security and privacy shortcomings such as confidentiality, integrity and availability attacks.As indicated by various studies [21,22,64], security vulnerabilities include: submission of fake contracts, double spending of energy or money, modification of transactions, possible Denial of Service (DoS) attacks on P2P DET systems, etc. Privacy problems on smart grid users are discussed in various studies [23,25,65,66].In addition, the location privacy of PEV users is critical as the location of the PEV can be identified based on the location of the charging station [24].Therefore, P2P DET system should be equipped with the necessary security, privacy and payment transaction mechanisms to guarantee proper operations and fairness.Even though security and privacy of the existing smart grid system has been discussed by several researchers, only few papers considered security and privacy with respect to P2P DET [22,67].

Mobility Challenges in PEVs
In traditional power systems, users consume power from fixed location (their home, office, business ... etc.).Therefore, power is delivered to that known location and users are also billed based on the power consumed at that fixed location.This approach does not work for PEV charging/discharging. PEV users are mobile and are assumed to be charging/discharging not only at their own home but also outside their home such as at a friend's house, public street charging point, private charging station, work place charging point, etc. Charging outside one's home is known as roaming charging.Roaming charging can further be divided into two categories: Internal roaming charging (IRC) and external roaming charging (ERC) [26][27][28].If the user charges outside his home but at a charging location that belongs to the same supplier as the user's home supplier, we call it IRC.However, if the user charges at a charging location that resides outside his home supplier network (in an external supplier network), we refer to that as ERC.As a result, PEVs need to participate in P2P DET dynamically for a short period of time as they move from one place to another.This mobility nature of PEVs poses another challenge to P2P DET.A proper authentication method as well as an appropriate energy flow control mechanism is required to allow PEVs charging or selling power by discharging power back to the grid [26][27][28].Moreover, authentication and payment mechanisms should be equipped with appropriate privacy preserving techniques to protect user's privacy from charging stations and external supplies.One other issue related to integrating PEVs to P2P DET is the impact of discharging on the PEV battery life.Studies have shown that frequent discharging/charging may cause up to three years of degradation in the life of a PEV battery [68].Nevertheless, research is currently being conducted to address this problem [68,69].
There are a limited number of studies conducted on P2P DET for PEVs [70,71].The article [70] proposed a P2P trading system that allows PEVs parked in the same area to trade with each other with the help of an aggregator that collects all the available offer/demand information among vehicles and determines an optimal peer-to-peer price per area and per time slot.However, the study does not satisfy most of the prerequisites mentioned earlier including mobility, security and privacy.Moreover, the trading takes place only between local PEVs.The work [71] came up with a localized Peer-to-Peer (P2P) electricity trading model for locally buying and selling electricity among Plug-in Hybrid Electric Vehicles (PHEVs) in smart grid.The model uses a consortium Blockchain to address transaction security and user privacy where local aggregators serve as miners to process transactions.The proposed work has attempted to address security and privacy as well as mobility.However, the platform is limited to local PHEVs and does not include other types of traders.

Enabling Technologies
In this section, we discuss three enabling technologies for future P2P DET systems: Energy Internet, SDN and Blockchain.

Energy Internet
The smart grid system accommodates only one type of energy i.e., electrical energy.However, energy can also be generated from other types of sources such as chemical, thermal and electromagnetic.Next generation energy trading will not be limited to just electrical energy and will incorporate all types of energy sources.The new power system that results from this interconnection is known as Energy Internet.Energy Internet [20] is envisioned to be the Internet of energy networks that integrates all forms of energy sources together in an open interconnection similar to the Internet we all know.Moreover, Energy Internet is expected to provide flexible energy scheduling, two-way power flow, power conversion and routing functionalities which are not available in the existing smart grid systems [72].A typical Energy Internet system consists of information and communication technologies and energy layers which are connected together by energy routers such as the digital grid [72][73][74].According to [72], the energy router is the most important element of Energy Internet enabling both energy and data flow forwarding.Energy Internet is one of the promising technologies for P2P energy trading and its importance in that regards has been discussed in [75].However, Energy Internet is an emerging system which has not been standardized and its associated concepts have not yet being well established making it an interesting area for future investigation.

SDN
Power routers such as the digital grid router plays an important role in enabling P2P DET by providing key functionalities including bidirectional power flow, power conversion, routing and transmission scheduling.However, effective management of networked power routers, dynamic routing configurations and efficient communication and coordination among power routers is very essential to achieve global stability in the power system.SDN has been proposed by several researchers as a possible solution to manage the complex networking architecture of smart grids [76][77][78][79][80]. Unlike traditional networking systems that work based on decentralized control and static configurations, SDN networking allows centralized control and dynamic configurations of network devices and systems.SDN achieves this by separating the network forwarding process (Data plane) from the decision making process (Control Plane).The Control Plane is placed as part of a centralized software controller.The centralized software controller allows management of several network devices from a single point and dynamic network configurations though open application programming interfaces.Earlier studies mainly suggested SDN based networking for better performance and to achieve desired QoS in existing smart grid systems, but did not discuss the management of power routers.
Recently, the authors in [18] suggested an SDN based networking architecture for digital grids routers and the authors in [11] indicated that SDN can be applied in energy trading to effectively support energy scheduling and optimize customer demands.We believe that an SDN-based communication network can allow easy management of power routers, dynamic routing configurations, better energy optimization and scheduling.Moreover, novel efficient routing algorithms need to be developed to enhance the performance and quality of energy trading.

Blockchain
Blockchain is an emerging technology that has the potential to fulfill security, privacy and payment transaction requirements in distributed energy trading [29].Blockchain allows the exchange, verification and storage of information publicly in a distributed manner using a peer to peer communication network.Blockchain prevents information from being forged and provides traceability of historical activities and user anonymity without the need to rely on trusted third parties [81].Users in a Blockchain are identified using their cryptographic public keys instead of their real identities which provides a great level of anonymity but not full anonymity as it is based on pseudonym.Pseudonym based anonymity can be defeated by linking a user's activities, such as time of use, usage pattern, network ID/location etc. to inference more sensitive information [82].Nevertheless, the anonymity based weakness of Blockchain can be enhanced by using zero knowledge proof techniques such as the ones explained in [82,83].In addition, Blockchain facilitates electronic contracts between distributed energy traders and consumers through what is known as smart contracts.Moreover, Blockchain can support energy trading of PEVs dynamically entering and leaving the smart grid network.These characteristics make Blockchain a good candidate for serving the distributed energy exchange market.There exist a limited number of works that associate distributed energy trading with Blockchain.However, Blockchain as a new technology integrated as part of smart grid systems is not yet well explored.Moreover, regulations in many countries do not recognize Blockchain based peer to peer energy markets [2].Hence, market regulations need to be modified before such kinds of energy markets can be implemented.

Smart Contracts
Smart contracts are an important element of Blockchain that are envisioned to change the traditional way of contract execution for many application areas.Smart contracts are computer programs that securely reside on the Blockchain and automatically execute the terms of a contract [84,85].Taking the advantage of the Blockchain technology, smart contracts enable two or more parties to engage in a trade contract with each other anonymously.Smart contracts consist of program logic, contract owner, contract unique identifier, account balance and private data storage.They are executed by the consensus of the miner nodes in the system.Smart contracts are created by sending a contract creation transaction to the Blockchain network.The new smart contract is added to the Blockchain after the network of miners verify the contract and reach a consensus.The smart contract code is immutable and cannot be changed once added to the Blockchain.This guarantees that the contract terms cannot be modified.However, the contract code may read or write data to its own storage.Nodes interested in participating in the contract have to send a contract invocation transaction to the network by using the contract unique identifier.The contract's code is executed when a contract invocation transaction is received.

Crypto Currency
Blockchain was originally designed for the electronic currency known as Bitcoin [86].Bitcoin is a publically available electronic currency.There are also other cryptocurrency technologies like Ethereum [87] that can be used for money transaction in private networks.One of these technologies could be used to allow electronic money transaction in P2P DET.The work done by Mihaylov et al. [88,89] proposes an energy trading system that uses electronic currency for locally produced renewable energy trading.In their approach, local energy producers generate and inject energy into the power grid which is managed by a Distribution System Operator (DSO).The DSO measures both the amount of energy fed to the grid by producers and the amount of energy consumed by consumers in real time.This enables producers to receive their payment based on actual usage instead of predicted market.The system introduces a decentralized digital currency for energy exchange similar to Bitcoin called NRGcoin.NRGcoins can then be exchanged for currency based money on an independent exchange market.Consumers pay to producers using NRGcoin rather than an official currency.However, the system does not address associated security and privacy issues.

Discussion and Future Directions
It is expected that P2P DET will be an integral part of the next generation power systems.This promising technology cannot be realized without some key underlying services such as demand response optimization mechanism, power routing, efficient communication network and appropriate security and privacy measures.As a result, various researches have been conducted to fulfill these requirements.In this paper, we reviewed existing literature regarding P2P trading including architecture, demand response optimization models, power routing devices and algorithms.We also pointed out two key challenges which are security and mobility issues.Four kinds of demand response optimization models have been proposed by the research community: centrally controlled, incentive driven, cooperative based and game theoretic models.Centrally controlled models rely on central entity to control and mediate the energy trading process.The centralized approach can be a good way when the number of participants is small such as for trading within microgrid and when privacy is not concern.However, centralized approaches cause privacy problems as they require information about traders to pass through the central entity.Moreover, the central entity might become a bottle neck for large scale energy trading.Existing incentive driven and cooperative based models are mainly proposed as a method of increasing mutual income or decreasing cost of electricity energy rather than peer to peer trading.
The most widely employed demand response approaches so far are game theoretic models.Game theoretic models have been suggested for energy trading at various levels ranging from local prosumers and consumers to PEVs and microgrids.The most frequently used game theoretic types are multi-leader multi-follower Stackelberg games.Game theoretic approaches are likely the most promising of all demand response optimization techniques as they allow peer to peer energy negotiation without mediators.However, game theoretic models are still at the microgrid level and do not consider wide area P2P energy trading at the distribution level.Moreover, privacy concerns are rarely considered by most researchers with only few models taking privacy issues into account [16].Furthermore, the transmission cost incurred for trading between geographically separated traders is not considered.In addition, some game theoretic models partially rely on central entity for mediating the energy trading process which results in several drawbacks as mentioned earlier.
Regarding power routing, while there are promising work on power router devices such as the digital grid router proposed by [17], the research on power routing algorithms is lagging behind.Digital grid routers are IP enabled routers that can route power from any type of energy source to any other source through power conversion.Therefore, we believe that digital grid routers satisfy most of the requirements for future P2P DET.This is why some researchers have already proposed digital grid router based energy trading [62].However, in the area of power routing algorithms, research is still at its infancy.Even though few power routing algorithms analogous to data packet routing have been suggested so far, they are not generally suitable for power routing since power signals are very sensitive to loss as compared to data packets.Therefore, routing algorithms that consider the unique characteristics of power routing are expected to be tackled by the research community.
In the future, we believe that an efficient and secure P2P DET system can be implemented by combining four state of the art technologies: Energy Internet, digital grids, Blockchain and SDN.Energy Internet is expected to provide the underlying platform and communication interface to integrate heterogeneous energy sources at a global scale.Digital grid routers can be implemented as part of the Energy Internet paradigm to provide routing services provided that appropriate routing algorithms are loaded on them.Such energy trading platform can utilize Blockchain technology to support public energy trading without sacrificing users' privacy.Moreover, energy contracts can be posted publicly by using smart contracts that are provided by Blockchain.
Smart contracts are used for contract creation and invocation.Producers can create energy contracts using smart contracts and publish them publicly in the distributed network.Consumers on the other hand purchase energy by invoking those contracts.All transactions are performed anonymously.However, as far as our knowledge is concerned, no one has implemented Blockchain for energy trading at a wide scale.Therefore, this is one of the areas that need further exploration.Moreover, Blockchain as a technology has three variants: public Blockchain, permissioned Blockchain and private Blockchain.Up to now, it is not clear which one of these forms is most appropriate for P2P DET.Investigating and identifying which kind of Blockchain scheme is best for distributed energy trading environment taking into consideration various properties such as scalability, cost, computational efficiency, transaction response time, transaction size, security and reversibility is still an open issue.SDN is an efficient networking technology in providing flexibility by separating the control plane from the data plane.In P2P DET, sophisticated energy routers can be centrally controlled by using an SDN controller for better efficiency and coordination.The integration of SDN with digital grids has not been studied well and needs further investigation.

Conclusions
In this paper, we presented a survey of existing research related to P2P DET.The topics covered include architecture of P2P DET, demand response optimization models, power routing devices and algorithms.First, we presented a review of P2P DET architectures.This was followed by a discussion on four types of demand response optimization approaches: centrally controlled, incentive driven, cooperative based and game theoretic models.In addition to surveying existing work, we also pointed out two key challenges related to security and privacy and mobility.Moreover, we discussed state of the art technologies and future directions which could enable the realization of future P2P DET systems such as Energy Internet, SDN and Blockchain.The paper provided a comprehensive study which could be of great befits to the various researchers in the field.