# Analysis of Agricultural Products Supply Chain Traceability System Based on Internet of Things and Blockchain

Authors: Qi Zhang
Journal: Mathematical Problems in Engineering
 (2022)

---

## Abstract

The quality and safety of agricultural products cannot be separated from rural revitalization. This is also related to the interests and development of participating in the agricultural supply chain. The traditional unitary agricultural product quality supervision system meets the growing market demand and requirements. This paper constructs the traceability and blockchain of agricultural products supply chain, as well as the trusted computing model of Internet of things nodes based on blockchain. The results show that the trusted computing model of IOT nodes based on blockchain can effectively identify and remove malicious nodes, ensure the effectiveness, tamperability, security, and reliability of agricultural product process data, greatly reduce the transaction delay, and provide a guarantee.


---

## Body

## 1. Introduction

Food is a very important part of people’s life. A qualified food inspection report is an important voucher for solving quality disputes. False inspection and testing reports not only disrupt the normal business order, but also may cause product quality problems and pose potential risks to consumers’ life, health, and property safety. The exposure of the “cadmium rice” incident, the smuggling of frozen meat incident, and the crayfish incident has led to the continuous improvement of consumers’ awareness of food safety. There are many kinds and large quantities of agricultural products. The traditional supervision model not only needs high cost but also relatively low efficiency. At the same time, it does not build a complete and effective information disclosure mechanism food quality and safety information, resulting in serious asymmetry of information and failure of supervision [1]. Agricultural departments at all levels should make every effort to promote the achievement in positive progress and results and to ensure the quality and safety of agricultural products and maintain an overall stable and gradually improving trend.Compared with the other products, agricultural products need to go through multiple links from planting and production to genuine consumers, and agricultural products themselves are organic organisms, which have the problems of preservation, storage, and transportation and easy decay [2]. Therefore, there are safety risks in any link of agricultural products. To explore the establishment of the environmental safety monitoring and evaluation system for the producing areas of agricultural products, we need to concentrate our efforts on exploring the products, the suburbs of the surrounding areas of industrial and mining enterprises, and other key areas. Most scholars believe that this is due to the simplification of the quality and safety supervision system of agricultural products, which is prone to problems such as blind spots and low efficiency [3, 4]. It is difficult for consumers to identify the responsibility subject of agricultural products, and the division of responsibility is not clear [5, 6]. Other scholars pointed out that the detection system of food additives, harmful substances, and other substances in the quality inspection process of each link in the whole agricultural product supply chain is not perfect, the strength and quantity of detection cannot meet the product regulatory market, and there is a lack of corresponding professional quality inspection talents and effective quality inspection methods [7, 8]. In addition, some scholars pointed out that some agricultural products are vulnerable to pollution in the process of storage and transportation, while there is a lack of reasonable and scientific supervision system for storage and transportation in the safety and quality inspection of agricultural products, and the information transparency of agricultural product supply chain is low [9, 10].Ensuring the major task in the new stage of agricultural development, but also a major responsibility for the agricultural department to perform its duties according to law. Some scholars proposed to build the management system of agricultural key control points, so as to quickly perceive and timely feed back the harmful substances existing from planting to processing and sales, so as to ensure the quality and safety of agricultural products [11]. Other scholars have applied bar code and vegetables and agricultural products, which improves the efficiency of agricultural product information traceability. It can effectively monitor the quality and safety and enable consumers to carry out effective information traceability [12, 13]. The production team, time, and process of products can be traced through bar code. It is through tracing management to investigate the quality of the person accident, so as to increase the awareness of the producers and operators [14]. In addition, some scholars have effectively combined blockchain technology with RFID, QR code, and other technologies to build a real-time data tracking system for all links put on the chain [15, 16]. At the same time, some scholars pointed out that the application of product traceability system still has security and distribution problems, which should be optimized and improved in combination with other technologies, and the query function of blockchain system has been expanded in an easy to implement way [17, 18].The development of agricultural product traceability system can recall the existing agricultural products, reduce the damage to the interests of consumers, and clarify the responsibilities of relevant enterprises. Consumers and enterprises can reduce the cost of obtaining relevant information, improve the credibility of agricultural products, and promote the development of transaction rate and brand of agricultural products [19]. Enterprises can better improve management efficiency, optimize product quality, and improve the overall market core competitiveness by using relevant information.


## 2. Agricultural Product Tracking System

The quality and safety traceability system and traceability system of agricultural products have also been gradually built, and great changes have taken place in its production field. At present, there are many traceability systems for agricultural products in China. These traceability systems can trace the source of agricultural products to a certain extent. However, compared with foreign traceability systems, there is a lack of unified standards and cannot be shared among provinces, which seriously affects the implementation and promotion of traceability systems. China is rich in agricultural products. The establishment of a quality traceability system can greatly promote the standardization, and systematization of the planting of characteristic agricultural products. It can play a positive role in improving the quality of agricultural products, strengthening the market competitiveness of products, and protecting characteristic resources.The supply chain of agricultural products needs to go through many links from production to sales. There may be safety and quality problems in each link, and the subject of responsibility in each link is different. At the same time, agricultural products have a wide variety, short shelf life, difficult storage, and different needs for transportation environmental conditions. Therefore, the traceability link of agricultural products supply chain is complex and the main body is changeable. The normal system is not only inefficient, but also difficult to ensure the reliability of agricultural product safety information, and cannot meet the pursuit and demand of consumers [20]. The key to the traceability is to build a complete and continuous information system combining supply chain and logistics to ensure the information transparency of agricultural products in the whole supply chain, so as to realize the forward and reverse traceability and accountability of farm product supply chain in a short time. Internet of things technology can build a traceable chain system and solve the quality and safety problems through intelligent management and control. However, the system has the problems of low information reliability and data can be tampered with, and it is difficult to share traceability information among different enterprises [21]. The blockchain is not only traceable in the whole process, but also has the characteristics of unforgeability, openness, transparency, and decentralization. The combination of the two can learn from each other, locate and detect malicious nodes of the Internet of things, optimize data storage, improve identity authentication, make the traceability information of agricultural products supply chain completely open and transparent, realize the efficient transmission of credit risk-free and leverage free between things, and ensure the reliability and integrity of agricultural products supply chain information.


### 2.1. Construction of Traceability System

Agricultural product traceability system refers to the system that tracks the entry of agricultural products (including food and means of production) into the market at all stages (the whole process from production to circulation). It involves many links such as the origin, processing, transportation, wholesale, and sales of agricultural products, which is conducive to quality control and recall of products when necessary. The traceability system of agricultural products can realize the traceability from the source of products to the processing and circulation process, ensure that end users can buy assured products, and prevent fake and shoddy agricultural products from entering the market.As shown in Figure1, it is a product safety traceability system. The system introduces blockchain technology and superimposes the operation rules of the agricultural product supply chain product safety traceability system. The system mainly includes four layers. The physical layer uses an equipment to realize the automatic data collection, transmission, and management of agricultural products in different links. The data layer, that is, the node with accounting right. The blockchain generates timestamp data signatures that can correspond to agricultural products one by one, and uses distributed data storage to ensure the integrity of the data. The data layer can realize the sharing of agricultural product data information, promote, and avoid the problem of information island. The core layer, i.e., blockchain, embeds the laws, and tests whether the uploaded data complies with the relevant contract provisions, which promotes the development of standardized and intelligent supervision of agricultural products and greatly improves the supervision efficiency. The application layer is that all enterprises and consumers in the agricultural product supply chain can query and trace the relevant agricultural product quality and safety information data through computers or mobile intelligent terminals.Figure 1
Product safety traceability system.As shown in Figure1, it is a product safety traceability system based on the Internet of things and blockchain. The system introduces and superimposes the operation rules of the agricultural product supply chain product safety traceability system. The system mainly includes four layers. The physical layer uses equipment to realize the automatic data collection, transmission, and management of agricultural products in different links. The data layer, that is, the node with accounting right, writes the relevant data into the block and encapsulates it. At the same time, the blockchain generates timestamp data signatures that can correspond to agricultural products one by one, and uses distributed data storage to ensure the integrity of the data. The data layer can realize the sharing of agricultural product data information, promote the efficiency of information transmission, and avoid the problem of information island. The core layer, i.e., blockchain in the form of smart contract, and tests whether the uploaded data complies with the relevant contract provisions, which promotes the development of standardized and intelligent supervision of agricultural products and greatly improves the supervision efficiency. The application layer is that all enterprises and consumers can query and trace the relevant agricultural product quality and safety information data through computers or mobile intelligent terminals.


### 2.2. Construction of Trusted Computing Model of Internet of Things Nodes Based on Blockchain

The wireless sensor network of the Internet of things includes multiple microsensor nodes, which can cover a wide area, deploy quickly, and monitor remotely. It has high accuracy; WSNs nodes are vulnerable to the threat of malicious nodes due to their large number of nodes and relatively weak perception. Distributed algorithms in the Internet of things depend on single agent computing. However, it is vulnerable to data injection attacks from internal malicious nodes. Most of the existing detection methods run locally, and there are problems such as data closure, single point of failure, and opaque detection process. We can consider using blockchain technology and smart contract to detect malicious nodes in the network. Based on the decentralization and multilocation backup characteristics of blockchain technology, the proposed method realizes data sharing and avoids the problem of single point of failure.One of the most valuable attributes of most blockchain applications is “Trustlessness,” that is, the application can keep running in the expected way without relying on specific participants to act in a specific form, even if their relevant interests may change in the future and make them make unexpected actions. Blockchain applications are never completely trust free, but some applications are more trust free than others.Therefore, this paper combines the blockchain trust model to detect malicious nodes in the Internet of things framework, so as to curb the interference of malicious nodes and improve the security, authenticity, and reliability of traceability information in the agricultural supply chain. Figure2 shows the blockchain trust model.Figure 2
Overall structure diagram based on blockchain trust model.Let the model be abbreviated asBTW, which is an octet, as shown in (1):(1)BTW=BS,AN,Sensor,Cmndb,IC,T,α,β,where, the contract publishing point is bs and its finite set is BS=bsi|i∈ℕ+, the CA node and verification node are sn and its finite set is SN=sni|j∈ℕ+, the ordinary node is sensor and its finite set is Sensor=sensork|k∈ℕ+, the blockchain for malicious node detection of WSNs is Cmndb, its smart contract is IC, the mapping function of ordinary nodes and sn in the blockchain is α:Sensor∨SN⟶Cmndb, and the location list of ordinary nodes is β.Smart contracts are also octets, as shown in (2):(2)Cmndb−IC=bs,sn,sensor,δ,η,Cmndb−BDS,QM.In the formula,Cmndb−IC publisher is bs, bs authorized stock sink node is sn, candidate malicious node is sensor, malicious sensor evaluation index is δ, reputation is η, Cmndb data structure is Cmndb−BDS, and WSNs positioning method represents Cmndb−IC as QM.The evaluation of malicious nodes has certain subjectivity and uncertainty. Therefore, this paper selects four evaluation indexes. Let the processing delay be expressed asDT, and its evaluation value range is shown in formula (3):(3)DT=Tsensor_idT1∗100%,0<Tsensor_idT1<1,1,Tsensor_idT1≥1,where, the time taken by the id sensor to complete data reception and transmission in T1 time interval is expressed as Tsensor_id.The evaluation range of forwarding rate is shown in formula (4):(4)FR=sdtd∗100%.The range of response time evaluation value is shown in formula (5):(5)RT=dbn/bw+pd/ps+ptT2,where, the response time is expressed as RT, the propagation speed is expressed as pt, and a certain time interval is expressed as T2.The final single communication quality of the sensor node is shown in formula (6):(6)NCQ=0,state=0,γ∗DT+λ∗1−FR+σ∗RT,state=1,where the single communication quality is expressed as NCQ, the weight of processing delay is expressed as γ, the weight of forwarding rate is expressed as λ, the weight of response time is expressed as σ, and γ+λ+σ=1. Set the threshold k and when NCQ≤k, the number of successful communication Ns of the node increases once, otherwise the number of failed communication NF increases once. Calculate the node credit according to the number of successful and failed communications, as shown in formula (7):(7)η=Ns+1Ns+NF+2,where, the node credit is expressed as η.Because it is difficult to obtain the location information of all nodes in the initial stage of the sensor network system, this paper divides the terminal nodes into two types: the anchor node set with known location and the unknown node set without knowing its location. The nodes with unknown location can be obtained by four-sided measurement method. Let the distance between the expressed asd1,d2,d3,d4 respectively, then the calculation formula of node U position data is shown in formula (8):(8)x−x12+y−y12+z−z12=d12,x−x22+y−y22+z−z22=d22,x−x32+y−y32+z−z32=d32,x−x42+y−y42+z−z42=d42.In this paper, the frequent exchange of noncritical data is carried out through the DCPN model. Due to the time attribute of frequent exchange of noncritical data, this paper constructs a delay control Petri net, which is ten tuples, as shown in (9):(9)DCPN=S,T,F,R,C,DI,DC,CF,OP,M0s,where S=SN∪SF and SN=sn represent all finite sets of conventional discrete library and all finite sets of fuzzy library are SF=sf; T=TO∪TD and TO=to, TD=td is a finite set with finite delay; F⊂S×T∪T×S represents the finite set of arcs; R⊂SN×TD represents a finite set of suppression arcs; C⊂SF×TD denotes a finite set of control arcs; DI:TD⟶ℝ+ represents the time delay function of TD, DIt=λ means that the transition t needs λ time units to complete; DC:C⟶0,1 is the time delay control function on C; CF:TO×SF⟶0,1 is the confidence function of TN×SF; OP:T×SF⟶ℕ0+ is the output function of T×SN; M0:SN⟶ℕ0+ indicates DCPN initial identification. In the DCPN running rule, if the condition ∀s∈·to:Mis>0 is satisfied in to∈TO, the transition to of Mi has the right to occur, which is expressed as Mito>; When td∈TD, if ∀s∈·td&s,td∈F⟶Mis>0, ∀s∈·td&s,td∈R⟶Mis=0, the change td of the identification Mi has the right to occur, that is, it is expressed as Mitd>; Under the condition of Mi, the change t∈T will generate a new identification Mi+1, which is expressed as Mit>Mi+1, and its expression is shown in (10):(10)Mi+1s=0,ift∈T∧s∈SN∧s∈·t∧s,t∈F,maxMis,CFt,s,ift∈To∧s∈SF∧s∈t·,Mis+OPt,s,ift∈T∧s∈SN∧s∈t·,Mis,else.Under the condition ofMi, ∃s∈SF∧t∈TD, c=s,t,c∈C and Mis=α,α∈0,1, the time delay control function is shown in formula (11):(11)DCα=−11+eω∗α−ξ+σ,where the constant is expressed as ω,ξ,σ.UnderMi condition, ∃t∈TO∧s∈SF, t,s∈F and ∀s∈·to:Mis>0, the expression of confidence function is shown in (12):(12)CFt,s=2πarctan∏Mi·tρ,where the constant is ρ, and the state component product of all t’s pre libraries is expressed as ∏Mi·t.Under the condition ofMi, ∃t∈T∧s∈SN, t,s∈F, and ∀s∈·t:Mis>0, the output function expression is shown in (13):(13)OPt,s=ψ,if∃t′∈T∧t′≠t∧s,t′∈R,1,else.In this paper, the credit ratingα is used to evaluate the dynamic credit status of the initiator, as shown in formulas (14)–(16):(14)ε=Amountnds−η∗Amountbds,(15)ϕ=Countnds−κ∗Countbds,(16)α=2πarctanε∗ϕρ.Among them, the element summation function in the set is expressed asAmount, the counting function is expressed as Count, and the corresponding bad data exchange penalty coefficient is expressed as η,κ.


## 2.1. Construction of Traceability System

Agricultural product traceability system refers to the system that tracks the entry of agricultural products (including food and means of production) into the market at all stages (the whole process from production to circulation). It involves many links such as the origin, processing, transportation, wholesale, and sales of agricultural products, which is conducive to quality control and recall of products when necessary. The traceability system of agricultural products can realize the traceability from the source of products to the processing and circulation process, ensure that end users can buy assured products, and prevent fake and shoddy agricultural products from entering the market.As shown in Figure1, it is a product safety traceability system. The system introduces blockchain technology and superimposes the operation rules of the agricultural product supply chain product safety traceability system. The system mainly includes four layers. The physical layer uses an equipment to realize the automatic data collection, transmission, and management of agricultural products in different links. The data layer, that is, the node with accounting right. The blockchain generates timestamp data signatures that can correspond to agricultural products one by one, and uses distributed data storage to ensure the integrity of the data. The data layer can realize the sharing of agricultural product data information, promote, and avoid the problem of information island. The core layer, i.e., blockchain, embeds the laws, and tests whether the uploaded data complies with the relevant contract provisions, which promotes the development of standardized and intelligent supervision of agricultural products and greatly improves the supervision efficiency. The application layer is that all enterprises and consumers in the agricultural product supply chain can query and trace the relevant agricultural product quality and safety information data through computers or mobile intelligent terminals.Figure 1
Product safety traceability system.As shown in Figure1, it is a product safety traceability system based on the Internet of things and blockchain. The system introduces and superimposes the operation rules of the agricultural product supply chain product safety traceability system. The system mainly includes four layers. The physical layer uses equipment to realize the automatic data collection, transmission, and management of agricultural products in different links. The data layer, that is, the node with accounting right, writes the relevant data into the block and encapsulates it. At the same time, the blockchain generates timestamp data signatures that can correspond to agricultural products one by one, and uses distributed data storage to ensure the integrity of the data. The data layer can realize the sharing of agricultural product data information, promote the efficiency of information transmission, and avoid the problem of information island. The core layer, i.e., blockchain in the form of smart contract, and tests whether the uploaded data complies with the relevant contract provisions, which promotes the development of standardized and intelligent supervision of agricultural products and greatly improves the supervision efficiency. The application layer is that all enterprises and consumers can query and trace the relevant agricultural product quality and safety information data through computers or mobile intelligent terminals.


## 2.2. Construction of Trusted Computing Model of Internet of Things Nodes Based on Blockchain

The wireless sensor network of the Internet of things includes multiple microsensor nodes, which can cover a wide area, deploy quickly, and monitor remotely. It has high accuracy; WSNs nodes are vulnerable to the threat of malicious nodes due to their large number of nodes and relatively weak perception. Distributed algorithms in the Internet of things depend on single agent computing. However, it is vulnerable to data injection attacks from internal malicious nodes. Most of the existing detection methods run locally, and there are problems such as data closure, single point of failure, and opaque detection process. We can consider using blockchain technology and smart contract to detect malicious nodes in the network. Based on the decentralization and multilocation backup characteristics of blockchain technology, the proposed method realizes data sharing and avoids the problem of single point of failure.One of the most valuable attributes of most blockchain applications is “Trustlessness,” that is, the application can keep running in the expected way without relying on specific participants to act in a specific form, even if their relevant interests may change in the future and make them make unexpected actions. Blockchain applications are never completely trust free, but some applications are more trust free than others.Therefore, this paper combines the blockchain trust model to detect malicious nodes in the Internet of things framework, so as to curb the interference of malicious nodes and improve the security, authenticity, and reliability of traceability information in the agricultural supply chain. Figure2 shows the blockchain trust model.Figure 2
Overall structure diagram based on blockchain trust model.Let the model be abbreviated asBTW, which is an octet, as shown in (1):(1)BTW=BS,AN,Sensor,Cmndb,IC,T,α,β,where, the contract publishing point is bs and its finite set is BS=bsi|i∈ℕ+, the CA node and verification node are sn and its finite set is SN=sni|j∈ℕ+, the ordinary node is sensor and its finite set is Sensor=sensork|k∈ℕ+, the blockchain for malicious node detection of WSNs is Cmndb, its smart contract is IC, the mapping function of ordinary nodes and sn in the blockchain is α:Sensor∨SN⟶Cmndb, and the location list of ordinary nodes is β.Smart contracts are also octets, as shown in (2):(2)Cmndb−IC=bs,sn,sensor,δ,η,Cmndb−BDS,QM.In the formula,Cmndb−IC publisher is bs, bs authorized stock sink node is sn, candidate malicious node is sensor, malicious sensor evaluation index is δ, reputation is η, Cmndb data structure is Cmndb−BDS, and WSNs positioning method represents Cmndb−IC as QM.The evaluation of malicious nodes has certain subjectivity and uncertainty. Therefore, this paper selects four evaluation indexes. Let the processing delay be expressed asDT, and its evaluation value range is shown in formula (3):(3)DT=Tsensor_idT1∗100%,0<Tsensor_idT1<1,1,Tsensor_idT1≥1,where, the time taken by the id sensor to complete data reception and transmission in T1 time interval is expressed as Tsensor_id.The evaluation range of forwarding rate is shown in formula (4):(4)FR=sdtd∗100%.The range of response time evaluation value is shown in formula (5):(5)RT=dbn/bw+pd/ps+ptT2,where, the response time is expressed as RT, the propagation speed is expressed as pt, and a certain time interval is expressed as T2.The final single communication quality of the sensor node is shown in formula (6):(6)NCQ=0,state=0,γ∗DT+λ∗1−FR+σ∗RT,state=1,where the single communication quality is expressed as NCQ, the weight of processing delay is expressed as γ, the weight of forwarding rate is expressed as λ, the weight of response time is expressed as σ, and γ+λ+σ=1. Set the threshold k and when NCQ≤k, the number of successful communication Ns of the node increases once, otherwise the number of failed communication NF increases once. Calculate the node credit according to the number of successful and failed communications, as shown in formula (7):(7)η=Ns+1Ns+NF+2,where, the node credit is expressed as η.Because it is difficult to obtain the location information of all nodes in the initial stage of the sensor network system, this paper divides the terminal nodes into two types: the anchor node set with known location and the unknown node set without knowing its location. The nodes with unknown location can be obtained by four-sided measurement method. Let the distance between the expressed asd1,d2,d3,d4 respectively, then the calculation formula of node U position data is shown in formula (8):(8)x−x12+y−y12+z−z12=d12,x−x22+y−y22+z−z22=d22,x−x32+y−y32+z−z32=d32,x−x42+y−y42+z−z42=d42.In this paper, the frequent exchange of noncritical data is carried out through the DCPN model. Due to the time attribute of frequent exchange of noncritical data, this paper constructs a delay control Petri net, which is ten tuples, as shown in (9):(9)DCPN=S,T,F,R,C,DI,DC,CF,OP,M0s,where S=SN∪SF and SN=sn represent all finite sets of conventional discrete library and all finite sets of fuzzy library are SF=sf; T=TO∪TD and TO=to, TD=td is a finite set with finite delay; F⊂S×T∪T×S represents the finite set of arcs; R⊂SN×TD represents a finite set of suppression arcs; C⊂SF×TD denotes a finite set of control arcs; DI:TD⟶ℝ+ represents the time delay function of TD, DIt=λ means that the transition t needs λ time units to complete; DC:C⟶0,1 is the time delay control function on C; CF:TO×SF⟶0,1 is the confidence function of TN×SF; OP:T×SF⟶ℕ0+ is the output function of T×SN; M0:SN⟶ℕ0+ indicates DCPN initial identification. In the DCPN running rule, if the condition ∀s∈·to:Mis>0 is satisfied in to∈TO, the transition to of Mi has the right to occur, which is expressed as Mito>; When td∈TD, if ∀s∈·td&s,td∈F⟶Mis>0, ∀s∈·td&s,td∈R⟶Mis=0, the change td of the identification Mi has the right to occur, that is, it is expressed as Mitd>; Under the condition of Mi, the change t∈T will generate a new identification Mi+1, which is expressed as Mit>Mi+1, and its expression is shown in (10):(10)Mi+1s=0,ift∈T∧s∈SN∧s∈·t∧s,t∈F,maxMis,CFt,s,ift∈To∧s∈SF∧s∈t·,Mis+OPt,s,ift∈T∧s∈SN∧s∈t·,Mis,else.Under the condition ofMi, ∃s∈SF∧t∈TD, c=s,t,c∈C and Mis=α,α∈0,1, the time delay control function is shown in formula (11):(11)DCα=−11+eω∗α−ξ+σ,where the constant is expressed as ω,ξ,σ.UnderMi condition, ∃t∈TO∧s∈SF, t,s∈F and ∀s∈·to:Mis>0, the expression of confidence function is shown in (12):(12)CFt,s=2πarctan∏Mi·tρ,where the constant is ρ, and the state component product of all t’s pre libraries is expressed as ∏Mi·t.Under the condition ofMi, ∃t∈T∧s∈SN, t,s∈F, and ∀s∈·t:Mis>0, the output function expression is shown in (13):(13)OPt,s=ψ,if∃t′∈T∧t′≠t∧s,t′∈R,1,else.In this paper, the credit ratingα is used to evaluate the dynamic credit status of the initiator, as shown in formulas (14)–(16):(14)ε=Amountnds−η∗Amountbds,(15)ϕ=Countnds−κ∗Countbds,(16)α=2πarctanε∗ϕρ.Among them, the element summation function in the set is expressed asAmount, the counting function is expressed as Count, and the corresponding bad data exchange penalty coefficient is expressed as η,κ.


## 3. Experimental Results and Analysis of Traceability System

### 3.1. Experimental Results and Analysis of Network Node Trusted Computing Model

The data management center sends various data of agricultural products to the monitoring personnel, which improves the production and processing level of agricultural products. When there are safety risks in agricultural products, the network monitoring system will carry out automatic early warning and classify the risk level. To ensure the quality of agricultural products, it is imperative to apply the network information monitoring platform for data management. In order to test the trusted computing model of IOT nodes, the feasibility of the malicious node detection model of wireless sensor networks based on blockchain trust model is verified. In the experiment, the sensors to be tested are positioned accordingly, and in order, allsensor nodes will be clustered, as shown in Figure 3, which is the contract address of each node and the number of sensor nodes covered in the smart contract.Figure 3
The contract address of each node and the number of nodes covered in the smart contract.In order to further detect malicious sensors, allsensor credits are calculated, and the results are shown in Figure 4. In Figure 4, the abscissa is the sensor ID and the ordinate is the credit rating.Figure 4
All credit ratings.From the experiment based on the blockchain trust model, it can be seen that the model has a distributed data structure, which makes it closely related to the previous block and the next block. You need to change the records of more than 51% of its local data. The amount of data and change complexity realize the purpose that the process data cannot be tampered with. Therefore, it improves the stability and reliability of the whole model system. In addition, the data block based on time sequence can be permanently stored in all sensors, which provides a guarantee for tracing the original data and updating the tracking process in real time. Therefore, once the malicious node in WSNs is determined, the identity of the attacking node will be handled by corresponding measures to reduce its possible further adverse effects.There is a small transaction between an agricultural product retailer and five other initiators. The retailer and nine other retailers work together as the transaction verification node to verify the transaction. As shown in Figures5 and 6, the transaction distance, the composition time of the next block, and the credit degree of each initiator are shown, respectively.Figure 5
Each transaction distance and the composition time of the next block.Figure 6
Credit rating of each initiator.In the conventional transaction mode of blockchain, the transaction can be confirmed only after the composition of new blocks. Therefore, the time in Figure5 can be regarded as the time to wait for determination. During transaction confirmation, the model will complete the transaction with high credit degree in advance according to the credit degree of the initiator in Figure 6, reducing most unnecessary waiting time.As shown in Figure7, the total delay comparison results of multiple rounds of transactions of DCPN model and other methods are shown. In the figure that the delay time of multiple rounds of small transactions through DCPN model is less than that of the other two methods, which shows that the model improves the efficiency of transaction verification and greatly reduces the transaction delay based on the credit degree of the initiator.Figure 7
Comparison results of total delay of multiple rounds of transactions between DCPN model and other methods.To sum up, the trusted computing model of IOT nodes based on blockchain can detect and identify malicious nodes in WSNs, effectively trace the location to exclude the network, and reduce the adverse impact of its attacks. At the same time, the complexity of the data structure of the model makes the recorded process data cannot be tampered with, which ensures the reliability of tracing the original data. In addition, based on the credit degree of the transaction initiator, the model can effectively reduce the transaction delay, reduce unnecessary waiting time, and provide query time guarantee for the agricultural product supply chain traceability system.


### 3.2. Experimental Results and Analysis of Traceability Products

This paper tests and compares the traceability systems of different agricultural products supply chain, that is, to complete the same query task under the same situation. The system is constructed and developed by using two-dimensional code technology, database technology, and network information technology to realize the traceability of agricultural products. Track and trace the whole process from planting, harvesting, and processing to sales in the whole supply chain. The supervision of the quality and safety of agricultural products has been effectively strengthened to ensure the consumers’ final right to know. This paper uses the actual test results of the system in some areas of Jiangsu to verify the feasibility and effectiveness of the scheme.Considering that in practice, the query time of the system within a certain range due to the influence of other factors, in order to make a more objective comparative analysis, each group of data calculated for many times will be taken as the final comparison ratio. The number of system traceability records selected in the experiment is 10 K, 50 K, and 90 K, respectively. The correlation coefficient isR, the significance is expressed as P, and the significance level is α=0.05. As shown in Figure 8, the query time comparison results of different systems in different trace record quantities reflect the number of batch trace records in the case of a specific total number of trace records. From the results in the figure that the query time of system 1 and the query system in this paper, and the correlation coefficient between them is higher than 0.8, and P<0.05. The correlation coefficient between the query time of system 2 and the batch traceability record is lower than 0.5, showing weak correlation.Figure 8
Query time comparison results of different systems in different traceability records.As shown in Figure9, the query efficiency improvement rate of the system in this paper is compared with that of system 1 and system 2, respectively. According to the data in Figure 9(a), when the two systems query a single trace record, a large proportion of the time is the fluctuation interval. In terms of the improvement rate of query efficiency, the stability of the system in this paper is relatively low. It shows correlation with the two systems. At this time, the query improvement rate of the system is higher than that of system 1, and the state is more stable. As can be seen from Figure 9(b), the relationship between the two systems and the quantity of batch traceability records is different. This paper decreases with the increase of their quantity, and there is a weak correlation between system 2 and them. The number of batch records of agricultural products in the experiment kept within the range of 200 to 400. The overall number of traceability records in this system is positively correlated with nodes and time. When the number of query efficiency reaches 400, the system will continue to improve with the increase of the total number. When the total number reaches 10000, the efficiency of this system is negative, and the query efficiency is lower than system 2. However, when the total number exceeds 30000, the efficiency of this system is higher than system 2, and the advantages will continue to expand with the increase of the overall number.Figure 9
This paper compares the query efficiency improvement rate of the system with that of system 1 and system 2. (a) This paper compares the efficiency improvement of system and system 1. (b) This paper compares the efficiency improvement of system and system 2.
(a)(b)To sum up, there is a positive correlation between the query time number of batch traceability records. When the number exceeds 200, the query improvement rate of the system in this paper is more stable. When the number reaches 400, the query efficiency of this system continues to improve. When the number exceeds 30 K, the query efficiency of this system continues to expand due to system 2 and its advantages.


## 3.1. Experimental Results and Analysis of Network Node Trusted Computing Model

The data management center sends various data of agricultural products to the monitoring personnel, which improves the production and processing level of agricultural products. When there are safety risks in agricultural products, the network monitoring system will carry out automatic early warning and classify the risk level. To ensure the quality of agricultural products, it is imperative to apply the network information monitoring platform for data management. In order to test the trusted computing model of IOT nodes, the feasibility of the malicious node detection model of wireless sensor networks based on blockchain trust model is verified. In the experiment, the sensors to be tested are positioned accordingly, and in order, allsensor nodes will be clustered, as shown in Figure 3, which is the contract address of each node and the number of sensor nodes covered in the smart contract.Figure 3
The contract address of each node and the number of nodes covered in the smart contract.In order to further detect malicious sensors, allsensor credits are calculated, and the results are shown in Figure 4. In Figure 4, the abscissa is the sensor ID and the ordinate is the credit rating.Figure 4
All credit ratings.From the experiment based on the blockchain trust model, it can be seen that the model has a distributed data structure, which makes it closely related to the previous block and the next block. You need to change the records of more than 51% of its local data. The amount of data and change complexity realize the purpose that the process data cannot be tampered with. Therefore, it improves the stability and reliability of the whole model system. In addition, the data block based on time sequence can be permanently stored in all sensors, which provides a guarantee for tracing the original data and updating the tracking process in real time. Therefore, once the malicious node in WSNs is determined, the identity of the attacking node will be handled by corresponding measures to reduce its possible further adverse effects.There is a small transaction between an agricultural product retailer and five other initiators. The retailer and nine other retailers work together as the transaction verification node to verify the transaction. As shown in Figures5 and 6, the transaction distance, the composition time of the next block, and the credit degree of each initiator are shown, respectively.Figure 5
Each transaction distance and the composition time of the next block.Figure 6
Credit rating of each initiator.In the conventional transaction mode of blockchain, the transaction can be confirmed only after the composition of new blocks. Therefore, the time in Figure5 can be regarded as the time to wait for determination. During transaction confirmation, the model will complete the transaction with high credit degree in advance according to the credit degree of the initiator in Figure 6, reducing most unnecessary waiting time.As shown in Figure7, the total delay comparison results of multiple rounds of transactions of DCPN model and other methods are shown. In the figure that the delay time of multiple rounds of small transactions through DCPN model is less than that of the other two methods, which shows that the model improves the efficiency of transaction verification and greatly reduces the transaction delay based on the credit degree of the initiator.Figure 7
Comparison results of total delay of multiple rounds of transactions between DCPN model and other methods.To sum up, the trusted computing model of IOT nodes based on blockchain can detect and identify malicious nodes in WSNs, effectively trace the location to exclude the network, and reduce the adverse impact of its attacks. At the same time, the complexity of the data structure of the model makes the recorded process data cannot be tampered with, which ensures the reliability of tracing the original data. In addition, based on the credit degree of the transaction initiator, the model can effectively reduce the transaction delay, reduce unnecessary waiting time, and provide query time guarantee for the agricultural product supply chain traceability system.


## 3.2. Experimental Results and Analysis of Traceability Products

This paper tests and compares the traceability systems of different agricultural products supply chain, that is, to complete the same query task under the same situation. The system is constructed and developed by using two-dimensional code technology, database technology, and network information technology to realize the traceability of agricultural products. Track and trace the whole process from planting, harvesting, and processing to sales in the whole supply chain. The supervision of the quality and safety of agricultural products has been effectively strengthened to ensure the consumers’ final right to know. This paper uses the actual test results of the system in some areas of Jiangsu to verify the feasibility and effectiveness of the scheme.Considering that in practice, the query time of the system within a certain range due to the influence of other factors, in order to make a more objective comparative analysis, each group of data calculated for many times will be taken as the final comparison ratio. The number of system traceability records selected in the experiment is 10 K, 50 K, and 90 K, respectively. The correlation coefficient isR, the significance is expressed as P, and the significance level is α=0.05. As shown in Figure 8, the query time comparison results of different systems in different trace record quantities reflect the number of batch trace records in the case of a specific total number of trace records. From the results in the figure that the query time of system 1 and the query system in this paper, and the correlation coefficient between them is higher than 0.8, and P<0.05. The correlation coefficient between the query time of system 2 and the batch traceability record is lower than 0.5, showing weak correlation.Figure 8
Query time comparison results of different systems in different traceability records.As shown in Figure9, the query efficiency improvement rate of the system in this paper is compared with that of system 1 and system 2, respectively. According to the data in Figure 9(a), when the two systems query a single trace record, a large proportion of the time is the fluctuation interval. In terms of the improvement rate of query efficiency, the stability of the system in this paper is relatively low. It shows correlation with the two systems. At this time, the query improvement rate of the system is higher than that of system 1, and the state is more stable. As can be seen from Figure 9(b), the relationship between the two systems and the quantity of batch traceability records is different. This paper decreases with the increase of their quantity, and there is a weak correlation between system 2 and them. The number of batch records of agricultural products in the experiment kept within the range of 200 to 400. The overall number of traceability records in this system is positively correlated with nodes and time. When the number of query efficiency reaches 400, the system will continue to improve with the increase of the total number. When the total number reaches 10000, the efficiency of this system is negative, and the query efficiency is lower than system 2. However, when the total number exceeds 30000, the efficiency of this system is higher than system 2, and the advantages will continue to expand with the increase of the overall number.Figure 9
This paper compares the query efficiency improvement rate of the system with that of system 1 and system 2. (a) This paper compares the efficiency improvement of system and system 1. (b) This paper compares the efficiency improvement of system and system 2.
(a)(b)To sum up, there is a positive correlation between the query time number of batch traceability records. When the number exceeds 200, the query improvement rate of the system in this paper is more stable. When the number reaches 400, the query efficiency of this system continues to improve. When the number exceeds 30 K, the query efficiency of this system continues to expand due to system 2 and its advantages.


## 4. Conclusion

The traditional unitary agricultural product supervision system and requirements of the market, and retrospective investigation and analysis are carried out for product safety. Combined with Internet of things and blockchain, the reliability calculation model of product nodes based on blockchain is constructed. The trusted computing model of IOT nodes based on blockchain can effectively detect and identify malicious nodes in the network and remove them. The blockchain data structure makes the process data of agricultural products cannot be tampered, which ensures the security and reliability of the system. In addition, the trusted computing model of Internet of things nodes based on blockchain can effectively reduce the transaction delay and ensure the query efficiency of agricultural products supply chain traceability system. There is a positive correlation between the query time and records of the agricultural products and blockchain, and the query improvement rate of the system is more stable when the batch traceability records exceed 200. The total number of traceable records, the accuracy of the system is increasing, and the advantages are expanding. This paper has some limitations. Blockchain technology is not yet mature. This paper does not discuss the prominent contradiction between privacy protection and data sharing, the limitations of performance efficiency, and the lack of coordination inside and outside the chain. This needs further analysis in future research and analysis.



---

*Source: 3162871-2022-06-25.xml*