A kind of routing iinformation exchange method based on block chain overlay network
Technical field
It is a kind of based on block chain overlay network more particularly, to block chain the present invention relates to Internet technical field
Routing iinformation exchange method.
Background technique
Basis of the block chain technology as distributed account book and digital cash, is widely studied and is applied.Block
Chain technology successfully solves the problems, such as the synchronizing information between the trust problem of each participant and each distributed global function node.
After a block chain link point receives transaction request, it can be sent to transaction all nodes being connected with, Qi Tajie itself
After point receives this request, the node that it is connected also is sent by transaction, final Transaction Information is in entire block chain network
Broadcast.Global function node in block chain network is verified, confirmed and is stored to these transaction.
There is the scene of transaction to also imply that the side of participating in business there are social needs in fact, so also gradually someone starts to explore
Social networks based on block chain.
Current block chain technology, it is preferred that emphasis is the data synchronization problems between trust problem and distributed node are solved,
Transaction relies on point to point network and is broadcast to all block chain nodes.For relate only to both sides or it is multi-party between information hand over
Mutually, without the information broadcasted in entire block chain network, such as based on the social demand on block chain network, these
Information only has the both sides participated in or multi-party care, if these information broadcasted in block chain, undoubtedly in waste bandwidth.Area
Block chain network lacks the support to this application scenarios.
Summary of the invention
The present invention provides a kind of routing iinformation exchange methods based on block chain overlay network, to solve existing skill
At least one above-mentioned technical problem present in art.
In order to solve the above technical problems, a kind of routing iinformation based on block chain overlay network provided by the invention is handed over
Mutual method, the interaction for non-broadcasting information between block chain upper network node comprising:
S1: each network node saves and safeguards that (non-broadcasting information is based on a route information table on block chain
Route information table is propagated in block chain overlay network);
S2: the route information table includes several ways by recording;
Every route record includes: multiple fields such as reachable address, next hop address, time delay and time-out time;
Several route records include: about the machine route record of network node itself and about the network
The reachable route record of the accessibility reachable node of the information of node;
21) reachable address of the machine route record is the machine routing address of network node itself, the machine routing address pair
The next hop address answered is empty (or being zero), and corresponding time delay and time-out time are 0ms;
22) up to the reachable routing address that the reachable address of route record is up to node;
On from the machine routing address to the route lines up to routing address, the next hop address up to node is not empty;
Time delay is time delay of the network node to the routing procedure up to node;Up to the time delay in route record and surpass
When the time be greater than 0ms;
S3: carrying out information exchange by sending non-broadcasting information between block chain upper network node, sends non-broadcasting
The network node of information is sending node, and the destination node (destination) of non-broadcasting information being finally sent to is specified node;
S4: when sending node sends non-broadcasting information to specified node:
41) if specifying node is a reachable node on route information table described in sending node;
If the route information table of the sending node only includes the reachable route record for specifying node about this,
Sending node sends this up to the next hop address registered in route record, by the next hop address for non-broadcasting information
Non-broadcasting information is sent to specified node by next-hop node;
If the route information table of the sending node includes several reachable route records for specifying node about this, hair
One of node selection time delay minimum (postponing most short) is sent up to route record, sends the time delay most for non-broadcasting information
The next hop address registered in short reachable route record is sent out non-broadcasting information by the next-hop node of the next hop address
Give specified node;
If 42) specify node to be not belonging to the reachable node of sending node, i.e., do not wrapped on the route information table of sending node
The reachable route record that node is specified about this is included, then non-broadcasting information is sent all and its direct connection net by sending node
Network node;
S5: receive the non-broadcasting information node be receiving node, receiving node read non-broadcasting information and from
In parse specified address of node information;
51) if receiving node finds identical with specified node address up to ground in the route information table of oneself
Location, and the corresponding next hop address of the reachable address is sky, then the receiving node is specified node, and non-broadcasting information no longer passes
It passs, which parses and read sending node address information and Message Payload in non-broadcasting information;
52) if receiving node finds identical with specified node address up to ground in the route information table of oneself
Location, and the corresponding next hop address of the reachable address be not it is empty, then pass to the non-broadcasting information can for the receiving node
Up to the corresponding next hop address in address, non-broadcasting information is sent to specified section by the next-hop node of the next hop address
Point;
53) if receiving node does not inquire identical with specified node address up to ground in the route information table of oneself
Location, then non-broadcasting information is sent all and its direct connection node by receiving node;
S6: 52 in step S5 are repeated) and/or 53), until step 51) occurs.
Further, the non-broadcasting information includes at least: specifying the ground of (or purpose) address of node, sending node
Location, type of message, message-length (Msglen, including message header), message sequence (Sequence) and Message Payload (i.e. message
Content) etc. multiple fields.
The non-broadcasting information has standardized format, for example, field format is referring to the following table 1:
Table 1
Wherein, non-broadcasting information can be divided by type of message:
1: route requests class
2: routing respective class
3: route changing notifies class
4~64: reserved classification
65: application layer messages class, etc..
Further, the receiving node receives a plurality of non-broadcasting information from different paths, if a plurality of non-wide
The message sequence of the property broadcast information is identical, then it is assumed that a plurality of non-broadcasting information is identical message, and receiving node only handles the
The one non-broadcasting information being received receives identical non-broadcasting information after deleting other.
Based on the routing iinformation exchange method of block chain overlay network, non-broadcasting information is to be encapsulated in block
On the overlay network (i.e. business stacking network) of chain.Wherein preferably, the non-broadcasting information be encapsulated in TCP or
On person SSL.The routing iinformation exchange method based on block chain overlay network is not limited to above-mentioned association in certain the application
View, as long as can be realized other agreements of overlay network technology also under the application right covers.
Specifically, non-broadcasting information is sent to adjacent network node as the load of TCP or SSL.TCP/SSL
The load prior art, and there is reference format, according to including: for TCP
Ethernet header (14 bytes, purpose MAC, source MAC, ethernettype:0x0800 (ipv4));
IP (usually 20 bytes): destination IP, source IP address, IP length, IP packet length;
TCP header (20 bytes of half): source port number, destination slogan transmit Sequence Number, ack sequence number, flags, hair
Send window size etc.;
It is exactly the load of TCP after TCP header, the message in the document is just placed on after TCP header.
Further, the network node establishes the routing iinformation for reaching oneself itself in its initialization, according to
The routing iinformation records the machine routing address on the route information table.
Further, further include the steps that exchanging routing iinformation between network node:
S7: the new new node (global function node or wallet) being added in block chain network is at least and in a block chain
The global function node being formerly added is established TCP/SSL and is bi-directionally connected, between new node and the global function node being formerly added each other
To other side's request route information, i.e., mutual route information table is shared between new node and the global function node being first added, by two
It saves after information fusion in the route information table of person and respectively;
And/or periodically shared and synchronization of routing information, final each network node obtain between two neighboring network node
All routing iinformations in block chain network.
New node is to the global function node request route information being formerly added, and the global function node being formerly added is to new node
Request route information.
Wherein routing iinformation includes but is not limited to the relevant information in route record.
Further, routing iinformation is requested and shared between two network nodes mutually, two network nodes are divided into: issuing
The requesting party of request route information, and issue echo message to requesting party and/or share the reply party of oneself route information table;
Wherein, requesting party, which calculates, issues request route information and receives the time difference of echo message, and the time difference is made
The two node time delays between requesting party and reply party.
Further, received routing iinformation is merged and is recorded in the route information table of oneself by the requesting party,
In to follow fusion rule as follows:
If the reply party route record 1) received is new address information, and/or, and in requesting party's route record
Next hop address is different from the local address of reply party, then requesting party increases a new reachable routing note in its route information table
Record;
The new reachable address up to route record is the reachable address in reply party route record;
Next hop address is the local address of reply party in new reachable route record;
It is new (to be requested for the time delay in the reply party route record with the two nodes time delay up to time delay in route record
The sum of time delay between two nodes in side and reply party);
It is new to be updated to setting time up to time-out time in route record;
In the method for the present invention, as long as receiving the routing iinformation that other nodes send over, then it is assumed that this routing iinformation
For effective status, i.e., still by use, when so requesting party (receiving end) then need to only update the time-out of this routing iinformation
Between be setting time, for example, 5-10 minutes.
If in use, can not receive the feedback information of this routing for a long time, just illustrate that this routing is no longer valid, or
No one uses, and will delete the route record of this routing iinformation.
According to for 10 minutes this time-out times for example:
1.1. time-out time is updated to 10 points when increasing a route record (next-hop for reaching B purpose is A)
After clock (current system starts+10 minutes time)
1.2. if not receiving this routing iinformation (reaching the routing iinformation of B from A), this routing within ten minutes
Information will be deleted from route information table;
1.3. if having received the information of the routing in 10 minutes, time-out time was set as again after 10 minutes
(current system starts+10 minutes time).
If 2) have note in the reachable address of a reply party route record and the route information table of requesting party that receive
The reachable address of record is identical, and the next hop address of the route record of requesting party is the local address of reply party, then requesting party is more
The new time delay for having record and time-out time;
Have record new time delay be the reply party route record in time delay and the two nodes time delay (requesting party and
The sum of time delay between two nodes of reply party);
The new time-out time for having record is updated to setting time (such as 5~10 minutes).
That is, the local of requesting party has under the destination address (specified node address) for the same destination address
One hop-information, it is also possible to receive the routing iinformation for the destination address that adjacent node sends over, but next-hop and locally deposit
Next-hop may be different in route information table, in this case, needs (specified to this destination address at locally newly-built one
Node) routing iinformation.So on this node, it just will appear two routing iinformations of same purpose.
Further, it is shared between the network node and the synchronized update routing note in existing route information table each other
It records (routing iinformation item);
Network node be automatically deleted setting period (such as 30-60 minute) it is interior can not synchronized update route record.
For example, being deleted for the list item not updated for a long time by timeout mechanism, the time-out time of default is
30 minutes.
Further, regular request route information to each other between two network nodes of direct connection, wherein described to ask
The side of asking follows the fusion rule and merges received routing iinformation and be recorded in the route information table of oneself.
Wherein, when request direction reply party issues solicited message, time-out time can be set as 10-60 minutes, if super
When, then it is assumed that the corresponding already off connection of reply party, requesting party delete relevant to reply party address in route information table
Route record.
Further, when the routing iinformation that network node saves changes, the network node is actively to straight with oneself
The network node request of connection and shared routing iinformation.
Further, the network node is global function node and lightweight node;
The global function node is to save whole transaction data in entire block chain network, and it is new to be responsible for each pen of verification
The node of Transaction Information;The light weight node is the node that store transaction data are not needed in block chain.
Wherein, the global function node is connected to the network one mesh network of composition by P2P;Each global function node is not required to
The node of block chain can be added directly by other nodes.And light weight node, also referred to as SPV (simple
Payment verification) node is needed in block chain network by connecting one or more global function node
The node that can be added in block chain network.
Light weight node is in the edge of whole network, and light weight node does not need the transaction data in memory block chain network.
For example, the light weight node can be the wallet module node on block chain, wallet module node is having based on block chain
The program application of wallet function, and the global function node in block chain network usually also contains the function of wallet.Wallet module
Node can receive the remittance of other wallets by the way that the address of oneself is shared away.And wallet address is also to receive remittance of transferring accounts
The mark of the external information of money.
Further, the time-out time of routing is 20-60 minutes.
Further, if the network node is in time-out time can not receive connect some described reachable node or
The more new information of the routing of the next-hop node, then it is assumed that this is unreachable up to node or next-hop node, then from described
This is deleted in route information table up to node or the routing iinformation of next-hop node.
Time-out time is to be set based on system start-up time, and modification system time will not cause shifting to an earlier date for routing iinformation list item
Or delayed deletion.
By adopting the above technical scheme, the invention has the following beneficial effects:
A kind of routing iinformation exchange method based on block chain overlay network provided by the invention, can be used for block chain
In two or more nodes between communication can effectively avoid existing such as based on the social activity on block chain overlay network
Broadcast message brought by inefficiency, the wasting of resources the problem of.
Detailed description of the invention
It below will be to specific in order to illustrate more clearly of the specific embodiment of the invention or technical solution in the prior art
Embodiment or attached drawing needed to be used in the description of the prior art be briefly described, it should be apparent that, it is described below
Attached drawing is some embodiments of the present invention, for those of ordinary skill in the art, before not making the creative labor
It puts, is also possible to obtain other drawings based on these drawings.
Fig. 1 is that new node and direct connection node-routing are believed during TCP connection in the embodiment of the present invention between the node that provides
The schematic diagram of breath request and exchange.
Specific embodiment
Technical solution of the present invention is clearly and completely described below in conjunction with attached drawing, it is clear that described implementation
Example is a part of the embodiment of the present invention, instead of all the embodiments.Based on the embodiments of the present invention, ordinary skill
Personnel's every other embodiment obtained without making creative work, shall fall within the protection scope of the present invention.
In the description of the present invention, it should be noted that term " center ", "upper", "lower", "left", "right", "vertical",
The orientation or positional relationship of the instructions such as "horizontal", "inner", "outside" be based on the orientation or positional relationship shown in the drawings, merely to
Convenient for description the present invention and simplify description, rather than the device or element of indication or suggestion meaning must have a particular orientation,
It is constructed and operated in a specific orientation, therefore is not considered as limiting the invention.In addition, term " first ", " second ",
" third " is used for descriptive purposes only and cannot be understood as indicating or suggesting relative importance.
In the description of the present invention, it should be noted that unless otherwise clearly defined and limited, term " installation ", " phase
Even ", " connection " shall be understood in a broad sense, for example, it may be being fixedly connected, may be a detachable connection, or be integrally connected;It can
To be mechanical connection, it is also possible to be electrically connected;It can be directly connected, can also can be indirectly connected through an intermediary
Connection inside two elements.For the ordinary skill in the art, above-mentioned term can be understood at this with concrete condition
Concrete meaning in invention.
Below with reference to specific embodiment the present invention will be further explained explanation.
A kind of routing iinformation exchange method based on block chain overlay network provided in this embodiment is used for block chain
The interaction of non-broadcasting information (such as social information) between upper network node comprising:
S1: each network node saves and safeguards a route information table on block chain;
S2: route information table includes several ways by recording;
Ginseng is shown in Table 2, and every route record includes: that reachable address, next hop address, time delay and time-out time etc. are multiple
Field;
Several ways include: about the machine route record of network node itself and about the network node by recording
The accessibility reachable node of information reachable route record;
No.0 is recorded as the machine route record in table 2, other are recorded as up to route record.
21) reachable address of the machine route record is the machine routing address of network node itself, the machine routing address pair
The next hop address answered is empty (or being zero), does not need the next-hop sent by TCP, corresponding time delay and time-out time are
0ms;
22) up to the reachable routing address that the reachable address of route record is up to node;
On from the machine routing address to the route lines up to routing address, the next hop address up to node is not empty;
For example, next-hop is the IP address of peer node (peer node).Time delay is routing procedure of the network node to reachable node
Time delay;Time delay and time-out time in reachable route record are greater than 0ms.
Table 2
It, will from local road information table if not receiving routing update or the reply up to node in time-out time
This route record is deleted, and time-out time is set based on system start-up time, and modification system time not will lead to routing note
Record is because shifting to an earlier date or postponing and be deleted.Under default situations, the timeout time of routing iinformation is 30 minutes.
It is shown in Table 2, No.1 and No.2 is the routing iinformation record for the reachable node being connected directly with (local) network node,
Next-hop is the IP address of peer;
No.3 and No.4 is the routing iinformation record for the reachable node that (local) network node is indirectly connected, local network section
Point can be reachable by direct-link node 182.1.1.2 and 182.1.1.3 respectively, also has recorded local network in route record simultaneously
Time delay of the node to reachable node.Local network node can reach same reachable address by mulitpath, and time delay may
It is variant, No.3 and No.4 two records in example as above.
S3: carrying out information exchange by sending non-broadcasting information between block chain upper network node, sends non-broadcasting
The network node of information is sending node, and the destination node of non-broadcasting information being finally sent to is specified node;
S4: when sending node sends non-broadcasting information to specified node:
41) if specifying node is a reachable node on sending node route information table;
If the route information table of sending node only includes the reachable route record for specifying node about this, send
Node sends this up to the next hop address registered in route record, by the next of the next hop address for non-broadcasting information
Non-broadcasting information is sent to specified node by hop node;
If the route information table of sending node includes several reachable route records for specifying node about this, section is sent
It is shortest to send the time delay for non-broadcasting information up to route record by one of point selection time delay minimum (postponing most short)
Up to the next hop address registered in route record, non-broadcasting information is sent to by the next-hop node of the next hop address
Specified node;
If 42) specify node to be not belonging to the reachable node of sending node, i.e., do not wrapped on the route information table of sending node
The reachable route record that node is specified about this is included, then non-broadcasting information is sent all and its direct connection net by sending node
Network node;
S5: the node for receiving non-broadcasting information is receiving node, and receiving node reads non-broadcasting information and therefrom solves
Specified address of node information is precipitated;
51) if receiving node finds identical with specified node address up to ground in the route information table of oneself
Location, and the corresponding next hop address of the reachable address is sky, then the receiving node is specified node, and non-broadcasting information no longer passes
It passs, which parses and read sending node address information and Message Payload in non-broadcasting information;
52) if receiving node finds identical with specified node address up to ground in the route information table of oneself
Location, and the corresponding next hop address of the reachable address is not sky, then the receiving node passes to non-broadcasting information up to ground
Non-broadcasting information is sent to specified node by the next-hop node of the next hop address by the corresponding next hop address in location;
53) if receiving node does not inquire identical with specified node address up to ground in the route information table of oneself
Location, then non-broadcasting information is sent all and its direct connection node by receiving node;
S6: 52 in step S5 are repeated) and/or 53), until step 51) occurs.
Wherein, non-broadcasting information includes at least: specified (or purpose) address of node, the address of sending node, message
Type, message-length (Msglen, including message header), message sequence (Sequence) and Message Payload (i.e. message content) etc.
Multiple fields.
Non-broadcasting information has standardized format, for example, field format is referring to following table:
Wherein, non-broadcasting information can be divided by type of message:
1: route requests class
2: routing respective class
3: route changing notifies class
4~64: reserved classification
65: application layer messages class, etc..
Receiving node receives a plurality of non-broadcasting information from different paths, if the message sequence of a plurality of non-broadcasting information
It is identical, then it is assumed that a plurality of non-broadcasting information is identical message, and receiving node only handles first non-broadcasting being received letter
Breath receives identical non-broadcasting information after deleting other.
Wherein, non-broadcasting information is encapsulated on the overlay network (i.e. business stacking network) of block chain.Example
Such as, non-broadcasting information is encapsulated on TCP or SSL.
Network node establishes the routing iinformation for reaching oneself itself in its initialization, according to the routing iinformation on road
By recording the machine routing address on information table.
And the step of routing iinformation is exchanged between network node, is as follows:
S7: the new new node (global function node or wallet) being added in block chain network is at least and in a block chain
The global function node being formerly added is established TCP/SSL and is bi-directionally connected, between new node and the global function node being formerly added each other
To other side's request route information, i.e., mutual route information table is shared between new node and the global function node being first added, by two
It saves after information fusion in the route information table of person and respectively.
When there is a new node (global function node or wallet) that block chain network is added, it understands and one or more
Global function node in block chain network is established TCP/SSL and is bi-directionally connected, as shown in this Fig. 1, new node X and node A, node B
Establish connection.Once establishing connection, new node X can be respectively to node A, B request route information, while node A, B also can Xiang Xin
Node B requests routing iinformation.
New node is to the global function node request route information being formerly added, and the global function node being formerly added is to new node
Request route information.Alternatively, periodically being shared between two neighboring network node and synchronization of routing information, final each network node
Obtain all routing iinformations in block chain network.
Routing iinformation is requested and shared between two network nodes mutually, two network nodes are divided into: issuing request routing
The requesting party of information, and issue echo message to requesting party and/or share the reply party of oneself route information table;
Wherein, requesting party, which calculates, issues request route information and receives the time difference of echo message, and the time difference is made
The two node time delays between requesting party and reply party.
Received routing iinformation is merged and is recorded in the route information table of oneself by requesting party, and follows fusion rule such as
Under:
If the reply party route record 1) received is new address information, and/or, and in requesting party's route record
Next hop address be different from reply party local address (such as: if A has received the routing iinformation of B, A can be the routing received
Next-hop in information is both configured to B, and in this way if there is data message is dealt into this routing, message will be given to B by A), then
Requesting party increases a new reachable route record in its route information table;
The new reachable address up to route record is the reachable address in reply party route record;
Next hop address is the local address of reply party in new reachable route record;
Time delay is the time delay and two node time delay (requesting party and replies in reply party route record in new reachable route record
The sum of time delay between two nodes in side);
It is new to be updated to setting time, such as 10 minutes up to time-out time in route record.
If 2) have note in the reachable address of a reply party route record and the route information table of requesting party that receive
The reachable address of record is identical, and the next hop address of the route record of requesting party is the local address of reply party, then requesting party is more
Newly have the time delay and time-out time of record;
Has the new time delay of record for the time delay and two node time delays (requesting party and reply party two in reply party route record
The sum of time delay between a node);
The new time-out time for having record was updated to after 10 minutes.
It is shared between network node and the synchronized update route record (routing iinformation in existing route information table each other
);
Network node be automatically deleted setting period (such as 30-60 minute) it is interior can not synchronized update route record.
For example, being deleted for the list item not updated for a long time by timeout mechanism, the time-out time of default is
30 minutes.
Regular request route information to each other between two network nodes of direct connection, wherein requesting party follows fusion rule
Received routing iinformation is merged and is recorded in the route information table of oneself.
Wherein, when request direction reply party issues solicited message, time-out time can be set as 10-60 minutes, if super
When, then it is assumed that the corresponding already off connection of reply party, requesting party delete relevant to reply party address in route information table
Route record.
When the routing iinformation that network node saves changes, the network node is actively to the network section with oneself direct connection
Point request and shared routing iinformation.
Network node is global function node and lightweight node;
Global function node is to save whole transaction data in entire block chain network, and be responsible for each New Transaction of verification
The node of information;Light weight node is the node that store transaction data are not needed in block chain.
Wherein, global function node is connected to the network one mesh network of composition by P2P;Each global function node does not need to lead to
Cross the node that other nodes can be added directly into block chain.And light weight node, also referred to as SPV (simple payment
Verification) node is to need to be added to by connecting one or more global function node just in block chain network
Node in block chain network.
Light weight node is in the edge of whole network, and light weight node does not need the transaction data in memory block chain network.
For example, light weight node can be the wallet module node on block chain, wallet module node is to have wallet based on block chain
The program application of function, and the global function node in block chain network usually also contains the function of wallet.Wallet module node
The remittance of other wallets can be received by the way that the address of oneself is shared away.And wallet address is also to receive to transfer accounts to remit money it
The mark of external information.
If network node can not receive in time-out time connects some up to the routing of node or next-hop node
More new information, then it is assumed that this is unreachable up to node or next-hop node, then deleted from route information table this up to section
The routing iinformation of point or next-hop node.
Time-out time is to be set based on system start-up time, and modification system time will not cause shifting to an earlier date for routing iinformation list item
Or delayed deletion.
Wherein, route information table contains directly or indirectly up to node address, next hop information, path quality and road
The whether effective information of diameter;Node can be fixed between direct connection node switching routing iinformation and node when accessing block chain network
Phase exchanges routing iinformation;It, also can proactive notification direct connection node updates routing letter meanwhile when the routing iinformation of network node changes
Breath;When node disconnects, related route table items are deleted, and delete the routing iinformation not updated for a long time.
In addition, mark of the time difference of route requests and route response as path quality between two network nodes of evaluation
Standard, during route switching, accumulated path postpones, and selection postpones the smallest path in message transmitting procedure.
The communication that the present invention can be used between two or more nodes in block chain is such as based on block chain overlay net
Social activity on network, the problem of can effectively avoid inefficiency brought by existing broadcast message, the wasting of resources.
Finally, it should be noted that the above embodiments are only used to illustrate the technical solution of the present invention., rather than its limitations;To the greatest extent
Pipe present invention has been described in detail with reference to the aforementioned embodiments, those skilled in the art should understand that: its according to
So be possible to modify the technical solutions described in the foregoing embodiments, or to some or all of the technical features into
Row equivalent replacement;And these are modified or replaceed, various embodiments of the present invention technology that it does not separate the essence of the corresponding technical solution
The range of scheme.