CN113328890A - Network communication model construction method based on distributed system - Google Patents

Network communication model construction method based on distributed system Download PDF

Info

Publication number
CN113328890A
CN113328890A CN202110632800.5A CN202110632800A CN113328890A CN 113328890 A CN113328890 A CN 113328890A CN 202110632800 A CN202110632800 A CN 202110632800A CN 113328890 A CN113328890 A CN 113328890A
Authority
CN
China
Prior art keywords
node
central
tree
central node
network topology
Prior art date
Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
Granted
Application number
CN202110632800.5A
Other languages
Chinese (zh)
Other versions
CN113328890B (en
Inventor
齐翔
瞿洪桂
张男男
Current Assignee (The listed assignees may be inaccurate. Google has not performed a legal analysis and makes no representation or warranty as to the accuracy of the list.)
Beijing Sinonet Science and Technology Co Ltd
Original Assignee
Beijing Sinonet Science and Technology Co Ltd
Priority date (The priority date is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the date listed.)
Filing date
Publication date
Application filed by Beijing Sinonet Science and Technology Co Ltd filed Critical Beijing Sinonet Science and Technology Co Ltd
Priority to CN202110632800.5A priority Critical patent/CN113328890B/en
Publication of CN113328890A publication Critical patent/CN113328890A/en
Application granted granted Critical
Publication of CN113328890B publication Critical patent/CN113328890B/en
Active legal-status Critical Current
Anticipated expiration legal-status Critical

Links

Images

Classifications

    • HELECTRICITY
    • H04ELECTRIC COMMUNICATION TECHNIQUE
    • H04LTRANSMISSION OF DIGITAL INFORMATION, e.g. TELEGRAPHIC COMMUNICATION
    • H04L41/00Arrangements for maintenance, administration or management of data switching networks, e.g. of packet switching networks
    • H04L41/14Network analysis or design
    • H04L41/145Network analysis or design involving simulating, designing, planning or modelling of a network
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F16/00Information retrieval; Database structures therefor; File system structures therefor
    • G06F16/20Information retrieval; Database structures therefor; File system structures therefor of structured data, e.g. relational data
    • G06F16/27Replication, distribution or synchronisation of data between databases or within a distributed database system; Distributed database system architectures therefor
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F30/00Computer-aided design [CAD]
    • G06F30/10Geometric CAD
    • G06F30/18Network design, e.g. design based on topological or interconnect aspects of utility systems, piping, heating ventilation air conditioning [HVAC] or cabling
    • HELECTRICITY
    • H04ELECTRIC COMMUNICATION TECHNIQUE
    • H04LTRANSMISSION OF DIGITAL INFORMATION, e.g. TELEGRAPHIC COMMUNICATION
    • H04L67/00Network arrangements or protocols for supporting network services or applications
    • H04L67/01Protocols
    • H04L67/10Protocols in which an application is distributed across nodes in the network
    • H04L67/1095Replication or mirroring of data, e.g. scheduling or transport for data synchronisation between network nodes
    • HELECTRICITY
    • H04ELECTRIC COMMUNICATION TECHNIQUE
    • H04LTRANSMISSION OF DIGITAL INFORMATION, e.g. TELEGRAPHIC COMMUNICATION
    • H04L67/00Network arrangements or protocols for supporting network services or applications
    • H04L67/01Protocols
    • H04L67/10Protocols in which an application is distributed across nodes in the network
    • H04L67/1097Protocols in which an application is distributed across nodes in the network for distributed storage of data in networks, e.g. transport arrangements for network file system [NFS], storage area networks [SAN] or network attached storage [NAS]
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F2111/00Details relating to CAD techniques
    • G06F2111/02CAD in a network environment, e.g. collaborative CAD or distributed simulation

Abstract

The invention relates to the technical field of computers, and discloses a network communication model construction method based on a distributed system, which comprises the steps of networking each node; carrying out network topology creation; carrying out tree network topology issuing; keep-alive is carried out by adopting a mode of a central network model and a mode of sending heartbeat packets; rearranging the whole tree network topology; sending data from the root node, wherein the data of the root node is only sent to the child nodes corresponding to the root node; and the child nodes receive the data and send the data to the self child nodes. The invention adopts special tree network topology to reduce the data transmission time, fully utilizes the resources of other nodes in the cluster, reduces the processing time and pressure of the central node, and ensures that the data transmission time is overlong and the intermediate state is excessive because a key path is not generated during the data transmission. The invention adopts different transmission modes aiming at different data transmission, has higher transmission efficiency and reduces the complexity of interaction between nodes.

Description

Network communication model construction method based on distributed system
Technical Field
The invention relates to the technical field of computers, in particular to a network communication model construction method based on a distributed system.
Background
In the prior art, a distributed cloud storage system can store data in a plurality of nodes, so that the reliability of the data is ensured, and meanwhile, a huge storage space is provided. However, the particularity of the distributed storage system causes frequent communication among the nodes in the distributed storage system and interaction and transmission of data in most cases. The single communication mode may cause inefficiency in some cases, such as large-scale data interaction, or bulk file transmission, which may cause each node in the distributed system to use most of the running time for data transmission, and cause a long time for completing synchronization of all data, which may have a great impact on reliability and availability of the distributed system. Meanwhile, in order to generate larger profit, reduce product power consumption and improve product competitiveness, some distributed systems adopt low-cost isomorphic embedded devices, that is, the computing capacity and storage capacity of each node are equivalent, and compared with x86, the server is weaker, and each node serves almost the same data. Although the architecture is not easy to linearly expand when the copies are added, the architecture system is simple to deploy, convenient to use, cost-saving and high in competitiveness in the market. In such a system, a single node with strong capability cannot be selected as a scheduling and control node, and when more tasks are executed, the diversity of the network model in the distributed system is very important.
The existing distributed system network architecture model mainly comprises: 1. the design idea of the method is simple, the node equipment in the distributed cluster is divided into two roles according to the role division: a central node and a common node. The central node is sometimes also called a master control node and is used for maintaining data distribution information, a plurality of control nodes may exist in each distributed system, but only one central node exists, and a plurality of data nodes still exist under each control node. The method can cause that the load of the control node or the central node is high under certain conditions, for example, when files are transmitted, the time for sequentially transmitting the files is multiple times of the data nodes and the control nodes of the time required for transmitting the files; 2. the decentralized network design and decentralized structure use distributed accounting and storage, centralized nodes do not exist, rights and obligations of any node are equal, data blocks in the system are maintained by the nodes with maintenance functions in the whole system, and the whole operation of the system cannot be influenced when any node stops working. In this way, in some cases, the entire cluster network may generate a large load, and each node may use a large overall network bandwidth during data synchronization, which may be multiplied by the number of nodes occupied by the general network bandwidth.
Therefore, it is necessary to use a network communication method between a plurality of nodes according to different situations in order to solve the problem of network utilization in the existing distributed system.
Disclosure of Invention
The invention provides a network communication model building method based on a distributed system, thereby solving the problems in the prior art.
The invention provides a network communication model construction method based on a distributed system, which comprises the following steps:
s1) networking each node in the distributed system;
s2) the central node creates network topology according to the receiving sequence of the broadcast packet sent by each non-central node, and creates optimal tree network topology according to the relation among the number, degree and depth of the nodes of the tree;
s3), establishing a first node inequality, setting three node conditions according to the first node inequality, preliminarily constructing a tree network topology by a central node, wherein the node distribution of the preliminarily constructed tree network topology meets the first node inequality, and the optimal tree network topology not only meets the first node inequality, but also meets one of the three node conditions;
s4), after the distributed system is started, the central node issues the optimal tree network topology to each non-central node for recording, each non-central node records a father node and a child node corresponding to the node, and simultaneously each non-central node also records central node information;
s5) in order to enable the central node to record the running state of each non-central node, each non-central node adopts a mode of a central network model and keeps alive by sending heartbeat packets, and simultaneously, in order to ensure the synchronization of network topology information, the central node returns a reverse heartbeat packet to each non-central node, and the reverse heartbeat packet carries the latest network topology information recorded by the central node;
s6) when a node is newly added or removed in the distributed system, rearranging the whole tree network topology;
s7) when large data need to be sent to all nodes, sending the data from the root node, wherein the data of the root node is only sent to the child nodes corresponding to the root node; and the child nodes receive the data, send the data to the child nodes of the children nodes and process the data of the children nodes.
In step S4), the topology delivery is mainly performed: after the distributed system is started for a preset time, the central node issues the network topology to each non-central node for recording, each non-central node focuses on the position of the non-central node in the tree, namely the father node and the son node corresponding to the node, and meanwhile, the relevant information of the central node is recorded according to the previous process. In addition, each non-central node does not need to record other joint-free point information. Heartbeat keep-alive is mainly performed in step S5): in order to enable the central node to record the operation state of each non-central node, each non-central node can keep alive by sending a heartbeat packet. Because the data volume of the heartbeat data packet is small, the data sending frequency is low, the mode of the central network model is adopted at the moment, namely, the operation is carried out in a mode that each non-central node sends a small amount of data to the central node periodically, meanwhile, in order to ensure the synchronization of network topology information, the central node also needs to return a reverse heartbeat packet to each non-central node, and the reverse heartbeat packet carries the latest network topology information recorded by the central node. In step S7), when large data needs to be sent to all nodes but is sent from the root node, the data of the root node is sent only to the corresponding child nodes. And the child nodes obtain the data, then send the data to the child nodes of the child nodes and process the data of the child nodes. So that the time for sending the whole data to all nodes is greatly reduced.
Further, in step S1), networking the nodes in the distributed system, including the following steps:
s11) carrying out role distribution on each node in the distributed system, wherein the roles comprise a central node and a non-central node, and meanwhile, the central node can be used as the non-central node to communicate with the node per se;
s12) monitoring a corresponding data port after the central node is started, discovering the central node in a broadcast mode after a non-central node is started, and sending a broadcast packet to the central node;
s13) after receiving the broadcast packet of the non-central node, the central node records the current non-central node information, wherein the current non-central node information includes but is not limited to the IP address of the non-central node, the hardware information of the non-central node and the configuration information of the non-central node; the central node returns a unicast packet to the non-central node, the unicast packet includes but is not limited to the IP address of the central node, the hardware information of the central node and the configuration information of the central node, and the unicast packet is used for storing and recording the information of the central node by the non-central node; and finally, the central node records all the non-central node address information in the distributed system, and each non-central node records the central node address information in the distributed system.
Further, in step S2), the central node creates a network topology according to the receiving order of the broadcast packets sent by each non-central node; according to the definition of the balanced tree, and through the relation among the number of the nodes of the tree, the degree and the depth, the optimal tree type network topology is established, and the method comprises the following steps:
s21) root node creation: taking the central node as a root node, taking the layer where the root node is located as a 0 th layer, and setting the height of the tree as 0; when the distributed system starts each node to send the broadcast packet, the central node also sends the broadcast packet; when the central node receives the broadcast packet, if the central node finds that the source address of the broadcast packet is a local address, the central node is established as a root node for recording, and other broadcast packets are discarded under the condition that the root node is not established;
s22) layer 1 child node creation: taking a node corresponding to the next packet of broadcast packet received by the central node as a first left node in the tree network topology, taking a node corresponding to the next packet of broadcast packet received by the central node as a first right node in the tree network topology, and if the central node receives repeated broadcast packets, ignoring the repeated broadcast packets;
s23) other layer child node creation: and the other layers of child nodes sequentially establish a left node and a right node according to the step S22), and when the ith layer of child node is inserted, the ith layer of child node needs to be inserted into the parent node with the least leaf child nodes in the i-1 layer, h is more than or equal to i and more than or equal to 1, and h is the maximum layer number of the current tree.
When inserting the child nodes of the 2 nd layer and the later, the node needs to be inserted into the parent node with the least leaf child nodes in the h-1 layer, that is, the right child node position of the corresponding parent node cannot be sequentially searched from left to right according to the insertion rule of the common balanced binary tree, and the node needs to be inserted into the left child node position corresponding to the parent node with the least leaf nodes.
Further, in step S3), the first node inequality is
Figure BDA0003104313790000051
k is the degree of the tree, h is the maximum layer number of the current tree, N is the total number of nodes of the tree, and m is the node adjustment sequence number; the three node conditions are k ═ h, k +1 ═ h and k ═ h +1, respectively; three node inequalities corresponding to the three node conditions are respectively
Figure BDA0003104313790000052
And
Figure BDA0003104313790000053
when the node is added to adjust the tree network topology structure, the first node inequality and the three node conditions are used for judgment, and when new nodes are added or existing nodes are removed in the subsequent steps, the whole tree is usedAnd the structure of the network topology directly calculates the h value or the k value corresponding to the optimal tree according to the inequality of the three nodes.
And in a certain time, the central node can initially construct and complete the tree network topology. The distribution of the nodes of the network tree structure needs to meet the first node inequality, and in addition, in order to ensure the highest efficiency, the structure of the tree needs to be ensured to meet the conditions of three nodes. Since the maximum time for each node of the whole system to complete data synchronization is the completion time of the rightmost node in the whole balanced tree structure, the time is related to the system condition and is uncontrollable. Therefore, as the number of nodes of the tree type is gradually increased, that is, as N is increased, if k is too large and h is too small, each node needs to traverse too much child node information when sending data; if h is too large and k is too small, the number of transfer times in the data sent by each node is too large, so that the overall completion time is too long. So when N increases, the value of h or k needs to be adjusted appropriately according to the three node inequalities. When the node adjusting structure is added, the judgment can be carried out by using the first node inequality and the three node conditions. And when new nodes are added or existing nodes are removed subsequently, the structure of the whole network topology directly calculates the h value or the k value corresponding to the optimal tree according to the inequalities of the three nodes.
Further, in step S6), when there is a node addition or a node removal in the distributed system, the whole tree network topology is rearranged, which includes the following steps:
s61) adding nodes: assuming that the newly added node is P, when the central node receives a new broadcast packet, the central node judges whether P node information exists in the network topology recorded by the central node, and if the P node information exists, the tree network topology is not rearranged; if not, traversing to the deepest non-leaf node layer in the tree, wherein the deepest non-leaf node layer is the leftmost node of the h-1 th layer; sequentially acquiring the quantity of the sub-nodes of the deepest non-leaf node layer from left to right, finding out the non-leaf node with the fewest first sub-node, wherein the degree of the non-leaf node with the fewest first sub-node is smaller than that of the current tree, and inserting the newly added node P into the non-leaf node with the fewest first sub-node; if the sub-node quantity of all the nodes of the deepest non-leaf node layer is consistent, judging whether the node degree of the deepest non-leaf node layer is consistent with the tree degree, and if not, inserting a newly added node P into the left-leaf sub-node position of the first node of the deepest non-leaf node layer; if the node inequalities are consistent, recalculating the topological structure of the optimal tree according to the three node inequalities;
s62) node removal: assuming that a deleting node is Q, a father node of the deleting node Q is F, when a certain non-central node does not send a heartbeat packet to the central node for a long time, the central node considers that the non-central node which does not send the heartbeat packet to the central node for a long time is disconnected and can not communicate any more, the central node searches the position of the deleting node Q in a network topology, and if the deleting node Q is a leaf node at the bottom layer, the deleting node Q is directly removed without adjusting all other original subtrees; and if the deleting node Q is a non-leaf node, judging the overall structure of the tree network topology and the condition of deleting the sub-tree under the node Q.
Further, in step S62), the determining the overall structure of the tree network topology and the deleting of the sub-tree under the node Q includes the following steps:
s621) the delete node Q has only one left child node: if the tree network topology meets one of the three node conditions, removing the deleted node Q, and then directly connecting the child node of the deleted node Q with the father node F;
s622) the deletion node Q has a plurality of child nodes: and if the tree network topology meets one of the three node conditions, directly replacing the last inserted node of the tree to the position of the deleted node Q and connecting with the father node F.
When the Q node only has one left child node, if one of the three node conditions is still met at the moment, the Q node is deleted, and then the child node of the Q node is directly connected to the position where the original Q node is connected with the parent node F (the father node F). When the Q node has a plurality of child nodes, if one of the three node conditions is still met at the moment, the last inserted node in the tree is directly replaced to the deleted node and is connected to the place where the original Q node is connected with the parent node F, and the fact that when part of nodes in the tree are deleted, the topological structure cannot be greatly influenced and changed is guaranteed.
The invention has the beneficial effects that: the invention is different from the method for communicating by only adopting a single central network model in the prior art, adopts a special tree network topology to reduce the data transmission time, fully utilizes the resources of other nodes in the cluster and reduces the processing time and pressure of the central node. The tree structure is different from the common balanced tree or B tree in the construction mode, the tree needs the similar relation between the depth of the balanced tree and the tree degree during creation, and a special node adding strategy is adopted during construction, so that the data transmission time is not too long and the intermediate state is not too much due to the fact that a key path is not generated during data transmission. The invention adopts different transmission modes aiming at different data transmission, if a central node is required to send a large amount of data to all other nodes, the efficiency is improved by adopting a tree mode, and when the data is returned to the central node or a reverse heartbeat packet is reported to the central node, the efficiency is higher by adopting a mode of directly sending the data to the central node by adopting a central structure. The central node in the invention needs to control, change and record the current structure state of the whole cluster network and synchronize to other nodes. Each node only needs to search and record the information of the father node and the son node of the node, so that the data transmitted from the father node is ensured to be synchronized to the son node after the data is processed by the node, the information of other nodes is not required to be recorded, and the complexity of interaction between the nodes is reduced.
Drawings
In order to more clearly illustrate the technical solutions of the embodiments of the present invention, the drawings used in the embodiments are briefly described below, and it is obvious that the drawings in the following description are some embodiments of the present invention, and it is obvious for those skilled in the art to obtain other drawings without creative efforts.
Fig. 1 is a schematic flow chart of a method for building a network communication model based on a distributed system according to a first embodiment of the present invention.
Fig. 2 is a tree network topology structure diagram formed by 5 nodes provided in the first embodiment.
Fig. 3 is a tree network topology structure diagram formed by 20 nodes provided in the first embodiment.
Fig. 4 is a schematic diagram of transmission order and usage time of the tree network topology during data transmission according to the first embodiment.
Detailed Description
In order to make the objects, technical solutions and advantages of the present invention more apparent, the present invention is further described in detail below with reference to the accompanying drawings. It should be understood that the detailed description and specific examples, while indicating the invention, are intended for purposes of illustration only and are not intended to limit the scope of the invention. It is noted that the terms "comprises" and "comprising," and any variations thereof, in the description and claims of the present invention and the above-described drawings are intended to cover a non-exclusive inclusion, such that a process, method, system, article, or apparatus that comprises a list of elements is not necessarily limited to those elements, but may include other elements not expressly listed or inherent to such process, method, article, or apparatus.
In a first embodiment, a method for constructing a network communication model based on a distributed system, as shown in fig. 1, includes the following steps:
s1) networking each node in the distributed system; in step S1), networking each node in the distributed system, including the following steps:
s11) carrying out role distribution on each node in the distributed system, wherein the roles comprise a central node and a non-central node, and meanwhile, the central node can be used as the non-central node to communicate with the node per se;
s12) monitoring a corresponding data port after the central node is started, discovering the central node in a broadcast mode after a non-central node is started, and sending a broadcast packet to the central node;
s13) after receiving the broadcast packet of the non-central node, the central node records the current non-central node information, wherein the current non-central node information includes but is not limited to the IP address of the non-central node, the hardware information of the non-central node and the configuration information of the non-central node; the central node returns a unicast packet to the non-central node, the unicast packet includes but is not limited to the IP address of the central node, the hardware information of the central node and the configuration information of the central node, and the unicast packet is used for storing and recording the information of the central node by the non-central node; and finally, the central node records all the non-central node address information in the distributed system, and each non-central node records the central node address information in the distributed system.
S2) the central node creates network topology according to the receiving sequence of the broadcast packets sent by each non-central node; according to the definition of the balanced tree, and through the relation among the number of the nodes of the tree, the degree and the depth, the optimal tree type network topology is established, and the method comprises the following steps:
s21) root node creation: taking the central node as a root node, taking the layer where the root node is located as a 0 th layer, and setting the height of the tree as 0; when the distributed system starts each node to send the broadcast packet, the central node also sends the broadcast packet; when the central node receives the broadcast packet, if the central node finds that the source address of the broadcast packet is a local address, the central node is established as a root node for recording, and other broadcast packets are discarded under the condition that the root node is not established;
s22) layer 1 child node creation: taking a node corresponding to the next packet of broadcast packet received by the central node as a first left node in the tree network topology, taking a node corresponding to the next packet of broadcast packet received by the central node as a first right node in the tree network topology, and if the central node receives repeated broadcast packets, ignoring the repeated broadcast packets;
s23) other layer child node creation: and the other layers of child nodes sequentially establish a left node and a right node according to the step S22), and when the ith layer of child node is inserted, the ith layer of child node needs to be inserted into the parent node with the least leaf child nodes in the i-1 layer, h is more than or equal to i and more than or equal to 1, and h is the maximum layer number of the current tree.
When inserting the child nodes of the 2 nd layer and the later, the node needs to be inserted into the parent node with the least leaf child nodes in the h-1 layer, that is, the right child node position of the corresponding parent node cannot be sequentially searched from left to right according to the insertion rule of the common balanced binary tree, and the node needs to be inserted into the left child node position corresponding to the parent node with the least leaf nodes.
S3), establishing a first node inequality, setting three node conditions according to the first node inequality, initially constructing by a central node to complete a tree network topology, wherein the node distribution of the initially constructed tree network topology meets the first node inequality, and the optimal tree network topology not only needs to meet the first node inequality, but also needs to meet one of the three node conditions.
In step S3), the first node inequality is
Figure BDA0003104313790000101
k is the degree of the tree, h is the maximum layer number of the current tree, N is the total number of nodes of the tree, and m is the node adjustment sequence number; the three node conditions are k ═ h, k +1 ═ h and k ═ h +1, respectively; three node inequalities corresponding to the three node conditions are respectively
Figure BDA0003104313790000102
And
Figure BDA0003104313790000103
Figure BDA0003104313790000104
and when a node is added to adjust the structure of the tree network topology, judging by using the first node inequality and the three node conditions, and when new nodes are added or existing nodes are removed in the subsequent steps, directly calculating the h value or the k value corresponding to the optimal tree by using the structure of the whole tree network topology according to the three node inequalities.
And in a certain time, the central node can initially construct and complete the tree network topology. The distribution of the nodes of the network tree structure needs to meet the first node inequality, and in addition, in order to ensure the highest efficiency, the structure of the tree needs to be ensured to meet the conditions of three nodes. Since the maximum time for each node of the whole system to complete data synchronization is the completion time of the rightmost node in the whole balanced tree structure, the time is related to the system condition and is uncontrollable. Therefore, as the number of nodes of the tree type is gradually increased, that is, as N is increased, if k is too large and h is too small, each node needs to traverse too much child node information when sending data; if h is too large and k is too small, the number of transfer times in the data sent by each node is too large, so that the overall completion time is too long. So when N increases, the value of h or k needs to be adjusted appropriately according to the three node inequalities. When the node adjusting structure is added, the judgment can be carried out by using the first node inequality and the three node conditions. And when new nodes are added or existing nodes are removed subsequently, the structure of the whole network topology directly calculates the h value or the k value corresponding to the optimal tree according to the inequalities of the three nodes.
S4), after the distributed system is started, the central node issues the optimal tree network topology to each non-central node for recording, each non-central node records a father node and a child node corresponding to the node, and simultaneously each non-central node also records central node information.
In step S4), the topology delivery is mainly performed: after the distributed system is started for a preset time, the central node issues the network topology to each non-central node for recording, each non-central node focuses on the position of the non-central node in the tree, namely the father node and the son node corresponding to the node, and meanwhile, the relevant information of the central node is recorded according to the previous process. In addition, each non-central node does not need to record other joint-free point information. Heartbeat keep-alive is mainly performed in step S5): in order to enable the central node to record the operation state of each non-central node, each non-central node can keep alive by sending a heartbeat packet. Because the data volume of the heartbeat data packet is small, the data sending frequency is low, the mode of the central network model is adopted at the moment, namely, the operation is carried out in a mode that each non-central node sends a small amount of data to the central node periodically, meanwhile, in order to ensure the synchronization of network topology information, the central node also needs to return a reverse heartbeat packet to each non-central node, and the reverse heartbeat packet carries the latest network topology information recorded by the central node. In step S7), when large data needs to be sent to all nodes but is sent from the root node, the data of the root node is sent only to the corresponding child nodes. And the child nodes obtain the data, then send the data to the child nodes of the child nodes and process the data of the child nodes. So that the time for sending the whole data to all nodes is greatly reduced.
S5) in order to enable the central node to record the running state of each non-central node, each non-central node adopts a mode of a central network model and keeps alive by sending heartbeat packets, and simultaneously in order to ensure the synchronization of network topology information, the central node returns a reverse heartbeat packet to each non-central node, wherein the reverse heartbeat packet carries the latest network topology information recorded by the central node;
s6) when a node is newly added or removed in the distributed system, rearranging the whole tree network topology;
s7) when large data need to be sent to all nodes, sending the data from the root node, wherein the data of the root node is only sent to the child nodes corresponding to the root node; and the child nodes receive the data, send the data to the child nodes of the children nodes and process the data of the children nodes.
In step S6), when a node is added or removed from the distributed system, the whole tree network topology is rearranged, including the following steps:
s61) adding nodes: assuming that the newly added node is P, when the central node receives a new broadcast packet, the central node judges whether P node information exists in the network topology recorded by the central node, and if the P node information exists, the tree network topology is not rearranged; if not, traversing to the deepest non-leaf node layer in the tree, wherein the deepest non-leaf node layer is the leftmost node of the h-1 th layer; sequentially acquiring the quantity of the sub-nodes of the deepest non-leaf node layer from left to right, finding out the non-leaf node with the fewest first sub-node, wherein the degree of the non-leaf node with the fewest first sub-node is smaller than that of the current tree, and inserting the newly added node P into the non-leaf node with the fewest first sub-node; if the sub-node quantity of all the nodes of the deepest non-leaf node layer is consistent, judging whether the node degree of the deepest non-leaf node layer is consistent with the tree degree, and if not, inserting a newly added node P into the left-leaf sub-node position of the first node of the deepest non-leaf node layer; if the node inequalities are consistent, recalculating the topological structure of the optimal tree according to the three node inequalities;
s62) node removal: assuming that a deleting node is Q, a father node of the deleting node Q is F, when a certain non-central node does not send a heartbeat packet to the central node for a long time, the central node considers that the non-central node which does not send the heartbeat packet to the central node for a long time is disconnected and can not communicate any more, the central node searches the position of the deleting node Q in a network topology, and if the deleting node Q is a leaf node at the bottom layer, the deleting node Q is directly removed without adjusting all other original subtrees; and if the deleting node Q is a non-leaf node, judging the overall structure of the tree network topology and the condition of deleting the sub-tree under the node Q.
Step S62), the method for determining the entire structure of the tree network topology and the deletion of the subtree at node Q includes the steps of:
s621) the delete node Q has only one left child node: if the tree network topology meets one of the three node conditions, removing the deleted node Q, and then directly connecting the child node of the deleted node Q with the father node F;
s622) the deletion node Q has a plurality of child nodes: and if the tree network topology meets one of the three node conditions, directly replacing the last inserted node of the tree to the position of the deleted node Q and connecting with the father node F.
When the Q node only has one left child node, if one of the three node conditions is still met at the moment, the Q node is deleted, and then the child node of the Q node is directly connected to the position where the original Q node is connected with the parent node F (the father node F). When the Q node has a plurality of child nodes, if one of the three node conditions is still met at the moment, the last inserted node in the tree is directly replaced to the deleted node and is connected to the place where the original Q node is connected with the parent node F, and the fact that when part of nodes in the tree are deleted, the topological structure cannot be greatly influenced and changed is guaranteed.
In the embodiment, data transmission processing by multiple threads is not considered, all file transmission and data synchronization are processed in a single-thread mode, that is, a certain node can only perform complete communication with another node once every time, so that advantages of a polling transmission mode are easily compared.
In this embodiment, when node information synchronization is performed, it is assumed that 20 nodes are included in the current cluster, and the numbers are 1 to 20, where the node 1 is a central node; after receiving the broadcast packet of the non-central node, the central node records the current information of the non-central node, including but not limited to: node IP address, node hardware information, node configuration information, etc.
Constructing a tree network topology, wherein the specific process comprises the following steps:
(2a) when the system starts each node to send the broadcast data packet, the central node also sends the broadcast data. When the central node receives the broadcast packet, if the source address of the broadcast packet is found to be the local address, the broadcast packet is created as the root node to record, and other broadcast packets can be discarded under the condition that the root node is not created.
(2b) At this time, when the root node receives the broadcast packet of the node No. 2, whether the tree network topology stored by the root node comprises the node No. 2 is judged, if yes, the broadcast packet of the node No. 2 is ignored, and a confirmation packet is returned, so that the newly added node does not need to send the broadcast packet again in the follow-up process, and the newly added node sends the heartbeat packet to keep alive. If not, the node 2 is inserted into the left leaf child node position of the root node.
(2c) And (3) inserting the node 3 into the right leaf node of the root node when the broadcast packet of the node 3 is received, similarly to the step (2 b).
(2d) When the 5 th node is added, the node needs to be inserted into the parent node with the least leaf child nodes in the h-1 layer, namely the node can not be inserted into the right child node position of the node No. 2 in the insertion order of the common binary tree any more, and needs to be inserted into the left child node position of the node No. 3 (see FIG. 2). Meanwhile, the tree degree and the tree depth (i.e. the maximum number of layers of the current tree) are both 2 at present, and still meet the node inequality requirement (meet the node condition k ═ h).
(2e) When the 8 th node is added, the maximum number of layers h of the tree is 3, at this time, since
Figure BDA0003104313790000141
Figure BDA0003104313790000142
The first node inequality is satisfied, and the node condition h is satisfied as k +1, so that the tree-type overall structure may not be changed at this time. (in this embodiment, the maximum number of tree layers h may be adjusted to h-1, that is, the maximum number of tree layers h is adjusted to 2, the tree degree may be adjusted to k +1, that is, the tree degree may be adjusted to 3, and in this case, the maximum number of tree layers h may be adjusted to k +1
Figure BDA0003104313790000151
The first node inequality is also satisfied, and the node condition k ═ h +1 is satisfied. )
(2f) In the same step (2d), when the 9 th node is inserted, the parent node with the least child nodes in the h-1 th layer of the current tree also needs to be found, that is, the parent node is inserted into the position of the left leaf child node of the node No. 6.
(2g) When the 16 th node is inserted, if the structure of the tree has not been adjusted before, i.e. the degree k of the tree is still 2, and the maximum number of layers h of the tree becomes 4, since any one of k ═ h, k ═ h +1, and h ═ k +1 has not been satisfied, then it is necessary to select an appropriate value of k, i.e. satisfy:
Figure BDA0003104313790000152
and k ═ h. In this case, h-4 is sequentially reduced and substituted into the first node inequality, and when h-3, it is satisfied that k-h-3. The creation of a new tree-type network topology is performed again according to the degree of 3 while synchronizing to each of the other nodes.
(2h) The tree topology composed of the final 20 nodes has the effect as shown in fig. 3. At this time, if there is data to be transferred and the time required for data transfer between nodes is assumed to be t, the order of transfer and the time used are as shown in fig. 4, i.e. a total of 6t of time is required to complete data transfer without considering multithreading. However, if the transmission is performed in a polling manner, a total time of 20t is required to complete the transmission and synchronization of all data. The invention makes full use of the resources of other nodes, and the whole network structure is convenient to maintain.
By adopting the technical scheme disclosed by the invention, the following beneficial effects are obtained:
the invention is different from the method for communicating by only adopting a single central network model in the prior art, adopts a special tree network topology to reduce the data transmission time, fully utilizes the resources of other nodes in the cluster and reduces the processing time and pressure of the central node. The tree structure is different from the common balanced tree or B tree in the construction mode, the tree needs the similar relation between the depth of the balanced tree and the tree degree during creation, and a special node adding strategy is adopted during construction, so that the data transmission time is not too long and the intermediate state is not too much due to the fact that a key path is not generated during data transmission. The invention adopts different transmission modes aiming at different data transmission, if a central node is required to send a large amount of data to all other nodes, the efficiency is improved by adopting a tree mode, and when the data is returned to the central node or a reverse heartbeat packet is reported to the central node, the efficiency is higher by adopting a mode of directly sending the data to the central node by adopting a central structure. The central node in the invention needs to control, change and record the current structure state of the whole cluster network and synchronize to other nodes. Each node only needs to search and record the information of the father node and the son node of the node, so that the data transmitted from the father node is ensured to be synchronized to the son node after the data is processed by the node, the information of other nodes is not required to be recorded, and the complexity of interaction between the nodes is reduced.
The foregoing is only a preferred embodiment of the present invention, and it should be noted that it will be apparent to those skilled in the art that various modifications and improvements can be made without departing from the principle of the present invention, and such modifications and improvements should also be considered within the scope of the present invention.

Claims (6)

1. A network communication model building method based on a distributed system is characterized by comprising the following steps:
s1) networking each node in the distributed system;
s2) the central node creates network topology according to the receiving sequence of the broadcast packet sent by each non-central node, and creates optimal tree network topology according to the relation among the number, degree and depth of the nodes of the tree;
s3), establishing a first node inequality, setting three node conditions according to the first node inequality, and initially constructing and completing a tree network topology by a central node, wherein the node distribution of the initially constructed tree network topology meets the first node inequality, and the optimal tree network topology not only meets the first node inequality, but also meets one of the three node conditions;
s4), after the distributed system is started, the central node issues the optimal tree network topology to each non-central node for recording, each non-central node records a father node and a child node corresponding to the node, and simultaneously each non-central node also records central node information;
s5) in order to enable the central node to record the running state of each non-central node, each non-central node adopts a mode of a central network model and keeps alive by sending heartbeat packets, and simultaneously in order to ensure the synchronization of network topology information, the central node returns a reverse heartbeat packet to each non-central node, wherein the reverse heartbeat packet carries the latest network topology information recorded by the central node;
s6) when a node is newly added or removed in the distributed system, rearranging the whole tree network topology;
s7), when the data needs to be sent to all nodes, the data is sent from the root node, and the data of the root node is only sent to the child nodes corresponding to the root node; and the child nodes receive the data, send the data to the child nodes of the children nodes and process the data of the children nodes.
2. The method for building a network communication model based on a distributed system according to claim 1, wherein in step S1), networking each node in the distributed system includes the following steps:
s11) carrying out role distribution on each node in the distributed system, wherein the roles comprise a central node and a non-central node, and the central node can be used as the non-central node to communicate with the node per se;
s12) monitoring a corresponding data port after the central node is started, discovering the central node in a broadcast mode after a non-central node is started, and sending a broadcast packet to the central node;
s13) after receiving the broadcast packet of the non-central node, the central node records the current non-central node information, wherein the current non-central node information includes but is not limited to the IP address of the non-central node, the hardware information of the non-central node and the configuration information of the non-central node; the method comprises the steps that a central node returns a unicast packet to a non-central node, wherein the unicast packet comprises but is not limited to a central node IP address, central node hardware information and central node configuration information, and the unicast packet is used for storing and recording the central node information by the non-central node; and finally, the central node records all the non-central node address information in the distributed system, and each non-central node records the central node address information in the distributed system.
3. The method for constructing a network communication model based on a distributed system according to claim 2, wherein in step S2), the central node performs network topology creation according to the receiving order of the broadcast packets sent by each non-central node, and creates an optimal tree-type network topology by the relationship among the number of nodes, the degree and the depth of the tree, comprising the steps of:
s21) root node creation: taking the central node as a root node, taking the layer where the root node is located as a 0 th layer, and setting the height of the tree as 0; when the distributed system starts each node to send the broadcast packet, the central node also sends the broadcast packet; when the central node receives the broadcast packet, if the central node finds that the source address of the broadcast packet is a local address, the central node is established as a root node for recording, and other broadcast packets are discarded under the condition that the root node is not established;
s22) layer 1 child node creation: taking a node corresponding to the next packet of broadcast packet received by the central node as a first left node in the tree network topology, taking a node corresponding to the next packet of broadcast packet received by the central node as a first right node in the tree network topology, and if the central node receives repeated broadcast packets, ignoring the repeated broadcast packets;
s23) other layer child node creation: and the other layers of child nodes sequentially establish a left node and a right node according to the step S22), and when the ith layer of child node is inserted, the ith layer of child node needs to be inserted into the parent node with the least leaf child nodes in the i-1 layer, h is more than or equal to i and more than or equal to 1, and h is the maximum layer number of the current tree.
4. The distributed system-based network communication model building method according to claim 1 or 3, wherein in step S3), the first node inequality is
Figure FDA0003104313780000031
k is the tree degree, h is the maximum layer number of the current tree, and N is the total node number of the tree; the three node conditions are k ═ h, k +1 ═ h and k ═ h +1, respectively; three node inequalities corresponding to the three node conditions are respectively
Figure FDA0003104313780000032
And
Figure FDA0003104313780000033
Figure FDA0003104313780000034
and when a node is added to adjust the structure of the tree network topology, judging by using the first node inequality and the three node conditions, and when new nodes are added or existing nodes are removed in the subsequent steps, directly calculating the h value or the k value corresponding to the optimal tree by using the structure of the whole tree network topology according to the three node inequalities.
5. The method for constructing a network communication model based on a distributed system according to claim 4, wherein in step S6), when a node is added or removed in the distributed system, the whole tree network topology is rearranged, comprising the following steps:
s61) adding nodes: assuming that the newly added node is P, when the central node receives a new broadcast packet, the central node judges whether P node information exists in the network topology recorded by the central node, and if the P node information exists, the tree network topology is not rearranged; if not, traversing to the deepest non-leaf node layer in the tree, wherein the deepest non-leaf node layer is the leftmost node of the h-1 th layer; sequentially acquiring the number of child nodes of the deepest non-leaf node layer from left to right, finding out the non-leaf node with the least first child node, wherein the degree of the non-leaf node with the least first child node is smaller than that of the current tree, and inserting a newly added node P into the non-leaf node with the least first child node; if the sub-node numbers of all the nodes of the deepest non-leaf node layer are consistent, judging whether the node degrees of the deepest non-leaf node layer are consistent with the tree degrees or not, and if not, inserting a newly added node P into the left-leaf sub-node position of the first node of the deepest non-leaf node layer; if the three node inequalities are consistent, recalculating the topological structure of the optimal tree according to the three node inequalities;
s62) node removal: assuming that a deleting node is Q, a father node of the deleting node Q is F, when a certain non-central node does not send a heartbeat packet to the central node for a long time, the central node considers that the non-central node which does not send the heartbeat packet to the central node for a long time is disconnected and can not communicate any more, the central node searches the position of the deleting node Q in a network topology, and if the deleting node Q is a leaf node at the bottom layer, the deleting node Q is directly removed without adjusting all other original subtrees; and if the deleted node Q is a non-leaf node, judging the overall structure of the tree network topology and the condition of deleting the sub-tree under the node Q.
6. The method for constructing a network communication model based on a distributed system according to claim 5, wherein in step S62), the steps of determining the whole structure of the tree network topology and deleting the sub-tree under the node Q comprise:
s621) the deletion node Q has only one left child node: if the tree network topology meets one of the three node conditions, removing the deleted node Q, and then directly connecting the child node of the deleted node Q with the father node F;
s622) the deletion node Q has a plurality of child nodes: and if the tree network topology meets one of the three node conditions, directly replacing the last inserted node of the tree to the position of the deleted node Q and connecting the deleted node Q with the father node F.
CN202110632800.5A 2021-06-07 2021-06-07 Network communication model construction method based on distributed system Active CN113328890B (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN202110632800.5A CN113328890B (en) 2021-06-07 2021-06-07 Network communication model construction method based on distributed system

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN202110632800.5A CN113328890B (en) 2021-06-07 2021-06-07 Network communication model construction method based on distributed system

Publications (2)

Publication Number Publication Date
CN113328890A true CN113328890A (en) 2021-08-31
CN113328890B CN113328890B (en) 2021-11-23

Family

ID=77419889

Family Applications (1)

Application Number Title Priority Date Filing Date
CN202110632800.5A Active CN113328890B (en) 2021-06-07 2021-06-07 Network communication model construction method based on distributed system

Country Status (1)

Country Link
CN (1) CN113328890B (en)

Cited By (1)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN115242812A (en) * 2022-07-25 2022-10-25 济南浪潮数据技术有限公司 Node data synchronization method and device and computer readable storage medium

Citations (8)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US6839541B2 (en) * 2001-12-04 2005-01-04 Illinois Institute Of Technology Technique for establishing a virtual backbone in an ad hoc wireless network
CN1998198A (en) * 2004-07-13 2007-07-11 兄弟工业株式会社 Distribution apparatus, receiving apparatus tree-type distribution system, and information processing method etc.
CN102137405A (en) * 2010-06-01 2011-07-27 华为技术有限公司 Method and device for constructing network topology
CN103974310A (en) * 2014-05-08 2014-08-06 江苏物联网研究发展中心 Method, device and system for establishing tree topology of wireless communication multi-hop network device
CN107579915A (en) * 2017-09-28 2018-01-12 北京千丁互联科技有限公司 Ad hoc network method, node, gateway and communication system based on tree network
US10015075B1 (en) * 2017-03-09 2018-07-03 Cisco Technology, Inc. Directed acyclic graph optimization for future time instance advertised by a parent network device
CN111314023A (en) * 2020-02-18 2020-06-19 中国电子科技集团公司第五十四研究所 Synchronization method of tree network topology information
CN111464450A (en) * 2020-03-27 2020-07-28 杭州海康威视数字技术股份有限公司 Method and device for generating network topology structure

Patent Citations (8)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US6839541B2 (en) * 2001-12-04 2005-01-04 Illinois Institute Of Technology Technique for establishing a virtual backbone in an ad hoc wireless network
CN1998198A (en) * 2004-07-13 2007-07-11 兄弟工业株式会社 Distribution apparatus, receiving apparatus tree-type distribution system, and information processing method etc.
CN102137405A (en) * 2010-06-01 2011-07-27 华为技术有限公司 Method and device for constructing network topology
CN103974310A (en) * 2014-05-08 2014-08-06 江苏物联网研究发展中心 Method, device and system for establishing tree topology of wireless communication multi-hop network device
US10015075B1 (en) * 2017-03-09 2018-07-03 Cisco Technology, Inc. Directed acyclic graph optimization for future time instance advertised by a parent network device
CN107579915A (en) * 2017-09-28 2018-01-12 北京千丁互联科技有限公司 Ad hoc network method, node, gateway and communication system based on tree network
CN111314023A (en) * 2020-02-18 2020-06-19 中国电子科技集团公司第五十四研究所 Synchronization method of tree network topology information
CN111464450A (en) * 2020-03-27 2020-07-28 杭州海康威视数字技术股份有限公司 Method and device for generating network topology structure

Cited By (1)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN115242812A (en) * 2022-07-25 2022-10-25 济南浪潮数据技术有限公司 Node data synchronization method and device and computer readable storage medium

Also Published As

Publication number Publication date
CN113328890B (en) 2021-11-23

Similar Documents

Publication Publication Date Title
US10348827B2 (en) Distributed storage system, cluster node and range management method thereof
US10212227B1 (en) Systems and methods for synchronizing data between communication devices in a networked environment
KR101120847B1 (en) Data overlay, self-organized metadata overlay, and application level multicasting
KR101752928B1 (en) Swarm-based synchronization over a network of object stores
US20100027442A1 (en) Constructing scalable overlays for pub-sub with many topics: the greedy join-leave algorithm
US11265182B2 (en) Messaging to enforce operation serialization for consistency of a distributed data structure
CA3131954C (en) Information synchronization method, system, apparatus, computer device and storage medium
US20200412795A1 (en) Merge trees for collaboration
CN113722127A (en) Efficient lightweight easy-to-use distributed network message middleware
CN113328890B (en) Network communication model construction method based on distributed system
CN112860799A (en) Management method for data synchronization of distributed database
CN102957546A (en) Method, device and system for processing configuration
CN105207825B (en) A kind of network element Fast synchronization system and network element fast synchronization method
CN102624932A (en) Index-based remote cloud data synchronizing method
CN111800516B (en) Internet of things equipment management method and device based on P2P
CN107908713A (en) A kind of distributed dynamic cuckoo filtration system and its filter method based on Redis clusters
CN1182680C (en) Pacing synchronizing method for rout selecting information in data exchange environmemt
CN102647424B (en) Data transmission method and data transmission device
Huang et al. PeerCluster: a cluster-based peer-to-peer system
CN112751789A (en) Method and system for realizing asymmetric SDN controller cluster
Mandal et al. Deterministic 1–2 skip list in distributed system
CN108111338B (en) A kind of data consistency system under the environment based on satellite network
CN114490691B (en) Distributed system data consistency method
Riley et al. Guaranteed broadcasting using SPON: Supervised P2P overlay network
CN111817894B (en) Cluster node configuration method and system and readable storage medium

Legal Events

Date Code Title Description
PB01 Publication
PB01 Publication
SE01 Entry into force of request for substantive examination
SE01 Entry into force of request for substantive examination
GR01 Patent grant
GR01 Patent grant