A LoRaWAN networking and positioning simulation system based on NS3 and ChirpStack

By combining the NS3 simulator and ChirpStack server, the LoRaWAN signal propagation model is optimized using real network data, and the problem of the gap between the LoRaWAN simulation results and the actual difference is solved, and networking and positioning simulation with higher accuracy is achieved, reducing research costs and time.

CN118631677BActive Publication Date: 2024-12-10NORTHWESTERN POLYTECHNICAL UNIV
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202411088476.5
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2024-08-09
Publication Date
2024-12-10
Estimated Expiration
2044-08-09

AI Technical Summary

Technical Problem

The existing LoRaWAN Model is difficult to accurately simulate signal propagation models, resulting in a large gap between the simulation results and the actual network performance. The wide coverage and large connection characteristics of the LoRaWAN network have caused researchers to face time and cost challenges when deploying the network.

Method used

Using LoRaWAN networking and positioning simulation system based on NS3 and ChirpStack, through the combination of LoRaWAN terminal, LoRaWAN gateway, ChirpStack server and NS3 simulator, the signal propagation model is optimized using real network data, and the fluctuation of Gaussian noise analog signal arrival time is introduced to realize the fluctuation of Gaussian noise analog signal arrival time. More accurate networking and positioning simulation.

Benefits of technology

It improves the accuracy of simulation results, reduces experimental costs, improves research efficiency, and provides researchers with simulation capabilities for more complex networks.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN118631677B_ABST
    Figure CN118631677B_ABST
Patent Text Reader

Abstract

The present invention discloses a LoRaWAN networking and positioning simulation system based on NS3 and ChirpStack, comprising a LoRaWAN terminal, a LoRaWAN gateway, a ChirpStack server, an NS3 operating platform, a data acquisition program and an NS3 simulator; the LoRaWAN terminal sends data to the LoRaWAN gateway, and then forwards it to the ChirpStack server; the data acquisition program communicates with the ChirpStack server and reads the data; the NS3 simulator simulates the fluctuation of the time when the signal in the NS3 simulator reaches the LoRaWAN gateway according to the data read from the ChirpStack server by the data acquisition program; and the LoRaWAN networking and positioning simulation process is completed. The present invention can obtain simulation results with higher accuracy.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention belongs to the technical field of Internet of Things, and in particular relates to a LoRaWAN networking and positioning simulation system based on NS3 and ChirpStack. Background Art

[0002] As an emerging IoT technology, LoRa (Long Range) can communicate up to 5km and 15km in urban and suburban areas respectively. It has the characteristics of wide coverage, large connections, low power consumption, low cost, simple network structure and flexible deployment, making LoRa positioning an effective means to solve the problems of GNSS denial, cellular positioning limited by infrastructure, and small coverage of ZigBee / Bluetooth positioning. Since its establishment in 2015, the LoRa Alliance has continuously promoted the commercial application of LoRa technology in the fields of low-power networking, wide-area positioning, etc. by formulating the LoRaWAN protocol specification and publishing the LoRaWAN positioning white paper, and has aroused widespread interest among relevant researchers.

[0003] In order to continuously improve the networking and positioning performance of LoRaWAN, many researchers have used the open source NS3 simulator and introduced the LoRaWAN Model in the APP Store of the NS3 simulator to carry out related model simulation work. However, since the actual LoRaWAN network is deployed in various complex environments such as cities, suburbs, and mountains, it is difficult for the existing LoRaWAN Model to simulate the signal propagation model more accurately, resulting in a large gap between the simulation results and the actual network performance.

[0004] There are also many researchers who have carried out specific experimental work by deploying actual LoRaWAN networks, and have studied the optimization of LoRaWAN's networking protocols and the improvement of positioning algorithms. At present, the open source ChirpStack platform is widely used to build LoRaWAN servers, allowing users to manage LoRaWAN terminals, LoRaWAN gateways and other devices through the Web interface, and provide a gRPC-based API to facilitate users to expand the functions of the ChirpStack server. However, the wide coverage and large number of connections of the LoRaWAN network make researchers face challenges in time, cost and other aspects when changing the network deployment according to experimental needs, which is not conducive to researchers to carry out scientific research conveniently and efficiently.

[0005] Therefore, conducting research on the LoRaWAN networking and positioning simulation system based on NS3 and ChirpStack will help enhance the connectivity between the simulated network environment and the real network world. That is, it will not only be able to improve the signal propagation model in the simulated network based on the data in the real network, but also be able to simulate parameters such as signal propagation time in larger-scale and more complex networks based on the data in the real network, so that researchers can obtain more accurate simulation results when conducting LoRaWAN networking and positioning simulations for specific environments. Summary of the invention

[0006] In order to overcome the shortcomings of the prior art, the present invention provides a LoRaWAN networking and positioning simulation system based on NS3 and ChirpStack, comprising a LoRaWAN terminal, a LoRaWAN gateway, a ChirpStack server, an NS3 operating platform, a data acquisition program and an NS3 simulator; the LoRaWAN terminal sends data to the LoRaWAN gateway, and then forwards it to the ChirpStack server; on the operating platform of the NS3 simulator, the data acquisition program communicates with the ChirpStack server and reads data; the NS3 simulator optimizes the existing ConstantSpeedPropagationDelayModel of the NS3 simulator according to the data read from the ChirpStack server by the data acquisition program, and simulates the fluctuation of the time for the signal in the NS3 simulator to reach the LoRaWAN gateway; the NS3 simulator obtains data such as the time for the same signal sent by the simulated LoRaWAN terminal to arrive at different simulated LoRaWAN gateways through simulation, and completes the networking and positioning simulation process of the LoRaWAN. The present invention makes full use of the characteristics of both the NS3 simulator and the ChirpStack server, such as open source code, rich functions, and good scalability, so that researchers can obtain more accurate simulation results when conducting LoRaWAN networking and positioning simulation for specific environments.

[0007] The technical solution adopted by the present invention to solve the technical problem is as follows:

[0008] A LoRaWAN networking and positioning simulation system based on NS3 and ChirpStack, including a LoRaWAN terminal, a LoRaWAN gateway, a ChirpStack server, an NS3 operating platform, a data acquisition program and an NS3 simulator;

[0009] The LoRaWAN terminal includes a microprocessor module, a LoRa communication module, a Beidou positioning module and a power module; the LoRa communication module, the Beidou positioning module and the power module are all connected to the microprocessor module;

[0010] The data interaction between the LoRaWAN terminal, the LoRaWAN gateway and the ChirpStack server complies with the LoRaWAN protocol and constitutes a LoRaWAN network; the LoRaWAN terminal can be in a stationary or moving state; the LoRaWAN gateway is in a stationary state; the LoRaWAN terminal is always within the communication coverage of the LoRaWAN gateway;

[0011] The LoRaWAN terminal sends its own transmission power, the longitude and latitude coordinates obtained by the Beidou positioning module, and the signal transmission time as data load to the LoRaWAN gateway, and then forwards it to the ChirpStack server;

[0012] The data acquisition program runs on the NS3 operating platform, uses the API interface provided by the ChirpStack server, and communicates with the ChirpStack server based on the gRPC framework, and stores the data read from the ChirpStack server as a data_from_chirpstack.txt file on the NS3 operating platform;

[0013] The NS3 simulator periodically reads the contents of the data_from_chirpstack.txt file and determines Follow The law of change and the standard deviation of Gaussian noise introduced during network simulation ,in, It is the propagation time required for the signal sent by the LoRaWAN terminal in the actual network to reach the LoRaWAN gateway. It is the distance between the LoRaWAN terminal and the LoRaWAN gateway in the actual network;

[0014] The NS3 simulator uses the actual network Follow According to the law of change, the existing ConstantSpeedPropagationDelayModel of the NS3 simulator is optimized, that is, in the simulated network, according to the distance between the simulated LoRaWAN terminal and the simulated LoRaWAN gateway , calculate the propagation time required for the signal sent by the simulated LoRaWAN terminal to reach the simulated LoRaWAN gateway Then, The mean is 0 and the standard deviation is Gaussian noise is used to simulate the fluctuation of the time it takes for the signal sent by the LoRaWAN terminal to reach the LoRaWAN gateway in the actual network;

[0015] In the simulated network, the NS3 simulator obtains the time when the same signal sent by the simulated LoRaWAN terminal arrives at different simulated LoRaWAN gateways, calculates the arrival time difference of the same signal sent by the simulated LoRaWAN terminal to arrive at different simulated LoRaWAN gateways, and then calculates the location information of the simulated LoRaWAN terminal according to the TDOA positioning algorithm to complete the LoRaWAN networking and positioning simulation process.

[0016] Preferably, in the NS3 simulator, The initial value is 0, and then follow the steps below to periodically read the data_from_chirpstack.txt file content and determine Follow The law of change and the standard deviation of Gaussian noise introduced during network simulation :

[0017] Step 1: The NS3 simulator selects a LoRaWAN terminal and a LoRaWAN gateway from the data_from_chirpstack.txt file according to the short address devaddr and the gateway ID number gatewayId, and records them as EndDevice0 and Gateway0 respectively;

[0018] Step 2: The NS3 simulator reads the latest data sent by EndDevice0 to Gateway0 and then forwarded to the ChirpStack server from the data_from_chirpstack.txt file. Get the longitude and latitude of Gateway0 , and The data contains: the latitude and longitude information of EndDevice0 、EndDevice0 sends the The transmission power of the data , Sending time , and The time when the data arrives at Gateway0 , received signal strength ,in, ;

[0019] Step 3: NS3 simulator sets the longitude and latitude of Gateway0 and the latitude and longitude of EndDevice0 The projection is converted into two-dimensional coordinates, and the two-dimensional coordinates of Gateway0 are obtained as follows: , the two-dimensional coordinates of EndDevice0 are , and then calculate the different values ​​of the distance between EndDevice0 and Gateway0, that is, , calculate the different values ​​of the air propagation time required for the data frame to be sent from EndDevice0 to Gateway0, that is , calculate the signal attenuation of the data frame sent from EndDevice0 to Gateway0 Different values ​​of , calculate the average moving speed of EndDevice0 ,in, , Respectively represent the first The latitude and longitude information of EndDevice0 contained in the data The projection is converted into the horizontal and vertical coordinates of two-dimensional coordinates. Indicates the first The EndDevice0 contained in the data sends the The time when the data is sent;

[0020] Step 4: NS3 Simulator , The value is obtained ,in, , ,according to , The value is obtained ,in, , , and then according to the average moving speed of EndDevice0 ,get , among which if ,but ,like ,but ;

[0021] Step 5: NS3 Simulator The value of When, according to The value of The sample standard deviation of , and order ;when When , then let , otherwise let The value of remains unchanged;

[0022] Step 6: Repeat step 1.

[0023] Preferably, after the data interaction between the LoRaWAN terminal, the LoRaWAN gateway and the ChirpStack server follows the LoRaWAN protocol and forms a LoRaWAN network, the data load of the signal sent by the LoRaWAN terminal includes 4 parts: its own latitude obtained by the Beidou positioning module, its own longitude obtained by the Beidou positioning module, the signal sending time, and the LoRaWAN terminal's own sending power.

[0024] The beneficial effects of the present invention are as follows:

[0025] (1) The NS3 simulator and ChirpStack server of the present invention are both open source, feature-rich, and highly scalable, and are widely used by researchers in network simulation and actual network deployment. The actual LoRaWAN network has a typical feature of wide coverage. The present invention integrates the NS3 simulator and the ChirpStack server and applies them to the LoRaWAN networking and positioning simulation research, which can improve the accuracy of the simulation results and help improve the experimental efficiency and reduce costs compared to the full physical network deployment.

[0026] (2) The method provided by the present invention for processing simulated data in the NS3 simulator based on real LoRaWAN network data enables researchers to optimize the existing LoRaWAN Model and other models in the NS3 simulator according to the characteristics of actual network deployment, which helps to further improve the performance of the NS3 simulator.

[0027] (3) The communication method between the NS3 simulator and the ChirpStack server provided by the present invention can provide a reference for researchers to achieve interconnection between the NS3 simulator and other servers or development platforms, thereby providing a new simulation method for researchers to carry out research work in other fields. BRIEF DESCRIPTION OF THE DRAWINGS

[0028] Figure 1 It is a simulation system architecture diagram of the present invention;

[0029] Figure 2 Schematic diagram of the data payload format of a signal sent by a LoRaWAN terminal in an embodiment of the present invention;

[0030] Figure 3 It is a topology diagram of a LoRaWAN networking and positioning experiment based on an NS3 simulator and a ChirpStack server when the terminal in an embodiment of the present invention is stationary;

[0031] Figure 4In the case where the LoRaWAN terminal of the embodiment of the present invention is stationary, Figure 3 Schematic diagram of the error distribution of the simulation data of the original model of the NS3 simulator, the real data measured experimentally, and the semi-physical simulation data based on the NS3 simulator and the ChirpStack server under the topology shown;

[0032] Figure 5 It is a topology diagram of a LoRaWAN networking and positioning experiment based on an NS3 simulator and a ChirpStack server when a LoRaWAN terminal moves in an embodiment of the present invention, wherein the terminal moves back and forth along a dotted line;

[0033] Figure 6 In the case where the LoRaWAN terminal of the embodiment of the present invention moves at a speed of 2m / s, Figure 5 Schematic diagram of the error distribution of the simulation data of the original model of the NS3 simulator, the real data measured experimentally, and the semi-physical simulation data based on the NS3 simulator and the ChirpStack server under the topology shown. DETAILED DESCRIPTION

[0034] The present invention is further described below in conjunction with the accompanying drawings and embodiments.

[0035] In view of the challenges faced in the LoRaWAN networking and positioning simulation process, the purpose of the present invention is to provide a LoRaWAN networking and positioning simulation system based on NS3 simulator and ChirpStack server. By realizing the interconnection between NS3 simulator and ChirpStack server, the signal propagation model used by LoRaWAN Model in NS3 simulator is improved by using data from the real LoRaWAN network, and the parameters such as received signal strength and signal arrival time required for positioning simulation are simulated, so that the simulation results of LoRaWAN networking and positioning are closer to the real LoRaWAN network.

[0036] In reality, ChirpStack servers are usually deployed on the cloud or other remote servers, and there are differences between the actual LoRaWAN network scenarios and the intended LoRaWAN network scenarios. Therefore, in order to achieve the interconnection between the NS3 simulator and the ChirpStack server, as well as the improvement of related models in the NS3 simulator, the following issues should be addressed: 1) The composition of the LoRaWAN networking and positioning simulation system based on the NS3 simulator and the ChirpStack server; 2) The communication method between the NS3 simulator and the ChirpStack server; 3) How to process the simulated data in the NS3 simulator based on the data of the real LoRaWAN network.

[0037] In order to solve the above technical problems, the present invention adopts the following technical solutions to achieve the above problems:

[0038] A LoRaWAN networking and positioning simulation system based on NS3 and ChirpStack, including a LoRaWAN terminal, a LoRaWAN gateway, a ChirpStack server, an NS3 operating platform, a data acquisition program and an NS3 simulator;

[0039] The LoRaWAN terminal includes a microprocessor module, a LoRa communication module, a Beidou positioning module and a power module; the LoRa communication module, the Beidou positioning module and the power module are all connected to the microprocessor module;

[0040] The data interaction between LoRaWAN terminals, LoRaWAN gateways and ChirpStack servers follows the LoRaWAN protocol and forms a LoRaWAN network; LoRaWAN terminals can be stationary or in motion; LoRaWAN gateways are stationary; LoRaWAN terminals are always within the communication coverage of the LoRaWAN gateway;

[0041] The LoRaWAN terminal sends its own transmission power, the longitude and latitude coordinates obtained by the Beidou positioning module, and the signal transmission time as data payload to the LoRaWAN gateway, which is then forwarded to the ChirpStack server;

[0042] The data collection program runs on the NS3 operating platform, uses the API interface provided by the ChirpStack server, and communicates with the ChirpStack server based on the gRPC framework, and stores the data read from the ChirpStack server as the data_from_chirpstack.txt file on the NS3 operating platform;

[0043] The NS3 simulator periodically reads the contents of the data_from_chirpstack.txt file and determines Follow The law of change and the standard deviation of Gaussian noise introduced during network simulation ,in, It is the propagation time required for the signal sent by the LoRaWAN terminal in the actual network to reach the LoRaWAN gateway. It is the distance between the LoRaWAN terminal and the LoRaWAN gateway in the actual network;

[0044] NS3 simulator uses the actual network Follow According to the law of change, the existing ConstantSpeedPropagationDelayModel of the NS3 simulator is optimized, that is, in the simulated network, according to the distance between the simulated LoRaWAN terminal and the simulated LoRaWAN gateway , calculate the propagation time required for the signal sent by the simulated LoRaWAN terminal to reach the simulated LoRaWAN gateway Then, The mean is 0 and the standard deviation is Gaussian noise is used to simulate the fluctuation of the time it takes for the signal sent by the LoRaWAN terminal to reach the LoRaWAN gateway in the actual network, so that the simulation results are closer to the actual network situation;

[0045] In the simulated network, the NS3 simulator obtains the time it takes for the same signal sent by the simulated LoRaWAN terminal to arrive at different simulated LoRaWAN gateways, calculates the arrival time difference of the same signal sent by the simulated LoRaWAN terminal to arrive at different simulated LoRaWAN gateways, and then calculates the location information of the simulated LoRaWAN terminal according to the TDOA positioning algorithm to complete the LoRaWAN networking and positioning simulation process.

[0046] In the NS3 simulator, The initial value is 0, and then follow the steps below to periodically read the data_from_chirpstack.txt file content and determine Follow The law of change and the standard deviation of Gaussian noise introduced during network simulation :

[0047] Step 1: The NS3 simulator selects a LoRaWAN terminal and a LoRaWAN gateway from the data_from_chirpstack.txt file according to the short address devaddr and the gateway ID number gatewayId, and records them as EndDevice0 and Gateway0 respectively;

[0048] Step 2: The NS3 simulator reads the latest data sent by EndDevice0 to Gateway0 and then forwarded to the ChirpStack server from the data_from_chirpstack.txt file. Get the longitude and latitude of Gateway0 , and The data contains: the latitude and longitude information of EndDevice0 、EndDevice0 sends the The transmission power of the data , Sending time , and The time when the data arrives at Gateway0 , received signal strength ,in, ;

[0049] Step 3: NS3 simulator sets the longitude and latitude of Gateway0 and the latitude and longitude of EndDevice0 The projection is converted into two-dimensional coordinates, and the two-dimensional coordinates of Gateway0 are obtained as follows: , the two-dimensional coordinates of EndDevice0 are , and then calculate the different values ​​of the distance between EndDevice0 and Gateway0, that is, , calculate the different values ​​of the air propagation time required for the data frame to be sent from EndDevice0 to Gateway0, that is , calculate the signal attenuation of the data frame sent from EndDevice0 to Gateway0 Different values ​​of , calculate the average moving speed of EndDevice0 ,in, , Respectively represent the first The latitude and longitude information of EndDevice0 contained in the data The projection is converted into the horizontal and vertical coordinates of two-dimensional coordinates. Indicates the first The EndDevice0 contained in the data sends the The time when the data is sent;

[0050] Step 4: NS3 Simulator , The value is obtained ,in, , ,according to , The value is obtained ,in, , , and then according to the average moving speed of EndDevice0 ,get , among which if ,but ,like ,but ;

[0051] Step 5: NS3 Simulator The value of When, according to The value of The sample standard deviation of , and order ;when When , then let , otherwise let The value of remains unchanged;

[0052] Step 6: Repeat step 1.

[0053] After the LoRaWAN terminal, LoRaWAN gateway and ChirpStack server form a LoRaWAN network, the data load of the signal sent by the LoRaWAN terminal includes 4 parts: its own latitude obtained by the Beidou positioning module, its own longitude obtained by the Beidou positioning module, the signal sending time, and the LoRaWAN terminal's own sending power.

[0054] Example:

[0055] The present invention can improve the accuracy of LoRaWAN networking and positioning simulation results, and has the advantages of high efficiency and low cost compared with full physical experiments. The basic implementation idea is: LoRaWAN terminals, LoRaWAN gateways and ChirpStack servers form a LoRaWAN network, wherein the LoRaWAN gateways are stationary, and signals sent by the LoRaWAN terminals can be received by all LoRaWAN gateways; the LoRaWAN terminals send data to the LoRaWAN gateways, and then forward them to the ChirpStack servers, wherein the data load sent by the LoRaWAN terminals includes their own transmission power, their own latitude and longitude coordinates obtained by a Beidou positioning module, and signal sending time; on the running platform of the NS3 simulator, a data acquisition program communicates with the ChirpStack server and reads data; the NS3 simulator optimizes the existing Model of the NS3 simulator according to the data read from the ChirpStack server by the data acquisition program; the NS3 simulator obtains data such as the time when the same signal sent by the simulated LoRaWAN terminal arrives at different simulated LoRaWAN gateways through simulation, and completes the LoRaWAN networking and positioning simulation process.

[0056] This embodiment provides a LoRaWAN networking and positioning simulation system based on NS3 and ChirpStack. Figure 1As shown, it includes LoRaWAN terminal, LoRaWAN gateway, ChirpStack server, NS3 operating platform, data acquisition program and NS3 simulator;

[0057] The LoRaWAN terminal includes a microprocessor module, a LoRa communication module, a Beidou positioning module and a power module, and the LoRa communication module, the Beidou positioning module and the power module are all connected to the microprocessor module;

[0058] The data interaction between LoRaWAN terminals, LoRaWAN gateways and ChirpStack servers follows the LoRaWAN protocol and forms a LoRaWAN network. LoRaWAN terminals can be stationary or in motion, and LoRaWAN gateways are stationary. Moreover, any LoRaWAN terminal is always within the communication coverage of a certain LoRaWAN gateway.

[0059] The LoRaWAN terminal sends its own transmission power, its own latitude and longitude coordinates obtained by the Beidou positioning module, and the signal transmission time as data payload to the LoRaWAN gateway, and then forwards it to the ChirpStack server;

[0060] The data collection program also runs on the NS3 operating platform, using the API interface provided by the ChirpStack server and communicating with the ChirpStack server based on the gRPC framework, and stores the data read from the ChirpStack server as the data_from_chirpstack.txt file on the NS3 operating platform;

[0061] The NS3 simulator periodically reads the contents of the data_from_chirpstack.txt file and determines Follow The law of change and the standard deviation of Gaussian noise introduced during network simulation ,in, It is the propagation time required for the signal sent by the LoRaWAN terminal in the actual network to reach the LoRaWAN gateway. It is the distance between the LoRaWAN terminal and the LoRaWAN gateway in the actual network;

[0062] NS3 simulator uses the actual network Follow According to the law of change, the existing ConstantSpeedPropagationDelayModel of the NS3 simulator is optimized, that is, in the simulated network, according to the distance between the simulated LoRaWAN terminal and the simulated LoRaWAN gateway , calculate the propagation time required for the signal sent by the simulated LoRaWAN terminal to reach the simulated LoRaWAN gateway Then, The mean is 0 and the standard deviation is Gaussian noise is used to simulate the fluctuation of the time it takes for the signal sent by the LoRaWAN terminal to reach the LoRaWAN gateway in the actual network, so that the simulation results are closer to the actual network situation;

[0063] In the simulated network, the NS3 simulator obtains the time it takes for the same signal sent by the simulated LoRaWAN terminal to arrive at different simulated LoRaWAN gateways, calculates the arrival time difference of the same signal sent by the simulated LoRaWAN terminal to arrive at different simulated LoRaWAN gateways, and then calculates the location information of the simulated LoRaWAN terminal according to the TDOA positioning algorithm to complete the LoRaWAN networking and positioning simulation process.

[0064] In the NS3 simulator, The initial value is 0, and then follow the steps below to periodically read the data_from_chirpstack.txt file content and determine Follow The law of change and the standard deviation of Gaussian noise introduced during network simulation :

[0065] Step 1: The NS3 simulator selects a LoRaWAN terminal and a LoRaWAN gateway from the data_from_chirpstack.txt file according to the short address devaddr and the gateway ID number gatewayId, and records them as EndDevice0 and Gateway0 respectively;

[0066] Step 2: The NS3 simulator reads the latest data sent by EndDevice0 to Gateway0 and then forwarded to the ChirpStack server from the data_from_chirpstack.txt file. Get the longitude and latitude of Gateway0 , and The data contains: the latitude and longitude information of EndDevice0 、EndDevice0 sends the The transmission power of the data , Sending time , and The time when the data arrives at Gateway0 , received signal strength ,in, ;

[0067] Step 3: NS3 simulator sets the longitude and latitude of Gateway0 and the latitude and longitude of EndDevice0 The projection is converted into two-dimensional coordinates, and the two-dimensional coordinates of Gateway0 are obtained as follows: , the two-dimensional coordinates of EndDevice0 are , and then calculate the distance between EndDevice0 and Gateway0 Different values ​​of , calculate the air propagation time required for a data frame to be sent from EndDevice0 to Gateway0 Different values ​​of , calculate the signal attenuation of the data frame sent from EndDevice0 to Gateway0 Different values ​​of , calculate the average moving speed of EndDevice0 ,in, , Respectively represent the first The latitude and longitude information of EndDevice0 contained in the data The projection is converted into the horizontal and vertical coordinates of two-dimensional coordinates. Indicates the first The EndDevice0 contained in the data sends the The time when the data is sent;

[0068] Step 4: NS3 Simulator , The value is obtained ,in, , ,according to , The value is obtained ,in, , , and then according to the average moving speed of EndDevice0 ,get , among which if ,but ,like ,but ;

[0069] Step 5: NS3 Simulator The value of When, according to The value of The sample standard deviation of , and order ;when When , then let , otherwise let The value of remains unchanged;

[0070] Step 6: Repeat step 1.

[0071] After the LoRaWAN terminal, LoRaWAN gateway and ChirpStack server form a LoRaWAN network, the data load of the signal sent by the LoRaWAN terminal includes 4 parts: its own latitude obtained by the Beidou positioning module , the longitude obtained by Beidou positioning module , signal sending time , the transmission power of the LoRaWAN terminal itself , such as Figure 2 shown.

[0072] In order to verify the effectiveness of this solution, a LoRaWAN networking and positioning simulation test based on NS3 and ChirpStack was carried out on the present invention.

[0073] The experiment of the LoRaWAN terminal being stationary, Figure 3 In the topology shown in the figure, GW1, GW2, and GW3 represent three LoRaWAN gateways, and ED represents a LoRaWAN terminal. If the position of GW1 is set as the coordinate origin, the positions of GW2, GW3, and ED are as follows: Figure 3 The unit is meter.

[0074] The data acquisition program reads data from the ChirpStack server and stores it in the file data_from_chirpstack.txt. The NS3 simulator periodically reads the contents of the file data_from_chirpstack.txt and determines Follow The law of change and the standard deviation of Gaussian noise introduced during network simulation NS3 simulator uses the actual network Follow According to the law of change, the existing ConstantSpeedPropagationDelayModel in the NS3 simulator is optimized, that is, in the simulated network, according to the distance between the simulated LoRaWAN terminal and the simulated LoRaWAN gateway , calculate the propagation time required for the signal sent by the simulated LoRaWAN terminal to reach the simulated LoRaWAN gateway Then, The mean is 0 and the standard deviation is Gaussian noise is used to simulate the fluctuation of the time it takes for the signal sent by the LoRaWAN terminal to reach the LoRaWAN gateway in the actual network, so that the simulation results are closer to the actual network situation.

[0075] The NS3 simulator uses simulation scripts to build a positioning simulation scenario consisting of a simulated LoRaWAN terminal and a simulated LoRaWAN gateway. In the simulated network, the arrival time difference of the same signal sent by the simulated LoRaWAN terminal to different simulated LoRaWAN gateways is calculated by obtaining the time it takes for the same signal sent by the simulated LoRaWAN terminal to arrive at different simulated LoRaWAN gateways. Then, the location information of the simulated LoRaWAN terminal is calculated according to the TDOA positioning algorithm to complete the LoRaWAN networking and positioning simulation process.

[0076] Figure 4 Is the LoRaWAN terminal in Figure 3 The error distribution of the simulation data of the original model of the NS3 simulator, the real data measured by the experiment, and the semi-physical simulation data based on the NS3 simulator and the ChirpStack server when in a stationary state under the topology shown. Among them, when simulating with the original model of the NS3 simulator, the ConstantSpeedPropagationDelayModel is not optimized, and the fluctuation of the time when the signal reaches the LoRaWAN gateway can only be simulated by introducing Gaussian noise based on experience. The experimental results show that the present invention can obtain more accurate simulation results when the LoRaWAN terminal is stationary.

[0077] The experiment of LoRaWAN terminal moving, Figure 5 GW1, GW2, and GW3 represent three LoRaWAN gateways. If the position of GW1 is set as the coordinate origin, the positions of GW2 and GW3 are as follows: Figure 5 The unit is meter. The LoRaWAN terminal is carried by the experimenter and Figure 5 The dotted line shown moves at a speed of 2m / s.

[0078] Experiments with the LoRaWAN terminal in a stationary state (such as Figure 3 Compared with the above, since the LoRaWAN terminal moves at a speed of 2m / s, and , , The calculation method is different when the relationship between the two is different; in addition, the NS3 simulator still uses the experimental results obtained when the LoRaWAN terminal is stationary. The changes in By introducing a mean of 0 and a standard deviation of The Gaussian noise is used to simulate the fluctuation of the time it takes for the signal to reach the LoRaWAN gateway in the NS3 simulator. Other than that, the other experimental processes are the same.

[0079] Figure 6 Is the LoRaWAN terminal in Figure 5 The error distribution of the simulation data of the original model of the NS3 simulator, the real data measured by the experiment, and the semi-physical simulation data based on the NS3 simulator and the ChirpStack server when moving at a speed of 2m / s in the topology shown. Among them, when simulating with the original model of the NS3 simulator, the ConstantSpeedPropagationDelayModel is not optimized, and the fluctuation of the time when the signal reaches the LoRaWAN gateway can only be simulated by introducing Gaussian noise based on experience. The experimental results show that the present invention can obtain more accurate simulation results when the LoRaWAN terminal is moving.

Claims

1. A LoRaWAN networking and positioning simulation system based on NS3 and ChirpStack, It is characterized in that Including LoRaWAN terminal, LoRaWAN gateway, ChirpStack server, NS3 operating platform, data acquisition program and NS3 simulator; The LoRaWAN terminal includes a microprocessor module, a LoRa communication module, a Beidou positioning module and a power module; the LoRa communication module, the Beidou positioning module and the power module are all connected to the microprocessor module; The data interaction between the LoRaWAN terminal, the LoRaWAN gateway and the ChirpStack server complies with the LoRaWAN protocol and constitutes a LoRaWAN network; the LoRaWAN terminal can be in a stationary or moving state; the LoRaWAN gateway is in a stationary state; the LoRaWAN terminal is always within the communication coverage of the LoRaWAN gateway; The LoRaWAN terminal sends its own transmission power, the longitude and latitude coordinates obtained by the Beidou positioning module, and the signal transmission time as data load to the LoRaWAN gateway, and then forwards it to the ChirpStack server; The data collection program runs on the NS3 operating platform, uses the API interface provided by the ChirpStack server, and communicates with the ChirpStack server based on the gRPC framework, and stores the data read from the ChirpStack server as a data_from_chirpstack.txt file on the NS3 operating platform; The NS3 simulator periodically reads the contents of the data_from_chirpstack.txt file and determines the law of how t changes with d, as well as the standard deviation σ of the Gaussian noise introduced during network simulation, where t is the propagation time required for the signal sent by the LoRaWAN terminal in the actual network to reach the LoRaWAN gateway, and d is the distance between the LoRaWAN terminal and the LoRaWAN gateway in the actual network; The NS3 simulator optimizes the existing ConstantSpeedPropagationDelayModel of the NS3 simulator by using the law that t changes with d in the actual network, that is, in the simulated network, according to the distance d′ between the simulated LoRaWAN terminal and the simulated LoRaWAN gateway, the propagation time t′ required for the signal sent by the simulated LoRaWAN terminal to reach the simulated LoRaWAN gateway is calculated, and then Gaussian noise with a mean of 0 and a standard deviation of σ is introduced into t′ to simulate the fluctuation of the time when the signal sent by the LoRaWAN terminal in the actual network reaches the LoRaWAN gateway; In the simulated network, the NS3 simulator obtains the time when the same signal sent by the simulated LoRaWAN terminal arrives at different simulated LoRaWAN gateways, calculates the arrival time difference of the same signal sent by the simulated LoRaWAN terminal to arrive at different simulated LoRaWAN gateways, and then calculates the location information of the simulated LoRaWAN terminal according to the TDOA positioning algorithm to complete the LoRaWAN networking and positioning simulation process; In the NS3 simulator, the initial value of σ is set to 0, and then the following steps are followed to periodically read the content of the data_from_chirpstack.txt file, and determine the law of t changing with d, as well as the standard deviation σ of the Gaussian noise introduced during network simulation: Step 1: The NS3 simulator selects a LoRaWAN terminal and a LoRaWAN gateway from the data_from_chirpstack.txt file according to the short address devaddr and the gateway ID number gatewayId, and records them as EndDevice0 and Gateway0 respectively; Step 2: The NS3 simulator reads the latest n data sent by EndDevice0 to Gateway0 and then forwarded to the ChirpStack server from the data_from_chirpstack.txt file, and obtains the latitude and longitude of Gateway0 (lng 0 ,lat 0 ), and the i-th data contains: the latitude and longitude information of EndDevice0 (lng i ,lat i ), the sending power Ps of EndDevice0 to send the i-th data i , sending time eT i , and the time gT when the i-th data arrives at Gateway0 i , received signal strength Prx, where i=1, 2, 3, ..., n; Step 3: NS3 simulator will Gateway0's longitude and latitude (lng 0 ,lat 0 ) and the latitude and longitude of EndDevice0 (lng i ,lat i ) projection is converted to two-dimensional coordinates, and the two-dimensional coordinates of Gateway0 are (x 0 ,y 0 ), the two-dimensional coordinates of EndDevice0 are (x i ,y i ), and then calculate the different values ​​of the distance between EndDevice0 and Gateway0, that is, Calculate the different values ​​of the air propagation time required for the data frame to be sent from EndDevice0 to Gateway0, that is, t i =gT i -eT i , calculate the different values ​​of signal attenuation Pl of the data frame sent from EndDevice0 to Gateway0, that is, Pl i =Ps i -Pr i , calculate the average moving speed of EndDevice0 Among them, x i+1 ,y i+1 They represent the latitude and longitude information of EndDevice0 contained in the i+1th data read from the data_from_chirpstack.txt file (lng i+1 ,lat i+1 ) projection is converted into the horizontal and vertical coordinates of two-dimensional coordinates, eT i+1 Indicates the sending time of the i+1th data sent by EndDevice0 contained in the i+1th data read from the data_from_chirpstack.txt file; Step 4: NS3 simulator according to t i d i The value of f(d)=a 1 +b 1 d, where According to t i Pl i The value of g(d)=a 2 +b 2 d, where Then according to the average moving speed v of EndDevice0 e , we get t = (1-α)·f(d)+α·g(d), where if v e ≤1.5m / s, then α=0, if v e >1.5m / s, then α=0.25; Step 5: NS3 simulator according to v e The value of v e ≤1.5m / s, according to t i , calculate the sample standard deviation σ′ of t, and let σ=σ′; when v e >1.5m / s, if σ=0, let σ=100ns, otherwise let the value of σ remain unchanged; Step 6: Repeat step 1.

2. A LoRaWAN networking and positioning simulation system based on NS3 and ChirpStack according to claim 1, It is characterized in that After the data interaction between the LoRaWAN terminal, the LoRaWAN gateway and the ChirpStack server follows the LoRaWAN protocol and forms a LoRaWAN network, the data load of the signal sent by the LoRaWAN terminal includes 4 parts: its own latitude obtained by the Beidou positioning module, its own longitude obtained by the Beidou positioning module, the signal sending time, and the LoRaWAN terminal's own sending power.