Summary of the invention
Goal of the invention: technical problem to be solved by this invention is for the deficiencies in the prior art, and a kind of mobile ad hoc network address configuration implementation method based on tree is provided.
Technical scheme: the invention discloses a kind of mobile ad hoc network address configuration implementation method based on tree, described implementation method is divided into a plurality of subnets by mobile self-grouping network, and subnet is by subnet ID unique identification, and subnet ID value generates at random by random function; A subnet consists of a plurality of nodes, direct communication or carry out indirect communication by intermediate node between node;
Each node is identified by a node ID, and the length of node ID is the i bit, has uniqueness in subnet, and the subnet ID of node place subnet and node ID form node address; The state of node comprises configuration status and not configuration status, and the configuration status dactylus is put configuration node address, and configuration status dactylus point does not have the configuration node address; The node ID configuration space of a subnet is [0,2
i-1], the i value is random natural number;
In subnet, all nodes are configured to tree, in a tree, each node comprises at most S child node, in tree, each node is preserved a sub-nodes records table, each records the corresponding child node of list item, each records list item and comprises child node value c and two territories of child node state, 1≤c≤S wherein, the child node state comprises unallocated state and distribution state; Child node value c and S value span are natural number;
The unallocated child node sum of configuration status node periodic broadcasting its place subnet ID and this node.
By tree, the configuration status node does not obtain the address with uniqueness by the node of configuration status in a jumping scope, without carrying out the address duplicate detection, has therefore reduced the address configuration cost, has shortened the address configuration time.Described tree can effectively reclaim the address resource that failure node discharges, and therefore the configuration status node has enough address spaces always and distributes to the node into configuration status, has improved the address configuration success rate.
In the method for the invention, after a node Y adds mobile ad hoc network, its initial condition is configuration node not, if node Y does not receive the broadcast of any node of configuration status in setting-up time, carries out following steps;
Step 301: start;
Step 302: described node Y broadcasts and sets up tree message in a jumping scope, and the message load is timestamp and the random subnet ID produced;
Step 303: judgement receives that whether the neighbor node of setting up tree message has father node, if having, carry out step 304, otherwise carry out step 305;
Step 304: abandon setting up tree message, carry out step 313;
Step 305: the priority of the foundation tree message received before whether the priority of neighbor node judging message is greater than and oneself send, if so, carry out step 306, otherwise carry out step 307;
Step 306: neighbor node is this message of broadcast in a jumping scope;
Step 307: after setting-up time, whether the priority of the foundation tree message of its transmission of neighbor node judging, for the highest, if so, carry out step 309, otherwise carry out step 308;
Step 308: the node of the foundation tree message that neighbor node is the highest using forwarding priority, as father node, carry out step 310;
Step 309: neighbor node is designated root node by oneself;
Step 310: at the appointed time, node Y judges whether to receive the message of the priority of the foundation tree message sent higher than oneself, if it is carry out step 311, otherwise carry out step 312;
Step 311: the node of the foundation tree message that node Y is the highest using forwarding priority, as father node, carry out step 313;
Step 312: node Y is designated root node by oneself;
Step 313: finish.
By said process, the configuration status node does not form tree, and obtains the address with uniqueness by the node of configuration status in a jumping scope, without carrying out the address duplicate detection, has therefore reduced the address configuration cost, has shortened the address configuration time.Described tree can effectively reclaim address resource, has improved the address configuration success rate.In said process, the transmission of message is controlled in a jumping scope, has reduced the address configuration cost, has shortened the address configuration delay, has strengthened extension of network.
In the method for the invention, if a timestamp of setting up tree message T is more Zao than the timestamp of another one foundation tree message T ', sets up the priority of tree message T and set message T ' higher than setting up;
If it is identical with the timestamp of setting up tree message T ' to set up the timestamp of tree message T, compare the subnet ID in message, be less than if set up the subnet ID of tree message T the subnet ID set up in tree message T ', set up the priority of tree message T higher than setting up tree message T ';
If it is identical with the timestamp and the subnet ID that set up tree message T ' with subnet ID to set up the timestamp of tree message T, the time of advent of relatively setting up tree message T and setting up tree message T ', be better than setting up tree message T ' if set up the time of advent of tree message T early than setting up tree message T ' or setting up the tree position of message T in waiting list, set up the priority of tree message T higher than setting up tree message T '.
By said process, can guarantee that in a subnet, all nodes are configured to a tree.
In the method for the invention, the node ID of root node oneself is set to 0, and in a jumping scope Broadcast Subnet ID and unallocated child node sum, start tree is carried out to initialization, the not configuration node in tree is by initialization procedure configuration node address:
Step 401: start;
Step 402: after configuration node is not received the broadcast of father node, judge in message, whether unallocated child node sum is not 0, if so, carry out step 403, otherwise carry out step 404;
Step 403: configuration node does not wait for that random time reselects father node and obtains address, carry out step 412;
Step 404: configuration node does not send address request to father node;
Step 405: after father node is received the message that configuration node does not send, check the child node record sheet, select record corresponding to minimum unassigned child node value, return to an address response message to configuration node not, the message load is the child node value c in corresponding record, this is recorded to the neutron node state simultaneously and is designated and distributes;
Step 406: after configuration node is not received response message, obtain the node ID of oneself according to formula y=Sx+c, wherein, the node ID that x is father node, node ID is combined to the node address that forms oneself with subnet ID, oneself is designated to configuration node simultaneously, and sets up the child node record sheet;
Step 407: configuration node judges that whether node ID corresponding to child node is greater than the address assignment space upper limit, if so, carry out step 408, otherwise carry out step 409;
Step 408: the distribution state of the corresponding child node of configuration node is set to unallocatedly, carry out step 410;
Step 409: the distribution state of the corresponding child node of configuration node is set to distribute;
Step 410: the unallocated child node sum of configuration node Broadcast Subnet ID and this node;
Step 411: after the child node of configuration node has been received broadcast, repeating step 402~step 410 is obtained address, until in tree, all nodes obtain node address;
Step 412: finish.
In said process, each the configuration status node have the right for other not the node of configuration status distribute address, the address configuration task is completed jointly by all nodes of configuration status, the node of configuration status does not obtain address by the node of configuration status in a jumping scope, and guarantees to distribute the uniqueness of address by formula y=Sx+c, without the address duplicate detection, reduced the address configuration cost, shorten the address configuration time, realized load balancing, improved address configuration efficiency.
In the method for the invention, wait for random time if newly add the not configuration node of mobile ad hoc network, receive the broadcast of a plurality of configuration nodes, select to supply to distribute the maximum configuration node of child node sum as father node, and obtain node address by following steps:
Step 501: start;
Step 502: configuration node does not send address request to father node;
Step 503: after father node is received the message that configuration node does not send, check the child node record sheet, select record corresponding to minimum unassigned child node value, return to an address response message to configuration node not, the message load is the child node value c in corresponding record, this is recorded to the neutron node state simultaneously and is designated distribution state;
Step 504: after configuration node is not received response message, obtain the node ID of oneself according to formula y=Sx+c, wherein, the node ID that x is father node, node ID is combined to the node address that forms oneself with subnet ID, oneself is designated to configuration node simultaneously, and sets up the child node record sheet;
Step 505: configuration node judges that whether node ID corresponding to child node is greater than the address assignment space upper limit, if so, carry out step 506, otherwise carry out step 507;
Step 506: the distribution state of the corresponding child node of configuration node is set to unallocatedly, carry out step 508;
Step 507: the distribution state of the corresponding child node of configuration node is set to distribute;
Step 508: the unallocated child node sum of configuration node Broadcast Subnet ID and this node;
Step 509: finish.
By said process, the configuration status node is not by adding tree to obtain address, and guarantees to distribute the uniqueness of address by formula y=Sx+c.Due to each the configuration status node have the right for other not the node of configuration status distribute the address with uniqueness, therefore, the address configuration task is completed jointly by all nodes of configuration status, the node of configuration status does not obtain the address with uniqueness by the node of configuration status in a jumping scope, without carrying out the address duplicate detection, reduced the address configuration cost, shortened the address configuration time, realize load balancing, improved address configuration efficiency.
In the method for the invention, after configuration node has obtained node ID, regularly to father node, send updating message and lay oneself open to normal condition to show, after father node is received the updating message of child node, reply the renewal response message to child node and lay oneself open to normal operating conditions to show;
In setting-up time, if father node is not received the updating message of child node, judge that child node lost efficacy or broken away from current subnet, and the state in child node record sheet corresponding to child node is set to unallocated state;
In setting-up time, if child node is not received the renewal response message of father node, judge that father node disappears or broken away from current subnet, will oneself be expressed as not configuration node, reselect father node and obtain node ID.
By said process, father node can reclaim the address that child node discharges effectively, guarantees to have enough address resources to distribute to other not configuration status nodes.Equally, child node is by judging whether father node guarantees correctness and the uniqueness of address in effective status.
In the method for the invention, after configuration node X has received the subnet ID of the broadcast of configuration node X ', carry out the subnet union operation in following two kinds of situations: 1) configuration node X is different from the subnet ID of configuration node X '; 2) configuration node X is identical with the address of configuration node X '.
In the method for the invention, node A in subnet M detects that subnet M needs and after subnet N carries out union operation, if in node A, unallocated child node sum is greater than 0, it carries out the subnet union operation, otherwise the father node of requesting node A is carried out the subnet union operation, and the father node of node A or node A is set as to configuration node Z; The union operation of configuration node Z place subnet M and subnet N comprises the steps:
Step 701: start;
Step 702: the tree root node R of configuration node Z-direction subnet N sends and merges message, the subnet ID that the message load is subnet M;
Step 703: after root node R receives and merges message, using configuration node Z as father node, and return to the merging response message to configuration node Z, root node R become merge after the node R of subnet M; If root node R receives a plurality of merging message, it only replys first merging message of receiving;
Step 704: after configuration node Z has received and merged response message, select record corresponding to minimum unassigned child node value, and return to an address response message to node R, the message load in record child node value c, by the status indicator of this record, be distribution state simultaneously;
Step 705: after node R is received address response message, according to formula y=Sx+c, get new node ID, wherein, x is the node ID of configuration node Z, and by the subnet ID of the subnet M calculated address that combines with node ID;
Step 706: whether the child node status field that node R judges the child node list entry is distribution state, if so, carry out step 707, otherwise carry out step 710;
Step 707: node R sends an address updating message to corresponding child node, and the message load is new node ID and the subnet ID of subnet M;
Step 708: after child node is received the address updating message, obtain new node ID according to formula y=Sx+c, wherein, x is the node ID that father node is new, c is the original child node value that father node distributes, then new node ID is combined to calculated address with the subnet ID of subnet M, sends an address updating message to the child node of distribution state simultaneously, the message load is new node ID and the subnet ID of subnet M;
Step 709: after child node is received the address updating message, repeating step 708, until in subnet N, the node ID of all nodes is all upgraded;
Step 710: subnet M and subnet N merge successfully, the subnet ID that the subnet ID after merging is subnet M;
Step 711: finish.
By above-mentioned union operation, in the subnet after can guaranteeing to merge, the uniqueness of node address, realized the correctness of communication and the correctness of route.
In the method for the invention, if one configuration node do not receive the subnet ID of any neighbor node broadcast or the subnet ID that receives when all different from own current subnet ID in setting-up time, it is designated not configuration node by again;
If configuration node is not received the network ID of any broadcast of configuration node in setting-up time, it starts to set up tree, and again obtains address by tree;
If configuration node is not received the network ID of configuration node broadcast in setting-up time, it adds this subnet place tree, and again obtains address by tree.
By said process, configuration node can not obtain the address with uniqueness.
In the method for the invention, the node A in subnet M receives the packet that Node B in subnet N sends and the address that node A detected is identical with the address of Node B; Now, the unicast path of the merging message that node A sends completes by the tree at Node B place, merge message and at first arrive Node B, then will merge message by Node B and send to its father node, father node will merge message again and be transmitted to its father node, until merge the root node that message finally arrives Node B place tree.
Said process has been realized the correctness of communication and the correctness of route.
Beneficial effect: the invention provides a kind of address of mobile ad hoc network implementation method of configuration automatically, for example, due to mobile ad hoc network and conventional network structure (the Internet) difference, for example: nodes in MANET has main frame and two identity of router simultaneously, address configuration scheme in therefore current legacy network can't be implemented in mobile self-grouping network, the address configuration scheme of using in the urgent need to a kind of applicable mobile self-grouping network.In the present invention, each nodes in MANET can be distributed address for other node, can guarantee the uniqueness of address without the address duplicate detection simultaneously, and this is that prior art can't realize.The implementation method that each node in described mobile self-grouping network configures automatically by address provided by the present invention, can have the address with uniqueness, realizes each other communication.The present invention can be applicable to the numerous areas such as traffic prosecution and agriculture project, is with a wide range of applications.
Embodiment:
The invention provides a kind of address of mobile ad hoc network implementation method of configuration automatically, in described method, each node in mobile self-grouping network can obtain the address with uniqueness, between node, by address, realizes communication each other.
Fig. 1 is mobile self-grouping network topological structure schematic diagram of the present invention.Described mobile self-grouping network 1 is divided into a plurality of subnets 2, and subnet 2 is by subnet ID unique identification, and subnet ID value generates at random by random function; A subnet consists of a plurality of nodes 3, direct communication or carry out indirect communication by intermediate node between node 3; The interior all nodes 3 of subnet 2 are configured to tree 4; Each node 3 is identified by a node ID, and the length of node ID is the i bit, in subnet 2, has uniqueness; The state of node comprises configuration status and not configuration status, and the configuration status dactylus is put configuration node address, and configuration status dactylus point does not have the configuration node address; The node ID configuration space of a subnet is [0,2
i-1], the i value is random natural number; The unallocated child node sum of configuration status node periodic broadcasting its place subnet ID and this node.
Fig. 2 is node address structural representation of the present invention.Node address is comprised of subnet ID and the node ID of place subnet, subnet of subnet ID unique identification, and subnet ID value generates at random by random function; Node of a node ID unique identification has uniqueness in subnet, and the length of node ID is the i bit, and the node ID configuration space of a subnet is [0,2
i-1], the i value is random natural number.
Fig. 3 is that child node of the present invention records the list item structural representation.In a tree, each node comprises at most S child node, in tree, each node is preserved a sub-nodes records table, each records the corresponding child node of list item, each records list item and comprises child node value c and two territories of child node state, 1≤c≤S wherein, the child node state comprises unallocated state and distribution state; Child node value c and S value span are natural number.
Fig. 4 is tree Establishing process schematic diagram of the present invention.After a node Y adds mobile ad hoc network, its initial condition is configuration node not, if node Y does not receive the broadcast of any node of configuration status in setting-up time, carries out following steps;
Step 301: start;
Step 302: described node Y broadcasts and sets up tree message in a jumping scope, and the message load is timestamp and the random subnet ID produced;
Step 303: judgement receives that whether the neighbor node of setting up tree message has father node, if having, carry out step 304, otherwise carry out step 305;
Step 304: abandon setting up tree message, carry out step 313;
Step 305: the priority of the foundation tree message received before whether the priority of neighbor node judging message is greater than and oneself send, if so, carry out step 306, otherwise carry out step 307;
Step 306: neighbor node is this message of broadcast in a jumping scope;
Step 307: after setting-up time, whether the priority of the foundation tree message of its transmission of neighbor node judging, for the highest, if so, carry out step 309, otherwise carry out step 308;
Step 308: the node of the foundation tree message that neighbor node is the highest using forwarding priority, as father node, carry out step 310;
Step 309: neighbor node is designated root node by oneself;
Step 310: at the appointed time, node Y judges whether to receive the message of the priority of the foundation tree message sent higher than oneself, if it is carry out step 311, otherwise carry out step 312;
Step 311: the node of the foundation tree message that node Y is the highest using forwarding priority, as father node, carry out step 313;
Step 312: node Y is designated root node by oneself;
Step 313: finish.
Fig. 5 is tree initialization schematic flow sheet of the present invention.The node ID of root node oneself is set to 0, and in a jumping scope Broadcast Subnet ID and unallocated child node sum, start tree is carried out to initialization, the not configuration node in tree is by initialization procedure configuration node address::
Step 401: start;
Step 402: after configuration node is not received the broadcast of father node, judge in message, whether unallocated child node sum is not 0, if so, carry out step 403, otherwise carry out step 404;
Step 403: configuration node does not wait for that random time reselects father node and obtains address, carry out step 412;
Step 404: configuration node does not send address request to father node;
Step 405: after father node is received the message that configuration node does not send, check the child node record sheet, select record corresponding to minimum unassigned child node value, return to an address response message to configuration node not, the message load is the child node value c in corresponding record, this is recorded to the neutron node state simultaneously and is designated and distributes;
Step 406: after configuration node is not received response message, obtain the node ID of oneself according to formula y=Sx+c, wherein, the node ID that x is father node, node ID is combined to the node address that forms oneself with subnet ID, oneself is designated to configuration node simultaneously, and sets up the child node record sheet;
Step 407: configuration node judges that whether node ID corresponding to child node is greater than the address assignment space upper limit, if so, carry out step 408, otherwise carry out step 409;
Step 408: the distribution state of the corresponding child node of configuration node is set to unallocatedly, carry out step 410;
Step 409: the distribution state of the corresponding child node of configuration node is set to distribute;
Step 410: the unallocated child node sum of configuration node Broadcast Subnet ID and this node;
Step 411: after the child node of configuration node has been received broadcast, repeating step 402~step 410 is obtained address, until in tree, all nodes obtain node address;
Step 412: finish.
Fig. 6 is that not configuration node of the present invention obtains the node address schematic flow sheet.If newly add the not configuration node of mobile ad hoc network to wait for random time, the broadcast of receiving a plurality of configuration nodes, select to supply to distribute the maximum configuration node of child node sum as father node, and obtain node address by following steps:
Step 501: start;
Step 502: configuration node does not send address request to father node;
Step 503: after father node is received the message that configuration node does not send, check the child node record sheet, select record corresponding to minimum unassigned child node value, return to an address response message to configuration node not, the message load is the child node value c in corresponding record, this is recorded to the neutron node state simultaneously and is designated distribution state;
Step 504: after configuration node is not received response message, obtain the node ID of oneself according to formula y=Sx+c, wherein, the node ID that x is father node, node ID is combined to the node address that forms oneself with subnet ID, oneself is designated to configuration node simultaneously, and sets up the child node record sheet;
Step 505: configuration node judges that whether node ID corresponding to child node is greater than the address assignment space upper limit, if so, carry out step 506, otherwise carry out step 507;
Step 506: the distribution state of the corresponding child node of configuration node is set to unallocatedly, carry out step 508;
Step 507: the distribution state of the corresponding child node of configuration node is set to distribute;
Step 508: the unallocated child node sum of configuration node Broadcast Subnet ID and this node;
Step 509: finish.
Fig. 7 is that subnet of the present invention merges schematic flow sheet.Node A in subnet M detects that subnet M needs and after subnet N carries out union operation, if in node A, unallocated child node sum is greater than 0, it carries out the subnet union operation, otherwise the father node of requesting node A is carried out the subnet union operation, and the father node of node A or node A is set as to configuration node Z; The union operation of configuration node Z place subnet M and subnet N comprises the steps:
Step 701: start;
Step 702: the tree root node R of configuration node Z-direction subnet N sends and merges message, the subnet ID that the message load is subnet M;
Step 703: after root node R receives and merges message, using configuration node Z as father node, and return to the merging response message to configuration node Z, root node R become merge after the node R of subnet M; If root node R receives a plurality of merging message, it only replys first merging message of receiving;
Step 704: after configuration node Z has received and merged response message, select record corresponding to minimum unassigned child node value, and return to an address response message to node R, the message load in record child node value c, by the status indicator of this record, be distribution state simultaneously;
Step 705: after node R is received address response message, according to formula y=Sx+c, get new node ID, wherein, x is the node ID of configuration node Z, and by the subnet ID of the subnet M calculated address that combines with node ID;
Step 706: whether the child node status field that node R judges the child node list entry is distribution state, if so, carry out step 707, otherwise carry out step 710;
Step 707: node R sends an address updating message to corresponding child node, and the message load is new node ID and the subnet ID of subnet M;
Step 708: after child node is received the address updating message, obtain new node ID according to formula y=Sx+c, wherein, x is the node ID that father node is new, c is the original child node value that father node distributes, then new node ID is combined to calculated address with the subnet ID of subnet M, sends an address updating message to the child node of distribution state simultaneously, the message load is new node ID and the subnet ID of subnet M;
Step 709: after child node is received the address updating message, repeating step 708, until in subnet N, the node ID of all nodes is all upgraded;
Step 710: subnet M and subnet N merge successfully, the subnet ID that the subnet ID after merging is subnet M;
Step 711: finish.
In sum, address of mobile ad hoc network provided by the invention is the implementation method of configuration automatically, technique can be applied to the numerous areas such as vehicle-mounted monitoring, medical treatment & health, military and national defense, for example, in the vehicle-mounted monitoring field, the automatic configuring technical of address of mobile ad hoc network can be applied to the road blocking monitor, every vehicle is a nodes in MANET, after their configuration addresss, can carry out information communication, the transmission road traffic condition, effectively to avoid road congested, keep the traffic moving, therefore, present technique has very high promotional value.
The invention provides a kind of thinking of the mobile ad hoc network address configuration implementation method based on tree; method and the approach of this technical scheme of specific implementation are a lot; the above is only the preferred embodiment of the present invention; should be understood that; for those skilled in the art; under the premise without departing from the principles of the invention, can also make some improvements and modifications, these improvements and modifications also should be considered as protection scope of the present invention.In the present embodiment not clear and definite each component part all available prior art realized.