Competitive-blockchain-based parking system with fairness constraints

Parking slot detection is one of the most popular applications of Vehicular ad Hoc Network research field. Proposing smart algorithms for fast parking is crucial not only to facilitate drivers, but also to reduce traffic congestion, pollution, and vehicle energy consumption. Typically, an urban area has several competitive car parks and, in order to make the parking process automatic, a mechanism to ensure a fair competition among them is needed. Among all the methods able to guarantee transparency and equity in a system, blockchain is a robust technology. It has been successfully applied in many different research fields, from financial to health. In this work, we provide an automatic parking system in which vehicles are allocated among several competitive parking areas (called competitors), through a blockchain-based approach, by applying a consensus mechanism to manage the system modifications. To this aim, two classes of fairness constraints are defined, according to which any new operation on the parking consortium must be approved by the members. Such an approach brings benefits for different reasons, starting from traffic condition improvement, up to driver stress and pollution decrease.


Introduction
Parking slot detection is a challenging issue in vehicular ad hoc networks (VANETs), since it is a process that seriously impacts several aspects. First of all, drivers looking for a free parking slot cause most of traffic congestion due to the need of travelling the same roads over and over until an available slot is found. One of the main aspects where advantages of VANETs are evident is the improvement of the traffic flow, but in order to reduce the congestion, researchers of this field should also consider the parking process as one of the main causes. Moreover, also the stress suffered by the drivers has to be taken into account: very often people come to give up on a dinner if they only think of the stressing situation of look- University of Naples, Federico II, Naples, Italy ing for a free parking slot. Last but not least, environmental pollution. As pointed out in Höglund (2004), vehicle energy consumption and the urban air quality need to be assessed. They also specify that the total air pollution in urban areas is due to exhaust emissions from traffic flow. Consequences of parking pollution are also studied in Bajçinovci and Jerliu (2016) on the Prishtina's first public parking garage. For this reason we strongly believe that a smart parking process would help reducing traffic congestion, and consequently air pollution. It is common knowledge that urban parking management is a topic that needs particular attention nowadays: interestingly, as authors of Faraji and Naozar (2019) highlight, the central part of cities very often does not offer accomodation for many vehicles, leading to a high traffic congestion as well as a high pollution level in that area.
Let's imagine having an autonomous parking system able to allocate vehicles approaching several car parks, in such a way to make drivers happy about the slot chosen for them, with regards to the position. It is quite reasonable speaking about several car parks when we have to deal with parking process in a wide urban area. Just think of the numerous car parks close to some shops or markets. Most probably, one of them is in a very strategic position, close to the most famous shops or interesting zones. Clearly, it would be the best choice for any driver looking for a free slot, but also the best choice for any allocation algorithm based on the smallest distance between the chosen slot and the destination of the driver. This scenario clearly demonstrates that if all the drivers try to reach the same car park, their vehicles would create even more traffic congestion, instead of reducing it.
Using a consortium of car parks (which are in the same neighborhood) able to guarantee a fair distribution of vehicles, by choosing, when it is possible, a slot which is near to the destination of the driver, we believe it is possible to dramatically reduce the traffic congestion caused by parking. By moving the attention from the single parking area to a consortium, we make clear that the vehicle allocation problem does not affect the driver or the parking owner alone, but it should be handled in the best interest of all of them. Introducing a consortium requires rules and constraints to manage it. To this aim, we decided to use the philosophy behind the blockchain mechanism based on a consensus to be reached before any operation on the network is performed. In our case, prices variations and capacity constraint modifications from any of the members should be approved, in a certain percentage, by any other member for a fair competition, aimed to an even distribution and not to the enrichment of the single. Since we are using the logic of blockchain, let us introduce it.
Blockchain has been introduced in 1991 and it is an emerging technology which is changing the way new systems operate: it is based on unifying a ledger between all the nodes of the network in a distributed manner, by avoiding that other nodes join the network without authorization (Mostafa 2019). A blockchain consists of a chain of blocks, where each block contains data whose access is handled through cryptography (typically the hash code of the current block, but also the code of the previous one). Anytime someone joins the network, he receives a copy of the blockchain: when someone adds a new block, it has to be validated from the rest of the network [BlockChain expl]. As clearly explained by authors of Crosby et al. (2016), each transaction in the public ledger is verified by consensus of a majority of the participants in the system.
Due to the numerous potentialities, blockchain are used for very different applications, not only in financial fields, but also non-financial ones, such as health, music, and industry (Kuo et al. 2017;Arcos 2018;Bodkhe et al. 2020). We suggest reading the work in Zheng et al. (2017) for a complete overview on the topic.
The typical use of blockchain is for financial purposes: if A wants to send money to B, such a transaction is represented as a block and submitted online for validation. Only after the transaction is approved by the network participants, the corresponding block is added to the chain, and finally A sends money to B (Crosby et al. 2016).
In this work, we propose a very innovative usage of blockchain technology, by exploiting its potential in Vehic-ular ad Hoc Network context, specifically for the automatic parking process, as anticipated above.
As highlighted in Tanwar et al. (2018), security is still an open issue in VANETs research field. Authors of Al Hasan et al. (2016) mention some security threats. Our proposal, is to deal with security problem integrating the blockchain technology in VANET context from a different point of view. Clearly, we are not speaking about security in the traditional manner, but we rather limit this concept to the parking problem. An automatic parking system has to be secure, meaning that it has to guarantee that no other interests interfere with the final goal of allocating vehicles in the smartest way possible. This is what we aim to achieve with our proposal.
For this work, we took inspiration form the idea proposed in Balzano et al. (2020) for a smart parking algorithm, exploiting the information about the destination that the driver wants to reach after having parked his car, in order to optimize the choice of the slot. In particular, the algorithm is a variation of known methods for dynamic memory allocation in operating systems, and it is proved to minimize the time needed to place a queue of ready vehicles.
In order to consider a more realistic scenario, we decided to extend the proposal of Balzano et al. (2020), by adding some characteristics to the environment in which the algorithm is supposed to be applied. Formalizing what we have only mentioned before, we consider a group of parking areas which are consortium members, each one characterized by a price (rate per hour), and a capacity (the number of available vehicles slots). In such a scenario, a criterion to guarantee a correct behavior while following the free market is needed. Such an objective is obtained by means of blockchain mechanism: any operation trying to modify the current configuration of the consortium is considered a transaction to be approved; the consortium members are the participants of the network; the validation mechanism is achieved through a consensus algorithm which decides when, and if, a transaction can be approved, according to some constraints (called fairness constraints), the first one regarding the capacity of each competitor, the second one the price, and their validation is left to the competitors themselves.
In our proposal, security of VANETs has a different meaning from the typical one. We strongly believe that, by reducing to the parking problem, guaranteeing a fair competition among competitors and an even vehicle distribution among them provides drivers a secure parking mechanism, which only aims to allocate vehicle in the smartest way possible, no matter what the economic interests of the single competitor are.
The approach chosen for this article, hence, aims to greatly improve VANETs benefits from different perspectives. Accordingly, as we will analyze in the last section, environment, cities, and citizens are going to benefit from the blockchain integration.
Outline The rest of the paper is organized as follows: in Sect. 2, we recall some background information needed to introduce our proposal. First of all, we recall the results obtained in Balzano et al. (2020), which constitute the basis of this work. We also report some other proposals integrating blockchain and VANET technologies. In Sect. 3, our proposal is explained, by first showing the system design, then describing the fairness constraints and the consensus algorithm, finally the benefits of our approach. Section 4 contains the conclusions.

Background
In this section, we recall the destination-based algorithm used to allocate vehicles in the available parking slots, which is based on some known algorithms for memory allocation in operating systems. Then, we explain the basics of blockchain technology and what are the aspects that can be exploited in a parking process and why it is worthy. Finally, we analyze the state of the art about integration between blockchain and vehicular networks.

Distance-based parking algorithm
Before introducing the blockchain-based parking system, we took inspiration from the distance-based parking algorithm proposed in Balzano et al. (2020). In this section, we recall the basic aspects of such an approach. The main idea behind this proposal is to reduce the vehicle parking problem to the most general and commonly known memory allocation problem in operating systems.
The central memory is a sequence of blocks of variable size, where processes, in order to be executed, need to be loaded beforehand.
The isomorphism between the two problems is quite intuitive: the set of vehicles ready to be parked, called ready queue, corresponds to the processes ready for the execution, the parking area corresponds to the central memory, and the time during which the vehicle will occupy the slot corresponds to the execution time characterizing each process. Similarly, dynamic memory allocation methods are customized and used. We recall the basic versions: (i) First-Fit, the first available and big-enough block of memory is chosen; (ii) Best-Fit, the smallest block, among the available ones and the ones having sufficient size, is chosen; (iii) Worst-Fit, the biggest block, among the available ones and ones having sufficient size, is chosen. We are going to map these policies (First-Fit, Best-Fit, Worst-Fit) into the parking domain.
In memory allocation the main goal is to optimize the resources, while in the parking one the goal is to fill the parking area as soon as possible, which means trying to consume the ready queue in the minimum time possible. Consequently, we can define the objective function formally as follows: Definition 1 Objective Function The objective function for the parking process requires to minimize the time to make the ready queue empty.
The objective function expressed as in Definition 1, says that the algorithm is going to minimize the time needed to find a slot for any vehicle in the ready queue: from the vehicle point of view, the total wait time will be reduced.
Each parking area is divided into slots. Each slot is represented by its position and its size. An example of values associated to each slot of each parking area is shown in Table 1.
The most innovative aspect of the proposed algorithm is that the distance parameter is used. Specifically, we speak about the distance between the parking slot and the final destination of the driver (information which is supposed to be known in advance). By using such a parameter, and assuming that the vehicle v has to be parked, the typical approaches for dynamic memory allocation in operating systems are revisited as follows: -Revisited-First-Fit (RFF): among all the available parking slots able to contain v, the nearest to the destination is chosen; -Revisited-Best-Fit (RBF): considering the size of the vehicle, among all the available parking slots which are large enough for the vehicle, the closest and smallest one is chosen; -Revisited-Worst-Fit (RWF): taken in consideration the size of the vehicle, among all the available parking slots with dimension equal or greater than the vehicle, the closest and biggest one is chosen; Simulation results proves that the revisited versions of First, Best, and Worst-Fit reduce the waiting time for the ready vehicles, and hence the total time needed to empty the queue. In Table 2, we report experimental results obtained after 4 blocks of 200 executions for the same parking area. Every time we generate 11 vehicles with random features.  When we speak about positive simulations, we mean a simulation in which the behavior of the revisited algorithm is better than the standard one. In Table 3, instead, we report failed attempts. It's easy to see that the worst-fit presents more failed attempts than the other ones, but still with very small values with respect to iterations number. We report in Table 4 the comparison results among the standard algorithms and the revisited ones: in particular, the revisited First-Fit yields an improvement around the 60%.

Blockchain
The name blockchain is very explicative about how this technology works: the basic mechanism is a consensus validation algorithm, which allows a peer-to-peer communication among participants, without the need of any kind of central authority. Every time a transaction is validated, a new block is added to the chain and, typically, it cannot be removed afterwards (Michael et al. 2018). We suggest (Ma et al. 2020) for an updated survey about blockchain technology.
The logic behind blockchain was inspiring for this work, for the construction of a robust parking system. Arguably, considering park consortiums, the first issue that has to be addressed is how anticompetitive behavior can be prevented. We also have to ensure that every member only acts with the aim of reducing traffic congestion. Blockchain mechanisms can be the answer to these problems. Introducing a consensus to validate any action from consortium members guarantees that no one can take advantage of the system. No member will be able to set a price which is too low with regards to the rest of the group. Even if they are not interested in reducing local traffic congestion, belonging to the network will enforce preservation of their economic interests. Such a mechanism, therefore, forces members to defend the entire process, while they naturally try to defend themselves. Members might disallow incorrect or dangerous behaviors from other components and, as a consequence, they will cooperate to make the parking process work flawlessly.
The same holds for capacity variations. Especially during a pandemic, it is easy to imagine that anti-contagion measures impose restrictions on the number of slots that can be effectively occupied in a car park. Someone could try to be crafty and violate such restrictions, in order to have more customers than the concurrency, hence being able to gain larger profits. The consensus-based blockchain mechanism avoids a situation like that. The capacity of each car park is supposed to be known in advance, hence if someone tries to overcome the number of allowed slots, the network would recognize it and would stop it.
Essentially, blockchain logic is hereby used to avoid incorrect behaviors from network participants, therefore preserving the entire parking process, while keeping the reduction of traffic congestion as the main concern.

Related work
Vehicular ad-hoc Networks (see Rasheed et al. 2017 for a survey) are largely employed nowadays in several and different research fields, such as environment monitoring (Senapati et al. 2020), Big Data management systems (Contreras-Castillo et al. 2016), but also less obvious fields such as health (Kamal et al. 2016). The decentralized nature, and the self-organizing capabilities render VANET a versatile technology, which attracted the attention of many researchers. VANETs are set of vehicles able to communicate vehicle-tovehicle (V2V) or with infrastructures (V2I) (Balzano et al. 2016). Vehicles are equipped with on-board units, while road infrastructures are provided with road side units. The communication between vehicles happens via broadcasting, meaning that when a vehicle detects some interesting event, it is able to broadcast it. Any vehicle in its communication range is able to receive such an information and relay it. With this schema, a multi-hop communication is performed, allowing an information flow through the network. Clearly, when the distance between vehicles does not cover the range of communication, infrastructure elements can be used as bridges to reach longer distances.
One of the most interesting applications of these vehicular networks is the parking detection. Finding available slots either in urban areas or parking may cause traffic congestion, environment pollution, and impact drivers mood. For these reasons, in the last few years, this topic has become a very hot research topic and an increasing number of researchers use known existing algorithms and adapt them to face the parking problem. For instance, in Balzano and Stranieri (2017), authors provide a logic approach to the distance geometry problem (DGP, for short), by classifying vehicles in ready, finding, and leaving, according to what is their role in the current network: starting from the network configuration, they draw an indirect graph representing all the parking information related to each vehicle, and transmit them via V2V communication. Authors of Balzano and Stranieri (2019), instead, modify the ant colony problem (ACO), by formulating the parking problem as an optimization problem, and by considering it through ACO. Specifically, the goal is to find a path from a starting position, leading as close as possible to a destination, which maximizes the number of free parking slot seen. In literature, we also find machine-learning-based approaches providing a smart parking system, such as the one proposed in Saharan et al. (2020). Moreover, authors in Ali et al. (2020) proposes an interesting framework based on a deep long short term memory network and a way to predict the parking availability.
The combination between the blockchain technology and VANET environment has been investigated already, since it provides a self-organizing, decentralized and transparent system, such as in Leiding et al. (2016), where authors rely on Ethereum, a decentralized platform based on Bitcoin's blockchain concept, and they propose mandatory applications such as traffic regulation application, vehicle tax and vehicle insurance applications. In Shrestha et al. (2020), authors consider a new type of blockchain which aims to improve critical message exchange in VANET, via the creation of smaller blockchains for country-level local communication and a larger "public" one which stores trusted nodes. Authors of Lu et al. (2018) highlight that security in VANET is still an open issue, due to its features: for this reason they provide a blockchain-based anonymous reputation system (BARS) in order to establish a privacy-preserving trust model for VANETs, by using a reputation algorithm that prevents the distribution of forged messages.
Furthermore, authors of Xie et al. (2019) also investigate security issues in a 5G-VANET: they determine that using a blockchain in such a network allows detecting malicious nodes and messages, significantly improving the trustworthiness of the whole network, while the performance remains acceptable. Another interesting proposal is Yang et al. (2019), where authors propose a proof-of-event consensus algorithm for blockchain, rather than the more common proof-of-work: data are collected by the road side units and every time a vehicle receives an event notification it has to verify the correctness.
Many authors also investigate the parking problem, by dealing with it through blockchain. In particular, authors of Al Amiri et al. (2019) and Hu et al. (2019) propose a schema to preserve driver's privacy; similarly, authors in Zinonos et al. (2019) propose ParkChain, which is a smart parking system based on blockchain, aimed to guarantee that no one can delete, revert, hack or question the time a registered vehicle securely entered a parking area.
Our contribution in this context is to integrate the blockchain technology to guarantee a fair commerce in a parking consortium. As far as we know, this is an application that has never been considered for blockchain and smart parking. In our opinion, the driver security begins with the corresponding security of the offered service. By guaranteeing a fair competition between the consortium members, we also guarantee security for drivers that take advantage of the service. This aim is obtained by introducing some fairness constraints, and an appropriate consensus algorithm.

Proposed system
In this section, we explain and show how our proposal works: first of all, we describe the system representation through blockchain technology, by pointing out the reasons why we took advantage from blockchain logic and what are the earned benefits. After that, we define some fairness constraints in order to guarantee a right competition, rules ensuring correct behavior of all the participants. Then we show the pseudocode of the proposed consensus algorithm, which is needed to validate any modification operation on the blockchain. Finally, we provide an overview of the benefits brought by such an approach from various points of view.

Competitive-blockchain-based representation
The scenario considered in Balzano et al. (2020) takes into account a single parking area with the aim of finding the best way to allocate a queue of ready vehicles, in such a way that the time needed to make empty the queue is minimized, and the slot assigned to each vehicle is optimal with respect to the destination of the driver.
We want to extend the application of the algorithm proposed in Balzano et al. (2020), by considering a different and, in our opinion, more realistic scenario made of several parking areas, which are members of a consortium but still work competitively, without affecting the free market laws. We will call them competitors for the rest of the paper.
The introduction of such a competitive attitude, clearly, raises the problem of guaranteeing equity and fairness. When we move to a competitive setting, we need to take into account that any participant wants to win, whatever it takes. It is quite easy to imagine that the single consortium-member could act to improve his personal gain, rather than choosing the strategy that reduces the traffic flow. Such incorrect behaviors have to be avoided at all costs and a proper protection mechanism is obtained by applying the logic behind the blockchain mechanism, introduced before, where any network modification must be approved, through a consensus, before it is applied. Figure 1 shows a simple example of the system we are going to define. Let us point out that, in our proposal, we consider four different competitors in the center of Naples, characterized by the following attributes: -the price, established by each competitors, is the rateper-hour required anytime a vehicle allocates a slot in the corresponding car park; -the capacity, in terms of number of parking slots in the corresponding parking area: moreover, a percentage limit may be imposed, if we consider, for instance, restrictive measures as the ones for the COVID pandemic.
The competitors are the nodes of the blockchain, while the transactions are all the proposed actions which modify the system configuration and, therefore, need a consensus from the network to be applied. A block of the blockchain is an association vehicle-slot, which has already been approved and hence is known by any participant.
In the described scenario, we consider two possible transactions: -One of the competitors receives a new vehicle from the ready queue. Such an operation needs a consensus, according to the considerations we made previously. It might be the case that a car park owner has reached the maximum capacity allowed for him, according to new anti-COVID restrictions (let's say 60% of the capacity), but he wants to cheat, and he keeps accepting more vehicles. Obviously, such an aggressive behavior has to be avoided, and other competitors will negate the consensus to accept new vehicles; -One of the competitors changes his price. Again, a price variation should be acceptable, considering a fair competition. Let's say, for instance, that the average rateper-hour of all the members of the consortium is 5$. Therefore we may have a member which applies a rate of 4$, one of 6$, but if someone wants to set a price of 1$ per hour, this would make the competition unfair. Most likely people would be encouraged to go to the cheapest car park, causing a traffic congestion. But actually, through the consensus mechanism, the other members will not allow such a price variation. They won't because they want to defend themselves, but consequentially they are also preserving the whole parking process.
Another possibility is that a vehicle leaves the corresponding parking slot, but in this case we assume that the consensus is not needed. We are only focusing on the vehicle allocation process, hence a vehicle leaving the parking area essentially represents the end of such a process. Figure 2 shows an example of the execution flow leading to the parking process: 1. At the beginning, the actual blockchain configuration is shown, meaning all the transaction that have already been accepted and are known by all the participants. In particular, it is commonly known that the orange vehicle is in the blue car park, and that the blue vehicle is in the white car park (2.(a)).

A new transaction is submitted to the participants. It cor-
responds to the action of parking the black vehicle in the blue competitor (2.(b)). 3. The transaction is accepted according to the specific consensus algorithm used. In this example, any other competitor allows the transaction (2.(c)). 4. The transaction has been approved, a new block is added to the chain, and it becomes common knowledge that the black vehicle is in the blue car park (2.(d)).

Fairness constraints
In order to prevent misbehaviors deriving from competitive environments and guarantee a fair competition between competitors, we define some fairness constraints. Assumption Without loss of generality, we assume that given the capacity C associated to some competitor, for reasons of force majeure, such as an anti-COVID measure, only a percentage of this capacity can be effectively occupied. We denote by c the actual capacity of each competitor. We define two distinct fairness constraints: -A price fairness constraint, which guarantees the free market for any competitor, and informs the rest of consortium members of any price change, in order to keep the competition fair, precisely. For instance, if the competitor P 1 wants to raise the parking rate to a price which is considered too high for other competitors, such a transaction will be denied from the system, as well as, similarly to the example proposed in the previous section, if he wants to decrease the rate to a price considered too cheap, again the transaction will be denied. -A capacity fairness constraint, which aims to guarantee that all the competitors follows the capacity restrictions shared by all the consortium members. For instance, if the competitor P 1 is trying to fill more parking slots than allowed, to increase his gain, such a transaction will be denied from the system.
Verification of the transactions must be on competitors side: establishing if a transaction does not violate the fairness constraints, and is hence authentic, is up to them. Essentially, these fairness constraints follow the democracy rules: if the majority of the participants accepts a given proposal, then it will be considered, otherwise it will not. The majority also guarantees fairness also in the preservation of fairness constraints. Obviously, one could negate the consensus just to limit the growth of the requiring member, while by introducing the majority we ensure an even judgment of the transactions.

The consensus algorithm
In literature, there are two main types of consensus algorithms (Nguyen and Kim 2018): -proof of work-based ones (PoW, for short); -pure stake-based ones (PoS, for short).
The main difference is that, with PoW, among all the nodes of the network, the one performing sufficient proof will get the right to append a new block, while in PoS the stake owned by each node determines if the node will modify the network (the basic idea is that the stake is proportional to the trust).
The consensus algorithm proposed in this work, for the particular setting described before, has a different approach with respect to the just explained PoW and PoS consensus algorithms. We rely on a simple, but in our opinion crucial, consideration: each competitor would not attack the same chain which guarantees him a profit. The consensus algorithm, hence, is thought to guarantee the system best interest, by letting each competitor do his own interest. In this case, the aim is an automatic parking system involving a consortium of parking areas which work in competitive fair manner. To guarantee fairness, we rely on the competitors themselves. That is, respecting market laws and letting other competitors respect market laws is their best interest. As we already mentioned, the traffic flow reduction is a mere consequence of members trying to improve their profits. And this is the strength of our model, because somehow no one is forced to do anything to reach the goal, they simply do it naturally.
For this reason, the consensus algorithm, that in our opinion fits the problem, essentially requires the majority of approvals for a proposed transaction. The pseudo-code shown in Algorithm 1 defines the basic idea for the consensus.
Essentially, the Algorithm 1 takes as input the proposed transaction that needs to be approved, and gives as output the updated blockchain: in particular, each competitor gives his opinion on the proposed transaction, voting on its approval. Once each competitor expresses his opinion, the votes are counted: if a majority has been reached, the transaction is approved and a new block is added to the chain, otherwise the same starting blockchain is returned.

Slot assignment process
As we mentioned before, the algorithm proposed in Balzano et al. (2020) constitutes the starting point for our proposal, since it defines the effective allocation algorithm, regardless the blockchain mechanism.
Clearly, the scenario considered in Balzano et al. (2020) is quite different from the one taken into account in this work and therefore needs some adjustments: if the algorithm, as considered in Balzano et al. (2020), assigns a parking slot to the next ready vehicle, in this case we first need to assign it to one of the competitors, then a specific slot in it. Essentially, we have to specify how the car park is chosen for a given vehicle ready to be parked.
In order to do so, we slightly modified the algorithm, by applying a new step: the next vehicle is assigned to the most similar competitor, before applying the algorithm in Balzano et al. (2020) and choosing the best slot for the driver. What does similar mean? To clarify this concept, we introduce only some of the additional characteristics we can imagine for each competitor, collected in a feature vector: -rate per hour; -closing hours; -key deposit; In this way, any competitor is defined by the price per hour, the time by which the driver has to pick up his car, and the necessity to leave the key of the car. This last attribute is supposed to be binary (0 for no, 1 for yes).
We assume that, similarly, any driver is characterized by the same 3-components-vector, which indicate his preferences on each feature. We also assume that the driver vector can have a special character * , which means don't care. This works like a jolly value. For instance, the vector d = ( * , * , 0) represents a driver who is only interested in not leaving the key, while he doesn't care about the price and the closing time. In this case, the driver feature vector is not a single vector, but is represented by all the possible vector whose third component is zero.
The driver feature vector can be built in two different ways: -explicitly: in this case the driver express his preferences; -implicitly: in this case the system keeps track of the driver history and previous choices.
In such a setting, the competitor which is more suitable for a given driver is the one whose feature vector is closer (in terms of Euclidean distance) to the driver feature vector.
In order to compute a more precise similarity between driver and competitor, we sum up some of the most interesting features that could be taken into account to know the driver's preferences: -Indoor/outdoor parking slots. Many people could prefer an indoor slot for their vehicle so the have it repaired from meteorologic inconveniences. -Payment methods. Very often people are more comfortable paying by card, rather than by cash, especially in a pandemic era. -Included shuttles toward center or airports. Very often, people need to leave their car before visiting a city or before reaching the airport, and hence they could be interested in such a facility. In case of ambiguity, meaning that the vector similarity does not produce a unique result, the choice falls on the competitor which is the closest to the destination of the driver.
The whole process is synthesized in Fig. 3: when a new vehicle has to be parked, his feature vector is compared with the ones of the competitors; the most similar (meaning the closest in terms of Euclidean distance) is chosen, in this example, competitor p 3 is selected; inside the parking area associated to the competitor p 3 , the slot which is the closest to the destination of the driver is chosen, according to the destination-based algorithm explained at the beginning of the paper.

Similarity-based-competitor-assignment
Distance-based-slot-assignment d p 1 p 2 p 3 p 3 d Fig. 3 Steps of the parking process programming language developed by Mozilla that, due to its particular memory management system, allows building fast, efficient and secure applications that can be executed on integrated devices using a small amount of resources.
It is also commonly used for blockchain applications development, due to the presence of the Substrate framework, which offloads the developers from the creation of the distributed network and automatically manages the state of the shared ledger.
Given a consortium (which holds a set of parking), and a parking request from a customer, the algorithm used to select the most appropriate parking lot is described in Algorithm 2. If a valid parking lot is found, the blockchain receives a new proposed block, which has to be accpeted by the majority of the consortium, as already explained in Algorithm 1.

Fig. 4 Advantages of the proposed system
Once the consortium accepts the block it becomes part of the blockchain, in order to keep the process transparent for all the participants. Notice that the constraint of a distance within 5km to find a parking slot should be relaxed if there isn't a slot satisfying such a property. Table 5 shows five differents simulated results with 10 parking lots and 1000 requests, and shows that the system is actually able to assign users evenly to the various competitors.

Benefits
In this section, we want to point out which are the advantages brought by the system proposed in this work, as shown in Fig. 4.
We analyze different points of view: -Driver point of view: according to the distance based algorithm proposed in Balzano et al. (2020), which is still used in this work, each driver will place his car in the parking slot which is as close as possible to his final destination. Such a criterion guarantees low time wasting to each the target (for instance a clothes shop) from the slot where the vehicle has been left. Moreover, the structure of the algorithm itself ensures that the time to empty the ready queue is minimized, and as a consequence also the waiting time for each driver is reduced. -Competitors point of view: the fairness constraints handled through a blockchain mechanism ensure a fair competition between the members of the same consortium, by not affecting market rules and guaranteeing correctness. Each competitor is somehow protected by the consortium itself, and a fair profit is guaranteed to any of them. -Consortium point of view: while protecting themselves, competitors also protect the whole consortium, acting in its best interest, even if they have the feeling of acting for their benefit only. -Environment point of view: reducing the time typically wasted while searching for a free parking slot dramatically decreases the amount of gas emission, contributing to reduction of air pollution. -Traffic point of view: as the previous case, traffic congestion is typically affected by drivers slowing down or cruising along the same streets over and over. Minimizing the time to complete the parking process, traffic conditions will also improve.

Conclusions
Vehicular ad hoc networks are largely studied and employed in many research fields due to their potential in terms of selforganizing capability and decentralization. One of the main and most interesting application is parking slots detection, since drivers involved in the parking process cause several dysfunctions in the network, such as traffic congestion and air pollution.
In this work, we enrich VANETs system by introducing blockchain technology, often employed for security purposes. In our case, security has an atypical meaning: we think that an automatic parking system should guarantee fairness to their customers. In fact, since a parking system also needs some car parks to allocate vehicles, and these parks are typically handled by owners, they could easily put their economic interests before the system ones. The common goal for the parking system and the car parks owners should be reducing traffic congestion and air pollution, by aiming to an even distribution of vehicles among the available car parks.
The VANETs integration with blockchain is finalized to an automatic parking process, where a consortium of car parks works competitively. This is, in our opinion, a realistic representation of the environment in which the vehicle allocation has to be performed. The obtained system guarantees a secure service for drivers through a fair competition, while not affecting the market laws on one side, and it ensures the minimization of the time needed for each driver to find an available parking slot, according to the final place he wants to reach. The fairness aspect is handled through the blockchain mechanism, requiring a consensus from the competitors for any action aimed to modify the network status. Any price variation or capability modification has to be approved by the network itself, in order to avoid that some consortium member misbehave, unfairly decreasing prices or increasing the slots availability. The result is an even system, which provides a smart and fast vehicle allocation and improves both drivers and consortium members perspective, but also traffic and environment pollution.

Future hints
The scalability of our system makes further improvements easy. As future work, we think that it could be interesting add some other properties to lead to a more precise choice of the competitor.
For instance, we can take into account the price variation between the first hour one occupies the car park, and the successive ones, as often happens for existent parking areas. It is very common that a car park imposes a price-per-hour for the first hour, and that such a price decreases for the successive hours, in order to encourage drivers to stay there longer. By introducing such a new feature, we make the computation a little bit more expensive, since we should compute a sort of predictive cost for a driver in a given car park, according to an estimation of the stay time. At the same time, we also need to keep the competition fair, avoiding situations in which a competitor imposes a rate which is too cheap with regards to the others, causing congestion in traffic flow.
We could also consider agreements between stores and competitors for further price variations. As a matter of fact, when we go to the theater, or to the cinema, or to some mall, we can take advantage of agreements that they have previously stipulated with car parks. Clearly, this is a situation that should be handled from different points of view. First of all, from the client point of view, such a discount need to be taken into account for the slot choice, but also from the consortium point of view. Consider two car parks that have an agreement with the same theater, but they offer different prices: clearly, any vehicle is somehow encouraged to find an available parking slot in the cheaper one, by creating traffic congestion. This is something that should be limited, if we want to achieve an even vehicles distribution.
Moreover, we think that more than a single target for each driver could be considered. In this case, each vehicle has more than one destination as information. Such a generalization is, indeed, pretty realistic. Drivers may want to park their car for a few hours and enjoy a walk passing by several shops in that area. In this scenario, the final slot choice should be performed by optimizing a path for the driver, rather than the distance from a single place. In this case, we do not have to deal with equity of competition, but rather with the path prediction building. We can assume that any driver has a list of destinations associated. Here the challenging aspect is in the management of the number of different combinations in which the driver can visit the destinations. For example, let us suppose that the driver d wants to reach shops A, B, and C during his permanence in the car park. He could follow the path ABC or AC B, or B AC or BC A or C AB or C B A. Clearly, any possible path corresponds to a candidate car park, close to the first stop possibly. The choice of the best path could be made according to different criterion, such as distance minimization, or time minimization, or even cost minimization.
Another interesting and very popular application of this system could be dedicated to electrical vehicles. One of the main challenging aspects is the time needed to reach a charging station and the time guaranteed with each charging cycle. By exploiting the VANETs self-organizing spirit, one can imagine of a system able to share energy among vehicles. Sharing is everywhere in VANETs-based system. The basic idea is to obtain a stronger system thanks to information sharing. By switching to electrical vehicles, we can therefore consider the sharing of the available energy towers.
We also plan to implement the algorithms in high performance computing parallel environments using an approach similar to that described in Laccetti et al. (2019Laccetti et al. ( , 2020. We could also apply, by following what made in Ferrante et al. (2009);Murano et al. (2008), some interesting strategic reasoning for multi-agent systems to handle the interaction between the members of the consortium, similarly to what has been done in Aminof et al. (2018Aminof et al. ( , 2016; Jamroga et al. (2019); Jamroga and Murano (2015), for instance by using automata to express fairness constraints, but also Nash equilibrium for equity. This last concept should be employed to parking algorithms to find a solution as an equilibrium. More precisely, the parking process could be defined as a multi-agents game, and each different slot choice could be a different strategy for any agent. The outcome of the game can be expressed in terms of time needed to park the car for any agent. Finding a Nash equilibrium means finding a solution for the game in which no agent is pushed to change his strategy, since it would not be convenient, in terms of outcome.