International Journal of Advanced Network, Monitoring and Controls Volume 05, No.01, 2020 DOI: 10.21307/ijanmc-2020-006 36 Research on Blockchain Availability Modeling in P2P Network Wang Zan School of Computer Science and Engineering Xi’an Technological University Xi’an, China E-mail: 18309220452@163.com Fu Yanfang School of Computer Science and Engineering Xi’an Technological University Xi’an, China E-mail: fuyanfang3000@aliyun.com Zhong Lianjiong School of Computer Science and Engineering Xi’an Technological University Xi’an, China E-mail: zhongli5180@sina.com Dai Fei School of Computer Science and Engineering Xi’an Technological University Xi’an, China E-mail: 8496579@qq.com Abstract—Blockchain establishes reliable trust among parties that do not know each other and achieves credible data sharing and point-to-point value transmission in an epoch-making way. The requirement of the availability of block chain network becomes more and more important due to the dynamic and changeable characteristics of block chain P2P network. Therefore, for the characteristics of block chain P2P network system, this paper constructs a availability model based on Markov stochastic process theory, analyzes the steady-state availability and instantaneous availability of the model, and finally carries out experimental verification through simulation, hoping to provide beneficial inspiration and guidance for future research on block chain network . Keywords—Blockchain; P2p; Markov; Availability I. INTRODUCTION Block chain is a distributed system composed of encryption mechanism, storage mechanism, consensus mechanism, which can realize the peer-to-peer trading function of mutual trust without central server. The biggest feature of blockchain is decentralization and distribution, and the consensus mechanism of blockchain enables participating nodes to jointly provide services for the system and realizes similar functions of financial intermediaries in the central system. As shown in Figure 1, blockchain system can achieve fast synchronization of data without central server and consistency of consensus mechanism through P2P network. P2P realizes the sharing of data resources and cooperation of services among terminal devices by means of direct exchange. However the dynamic and changeable of blockchain P2P network, the requirement of the availability of block chain network becomes more and more important. From the development trend of p2p network, the demand of modeling and verification evaluation on the availability of p2p network is more and more common and urgent. The establishment of high availability mailto:18309220452@163.com mailto:fuyanfang3000@aliyun.com mailto:zhongli5180@sina.com International Journal of Advanced Network, Monitoring and Controls Volume 05, No.01, 2020 37 network is the basis of accurate and timely information exchange, so as to meet the demand of network system to provide high reliable services for various users. consensus consistency InitTrans Address propagation discovery Message communication Check nodes seed nodes Flooding Distributed Hash Table consensus mechanism—p2p network Figure 1. The architecture of p2p networks in the blockchain II. RELATED WORK The traditional concept of availability is a typical measure of reliability in reliability theory. It is an important parameter in reliability engineering that combines maintainability to represent the effectiveness of the system. "Reliability" can only reflect the probability of failure of the network system or components, while "availability" can reflect the quality of the network by considering the repairability of the network. Therefore, analyzing the availability of tact network system is an important index to evaluate the design of system networking, system stability and maintenance ability. At present, availability studies mainly focus on the reliability and maintainability of the engineering capability of complex systems, and also on the availability of mission capability. Lianhong Zhou established the availability model of optical fiber communication system by using the state transfer equation[1]. Hailin Feng used Markov theory to study the steady-state availability of repairable network system, and analyzed the fuzzy availability of repairable network system and continuous kn(F) network. Fenghua Xie studied the availability of "N+X" UPS system and pointed out that the availability of parallel system was positively correlated with the number of redundant modules[2]. Jingle Zhang proposed a workflow availability modeling method based on random Petri net and studied and established the SPN model of e-commerce system[3]. Jikun Yang fused sample data with prior information, used fuzzy variables to deal with the uncertainty of sample data, and proposed a usability analysis method of navigation weapon system based on fuzzy Bayes[4]. Above all of these, we can find that the research on the availability of p2p network is relatively few and not very mature now. Therefore, research available technology based on P2P distributed collaborative network under different environmental conditions, analyze the unified modeling and expression of information, build a new generation of block chain network usability evaluation model, improve the information interaction and collaboration ability of block chain platform, and ensure the performance of system service and the formation of stable and reliable operation ability through availability technology. III. DISTRIBUTED P2P NETWORK STRUCTURE BASEDON BLOCK CHAIN Block chain technology is the first kind that can be globally distributed deployment of consensus agreement. Block chain system achieves efficient consensus through simple unauthenticated broadcast channel and block chain length competition mechanism. The typical blockchain system consists of network layer, consensus layer, data layer, intelligent contract layer and application layer[5]. The network layer is usually based on P2P protocol for communication between nodes; the consensus layer implements the consensus protocol, which can be freely selected according to the actual scenario, such as PoW based on workload proof, and PoS based on equity proof; the data layer is the data structure of the block chain, whose structural design is usually closely coupled with the application scenario according to the actual needs, each computing node is responsible for maintaining its own storage system; the intelligent International Journal of Advanced Network, Monitoring and Controls Volume 05, No.01, 2020 38 contract layer can perform different operations for different data input, this process is automatically executed based on the code, and consensus is reached across the network; the application layer is the basic business of the block chain system, such as financial services and data traceability, etc. There is no central node in the block chain network based p2p, and any two nodes can be directly traded, each node is free to join and exit at any time. Therefore, the block chain platform usually chooses the P2P protocol which is completely distributed and can tolerate single point of failure as the network transmission protocol. Block chain network nodes have the characteristics of equality, autonomy and distribution, presenting a flat topology without any centralized authority nodes or hierarchical structure (as shown in Figure 2). Each node has such functions as route discovery, broadcast transaction, and broadcast block and find new nodes[6]. In the blockchain network, the P2P protocol of the blockchain network is mainly used for the transfer of transaction data and block data between nodes. The node listens to the data broadcast in the network all the time. It can only be processed after by verifying the validity of these transactions and blocks when receives new transactions and new blocks sent by the neighbor node. C6 C1 C2 C5 C3 C4 Figure 2. P2P network topology IV. AVAILABILITY DEFINITION Reliability is defined as the ability of a product to perform specified functions under specified conditions and within specified time periods. The higher the reliability, the lower the failure rate of the product. The simplest expression for reliability can be expressed as an exponential distribution, which expresses random failure. (1) Where, t is mission time, is failure rate. Availability is defined as the ability to be in a state of executable function under specified conditions and at specified times or time intervals, provided that the required external resources are guaranteed. It is the comprehensive reflection of product reliability, maintainability and maintenance guarantee. The formula is as follows: (2) MTBF(Mean Time Between Failure)refers to the average working time between two adjacent failures and is a reliability indicator of a product. MTTR(Mean Time To Repair)describes the average repair time when a product changes from a failure state to a working state. In engineering, MTTR is a measure of the maintainability of a product, which is common in maintenance contracts and is used as a measure of service charges. According to the above analysis, "reliability" only reflects the probability of failure of the network system or components, while "availability" considers the repairability of the network and better reflects the quality of the network. Steady-state availability and instantaneous availability are two characteristic quantities that reflect availability. Therefore, analyzing the steady state availability and instantaneous availability of blockchain P2P network system is an International Journal of Advanced Network, Monitoring and Controls Volume 05, No.01, 2020 39 important index to evaluate the design of system networking, system stability and maintenance ability. V. MARKOVAVAILABILITY MODELING P2P network system is a complex system, its nodes states are changing at anytime, while the factors causing the change of the state of nodes mainly include hardware and software errors, human errors, natural disasters, malicious attacked, causing serious consequences to the network system, and even causing the entire network paralysis. The probability of occurrence of the first several factors is relatively small, while as an artificial means, the probability of occurrence of malicious attack is very high in the real war environment. A. Markov Chain Model of the System In this paper, the P2P network system targeted is a multi-state Markov repairable system, assuming that its failures are caused by malicious attacks. The system is composed of several network nodes and several repair equipment. The life distribution of each node is , and the repair time after node failure is .All of these random variables are independent of each other, and after the fault node is repaired, its life will be the same as the new node. Multi-state means that the nodes of the network system are damaged by attack, which may break one, two or more nodes; the number of fault nodes is different means the system state is different. In the process of system design, it is usually necessary to chose availability model to describe the availability of the system. The availability model adopted in this paper is the voting system model of take k in n. There are two types of voting system models of take k in n: one is a system of take k good nodes in n, which requires k or more of the n nodes of the system to be normal in order for the system to work normally, which is denoted as k/n[G]. The other kind is the system of take k bad nodes in n, which means that the system cannot work properly if k or more of the n nodes of the system fail, which is denoted as k/n[F][7].This paper chose the second system model. When the fault nodes are less than k, the system works normally and repairs the fault nodes. When there are k node failures, the system will fail. At this time, the remaining normal working nodes will also stop working and will not fail. The system will work again until one node under repair is repaired and there are less than k nodes under repair. The system studied in this paper simplifies the actual situation, the n nodes of the system are considered to be one type of node. For example, because the importance of each node is different in practice, the life distribution and repair time of the node may be different, so the node types are not all the same. Another example is that when a node fails, its workload must be borne by other nodes, thus accelerating the loss of other nodes. Therefore, these idealized conditions are temporarily listed as assumptions, called the basic type for analysis. The number of fault nodes in the system is defined as the state of the system, i.e. * + where the working states of the system are * + obviously, the working quality (quality of service) of the different working nodes included in these working states is different, but it is not differentiated in the basic type analysis, and all of them are considered as normal working. X(t)=j indicates that there are j node faults in the system at time t that need to be repaired, i.e. it is in the state of j, where * +. Node life and maintenance time obey the exponential distribution, according to the above, can prove to be time continuous multi-state time homogeneous Markov chain, state transition probability in △t time is shown in the following Formula (3). represents the probability that the system is in state j at time t. This is the Markov model of P2P network multi-state repairable system. The state transition probability diagram of the system is shown International Journal of Advanced Network, Monitoring and Controls Volume 05, No.01, 2020 40 in Figure 3: (the state of transition to itself is not shown in the figure)                     t)o(t)(P , 1)k-(nt)(P 1k-1,k-n k-n,1,2,jt),o(tj-tj)-(nt)(P 1jj, 1k-n,1,2,jt),o(tjt)(P 1jj, k-n,0,1,jt),o(tj)-(nt)(P 1jj, kj n       (3) 1 2 n-k n-k+1...0 nλ t (n-1)λ t kλ μ t 2μ t (n-k+1)μ Figure 3. State transition diagram The state transition probability matrix is represented by A, as follow:                     1)k-(n-1)k-(n kk-n-k-k-n 2-2)-(n-2 -1)-(n- nn- )()(  (4) B. Steady-State Availability of the System Steady-state availability is one of the reliability characteristics of markov repairable system, which means the proportion of the whole running time of the network without dismemberment when the network reaches the steady-state, it is the probability of the network being connected. This index is essentially the probability of connectivity at any time in the steady state. According to the properties of homogeneous Markov process: ( ) ( ) (5) According to formula (5), we get ∑ (6) Where is the probability distribution vector of state in steady state, ( ) , Matrix A is substituted into Equation (6), and we get                          0 1 )1( 0 2 )2( 1 ))1()1(()( 0 3 3 2 )2)2(( 1 0 2 2 1 ))1(( 0 0 00      kn kn kn k j j j jjn j jn nn nn n   (7) The value can be obtained by solving the linear equations, and the steady-state availability of the system is ∑ (8) C. Instantaneous availability of the system Instantaneous availability is also one of the reliability characteristics of markov repairable system. For some high-reliability systems like P2P networks, it takes a long time to reach their stable state, and the steady-state availability may also be disturbed during the system operation. Therefore, it is not enough to calculate the steady-state availability, but to consider the instantaneous index of the system. From the C-K equation, we can obtain that the instantaneous probability is:          0)0(,,0)0(,1)0( )()(t k10 rjirij PPP t P s P S P  (9) The intuitive meaning of the C-K equation is start from state i and arrive at state j after s+ttime, and must first arrive at any state r after s time, and then transfer International Journal of Advanced Network, Monitoring and Controls Volume 05, No.01, 2020 41 from state r to state j after t time. ( ) ( ) ( ) means that has a probability of 1 and the other states have a probability of 0 at the initial moment. Equation (9) is expressed as a matrix differential equation in the following form: { ( ) ( ) ( ) (10) ( ) = ( ) ( ) ( ) represents the distributed probability of the system in various states at time t, is the row vector, and is also a one-dimensional matrix. ( ) represents the derivative matrix of instantaneous probability of the system at time t This is a system of first order linear differential equations, the general form of its solution is: ( ) ( ) ( ) ∑ (11) Since P and A are matrices, it is difficult to find the analytic expression of the above equation, we can use the Laplace transform to find A simpler expression, and let ∗𝑗(𝑠) ∫ 𝑗( ) 𝑠 𝑑 𝑠 , The Laplace transform of Formula (10) simplifies to ∗(𝑠) ∫ 𝑗( ) 𝑠 𝑑 ( )( ) 𝑠 (12) Where I is the identity matrix, ( ) can be obtained by inverting transform ∗( ) , then the instantaneous availability of the system is ( ) ∑ 𝑗( )𝑗 (13) However, it is difficult to obtain analytic expressions by ∗( ) inverse transformation. Results can be obtained by means of calculation tools, such as Matlab, Maple and other scientific calculation software. VI. EXAMPLES VALIDATE Take Figure 2 as an example, the number of network nodes is 6, and the minimum number of network nodes that can work normally is 4, that is4/6[F] voting system. According to Equation (7), steady-state availability i π of each state is obtained, and then according to Equation (8), steady-state availability A of the network system is obtained. Table 1 is for steady-state availability of each states and the system when μ=0.5 hours and λ =2000 hours, Table 2 is for steady-state availability of each states and the system when μ=0.5 hours and λ =500 hours, and Table 3 is for steady-state availability of each states and the system when μ=1 hours and λ =100 hours. TABLE I. STEADY-STATE AVAILABILITY CALCULATION RESULTS 1 steady-state availability 0.9985013113  1 0.001497752142  2 0.0000009362705703  3 0.0000000002535257376 A 0.9999999997 TABLE II. STEADY-STATE AVAILABILITY CALCULATION RESULTS2 steady-state availability 0.9880833998  1 0.01185708958  2 0.00005937422712  3 0.0000001284512973 A 0.9999998637  0  0 International Journal of Advanced Network, Monitoring and Controls Volume 05, No.01, 2020 42 TABLE III. STEADY-STATE AVAILABILITY CALCULATION RESULTS 3 steady-state availability 0.9420286502  1 0.05653222481 π2 0.001423815141  3 0.00001530938621 A 0.9999846902 As can be seen from Table 1, 2 and 3, As can be seen from Table 1, 2 and 3, the probability of is the largest, and the probability of and are very small, even negligible. Table 4 is the steady-state availability of a different μ and lambda system. Figure 1 is the curve trend diagram of Table 4, a more intuitive reflection of how steady-state availability varies with μ and λ TABLE IV. STEADY-STATE AVAILABILITY CALCULATION RESULTSOF THE SYSTEM 2000 500 100 2.5 0.9999999609 0.999996172 0.9988771093 1.5 0.9999999928 0.9999994802 0.9999020658 1 0.9999999979 0.9999998637 0.9999846902 0.5 0.9999999997 0.9999999837 0.9999979543 Figure 4. Steady-state availability trend diagram In Table 4, the upper parameter is the node average failure parameter λ, the left parameter is μ. The x-coordinate of Figure 4 is the average node failure parameter λ, the y-coordinate is steady-state availability, and the four different curves are the average node repair time μ. As can be seen from Table 4 and Figure 4, under the Markov model, the steady-state availability of the system is very high, close to 1. The larger the λ, the smaller the μ, the more stable the system can be, which is consistent with the changing rules of P2P networks. According to the analysis of 5.3, P2P network availability cannot be fully reflected by calculating steady-state availability. Therefore, we also need to calculate the instantaneous availability of the system, and calculate the instantaneous availability of the system according to Equations (12) and (13) with the parameters used in Table 1. The results are shown in the following Figure 5. In Figure 5, the horizontal axis is time and the vertical axis is instantaneous availability. Since k=4, there are four curves in the instantaneous curves of multiple states, corresponding to and respectively. In order to make the graph more intuitive to reflect the change of the curve, the graph is divided into two parts, the left one are , and , with the vertical coordinate of 0 to 0.004, and the right one is , with the vertical coordinate of 0.996 to 1. When four nodes fail, the entire network system is down and the network is unavailable. From the figure, we can see that i.e. the zero nodes that are damaged gradually decrease from probability 1, and become stable after reaching a certain time point. The instantaneous availability of is very high, which is close to 1 indefinitely. While the instantaneous availability of other states is relatively small, gradually increases with time until it becomes stable, while the instantaneous availability of and are very small, approaching 0 infinitely. It can be seen that the probability of system failure is very  0 International Journal of Advanced Network, Monitoring and Controls Volume 05, No.01, 2020 43 small. Figure 5. Instantaneous availability graphs of multiple states VII. CONCLUSION For P2P networks, the discrete time Markov chain method is used to establish a model of state transition in P2P networks in this paper, and the repairability of network nodes is considered. The calculation formulas of steady-state availability and instantaneous availability are given by using the model, and the results of the above calculation are obtained. The results are compared with the changing rules of the network system, which conforms to the availability requirements of the P2P network. It shows that this model has certain reference value in the availability test of tactical P2P network. REFERENCES [1] Lianhong Zhou. Availability of fiber optic systems[J].Tsinghua Univ (Sci& Tech).2002.01 [2] Fenghua Xie. Modular UPS reliability calculation and analysis[J].Fuzzy Systems & Mathematics, 2002. [3] Jingle Zhang. Availability Analysis of Flexible Workflow Based on Stochastic Petri Net[J].Computer Engineering.2010.11 [4] Jikun Yang. Reliability and Availability Analysis of Missile Weapon System Based on Fuzzy Bayesian Theory[J]. Journal of Naval Aeronautical and Astronautical.2013 [5] Qifeng Shao. Block chain: Architecture and Research Progress[J].Chinese Journal of Computers. 2018,41(5):769-788 [6] Antonopoulos A M. Mastering Bitcoin : Unlocking Digital Cryptocurrencies[M].California:O’Reilly Media,2014:137-172. [7] Yongnian Wang. Reliability evaluation of k/n[G] system Availability Analysis of Flexible Workflow Based on Stochastic Petri Net. reliability analysis.2015:1-3 [8] Geng Yan. Markov modeling method for availability of twoitem system under passivation[J].Chinese Journal of Scientific Instrument .2016:1-6 [9] Yinan Jiang. The method of network reliability and availability simulation based on Monte Carlo[J]. ICQR2MSE.2012:1-5 [10] Patrick Wüchner. Queueing Networks & Markov Chains[M].Wiley-Interscience.1998:104-108 [11] Du Haidong. Simulation Assessment of Degradation System Reliability under Imperfect Maintenance[J]. Journal of System Simulation.2018,30(8):2834-2840 [12] Ivanovitch, Silva, Luiz Affonso, Guedes, Paulo, Portugal, et al. Reliability and availability evaluation of Wireless Sensor Networks for industrial applications[J]. Sensors, 2012, 12(1):806-838. [13] Datta A. An overview of codes tailor-made for better repairability in networked distributed storage systems[J]. AcmSigact News, 2013, 44(1):89-105. [14] YUAN Yong. Blockchain: The State of the Art and Future Trends [J]. ACTAAUTOMATICASINICA, 2016, 42(4)481-494 [15] Wenli Zhou. Survey of P2P technologies[J]. Computers Engineering and Design , 2006, 27(1):76-79 [16] Xuelong Wang, Jing Zhang,, et al. Survey on peer-to-peer key technologies[J]. Application Research of Computers, 2010, 27(3):801-805,823.