Detailed Description
Reference will now be made in detail to the exemplary embodiments, examples of which are illustrated in the accompanying drawings. When the following description refers to the accompanying drawings, like numbers in different drawings represent the same or similar elements unless otherwise indicated. The implementations described in the exemplary embodiments below are not intended to represent all implementations consistent with the present disclosure. Rather, they are merely examples of apparatus and methods consistent with certain aspects of the present disclosure, as detailed in the appended claims.
The block link point communication method provided by the invention can be applied to the communication system shown in fig. 1. As shown in fig. 1, the communication system includes: access network device 11, terminal device 12, and server 13. It should be noted that the communication System shown in fig. 1 may be applicable to different network formats, for example, may be applicable to Global System for Mobile communication (GSM), Code Division Multiple Access (CDMA), Wideband Code Division Multiple Access (WCDMA), Time Division-Synchronous Code Division Multiple Access (TD-SCDMA), Long Term Evolution (Long Term Evolution, LTE), and future 5G network formats. Optionally, the communication system may be a system in a scenario of high-reliability and Low-Latency Communications (URLLC) transmission in a 5G communication system.
Therefore, optionally, the access Network device 11 may be a Base Station (BTS) and/or a Base Station Controller in GSM or CDMA, a Base Station (NodeB, NB) and/or a Radio Network Controller (RNC) in WCDMA, an evolved Node B (eNB or eNodeB) in LTE, or a relay Station or an access point, or a Base Station (gbb) in a future 5G Network, and the present invention is not limited thereto.
The terminal device 12 may be a wireless terminal or a wired terminal. A wireless terminal may refer to a device that provides voice and/or other traffic data connectivity to a user, a handheld device having wireless connection capability, or other processing device connected to a wireless modem. A wireless terminal, which may be a mobile terminal such as a mobile telephone (or "cellular" telephone) and a computer having a mobile terminal, for example, a portable, pocket, hand-held, computer-included, or vehicle-mounted mobile device, may communicate with one or more core Network devices via a Radio Access Network (RAN), and may exchange language and/or data with the RAN. For another example, the Wireless terminal may also be a Personal Communication Service (PCS) phone, a cordless phone, a Session Initiation Protocol (SIP) phone, a Wireless Local Loop (WLL) station, a Personal Digital Assistant (PDA), and other devices. A wireless Terminal may also be referred to as a system, a Subscriber Unit (Subscriber Unit), a Subscriber Station (Subscriber Station), a Mobile Station (Mobile), a Remote Station (Remote Station), a Remote Terminal (Remote Terminal), an Access Terminal (Access Terminal), a User Terminal (User Terminal), a User Agent (User Agent), and a User Device or User Equipment (User Equipment), which are not limited herein. Optionally, the terminal device 12 may also be a smart watch, a tablet computer, or the like. In this embodiment, the terminal device 12 and the server 13 may be nodes in a blockchain network.
The invention provides a block link point communication method, which aims to solve the technical problems in the prior art.
The following describes the technical solutions of the present invention and how to solve the above technical problems with specific embodiments. The following several specific embodiments may be combined with each other, and details of the same or similar concepts or processes may not be repeated in some embodiments. Embodiments of the present invention will be described below with reference to the accompanying drawings.
Fig. 2 is a flowchart of a block link point communication method according to an embodiment of the present invention. The embodiment of the invention provides a block chain node communication method aiming at the technical problems in the prior art, and the method comprises the following specific steps:
step 201, a master storage node receives request information sent by a target node, where the request information indicates that the target node requests to become a slave storage node, and the request information includes identification information of the target node.
As shown in fig. 3, 31 denotes a master storage node in the blockchain network, 32 denotes a target node in the blockchain network, the target node 32 requests to become a slave storage node, and the target node 32 has its own public network IP address. Another target node is indicated at 33, the target node 33 requests to become a slave storage node, the target node 33 has no public Network IP Address, the target node 33 communicates with the blockchain Network via Network Address Translation (NAT), NAT is indicated at 34, and a querying node in the blockchain Network is indicated at 35. In this embodiment, the query node 35 is provided with a query service by a slave storage node. The method is only illustrative and does not limit the specific network architecture of the blockchain network. In addition, the query node 35 may be a node under the NAT or may not be a node under the NAT.
When the target node 32 or the target node 33 first joins the block chain network, it is necessary to obtain the created blocks from the nodes adjacent to the target node 32 or the target node 33, and optionally, all the nodes in the block chain network store the created blocks. In order to ensure that the target node 32 or the target node 33 acquires a real created block, the target node 32 or the target node 33 may send created block query requests to a plurality of neighboring nodes, for example, the target node 32 or the target node 33 sends created block query requests to the neighboring node B and the neighboring node C, after receiving the created block query requests, the neighboring node B and the neighboring node C send respective locally stored created blocks to the target node 32 or the target node 33, the target node 32 or the target node 33 compares whether the created blocks fed back by the neighboring node B and the neighboring node C are consistent, and if the created blocks fed back by the neighboring node B and the neighboring node C are consistent, the target node 32 or the target node 33 locally stores the created blocks; if the created blocks fed back by the adjacent node B and the adjacent node C are not consistent, the target node 32 or the target node 33 may further continue to send created block query requests to the adjacent node D and the adjacent node E, and receive created blocks fed back by the adjacent node D and the adjacent node E, respectively, and if the created blocks fed back by adjacent nodes exceeding a preset proportion among the adjacent node B, the adjacent node C, the adjacent node D, and the adjacent node E are consistent, the target node 32 or the target node 33 determines that the created blocks are real. Optionally, if the created blocks fed back by more than fifty percent of the neighboring nodes, such as the neighboring node C, the neighboring node D, and the neighboring node E, are consistent, the target node 32 or the target node 33 determines that the created block fed back by the neighboring node C is real, and the created block fed back by the neighboring node B is false.
When the target node 32 or the target node 33 acquires the real created block, the created block is stored locally, and the IP address of the main storage node is acquired from the created block, and optionally, the created block stores IP addresses of one or more main storage nodes, and the target node 32 or the target node 33 may send request information to the one or more main storage nodes according to the IP addresses of the one or more main storage nodes, for example, the created block stores the IP address of the main storage node 31, the target node 32 sends request information to the main storage node 31, the request information is used to indicate that the target node 32 intends to become a slave storage node, and includes identification information of the target node 32 and a terminal device number corresponding to the target node 32. Or/and the target node 33 sends request information to the master storage node 31, wherein the request information is used for indicating that the target node 33 wants to become a slave storage node, and the request information comprises identification information of the target node 33 and a terminal equipment number corresponding to the target node 33.
Step 202, the master storage node compares whether the source IP address of the request message is the same as the IP address broadcast by the target node when joining the blockchain network.
When the main storage node 31 receives the request information sent by the target node 32, the main storage node 31 obtains a source IP address, for example, TTT, of the request information, and searches a blockchain ledger locally stored in the main storage node 31 for an IP address, for example, UUU, broadcast by the target node 32 when joining the blockchain network, and further compares whether the source IP address, for example, TTT, of the request information is the same as the IP address, for example, UUU, broadcast by the target node 32 when joining the blockchain network.
Similarly, when the main storage node 31 receives the request message sent by the target node 33, the main storage node 31 obtains the source IP address, e.g., TTT, of the request message, and searches the blockchain ledger locally stored in the main storage node 31 for the IP address, e.g., UUU, broadcast by the target node 33 when joining the blockchain network, and further compares whether the source IP address, e.g., TTT, of the request message is the same as the IP address, e.g., UUU, broadcast by the target node 33 when joining the blockchain network.
Step 203, if the source IP address of the request information is different from the IP address broadcast by the target node when joining the block chain network, the main storage node determines that the target node is located under the network address translation NAT, and determines the public network IP address of the NAT corresponding to the target node and the port number mapped by the target node on the NAT.
As shown in fig. 3, the destination node 33 does not have its own public IP address, and therefore, the source IP address of the request message sent by the destination node 33 to the main storage node 31 may not be the own public IP address of the destination node 33, and the source IP address of the request message may be a public IP address allocated to the destination node 33 by an access point in a local area network corresponding to the destination node 33, and the source IP address of the request message may be different from the IP address broadcast by the destination node 33 when joining the blockchain network. Thus, when the primary storage node 31 compares the source IP address, e.g., TTT, of the request message sent by the target node 33 with the IP address, e.g., UUU, broadcast by the target node 33 when joining the blockchain network, the primary storage node 31 determines that the target node 33 is under NAT and that the target node 33 does not have its own public network IP address. The main storage node 31 further determines the public network IP address of the NAT corresponding to the destination node 33 and the port number mapped on the NAT by the destination node 33, specifically, the source IP address of the request information is the public network IP address of the NAT corresponding to the destination node 33, and the source port number of the request information is the port number mapped on the NAT by the destination node 33.
As shown in fig. 3, the destination node 32 has its own public network IP address, and therefore, the source IP address of the request message sent by the destination node 32 to the main storage node 31 is the own public network IP address of the destination node 32, and the source IP address of the request message is the same as the IP address broadcast by the destination node 32 when joining the blockchain network. Therefore, when the main storage node 31 compares the source IP address, e.g., TTT, of the request message sent by the target node 32 with the IP address, e.g., UUU, broadcast by the target node 32 when joining the blockchain network, and is the same, the main storage node 31 determines that the target node 32 is not under the NAT and the target node 32 has its own public network IP address, the source IP address of the request message sent by the target node 32 is the target node 32's own public network IP address, and the source port number of the request message sent by the target node 32 is the port number of the target node 32.
And step 204, the main storage node determines the type information of the NAT corresponding to the target node by sending a connection request to the target node.
When the main storage node 31 determines that the target node 33 is under the NAT and the target node 33 does not have its own public network IP address, the main storage node 31 further determines the type information of the NAT corresponding to the target node 33, where the type information of the NAT corresponding to the target node 33 includes an asymmetric type and a symmetric type.
And step 205, the master storage node sends the type information of the NAT to the target node.
When the main storage node 31 determines the type information of the NAT corresponding to the target node 33, the type information of the NAT corresponding to the target node 33 is sent to the target node 33.
In the embodiment of the invention, the main storage node receives the request information sent by the target node, compares whether the source IP address of the request information is the same as the IP address broadcast by the target node when the target node joins the block chain network, and if the source IP address of the request information is different from the IP address broadcast by the target node when the target node joins the block chain network, the main storage node determines that the target node is positioned under the NAT (network address translation), and determines the public network IP address of the NAT corresponding to the target node and the port number mapped by the target node on the NAT, so that the target node can become a slave storage node, the node without the public network IP address can also become a slave storage node, and the development of block chain service is promoted.
Fig. 4 is a flowchart of a block-node communication method according to another embodiment of the present invention. On the basis of the foregoing embodiment, the block link point communication method provided in this embodiment specifically includes the following steps:
step 401, a master storage node receives request information sent by a target node, where the request information indicates that the target node requests to become a slave storage node, and the request information includes identification information of the target node.
The implementation manner of step 401 and step 201 is consistent with specific principles, and is not described herein again.
Step 402, the master storage node compares whether the source IP address of the request message is the same as the IP address broadcast by the target node when joining the blockchain network.
The implementation manner of step 402 and step 202 is consistent with specific principles, and will not be described herein.
Step 403, if the source IP address of the request information is different from the IP address broadcast by the target node when joining the block chain network, the main storage node determines that the target node is located under the network address translation NAT.
The implementation manner of step 403 and step 203 is consistent with specific principles, and will not be described herein.
Step 404, the primary storage node sends a connection request to the target node according to the source IP address and the source port number of the request information.
The master storage node 31 sends a connection request, which may specifically be a TCP connection request, to the target node 33 according to the source IP address, e.g. TTT, and the source port number, e.g. 4040, of the request information sent by the target node 33.
Step 405, if the main storage node receives the connection response sent by the target node, the main storage node determines that the type information of the NAT corresponding to the target node is asymmetric.
If the target node 33 receives the connection request sent by the main storage node 31 and sends a connection response to the main storage node 31, it indicates that the target node 33 is under the asymmetric NAT, i.e. the type information of the NAT corresponding to the target node 33 is asymmetric.
And step 406, the main storage node sends the type information of the NAT to the target node.
When the main storage node 31 determines the type information of the NAT corresponding to the target node 33, the type information of the NAT corresponding to the target node 33 is sent to the target node 33.
Step 407, the main storage node receives a first packet sent by the target node, where a source IP address of the first packet is a public network IP address of an NAT corresponding to the target node at the current time, and a source port number of the first packet is a port number mapped on the NAT by the target node at the current time.
When the target node 33 receives that the type information of the NAT sent by the main storage node 31 is asymmetric, the target node 33 sends a first packet to the main storage node 31 according to the public network IP address of the NAT corresponding to the target node 33 at the current time and the port number of the target node 33 mapped on the NAT, where the source IP address of the first packet is the public network IP address of the NAT corresponding to the target node 33 at the current time, and the source port number of the first packet is the port number of the target node 33 mapped on the NAT at the current time. In addition, the first message further includes identification information of the target node 33 and a terminal device number corresponding to the target node 33, so that when the main storage node 31 receives the first message, the identity information of the target node 33 is identified according to the identification information of the target node 33. In addition, the target node 33 may also sign the first packet by using its own private key, that is, the target node 33 signs the identification information of the target node 33 and the terminal device number corresponding to the target node 33 by using its own private key, and sends the signed content to the main storage node 31, so that the main storage node 31 identifies the identity information of the target node 33 according to the signed content of the target node 33.
Optionally, the public network IP address of the NAT corresponding to the target node 33 and the port number mapped on the NAT by the target node 33 at different times may be different, that is, the public network IP address of the NAT corresponding to the target node 33 and the public network IP address of the NAT corresponding to the target node 33 at the current time may be different when the target node 33 sends the request information to the main storage node 31, and the port number mapped on the NAT by the target node 33 and the port number mapped on the NAT at the current time by the target node 33 when the target node 33 sends the request information to the main storage node 31 may be different.
Step 408, the main storage node sends a second packet to the target node according to the source IP address and the source port number of the first packet.
After receiving the first packet sent by the destination node 33, the main storage node 31 extracts the source IP address and the source port number of the first packet, uses the source IP address and the source port number of the first packet as a new communication address of the destination node 33, and sends a second packet to the destination node 33 according to the source IP address and the source port number of the first packet.
And 409, receiving the heartbeat message periodically sent by the target node by the main storage node.
After receiving the second message sent by the main storage node 31, the target node 33 periodically sends a heartbeat message to the main storage node 31 according to the new communication address of the target node 33 in the second message, so as to keep the heartbeat channel between the target node 33 and the main storage node 31 open all the time.
And step 410, the main storage node updates the locally recorded public network IP address of the NAT corresponding to the target node and the port number mapped on the NAT by the target node according to the heartbeat message periodically sent by the target node.
The main storage node 31 updates the locally recorded public network IP address of the NAT corresponding to the target node 33 and the port number mapped on the NAT by the target node 33 according to the heartbeat packet periodically sent by the target node 33. In addition, the target node 33 may also broadcast the public network IP address of the NAT corresponding to the current time and the port number mapped on the NAT by the target node 33 at the current time to the blockchain network, so as to correct the IP address and the port number declared by the target node 33 at the historical time.
In the embodiment of the invention, the main storage node receives the request information sent by the target node, compares whether the source IP address of the request information is the same as the IP address broadcast by the target node when the target node joins the block chain network, and if the source IP address of the request information is different from the IP address broadcast by the target node when the target node joins the block chain network, the main storage node determines that the target node is positioned under the NAT (network address translation), and determines the public network IP address of the NAT corresponding to the target node and the port number mapped by the target node on the NAT, so that the target node can become a slave storage node, the node without the public network IP address can also become a slave storage node, and the development of block chain service is promoted.
Fig. 5 is a flowchart of a block-node communication method according to another embodiment of the present invention. On the basis of the foregoing embodiment, the block link point communication method provided in this embodiment specifically includes the following steps:
step 501, a master storage node receives request information sent by a target node, where the request information indicates that the target node requests to become a slave storage node, and the request information includes identification information of the target node.
The implementation manner of step 501 and step 201 is consistent with specific principles, and is not described herein again.
Step 502, the master storage node compares whether the source IP address of the request message is the same as the IP address broadcast by the target node when joining the blockchain network.
The implementation manner of step 502 and step 202 is consistent with specific principles, and will not be described herein.
Step 503, if the source IP address of the request information is different from the IP address broadcast by the target node when joining the block chain network, the main storage node determines that the target node is located under the network address translation NAT.
The implementation manner of step 503 and step 203 is consistent with specific principles, and is not described herein again.
Step 504, the primary storage node sends a connection request to the target node according to the source IP address and the source port number of the request information.
The master storage node 31 sends a connection request, which may specifically be a TCP connection request, to the target node 33 according to the source IP address, e.g. TTT, and the source port number, e.g. 4040, of the request information sent by the target node 33.
Step 505, if the master storage node does not receive the connection response sent by the target node within a preset time, the master storage node determines that the type information of the NAT corresponding to the target node is a symmetric type.
After the main storage node 31 sends the connection request to the target node 33 according to the source IP address, e.g., TTT, and the source port number, e.g., 4040, of the request information sent by the target node 33, if the main storage node 31 does not receive the connection response sent by the target node 33 within the preset time, the main storage node 31 may send the connection request to the target node 33 again, and if the main storage node 31 still does not receive the connection response sent by the target node 33 within the preset time after sending the preset number of connection requests to the target node 33, it indicates that the target node 33 is under a symmetric NAT, that is, the type information of the NAT corresponding to the target node 33 is symmetric.
Step 506, the master storage node sends the type information of the NAT to the target node.
When the main storage node 31 determines the type information of the NAT corresponding to the target node 33, the type information of the NAT corresponding to the target node 33 is sent to the target node 33.
And step 507, the main storage node receives the query request sent by the query node.
For example, the master storage node 31 receives a query request sent by the query node 35.
Step 508, the main storage node sends the IP address and the port number of the query node to the target node, so that the target node and the query node perform information interaction.
The main storage node 31 sends the IP address and the port number of the querying node 35 to the target node 33, and optionally, the IP address of the querying node 35 is the source IP address of the querying request, and the port number of the querying node 35 is the source port number of the querying request. The target node 33 sends a heartbeat message to the query node 35 according to the IP address and the port number of the query node 35, and keeps a heartbeat channel between the target node 33 and the query node 35 open all the time, when the query node 35 needs to query information stored on the target node 33, the query node 35 can send a query request to the target node 33 through the heartbeat channel between the target node 33 and the query node 35, and the target node 33 can send a query result to the query node 35 through the heartbeat channel between the target node 33 and the query node 35.
In the embodiment of the invention, the main storage node receives the request information sent by the target node, compares whether the source IP address of the request information is the same as the IP address broadcast by the target node when the target node joins the block chain network, and if the source IP address of the request information is different from the IP address broadcast by the target node when the target node joins the block chain network, the main storage node determines that the target node is positioned under the NAT (network address translation), and determines the public network IP address of the NAT corresponding to the target node and the port number mapped by the target node on the NAT, so that the target node can become a slave storage node, the node without the public network IP address can also become a slave storage node, and the development of block chain service is promoted.
Fig. 6 is a schematic structural diagram of a block link point communication device according to an embodiment of the present invention. The block link point communicator may be the main storage node in the above embodiments. As shown in fig. 6, the block link point communication device 60 includes: a receiving module 61, a comparing module 62, a first determining module 63, a second determining module 64 and a sending module 65; the receiving module 61 is configured to receive request information sent by a target node, where the request information indicates that the target node requests to become a slave storage node, and the request information includes identification information of the target node; the comparing module 62 is configured to compare whether the source IP address of the request message is the same as the IP address broadcast by the target node when joining the blockchain network; the first determining module 63 is configured to determine that the target node is located under a network address translation NAT when a source IP address of the request information is different from an IP address broadcasted by the target node when the target node joins the block chain network, and determine a public network IP address of the NAT corresponding to the target node and a port number mapped by the target node on the NAT; the second determining module 64 is configured to determine the type information of the NAT corresponding to the target node by sending a connection request to the target node; the sending module 65 is configured to send the type information of the NAT to the target node.
Optionally, the sending module 65 is further configured to: sending a connection request to the target node according to the source IP address and the source port number of the request information; the second determining module 64 is specifically configured to: and when the receiving module receives the connection response sent by the target node, determining that the type information of the NAT corresponding to the target node is asymmetric.
Optionally, the receiving module 61 is further configured to: receiving a first message sent by the target node, wherein a source IP address of the first message is a public network IP address of an NAT corresponding to the target node at the current time, and a source port number of the first message is a port number mapped on the NAT by the target node at the current time; the sending module 65 is further configured to: sending a second message to the target node according to the source IP address and the source port number of the first message; the receiving module 61 is further configured to: receiving heartbeat messages periodically sent by the target node; the block-link point communication device 60 further includes: and the updating module 66, where the updating module 66 is configured to update the locally recorded public network IP address of the NAT corresponding to the target node and the port number mapped on the NAT by the target node according to the heartbeat packet periodically sent by the target node.
Optionally, the sending module 65 is further configured to: sending a connection request to the target node according to the source IP address and the source port number of the request information; the second determining module 64 is specifically configured to: and when the main storage node does not receive the connection response sent by the target node within the preset time, determining that the type information of the NAT corresponding to the target node is a symmetrical type.
Optionally, the receiving module 61 is further configured to: receiving a query request sent by a query node; the sending module 65 is further configured to: and sending the IP address and the port number of the query node to the target node so as to enable the target node and the query node to carry out information interaction.
The block link point communication apparatus of the embodiment shown in fig. 6 can be used to implement the technical solution of the above method embodiment, and the implementation principle and technical effect are similar, and are not described herein again.
Fig. 7 is a schematic structural diagram of a blockchain node according to an embodiment of the present invention. The block link point provided by the embodiment of the present invention may execute the processing procedure provided by the block link point communication method embodiment, as shown in fig. 7, the block link point 70 includes a memory 71, a processor 72, a computer program, and a communication interface 73; wherein a computer program is stored in the memory 71 and configured to be executed by the processor 72 for the block-link point communication method as described in the above embodiments.
The block link points of the embodiment shown in fig. 7 can be used to implement the technical solution of the above method embodiment, and the implementation principle and technical effect are similar, and are not described herein again.
In addition, the present embodiment also provides a computer-readable storage medium on which a computer program is stored, the computer program being executed by a processor to implement the block link point communication method described in the above embodiments.
In the embodiments provided in the present invention, it should be understood that the disclosed apparatus and method may be implemented in other ways. For example, the above-described apparatus embodiments are merely illustrative, and for example, the division of the units is only one logical division, and other divisions may be realized in practice, for example, a plurality of units or components may be combined or integrated into another system, or some features may be omitted, or not executed. In addition, the shown or discussed mutual coupling or direct coupling or communication connection may be an indirect coupling or communication connection through some interfaces, devices or units, and may be in an electrical, mechanical or other form.
The units described as separate parts may or may not be physically separate, and parts displayed as units may or may not be physical units, may be located in one place, or may be distributed on a plurality of network units. Some or all of the units can be selected according to actual needs to achieve the purpose of the solution of the embodiment.
In addition, functional units in the embodiments of the present invention may be integrated into one processing unit, or each unit may exist alone physically, or two or more units are integrated into one unit. The integrated unit can be realized in a form of hardware, or in a form of hardware plus a software functional unit.
The integrated unit implemented in the form of a software functional unit may be stored in a computer readable storage medium. The software functional unit is stored in a storage medium and includes several instructions to enable a computer device (which may be a personal computer, a server, or a network device) or a processor (processor) to execute some steps of the methods according to the embodiments of the present invention. And the aforementioned storage medium includes: various media capable of storing program codes, such as a usb disk, a removable hard disk, a Read-Only Memory (ROM), a Random Access Memory (RAM), a magnetic disk, or an optical disk.
It is obvious to those skilled in the art that, for convenience and simplicity of description, the foregoing division of the functional modules is merely used as an example, and in practical applications, the above function distribution may be performed by different functional modules according to needs, that is, the internal structure of the device is divided into different functional modules to perform all or part of the above described functions. For the specific working process of the device described above, reference may be made to the corresponding process in the foregoing method embodiment, which is not described herein again.
Finally, it should be noted that: the above embodiments are only used to illustrate the technical solution of the present invention, and not to limit the same; while the invention has been described in detail and with reference to the foregoing embodiments, it will be understood by those skilled in the art that: the technical solutions described in the foregoing embodiments may still be modified, or some or all of the technical features may be equivalently replaced; and the modifications or the substitutions do not make the essence of the corresponding technical solutions depart from the scope of the technical solutions of the embodiments of the present invention.