CN113395366A - Network address allocation method and device - Google Patents

Network address allocation method and device Download PDF

Info

Publication number
CN113395366A
CN113395366A CN202010176511.4A CN202010176511A CN113395366A CN 113395366 A CN113395366 A CN 113395366A CN 202010176511 A CN202010176511 A CN 202010176511A CN 113395366 A CN113395366 A CN 113395366A
Authority
CN
China
Prior art keywords
network address
address
network
allocated
identifier
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.)
Pending
Application number
CN202010176511.4A
Other languages
Chinese (zh)
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.)
Huawei Technologies Co Ltd
Original Assignee
Huawei Technologies 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 Huawei Technologies Co Ltd filed Critical Huawei Technologies Co Ltd
Priority to CN202010176511.4A priority Critical patent/CN113395366A/en
Publication of CN113395366A publication Critical patent/CN113395366A/en
Pending legal-status Critical Current

Links

Images

Classifications

    • HELECTRICITY
    • H04ELECTRIC COMMUNICATION TECHNIQUE
    • H04LTRANSMISSION OF DIGITAL INFORMATION, e.g. TELEGRAPHIC COMMUNICATION
    • H04L61/00Network arrangements, protocols or services for addressing or naming
    • H04L61/50Address allocation
    • H04L61/5038Address allocation for local use, e.g. in LAN or USB networks, or in a controller area network [CAN]
    • HELECTRICITY
    • H04ELECTRIC COMMUNICATION TECHNIQUE
    • H04LTRANSMISSION OF DIGITAL INFORMATION, e.g. TELEGRAPHIC COMMUNICATION
    • H04L12/00Data switching networks
    • H04L12/28Data switching networks characterised by path configuration, e.g. LAN [Local Area Networks] or WAN [Wide Area Networks]
    • H04L12/40Bus networks
    • H04L12/40006Architecture of a communication node
    • HELECTRICITY
    • H04ELECTRIC COMMUNICATION TECHNIQUE
    • H04LTRANSMISSION OF DIGITAL INFORMATION, e.g. TELEGRAPHIC COMMUNICATION
    • H04L61/00Network arrangements, protocols or services for addressing or naming
    • H04L61/50Address allocation

Landscapes

  • Engineering & Computer Science (AREA)
  • Computer Networks & Wireless Communication (AREA)
  • Signal Processing (AREA)
  • Small-Scale Networks (AREA)
  • Mobile Radio Communication Systems (AREA)

Abstract

The embodiment of the application discloses a network address allocation method and a network address allocation device, and particularly discloses that a master device broadcasts a first message to a slave device, wherein the first message comprises an address list, and the address list comprises N allocated network addresses. And for the newly added slave equipment, after receiving the first message, determining an unassigned first network address according to the address list in the first message, and sending the first network address to the master equipment through the second message. After receiving the second message, the master device confirms that the first network address can be allocated, and sends a third message to the slave device, so that the slave device confirms the allocated first network address according to the third message. Therefore, by the allocation method provided by the application, when the slave device selects the network address, the unassigned network address can be determined according to the address list sent by the master device, so that the problem that the allocated network address conflicts is solved.

Description

Network address allocation method and device
Technical Field
The present application relates to the field of communications technologies, and in particular, to a method and an apparatus for allocating network addresses.
Background
A bus communication protocol (modbus protocol) is a serial communication protocol, and is mainly applied to a master/slave (master/slave) network architecture. In the master/slave architecture, one node is set as a master, i.e., a master node, and the other nodes participating in communication using the modbus protocol are slaves, i.e., slave nodes. Each slave node is configured with a unique address. The master device sends a request message to the slave device that needs to communicate. And after receiving the request message, the slave device sends a response message, wherein the response message comprises the address of the slave device, so that the master device can know the slave device responding according to the response message. The problem of address conflict cannot be solved by the current address allocation mode between the master node and the slave node.
Disclosure of Invention
The embodiment of the application provides a network address allocation method and device, which are beneficial to avoiding address conflict of slave equipment.
In a first aspect, an embodiment of the present application provides a network address allocation method, which may be performed by a master device, where the master device broadcasts a first packet, where the first packet includes an address list, the address list includes N allocated network addresses, and N is an integer greater than or equal to 1. And for the newly added slave equipment, after receiving the first message, taking an unallocated network address as a first network address according to an address list in the first message, and sending a second message comprising the first network address to the master equipment. After receiving the second message sent by the slave device, the master device may acquire the first network address selected by the slave device according to the second message, and send a third message to the slave device, so as to determine the first network address allocated by the slave device by using the third message. Therefore, by using the technical scheme in the embodiment of the application, when the slave device selects the network address, the unassigned network address can be determined according to the address list sent by the master device, so that the problem that the network addresses assigned by the master device for the slave device conflict is solved.
In a possible implementation manner, before the master device sends the third packet, the master device may confirm that the first network address is an unallocated network address according to the first network address in the second packet and the address list, so as to allocate the first network address to the slave device. Further, the master device may also assign a corresponding identifier to the first network address. And the master equipment generates a third message according to the first network address and the identifier corresponding to the first network address.
In a possible implementation manner, to identify that a network address is allocated, the master device may further configure a corresponding identifier for the allocated network address, so as to identify that a network address is allocated by using the identifier. That is, the third packet includes the first network address and the identifier corresponding to the first network address, where the identifier corresponding to the first network address is used to identify that the first network address is allocated. After receiving the third packet, the slave device may not only confirm the allocated first network address, but also obtain an identifier corresponding to the first network address.
In a possible implementation manner, when configuring corresponding identifiers for the allocated network addresses, the N allocated network addresses include N network addresses and N identifiers, where a network address in the N network addresses corresponds to an identifier in the N identifiers one to one, and the identifier corresponding to the network address in the N network addresses is used to identify the network address corresponding to the identifier that is allocated. That is, each of the N allocated network addresses corresponds to an identifier.
In a possible implementation manner, in order to enable the slave device to know the master device that assigns the network address to the slave device, the first packet may further include an identifier of the master device, where the identifier of the master device is used to identify the master device that broadcasts the N assigned network addresses.
In a possible implementation manner, the third packet further includes an identifier of the master device, where the identifier of the master device is used to identify the master device that allocates the first network address. When the slave device receives the third packet, the master device to which the first network address is allocated may be determined according to the identifier of the master device.
In a possible implementation manner, before broadcasting the first message, the master device obtains an address list in advance, specifically, broadcasts a fourth message for the master device, where the fourth message is used to query an allocated network address; the method comprises the steps that a main device obtains N distributed network addresses from N slave devices, and the slave devices in the N slave devices are in one-to-one correspondence with the distributed network addresses in the N distributed network addresses; the master device obtains an address list according to the N allocated network addresses. In this implementation manner, the master device may obtain, in a manner of broadcasting the fourth packet, the network address allocated to each slave device to which the network address is currently allocated, so as to obtain the address list according to the network address allocated to each slave device.
In a possible implementation manner, when the master device may configure a corresponding identifier for the allocated network address, and when the master device acquires the network address allocated to each of the N slave devices, the master device may further send, to any one of the N slave devices, an identifier corresponding to the network address allocated to any one of the N slave devices, where the identifier corresponding to the network address of any one of the slave devices is used to identify that the network address of the slave device is allocated.
In a second aspect, an embodiment of the present application provides a network address allocation method, which is performed by a slave device, and in particular, the slave device receives a first packet broadcast by a master device, where the first packet includes an address list, and the address list includes N allocated network addresses, where N is an integer greater than or equal to 1. The slave device determines the unallocated network addresses from the address list and sets one of the unallocated network addresses as the first network address. The slave device sends a second message including the first network address to the master device, so that the master device can acquire the first network address determined by the slave device and send a third message to the slave device. And the slave equipment confirms that the master equipment distributes the first network address to the slave equipment according to the third message sent by the master equipment. Therefore, by using the technical scheme in the embodiment of the application, when the slave device selects the network address, the unassigned network address can be determined according to the address list sent by the master device, so that the problem that the network addresses assigned by the master device for the slave device conflict is solved.
In a possible implementation manner, to identify that a network address is allocated, the master device may further configure a corresponding identifier for the allocated network address, so as to confirm that a certain network address is allocated by using the identifier. That is, the third packet includes the first network address and the identifier corresponding to the first network address, where the identifier corresponding to the first network address is used to identify that the first network address is allocated.
In a possible implementation manner, after receiving the third packet, the slave device may store the first network address in the third packet and the identifier corresponding to the first network address.
In one possible implementation, when configuring corresponding identifiers for the allocated network addresses, the N allocated network addresses include N network addresses and N identifiers, where one of the N network addresses corresponds to one of the N identifiers, and the identifier corresponding to one of the N network addresses is used to identify the network address corresponding to the identifier that is allocated.
In one possible implementation, the slave device may determine the first network address according to two ways, namely, the slave device obtains the first network address which is not included in the N allocated network addresses according to the address list, where the N allocated network addresses do not include the identifier corresponding to the first network address. When the N allocated network addresses include N network addresses and N identifiers, when the slave device determines the first network address according to the address list, the identifier corresponding to the determined first network address does not exist in the N allocated network addresses, thereby ensuring that the determined first network address is an unallocated network address. The other is that the first message further includes an identifier of the master device, and when the slave device determines that the N allocated network addresses include the second network address of the slave device and an identifier corresponding to the second network address, and the identifier of the master device is different from the identifier of the master device corresponding to the second network address, the slave device acquires, according to the address list, the first network address that is not included in the N allocated network addresses. That is, when the newly added slave device itself stores the second network address and the identifier corresponding to the second network address, the slave device determines, according to the address list, that the N allocated network addresses include the second network address stored in itself and the identifier corresponding to the second network address, but the identifier of the master device that allocates the second network address is different from the identifier of the master device in the first message, which indicates that the second network address is allocated, and then determines, according to the address list, an unallocated network address as the first network address.
In one possible implementation, the slave device may determine the first network address by selecting, as the first network address, one network address according to the first random number and the address list, where the first network address is not included in the N allocated network addresses. That is, the slave device performs determination using the first random number when determining the first network address. The implementation mode can be applied to a scene that a plurality of slave devices determine respective network addresses according to an address list, each slave device selects one network address from unallocated network addresses as a first network address by utilizing different random numbers corresponding to each slave device, and the problem that the network addresses determined by the plurality of slave devices have conflict is avoided by utilizing the randomness of the random numbers.
The other is that when the first message further includes an identifier of the master device, and when the slave device determines that the N allocated network addresses include the second network address of the slave device and an identifier corresponding to the second network address, and the identifier of the master device included in the first message is different from the identifier of the master device corresponding to the second network address, the slave device selects one network address as the first network address according to the first random number and the address list, where the first network address is not included in the N allocated network addresses. That is, when the newly added slave device itself stores the second network address and the identifier corresponding to the second network address, the slave device determines, according to the address list, that the N allocated network addresses include the second network address stored in itself and the identifier corresponding to the second network address, but the identifier of the master device that allocates the second network address is different from the identifier of the master device in the first message, which indicates that the second network address is allocated, and then the slave device determines, according to the first random number and the address list, an unallocated network address as the first network address. The implementation mode can be applied to a scene that a plurality of slave devices determine respective network addresses according to an address list, each slave device selects one unallocated network address as a first network address by using different random numbers corresponding to each slave device, and the problem that the network addresses determined by the plurality of slave devices have conflict is avoided by using the randomness of the random numbers.
In a possible implementation manner, when the slave device wants the master device to send the second packet, the slave device may further determine a sending time according to the second random number, so as to send the second packet to the master device according to the sending time. The realization mode can be applied to a scene that a plurality of slave devices need to send messages to the master device, and in order to reduce the load of the master device, each slave device can determine the sending time of the messages according to the random numbers corresponding to the slave devices, thereby avoiding the situation that the plurality of slave devices send the messages to the master device at the same time.
In a third aspect, an embodiment of the present application provides a network address allocation apparatus, where the apparatus is provided in a master device, and includes: the device comprises a broadcasting unit, a first receiving unit and a first sending unit. The broadcast unit is used for broadcasting a first message, wherein the first message comprises an address list, the address list comprises N distributed network addresses, and N is an integer greater than or equal to 1; the first receiving unit is used for receiving a second message sent by a slave device, wherein the second message comprises a first network address, and the first network address is an unallocated address determined according to the address list; the first sending unit is configured to send a third packet to the slave device, where the third packet is used to confirm that the first network address is allocated.
In one possible implementation, the apparatus further includes: a validation unit and an allocation unit. The confirming unit is used for confirming that the first network address is an unallocated network address according to the first network address in the second message and the address list, so as to allocate the first network address to the slave device; the allocation unit is used for allocating corresponding identification for the first network address.
In a possible implementation, the apparatus further includes a generating unit. The generating unit is used for generating a third message according to the first network address and the identifier corresponding to the first network address.
In a possible implementation manner, the third packet includes the first network address and an identifier corresponding to the first network address, where the identifier corresponding to the first network address is used to identify that the first network address is allocated.
In a possible implementation manner, the N allocated network addresses include N network addresses and N identifiers, a network address in the N network addresses corresponds to an identifier in the N identifiers one to one, and the identifier corresponding to one network address in the N network addresses is used to identify that the network address corresponding to the identifier is allocated.
In a possible implementation manner, the first packet further includes an identifier of the master device, where the identifier of the master device is used to identify the master device that broadcasts the N allocated network addresses.
In a possible implementation manner, the third packet further includes an identifier of the master device, where the identifier of the master device is used to identify the master device that allocates the first network address.
In one possible implementation, the apparatus further includes: a first acquisition unit and a second acquisition unit. The broadcasting unit is further configured to broadcast a fourth packet before broadcasting the first packet, where the fourth packet is used to query the allocated network address; the first acquisition unit is used for acquiring the N allocated network addresses from N slave devices, wherein the slave devices in the N slave devices are in one-to-one correspondence with the allocated network addresses in the N allocated network addresses; a second obtaining unit, configured to obtain the address list according to the N allocated network addresses.
In one possible implementation, the apparatus further includes: and a second transmitting unit. The second sending unit is configured to send, to any slave device of the N slave devices, an identifier corresponding to a network address assigned by the any slave device.
In a fourth aspect, an embodiment of the present application provides a network address assignment device, where the device is provided in a slave device, and the device includes: the device comprises a second receiving unit, a determining unit, a third sending unit and a third receiving unit. The second receiving unit is configured to receive a first broadcast message, where the first message includes an address list, the address list includes N allocated network addresses, and N is an integer greater than or equal to 1; the determining unit is used for determining a first network address according to the address list, wherein the first network address is an unallocated address determined according to the address list; the third sending unit is configured to send a second packet to the master device, where the second packet includes the first network address; the third receiving unit is configured to receive a third packet sent by the master device, where the third packet is used to confirm that the first network address is allocated.
In a possible implementation manner, the third packet includes the first network address and an identifier corresponding to the first network address, where the identifier corresponding to the first network address is used to identify that the first network address is allocated.
In a possible implementation manner, the apparatus may further include a storage unit, where the storage unit is configured to store the first network address in the third message and an identifier corresponding to the first network address.
In a possible implementation manner, the N allocated network addresses include N network addresses and N identifiers, one of the N network addresses corresponds to one of the N identifiers, and the identifier corresponding to one of the N network addresses is used to identify that the network address corresponding to the identifier is allocated.
In a possible implementation manner, the determining unit is specifically configured to obtain, according to the address list, a first network address that is not included in the N allocated network addresses, where the N allocated network addresses do not include an identifier corresponding to the first network address; or, the first packet further includes an identifier of the master device, and the determining unit is specifically configured to select, when it is determined that the N allocated network addresses include a second network address of the slave device and an identifier corresponding to the second network address, and the identifier of the master device is different from the identifier of the master device corresponding to the second network address, a network address as a first network address according to a first random number and the address list, where the first network address is not included in the N allocated network addresses.
In a possible implementation manner, the determining unit is specifically configured to select a network address as the first network address according to the first random number and the address list, where the first network address is not included in the N allocated network addresses; or, the first packet further includes an identifier of the master device, and the determining unit is specifically configured to select, when it is determined that the N allocated network addresses include a second network address of the slave device and an identifier corresponding to the second network address, and the identifier of the master device is different from the identifier of the master device corresponding to the second network address, a network address as a first network address according to a first random number and the address list, where the first network address is not included in the N allocated network addresses.
In one possible implementation manner, the third sending unit includes: a determining subunit and a transmitting subunit. The determining subunit is used for determining the sending time according to the second random number; and the sending subunit is configured to send the second packet to the master device according to the sending time.
In the embodiment of the application, the master device broadcasts a first message to the slave device, where the first message includes an address list, and the address list includes N allocated network addresses, so that the slave device can determine which network addresses are not allocated according to the address list in the first message. And for the newly added slave equipment, after receiving the first message, determining an unassigned first network address according to the address list in the first message, and sending the first network address to the master equipment through the second message. After receiving the second message, the master device may obtain the first network address selected by the slave device through the second message, and send a third message to the slave device, so that the slave device confirms the allocated first network address according to the third message. Therefore, by the network address allocation method provided by the application, when the slave device selects the network address, the unassigned network address can be determined according to the address list sent by the master device, so that the problem that the network addresses allocated by the slave device conflict is solved.
Drawings
In order to more clearly illustrate the embodiments of the present application or the technical solutions in the prior art, the drawings needed to be used in the description of the embodiments or the prior art will be briefly described below, it is obvious that the drawings in the following description are only some embodiments described in the present application, and other drawings can be obtained by those skilled in the art without creative efforts.
Fig. 1 is a schematic view of an application scenario provided in an embodiment of the present application;
fig. 2 is a network address assignment signaling interaction diagram according to an embodiment of the present application;
fig. 3 is another network address assignment signaling interaction diagram provided in an embodiment of the present application;
fig. 4 is a diagram of still another network address assignment signaling interaction provided in an embodiment of the present application;
fig. 5 is a schematic view of an application scenario provided in an embodiment of the present application;
fig. 6 is a schematic structural diagram of a network address allocation apparatus according to an embodiment of the present application;
fig. 7 is a schematic structural diagram of another network address allocation apparatus according to an embodiment of the present application;
fig. 8 is a schematic structural diagram of a network device according to an embodiment of the present application.
Detailed Description
The embodiment of the application provides a network address allocation method and a network address allocation device, which are used for solving the problem of address conflict of slave equipment.
Generally, to avoid the conflict of network addresses allocated by slave devices in the deployed master/slave network architecture, the following two methods are mainly adopted for address allocation: one is to avoid address collision between different slave devices by writing network addresses in advance before the device leaves the factory. When a network topology is built by using devices of different manufacturers, the problem of conflict of network addresses written in advance by a plurality of slave devices can occur. The other is an address writing interface of the equipment opened by the manufacturer, and the system integrator allocates addresses to all the slave equipment in the field in an address writing mode, so that the addresses are guaranteed not to conflict. However, in practical application, site construction conditions may not be met, and the address writing system needs to be carried separately, so that a construction deployment link is increased, and deployment cost is increased. Moreover, when the system encounters a new terminal expansion access, besides a terminal manufacturer, related support personnel are required to synchronously support, the consistency of front and back address allocation is ensured, and the construction complexity is increased.
In order to implement automatic network address allocation under a Modbus protocol and avoid address conflict, an embodiment of the present application provides a network address allocation method, where a master device controls resources and address allocation permissions of all addresses, and periodically broadcasts a first message, so that each newly added slave device can know which network addresses are allocated through an address list in the first message, and further selects an unallocated network address, thereby ensuring that there is no conflict between network addresses allocated by the master device to the slave devices.
Referring to fig. 1, the figure is a schematic view of an application scenario provided in the embodiment of the present application.
The network topology B shown in fig. 1 includes a master device 100, a slave device 201, and a slave device 202. The slave 201 is a slave included in the network topology B shown in fig. 1. Slave device 202 is a slave device that newly joins network topology B shown in fig. 1. The master device 100 assigns a network address a1 to the slave device 201 in the network topology B shown in fig. 1, and the address list acquired by the master device 100 includes the network address a1 of the slave device 201. The master device 100 periodically broadcasts a first message that includes a list of addresses. After receiving the first message, the slave device 201 may determine, according to the address list and the network address a1 stored therein, that it is not necessary to obtain the network address from the master device again, and may not respond to the first message from the master device 100. For the slave device 202 newly joining the network topology B shown in fig. 1, it may obtain the network address that is not used by the slave device in the network topology B shown in fig. 1, that is, the first network address, according to the address list broadcast by the master device 100. Slave device 202 sends the first network address to master device 100. The master device 100 sends a third message to the slave device 202 to confirm that the first network address is allocated to the slave device 202, so that the allocated network address does not have the problem of address conflict.
Referring to fig. 2, this figure is a network address assignment signaling interaction diagram provided in an embodiment of the present application. The method provided by the embodiment of the present application is described below with reference to fig. 1 and 2.
S201: the master device broadcasts a first message.
For example, the master device may periodically broadcast a first packet in the network topology to which the master device belongs, where the first packet includes an address list including N allocated network addresses, where N is an integer greater than or equal to 1. The master device makes the slave device in the network topology to which the master device belongs know the allocated network address through periodically broadcasting the first message, so as to avoid address conflict between the network address selected by the slave device newly added to the network topology and the network address of the slave device included in the network topology to which the slave device belongs.
For example, the format of the first message conforms to the message format specified by the Modbus protocol. The messages in the Modbus protocol may include fields such as address fields, function codes, data, and error checking. Where an address field (field) is used for addressing. When the network address carried by the address field of a certain message is 0, the message is a broadcast message. When the network address carried by the address field of a certain packet is a value other than 0, for example, a specific network address, the packet is a unicast packet. The unicast message is sent to the slave device corresponding to the network address in the address domain. The address field may also be referred to as an address field. The function code is used to indicate an operation to be performed. The function code is expressed in hexadecimal. For example, the function code is 0x06, indicating that a single register is written. The function code is 0x10, indicating writing to a plurality of holding registers. The function code is 0x03, and indicates a read holding register, where the holding register is a register capable of read or write operations.
In the specific implementation, in order to enable the master device to query the network address allocated to each slave device, a function code, that is, an address query function code, is added. The hexadecimal corresponding to the address query function code can be selected from the currently reserved hexadecimal. For example, one hexadecimal from the currently reserved hexadecimal 0x 16-0 x40 is selected as the address query function code. Specifically, when the master device queries the network address assigned by the slave device, the functional code field in the fourth message broadcasted by the master device is the address query functional code. After receiving the fourth message, the slave device identifies the address query function code by analyzing the fourth message, and sends the network address allocated by the slave device to the master device. That is, the master device may obtain the network address of each slave device in the current network topology by broadcasting the fourth packet with the inquiry function code.
For example, before the master device broadcasts the first message, the master device broadcasts a fourth message, where the fourth message is used to query the allocated network address; the master device acquires N allocated network addresses from N slave devices, wherein the slave devices in the N slave devices are in one-to-one correspondence with the allocated network addresses in the N allocated network addresses, for example, the N slave devices include a first slave device and a second slave device, and the N allocated network addresses include the network address allocated to the first slave device and the network address allocated to the second slave device; the master device obtains the address list according to the N allocated network addresses, that is, the master device adds the network addresses corresponding to the N acquired slave devices to the address list.
S202: the slave device determines a first network address from the address list, the first network address being an unassigned address determined from the address list.
For example, the slave device determines an unassigned network address from the address list in the first message, and uses the unassigned network address as the first network address. In this embodiment, the slave device of the first network address is determined to be a slave device newly joining the network topology according to the address list. The slave device may determine the first network address according to a preset rule, for example, determine a first network address of the unallocated network addresses as the first network address; the first random number may also be used to select the first network address from the unassigned network addresses. The address list in the embodiment of the application may further include a plurality of unassigned addresses, and the slave device selects a network address matching the first random number as the first network address according to the first random number and the address list, which is helpful for reducing the probability of address collision with other slave devices. The network address matching the first random number may be an order of the selected network addresses among the unallocated network addresses (unallocated network addresses included in the address list) determined by the first random number.
S203: and the slave equipment sends a second message to the master equipment, wherein the second message comprises the first network address.
For example, the slave device generates a second message according to the first network address, where the second message includes the first network address. And the slave equipment sends a second message to the master equipment.
In the scenario shown in fig. 1, if the network topology B includes a plurality of newly joined slave devices, the plurality of newly joined slave devices send respective selected network addresses to the master device. The plurality of newly joined slave devices includes slave device 202, and slave device 202 may determine the transmission timing of its selected network address using the second random number. The slave device 202 transmits its selected network address to the master device 100 according to the determined transmission timing to improve the processing efficiency of the master device 100.
S204: and the master device sends a third message to the slave device, wherein the third message is used for confirming the allocated first network address.
For example, the master device may send a third message to the slave device if it is determined that the first network address of the second message may be assigned to the slave device. The destination address of the third message is the first network address. The third message also includes an identifier matching the first network address.
For example, for a method for acquiring a first network address from a device newly joining a network topology, the following three scenarios may be included:
in the first scenario, the slave device newly joining the network topology does not store or is configured with any network address, and after the slave device joins the network topology B shown in fig. 1, the first network address is determined according to the address list.
In the second scenario, a slave device newly joining the network topology is configured with an initialized network address, i.e., a second network address, after being initialized. The slave device judges whether the second network address is adopted by other slave devices according to the address list included in the first message. If the second network address is not adopted by other slave devices, the slave device takes the second network address as the first network address. If the second network address has already been assigned, the slave device determines the first network address from the address list. Specifically, the slave device may determine whether the second network address exists in the address list when determining whether the second network address is allocated, and if not, the slave device may indicate that the second network address is not allocated. If the second network address is present in the address list, which only indicates that the second network address is allocated, it is not possible to confirm whether the second network address is allocated to the slave device or to other slave devices.
Based on this, the master device may configure a corresponding identifier for each allocated network address, where the identifier corresponding to the network address is used to identify that its corresponding network address is allocated. Specifically, when the master device acquires the address list, the master device sends an identifier corresponding to a network address allocated to any one of the N slave devices to the slave device. For the N allocated network addresses included in the address list, the N allocated network addresses include N network addresses and N identifiers, the network addresses in the N network addresses correspond to the identifiers in the N identifiers one to one, and the identifier corresponding to one of the N network addresses is used to identify the network address corresponding to the identifier to be allocated. The identifier may be a serial number, a sequence code, or other information that can be used to identify the network address to be allocated, which is not limited herein. For example, the master device 100 obtains the network address a2 selected by the slave device 202 and assigns a corresponding identifier b2 to the network address a 2. The master device 100 transmits the network address a2 and the identification b2 to the slave device 202 so that the slave device 202 confirms that it is assigned the network address a2 according to the identification b2 and stores the identification b 2.
Based on the second scenario, the determining, by the slave device, the first network address according to the address list may be: after receiving the first message, the slave device determines whether a second network address exists in the address list, and if the second network address exists in the address list but the slave device does not store an identifier corresponding to the second network address, it indicates that the second network address is already allocated to other slave devices in the current network topology. The newly added slave device determines a first network address according to the address list. Specifically, the slave device may determine the first network address by: the method comprises the steps that a slave device acquires a first network address which is not contained in N allocated network addresses according to an address list, wherein the N allocated network addresses do not comprise identifications corresponding to the first network address; alternatively, the slave device selects a network address as the first network address according to the first random number and the address list, where the first network address is not included in the N allocated network addresses. If the second network address is not present in the address list, indicating that the second network address is not assigned, then it is treated as the first network address.
In a third scenario, the slave device newly joining the network topology (network topology B shown in fig. 1) is a slave device that is transferred to the network topology from another network topology. The slave device newly joining the network topology stores a network address acquired from another network topology, an identifier corresponding to the network address, and an identifier of a master device (master device in another network topology) that assigns the network address. If the network address acquired from the other network topology stored by the slave device of the newly added network topology and the identifier corresponding to the network address are included in the N allocated network addresses of the address list, the slave device of the newly added network topology considers that no address conflict exists and does not actually allocate the network address and the identifier corresponding to the network address for the master device in the newly added network topology. For example, slave device 202 was originally deployed in network topology a, which assigned network address a1 and the network address a1 corresponds to identity b 1. At this time, the slave device 202 is deployed in the network topology B due to traffic demand, and the slave device 201 in the network topology B has been assigned the network address a1 and the identity B1 corresponding to the network address a 1. The address list broadcast by the master device 100 in network topology B includes the network address a1 and the identifier B1. Slave device 202 joining network topology B determines from the address list, network address a1 and identification B1 that no new network address is selected, but there is an address conflict between slave device 201 and slave device 202. Wherein, the network topology A and the network topology B are both a master/slave network structure. Network topology a and network topology B are physically separate. The address pool corresponding to the network topology a and the address pool corresponding to the network topology B may be completely the same or partially the same. That is, the same network address exists between the plurality of network addresses assignable by the master device in network topology a and the plurality of network addresses assignable by the master device in network topology B.
For the third scenario, when the master device allocates a network address to the slave device, the master device sends its own identifier to the slave device, so that the slave device determines the master device that allocates the network address to the slave device according to the identifier of the master device. When the slave device determines that the network address and the identifier corresponding to the network address are included in the address list broadcast by the master device, the slave device may further determine whether the identifier of the master device to which the network address is allocated is the same as the identifier of the master device in the broadcast address list, and if the identifiers are not the same, it is determined that an address conflict exists, and the slave device needs to select a first network address from the address list received through broadcast. Optionally, the first packet may further include an identifier of the master device, where the identifier of the master device is used to identify the master device broadcasting the N allocated network addresses. After receiving the first message, the slave device determines that an address list included in the first message includes a stored network address and an identifier corresponding to the network address, and further determines whether the identifier of the master device included in the first message is the same as the identifier of the stored master device. If so, the slave device no longer selects a new network address. If not, the slave device determines the first network address according to the address list. For the method for determining the first network address by the slave device according to the address list, reference may be made to the foregoing method for determining the first network address by the slave device, which is not described herein again. In a third scenario, the third packet sent by the master device to the slave device further includes an identifier of the master device, where the identifier of the master device is used to identify the master device that assigns the first network address.
Fig. 3 is another network address assignment signaling interaction diagram provided in an embodiment of the present application. In the interaction process, the address list includes N allocated network addresses, and the N allocated network addresses include N network addresses and N identifiers. This embodiment is an explanation of the interaction between the master device and the slave device in the second scenario described above.
S301: the master device broadcasts a first message to the slave device, wherein the first message comprises an address list, and the address list comprises N allocated network addresses.
See S201 in the embodiment corresponding to fig. 2.
S302: the slave device determines whether the second network address has conflict according to the first message, and if so, executes S303; otherwise, S304 is performed.
For the slave device newly joining the network topology, after receiving the first message, it is determined whether the second network address currently stored by the slave device itself exists in the address list, and if the second network address of the newly added slave device exists in the address list, but the address list does not include the identifier corresponding to the second network address, indicating that the second network address has been allocated to other slave devices, S303 is executed. If the second network address of the newly added slave device does not exist in the address list, indicating that the second network address is not allocated, S304 is performed.
S303: and the slave equipment determines the unallocated network address as the first network address according to the address list.
The specific implementation of determining the first network address from the address list by the slave device may refer to the implementation of S202, which is not described herein again in this embodiment. This step is followed by S305.
S304: the slave device determines the second network address as the first network address.
S305: and the slave equipment sends a second message to the master equipment, wherein the second message comprises the first network address.
The specific implementation of sending the second message from the slave device may refer to the corresponding content of S203.
S306: and the master equipment allocates a corresponding identifier for the first network address according to the second message.
For example, after receiving a second message sent by the slave device, the master device allocates a corresponding identifier to the first network address in the second message. The identifier corresponding to the first network address may be a serial number, a sequence code, or other forms that can identify the first network address is allocated.
Optionally, after the master device allocates a corresponding identifier to the first network address, the first network address and the corresponding identifier may also be recorded in an address list. Since the master device may broadcast the first packet periodically, when a next broadcast period comes, the master device rebroadcasts the first packet, where an address list included in the first packet includes the first network address and an identifier corresponding to the first network address.
S307: and the master equipment sends a third message to the slave equipment, wherein the third message comprises the first network address and an identifier corresponding to the first network address.
The implementation manner of sending the third packet by the master device may refer to the corresponding content of S204.
S308: and the slave equipment acquires the identifier corresponding to the first network address according to the third message.
For example, the slave device obtains the first network address and the identifier corresponding to the first network address from the third packet, thereby avoiding address collision. Optionally, the slave device may save the first network address and an identification corresponding to the first network address.
Fig. 4 is a diagram of still another network address assignment signaling interaction provided in an embodiment of the present application. Two slave devices, such as a first slave device and a second slave device, are included in this embodiment, and there is an address conflict between the addresses of the two slave devices. The embodiment is to explain the interaction between the slave device and the master device in the third scenario.
S401: the method comprises the steps that a first message is broadcasted by a main device, wherein the first message comprises an address list and a main device mark, and the address list comprises N distributed network addresses.
The specific implementation of the master device broadcasting the first packet may refer to S301 in the embodiment corresponding to fig. 3.
S402: when the first slave device determines that the second network address has conflict according to the first message, the first slave device determines the first network address according to the first random number and the address list, determines the first sending time according to the second random number, and then executes S404.
For a first slave device newly added to the network topology, after receiving a first message, determining that a second network address currently stored by the first slave device and an identifier corresponding to the second network address are contained in an address list, and if the identifier of the master device included in the first message is different from the stored identifier of the master device, indicating that the second network address is allocated to other slave devices, determining the first network address according to the first random number and the address list, and determining the time for sending the second message according to the second random number.
For example, the first slave device may generate two random numbers, a first random number and a second random number. The first slave device firstly determines the unallocated network addresses according to the address list and then selects one network address from the unallocated network addresses as a first network address by using a first random number. The first slave device may determine the first duration according to the second random number and the delay function, for example, obtain the first duration by using the second random number as an argument of the delay function, and obtain the first sending time according to the first duration and the current time (the time when the first slave device determines the first network address).
S403: and when the second slave device determines that the fourth network address has conflict according to the first message, determining the third network address according to the third random number and the address list, determining the second sending time according to the fourth random number, and then executing S408.
For a second slave device newly added to the network topology, after receiving the first message, determining that a fourth network address currently stored by the second slave device and an identifier corresponding to the fourth network address are contained in the address list, and if the identifier of the master device included in the first message is different from the stored identifier of the master device, indicating that the fourth network address is allocated to other slave devices, determining a third network address according to the third random number and the address list, and determining a second sending time for sending a fifth message according to the fourth random number.
For example, the second slave device may generate two random numbers, a third random number and a fourth random number. The second slave device determines the unallocated network addresses according to the address list, and determines a network address from the unallocated network addresses as a third network address by using a third random number. The second slave device may determine the second time length according to the fourth random number and the delay function, and obtain the second sending time according to the second time length and the current time (the time when the second slave device determines the third network address).
In a specific implementation, the execution sequence of S402 and S403 is not limited to the above, and S403 may be executed first and then S402 may be executed, or S402 and S403 may be executed simultaneously.
Wherein the first slave device and the second slave device determine the selected network addresses from the unassigned network addresses by using different random numbers generated by the first slave device and the second slave device, and avoid the same network address from being selected by the first slave device and the second slave device by using the randomness principle. The first random number utilized by the first slave device to determine the first network address is different from the third random number utilized by the second slave device to determine the third network address. The second random number utilized by the first slave device to determine the first transmission time instant and the fourth random number utilized by the second slave device to determine the second transmission time instant are different. The following description will be given taking an example in which the first transmission time is earlier than the second transmission time.
S404: and the first slave equipment sends the second message to the master equipment according to the first sending time.
For example, the first slave device generates a second message according to the first network address, and a source address of the second message is the first network address. And the first slave equipment sends the second message to the master equipment at the first sending moment. The specific implementation of sending the second packet from the first slave device to the master device may refer to corresponding content in S305.
S405: the master device assigns a first identifier to the first network address.
For example, the master device may identify that the first network address is assigned to the first slave device based on the N assigned network addresses in the address list. And the master equipment allocates a corresponding first identifier for the first network address. For a specific implementation of the master device allocating the first identifier to the first network address, reference may be made to the implementation of S306 in the foregoing method embodiment, and details of this embodiment are not described herein again.
S406: and the master equipment sends the third message to the first slave equipment.
For example, the master device generates a third packet according to the first network address, the first identifier, and the identifier of the master device, where a destination address of the third packet is the first network address. The method for the master device to send the third packet to the slave device may refer to the corresponding content in S307.
S407: and the first slave equipment acquires the identifier of the master equipment, the first network address and the first identifier from the third message, and then the process of acquiring the network address by the first slave equipment is finished.
For example, the first slave device may store the identifier of the master device, the first network address, and the first identifier, which are obtained from the third packet.
S408: and the second slave equipment sends a fifth message to the master equipment according to the second sending time.
For example, the second slave device generates a fifth message according to the third network address, and a source address of the fifth message is the third network address. And the second slave equipment sends a fifth message to the master equipment at the second sending moment. The specific implementation of the second slave device sending the fifth packet to the master device may refer to the specific implementation of sending the second packet in S305.
S409: and the master equipment allocates a corresponding second identifier for the third network address.
For example, the master device may identify that the third network address may be assigned to the second slave device based on the address list and the third network address. And the master equipment allocates a corresponding second identifier for the third network address. The specific implementation of allocating the second identifier to the third network address by the master device may refer to the implementation of S306 in the foregoing method embodiment, which is not described herein again.
S410: and the master device sends a sixth message to the second slave device.
For example, the master device generates a sixth packet according to the third network address, the second identifier, and the identifier of the master device. The destination address of the sixth packet is the third network address. The manner in which the master device sends the sixth message to the second slave device may refer to the manner in which the master device sends the third message to the slave device in S307.
S411: and the second slave device acquires the identifier of the master device, the third network address and the second identifier from the sixth message.
For example, the second slave device may store the identifier of the master device, the third network address, and the second identifier, which are obtained from the sixth packet.
That is, when there are a plurality of slave devices that need to perform network address allocation, each slave device may select a network address using a different random number corresponding to each slave device, thereby avoiding a collision of network addresses selected by each slave device. Meanwhile, in order to reduce the load of the master device, each slave device can determine the time for sending the message by using different random numbers corresponding to each slave device, so that the master device can process the message separately.
In this embodiment, the method for acquiring N allocated network addresses in the address list by the master device through broadcasting the fourth packet may refer to corresponding contents in the embodiment corresponding to fig. 2, and details are not described here again.
The technical scheme provided by the embodiment of the application can be applied to various application scenes related to network address allocation, such as intelligent lamp pole scenes. The intelligent lamp post will be described as an example.
Referring to the schematic view of the application scene of the intelligent lamp pole shown in fig. 5, the gateway of the intelligent lamp pole is not only connected with the lamp pole environment sensor, but also can be connected with other sensors, such as a water pollution detection sensor, a water level detection sensor, a well lid detection sensor, etc., in an RS485 connection mode. The RS485 connection mode is to connect the devices in series by using a bus. At present, the sensors adopt a preset writing mode to avoid address conflict, however, when a new sensor is added to a lamp post, a network address needs to be configured for the added sensor so as to carry out communication. At this time, the network address allocated by each existing sensor needs to be inquired, and if the network address allocated by the existing sensor is not recorded due to various reasons, the inquiry can be carried out only on site; or the network address cannot be configured for the newly added sensor due to the reasons that the field configuration condition is not met and the like. Through the method provided by the embodiment of the application, the lamp pole can configure the master equipment through the gateway, various sensors or radio frequency terminals accessed by the master equipment are used as slave equipment, and the master equipment uniformly manages the network address allocation of each slave equipment. For devices newly added to a network topology, such as a sensor, a radio frequency terminal, and the like, a master device may allocate a network address to the devices by using the network address allocation method provided in the embodiment of the present application, which not only realizes flexible configuration of the network address, but also avoids address collision.
Any network address mentioned in the above embodiments of the present application is the address of modbus.
Based on the network address allocation method provided by the above embodiment, the embodiment of the present application further provides a corresponding apparatus, which will be described below with reference to the accompanying drawings.
Referring to fig. 6, it is a schematic structural diagram of a network address assignment device according to an embodiment of the present invention. As shown in fig. 6, the apparatus is applied to a master device, and the apparatus 600 may include: a broadcasting unit 601, a first receiving unit 602, and a first transmitting unit 603. The broadcasting unit 601 is configured to execute S201 in the foregoing method embodiment, the first receiving unit 602 is configured to receive the second packet sent by the slave device in S203, and the first sending unit 603 is configured to execute S204 in the foregoing method embodiment.
Specifically, the broadcasting unit 601 is configured to broadcast a first packet by the master device, where the first packet includes an address list, the address list includes N allocated network addresses, and N is an integer greater than or equal to 1;
a first receiving unit 602, configured to receive a second packet sent by the slave device, where the second packet includes a first network address, and the first network address is an unassigned address determined according to the address list;
a first sending unit 603, configured to send a third packet to the slave device, where the third packet is used to confirm that the first network address is allocated.
In one possible implementation, the apparatus further includes: a validation unit 604 and an assignment unit 605. A confirming unit 604, configured to confirm that the first network address is an unallocated network address according to the first network address in the second message and the address list, so as to allocate the first network address to the slave device; an assigning unit 605, configured to assign a corresponding identifier to the first network address.
In one possible implementation, the apparatus may further include: a recording unit (not shown in fig. 6). The recording unit is connected to the allocating unit 605 and is configured to record the first network address and the identifier allocated by the allocating unit 605 for the first network address in an address list.
In a possible implementation, the apparatus may further include a generating unit (not shown in fig. 6). The generating unit may generate the third packet according to the first network address confirmed by the confirming unit 604 and the identifier corresponding to the first network address and allocated by the allocating unit 605.
In a possible implementation manner, the third packet includes the first network address and an identifier corresponding to the first network address, where the identifier corresponding to the first network address is used to identify that the first network address is allocated.
In a possible implementation manner, the N allocated network addresses include N network addresses and N identifiers, one of the N network addresses corresponds to one of the N identifiers, and the identifier corresponding to one of the N network addresses is used to identify that the network address corresponding to the identifier is allocated.
In a possible implementation manner, the first packet further includes an identifier of the master device, where the identifier of the master device is used to identify the master device that broadcasts the N allocated network addresses.
In a possible implementation manner, the third packet further includes an identifier of the master device, where the identifier of the master device is used to identify the master device that allocates the first network address.
In one possible implementation, the apparatus further includes:
the broadcasting unit is further configured to broadcast a fourth packet before broadcasting the first packet, where the fourth packet is used to query the allocated network address;
a first obtaining unit configured to obtain the N allocated network addresses from N slave devices;
a second obtaining unit, configured to obtain the address list according to the N allocated network addresses.
In one possible implementation, the apparatus further includes:
a second sending unit, configured to send, to any slave device in the N slave devices, an identifier corresponding to a network address allocated by the any slave device.
In this embodiment, the implementation of each unit may refer to a specific implementation process of the main device in the foregoing method embodiment, and details are not described here.
Referring to fig. 7, this figure is a schematic structural diagram of another network address assignment device according to an embodiment of the present application. The apparatus is applied to a slave device, and specifically, the distribution apparatus 700 may include: a second receiving unit 701, a confirmation unit 702, a third transmitting unit 703 and a third receiving unit 704. The second receiving unit 701 is configured to receive a first packet broadcast by the master device in S201, the determining unit 702 is configured to execute S202 in the foregoing method embodiment, the third sending unit is configured to execute S203 in the foregoing method embodiment, and the third receiving unit is configured to receive a third packet sent by the master device in S204 in the foregoing method embodiment.
A second receiving unit 701, configured to receive a first broadcast message, where the first message includes an address list, where the address list includes N allocated network addresses, and N is an integer greater than or equal to 1;
a determining unit 702, configured to determine a first network address according to the address list, where the first network address is an unallocated address determined according to the address list;
a third sending unit 703, configured to send a second packet to the master device, where the second packet includes the first network address;
a third receiving unit 704, configured to receive a third packet sent by the master device, where the third packet is used to confirm that the first network address is allocated.
In a possible implementation manner, the third packet includes the first network address and an identifier corresponding to the first network address, where the identifier corresponding to the first network address is used to identify that the first network address is allocated.
In a possible implementation, the apparatus may further include a storage unit 705. The storage unit 705 is configured to store the first network address in the third message and the identifier corresponding to the first network address.
In a possible implementation manner, the N allocated network addresses include N network addresses and N identifiers, one of the N network addresses corresponds to one of the N identifiers, and the identifier corresponding to one of the N network addresses is used to identify that the network address corresponding to the identifier is allocated.
In a possible implementation manner, the determining unit is specifically configured to, when the network address stored by the slave device is included in the address list and does not store an identifier corresponding to the network address, the slave device obtains, according to the address list, a first network address that is not included in the N allocated network addresses, where the N allocated network addresses do not include the identifier corresponding to the first network address; or
The first message further includes an identifier of the master device, and when the network address stored in the slave device and the identifier corresponding to the network address are included in the address list and the identifier of the master device corresponding to the network address is different from the identifier of the master device in the first message, the slave device selects a network address as a first network address according to a first random number and the address list, where the first network address is not included in the N allocated network addresses.
In a possible implementation manner, the determining unit is specifically configured to, when the network address stored by the slave device is included in the address list and does not store an identifier corresponding to the network address, select, by the slave device, one network address as a first network address according to a first random number and the address list, where the first network address is not included in the N allocated network addresses; or
The first message further includes an identifier of the master device, and when the network address stored in the slave device and the identifier corresponding to the network address are included in the address list and the identifier of the master device corresponding to the network address is different from the identifier of the master device in the first message, the slave device selects a network address as a first network address according to a first random number and the address list, where the first network address is not included in the N allocated network addresses.
Specifically, the determination unit may perform S303 or S402 in the above-described method embodiment.
In a possible implementation manner, the third sending unit includes:
a determining subunit, configured to determine a sending time according to the second random number;
and the sending subunit is configured to send the second packet to the master device according to the sending time.
Specifically, the third transmitting unit may perform S402 and S404 in the above-described method example.
In this embodiment, the implementation of each unit may refer to a specific implementation process of the slave device in the foregoing method embodiment, and details are not described here.
The hardware structure of the aforementioned apparatus 600 and apparatus 700 may be as shown in fig. 8, and fig. 8 is a schematic structural diagram of an apparatus provided in an embodiment of the present application.
Referring to fig. 8, an apparatus 800 includes: a processor 810, a communication interface 820, and a memory 830. Wherein the number of the processors 810 in the device 800 may be one or more, and fig. 8 illustrates one processor as an example. In the embodiment of the present application, the processor 810, the communication interface 820 and the memory 830 may be connected by a bus system or other means, wherein fig. 8 is exemplified by the connection via the bus system 840.
The processor 810 may be a Central Processing Unit (CPU), a Network Processor (NP), or a combination of a CPU and an NP. The processor 810 may further include a hardware chip. The hardware chip may be an application-specific integrated circuit (ASIC), a Programmable Logic Device (PLD), or a combination thereof. The PLD may be a Complex Programmable Logic Device (CPLD), a field-programmable gate array (FPGA), a General Array Logic (GAL), or any combination thereof.
Memory 830 may include volatile memory (RAM), such as random-access memory (RAM); the memory 830 may also include a non-volatile memory (SSD), such as a flash memory (flash memory), a hard disk (HDD) or a solid-state drive (SSD); memory 830 may also comprise a combination of the above types of memory.
Optionally, memory 830 stores an operating system and programs, executable modules or data structures, or subsets thereof or extensions thereof, wherein the programs may include various operating instructions for performing various operations. The operating system may include various system programs for implementing various basic services and for handling hardware-based tasks. The processor 810 can read the program in the memory 830 to implement the network address allocation method provided by the embodiment of the present application.
The bus system 840 may be a Peripheral Component Interconnect (PCI) bus, an Extended Industry Standard Architecture (EISA) bus, or the like. The bus system 840 may be divided into an address bus, a data bus, a control bus, and so on. For ease of illustration, only one thick line is shown in FIG. 8, but this is not intended to represent only one bus or type of bus.
Embodiments of the present application also provide a computer-readable storage medium, which includes instructions or a computer program, when the computer-readable storage medium runs on a computer, causes the computer to execute the method for network address allocation provided by the above embodiments.
Embodiments of the present application also provide a computer program product containing instructions or a computer program, which when run on a computer, cause the computer to perform the method for network address allocation provided in the above embodiments.
The terms "first," "second," "third," "fourth," and the like in the description and in the claims of the present application and in the drawings described above, if any, are used for distinguishing between similar elements and not necessarily for describing a particular sequential or chronological order. Furthermore, the terms "comprises," "comprising," and "having," and any variations thereof, are intended to cover a non-exclusive inclusion, such that a process, method, system, article, or apparatus that comprises a list of steps or elements is not necessarily limited to those steps or elements expressly listed, but may include other steps or elements not expressly listed or inherent to such process, method, article, or apparatus.
It is clear to those skilled in the art that, for convenience and brevity of description, the specific working processes of the above-described systems, apparatuses and units may refer to the corresponding processes in the foregoing method embodiments, and are not described herein again.
In the several embodiments provided in the present application, it should be understood that the disclosed system, apparatus and method may be implemented in other manners. For example, the above-described embodiments of the apparatus are merely illustrative, and for example, a division of a unit is only a logical division, and an actual implementation may have another division, for example, a plurality of units or components may be combined or integrated into another system, or some features may be omitted, or not executed. In addition, the shown or discussed mutual coupling or direct coupling or communication connection may be an indirect coupling or communication connection through some interfaces, devices or units, and may be in an electrical, mechanical or other form.
Units described as separate parts may or may not be physically separate, and parts displayed as units may or may not be physical units, may be located in one place, or may be distributed on a plurality of network units. Some or all of the units can be selected according to actual needs to achieve the purpose of the solution of the embodiment.
In addition, each service unit in the embodiments of the present application may be integrated into one processing unit, or each unit may exist alone physically, or two or more units are integrated into one unit. The integrated unit can be realized in a hardware form, and can also be realized in a software service unit form.
The integrated unit, if implemented in the form of a software business unit and sold or used as a stand-alone product, may be stored in a computer readable storage medium. Based on such understanding, the technical solution of the present application may be substantially implemented or contributed to by the prior art, or all or part of the technical solution may be embodied in a software product, which is stored in a storage medium and includes instructions for causing a computer device (which may be a personal computer, a server, or a network device) to execute all or part of the steps of the method of the embodiments of the present application. And the aforementioned storage medium includes: a U-disk, a removable hard disk, a Read-Only Memory (ROM), a Random Access Memory (RAM), a magnetic disk or an optical disk, and other various media capable of storing program codes.
Those skilled in the art will recognize that, in one or more of the examples described above, the services described in this disclosure may be implemented in hardware, software, firmware, or any combination thereof. When implemented in software, the services may be stored on or transmitted over as one or more instructions or code on a computer-readable medium. Computer-readable media includes both computer storage media and communication media including any medium that facilitates transfer of a computer program from one place to another. A storage media may be any available media that can be accessed by a general purpose or special purpose computer.
The above embodiments are intended to explain the objects, aspects and advantages of the present invention in further detail, and it should be understood that the above embodiments are merely illustrative of the present invention.
The above embodiments are only used to illustrate the technical solutions of the present application, and not to limit the same; although the present application has been described in detail with reference to the foregoing embodiments, it should be understood by those of ordinary skill in the art that: the technical solutions described in the foregoing embodiments may still be modified, or some technical features may be equivalently replaced; and the modifications or the substitutions do not make the essence of the corresponding technical solutions depart from the scope of the technical solutions of the embodiments of the present application.

Claims (26)

1. A method for assigning network addresses, comprising:
the master device broadcasts a first message, wherein the first message comprises an address list, the address list comprises N distributed network addresses, and N is an integer greater than or equal to 1;
the master device receives a second message sent by a slave device, wherein the second message comprises a first network address, and the first network address is an unallocated address determined according to the address list;
and the master equipment sends a third message to the slave equipment, wherein the third message is used for confirming the allocation of the first network address.
2. The method of claim 1, wherein the third packet comprises the first network address and an identifier corresponding to the first network address, and wherein the identifier corresponding to the first network address is used to identify that the first network address is allocated.
3. The method according to claim 1 or 2, wherein the N allocated network addresses comprise N network addresses and N identifiers, wherein a network address of the N network addresses corresponds to an identifier of the N identifiers in a one-to-one manner, and wherein the identifier corresponding to the network address of the N network addresses is used for identifying the network address corresponding to the identifier is allocated.
4. The method according to any of claims 1 to 3, wherein the first message further comprises an identification of the master device, the identification of the master device being used to identify the master device broadcasting the N allocated network addresses.
5. The method according to any of claims 1 to 4, wherein the third packet further comprises an identifier of the master device, and the identifier of the master device is used to identify the master device that assigns the first network address.
6. The method according to any of claims 1 to 5, wherein before the master device broadcasts the first message, the method further comprises:
the master device broadcasts a fourth message, wherein the fourth message is used for inquiring the distributed network address;
the master device acquires the N allocated network addresses from N slave devices, wherein the slave devices in the N slave devices are in one-to-one correspondence with the allocated network addresses in the N allocated network addresses;
and the master equipment acquires the address list according to the N allocated network addresses.
7. The method of claim 6, further comprising:
and the master device sends an identification corresponding to the network address allocated by any slave device to any slave device in the N slave devices.
8. A method for assigning network addresses, comprising:
receiving a first broadcast message from a device, where the first message includes an address list, where the address list includes N allocated network addresses, and N is an integer greater than or equal to 1;
the slave device determines a first network address according to the address list, wherein the first network address is an unallocated address determined according to the address list;
the slave device sends a second message to the master device, wherein the second message comprises the first network address;
and the slave equipment receives a third message sent by the master equipment, wherein the third message is used for confirming the allocation of the first network address.
9. The method of claim 8, wherein the third packet comprises the first network address and an identifier corresponding to the first network address, and wherein the identifier corresponding to the first network address is used to identify that the first network address is allocated.
10. The method according to claim 8 or 9, wherein the N allocated network addresses comprise N network addresses and N identifiers, one of the N network addresses corresponds to one of the N identifiers, and the identifier corresponding to one of the N network addresses is used to identify the network address corresponding to the identifier that is allocated.
11. The method of any of claims 8 to 10, wherein the determining, by the slave device, the first network address from the address list comprises:
the slave device acquires a first network address which is not contained in the N allocated network addresses according to the address list, wherein the N allocated network addresses do not comprise an identifier corresponding to the first network address; or
The first packet further includes an identifier of the master device, and when the slave device determines that the N allocated network addresses include the second network address of the slave device and an identifier corresponding to the second network address, and the identifier of the master device is different from the identifier of the master device corresponding to the second network address, the slave device acquires, according to the address list, a first network address that is not included in the N allocated network addresses.
12. The method of any of claims 8 to 10, wherein the determining, by the slave device, the first network address from the address list comprises:
the slave device selects a network address as a first network address according to a first random number and the address list, wherein the first network address is not included in the N allocated network addresses; or
The first packet further includes an identifier of the master device, and when the slave device determines that the N allocated network addresses include a second network address of the slave device and an identifier corresponding to the second network address, and the identifier of the master device is different from the identifier of the master device corresponding to the second network address, the slave device selects a network address as a first network address according to a first random number and the address list, where the first network address is not included in the N allocated network addresses.
13. The method according to any of claims 8 to 12, wherein sending, by the slave device, the second message to the master device comprises:
the slave equipment determines the sending time according to the second random number;
and the slave equipment sends the second message to the master equipment according to the sending time.
14. A network address allocation apparatus, wherein the apparatus is provided in a master device, and the apparatus comprises:
a broadcasting unit, configured to broadcast a first packet, where the first packet includes an address list, the address list includes N allocated network addresses, and N is an integer greater than or equal to 1;
a first receiving unit, configured to receive a second packet sent from a device, where the second packet includes a first network address, and the first network address is an unassigned address determined according to the address list;
a first sending unit, configured to send a third packet to the slave device, where the third packet is used to confirm that the first network address is allocated.
15. The apparatus of claim 14, wherein the third packet comprises the first network address and an identifier corresponding to the first network address, and wherein the identifier corresponding to the first network address is used to identify that the first network address is allocated.
16. The apparatus according to claim 14 or 15, wherein the N allocated network addresses comprise N network addresses and N identifiers, a network address in the N network addresses is in one-to-one correspondence with an identifier in the N identifiers, and the identifier corresponding to one network address in the N network addresses is used to identify the network address corresponding to the identifier is allocated.
17. The apparatus according to any of claims 14 to 16, wherein the first message further comprises an identifier of the master device, and wherein the identifier of the master device is used to identify the master device broadcasting the N allocated network addresses.
18. The apparatus according to any of claims 14 to 17, wherein the third packet further comprises an identifier of the master device, and the identifier of the master device is used to identify the master device that assigns the first network address.
19. The apparatus of any one of claims 14 to 18, further comprising:
the broadcasting unit is further configured to broadcast a fourth packet before broadcasting the first packet, where the fourth packet is used to query the allocated network address;
a first obtaining unit, configured to obtain the N allocated network addresses from N slave devices, where a slave device of the N slave devices corresponds to an allocated network address of the N allocated network addresses one to one;
a second obtaining unit, configured to obtain the address list according to the N allocated network addresses.
20. The apparatus of claim 19, further comprising:
a second sending unit, configured to send, to any slave device in the N slave devices, an identifier corresponding to a network address allocated by the any slave device.
21. A network address assignment device, provided in a slave device, comprising:
a second receiving unit, configured to receive a first broadcast message, where the first broadcast message includes an address list, the address list includes N allocated network addresses, and N is an integer greater than or equal to 1;
a determining unit, configured to determine a first network address according to the address list, where the first network address is an unallocated address determined according to the address list;
a third sending unit, configured to send a second packet to the master device, where the second packet includes the first network address;
a third receiving unit, configured to receive a third packet sent by the master device, where the third packet is used to confirm that the first network address is allocated.
22. The apparatus of claim 21, wherein the third packet comprises the first network address and an identifier corresponding to the first network address, and wherein the identifier corresponding to the first network address is used to identify that the first network address is allocated.
23. The apparatus according to claim 218 or 22, wherein the N allocated network addresses comprise N network addresses and N identities, wherein one of the N network addresses corresponds to one of the N identities, and wherein the identity corresponding to one of the N network addresses is used to identify the network address to which it corresponds to be allocated.
24. The apparatus according to any one of claims 21 to 23, wherein the determining unit is specifically configured to obtain, according to the address list, a first network address that is not included in the N allocated network addresses, where the N allocated network addresses do not include an identifier corresponding to the first network address; or
The first packet further includes an identifier of the master device, and the determining unit is specifically configured to select, when it is determined that the N allocated network addresses include the second network address of the slave device and an identifier corresponding to the second network address, and the identifier of the master device is different from the identifier of the master device corresponding to the second network address, one network address as the first network address according to the first random number and the address list, where the first network address is not included in the N allocated network addresses.
25. The apparatus according to any of the claims 21 to 23, wherein the determining unit is specifically configured to select a network address as the first network address according to the first random number and the address list, the first network address not being included in the N allocated network addresses; or
The first packet further includes an identifier of the master device, and the determining unit is specifically configured to select, when it is determined that the N allocated network addresses include the second network address of the slave device and an identifier corresponding to the second network address, and the identifier of the master device is different from the identifier of the master device corresponding to the second network address, one network address as the first network address according to the first random number and the address list, where the first network address is not included in the N allocated network addresses.
26. The apparatus according to any of claims 21 to 25, wherein the third sending unit comprises:
a determining subunit, configured to determine a sending time according to the second random number;
and the sending subunit is configured to send the second packet to the master device according to the sending time.
CN202010176511.4A 2020-03-13 2020-03-13 Network address allocation method and device Pending CN113395366A (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN202010176511.4A CN113395366A (en) 2020-03-13 2020-03-13 Network address allocation method and device

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN202010176511.4A CN113395366A (en) 2020-03-13 2020-03-13 Network address allocation method and device

Publications (1)

Publication Number Publication Date
CN113395366A true CN113395366A (en) 2021-09-14

Family

ID=77616118

Family Applications (1)

Application Number Title Priority Date Filing Date
CN202010176511.4A Pending CN113395366A (en) 2020-03-13 2020-03-13 Network address allocation method and device

Country Status (1)

Country Link
CN (1) CN113395366A (en)

Cited By (1)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN114866516A (en) * 2022-04-21 2022-08-05 重庆瑞盾科技发展有限公司 Multi-intelligent-device address setting method and multi-intelligent-device communication system

Cited By (1)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN114866516A (en) * 2022-04-21 2022-08-05 重庆瑞盾科技发展有限公司 Multi-intelligent-device address setting method and multi-intelligent-device communication system

Similar Documents

Publication Publication Date Title
CN106603735B (en) Method, device and system for distributing communication addresses of intelligent instrument
EP1864227B1 (en) Simple installation of devices on a network
KR101596078B1 (en) A method for configurating CANopen network, a method for operating a slave apparatus of CANopen network and an operating system of PLC apparatus using CANopen network
CN108401037B (en) Binding method, device and system of user terminal and equipment
US20130173835A1 (en) Controlling HDMI Devices Via Intelligent Emulation of Consumer Electronics Control (CEC) Protocol
EP3422655B1 (en) Method for managing address of meter device, and acquisition terminal and meter device
KR20130114892A (en) Method and apparatus for transmission of data between can network and ethernet network
CN110708400B (en) Network address allocation method, device, node equipment and storage medium
US20120008627A1 (en) Method and apparatus for assigning device identifier with collision avoidance
CN113395366A (en) Network address allocation method and device
CN111683159A (en) IP address allocation method, device, system and storage medium
CN102025797A (en) Address prefix processing method, device, system and network equipment
RU2010111754A (en) NETWORK SYSTEM
US9661597B2 (en) Method and device for deregistering terminal peripheral
CN106413125B (en) Data transmission method and device
CN108134858B (en) Networking method, server, client and network system
US7583690B2 (en) Allocation of station addresses to communication users in a bus system
CN115334041A (en) Method for automatically allocating addresses to communication equipment of master station and slave station, master station, slave station and system
CN112243042B (en) Distribution method, secure communication method, detection device, gateway module and system
CN110611589B (en) Control method and device of regional control system and air conditioning system
CN102348176B (en) Short message sending method and device
CN117201460A (en) Address allocation method and device, electronic equipment and medium
KR20190135052A (en) IP address setting method and device
CN110233909B (en) Address code allocation method and device for wireless gateway and network equipment
EP3179376A1 (en) Communication terminal device and transmission/reception method therefor, and recording medium containing computer program

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