Method for realizing power line carrier communication ad hoc network

文档序号:1101249 发布日期:2020-09-25 浏览:9次 中文

阅读说明:本技术 电力线载波通信自组网实现方法 (Method for realizing power line carrier communication ad hoc network ) 是由 张有清 姚华文 于 2020-06-12 设计创作,主要内容包括:本发明公开了一种电力线载波通信自组网实现方法,通过主机发送组网命令,未组网从机进行组网回复,主机接收到组网回复后发送握手命令,从机接收到握手命令后接收组网地址,并进行握手回复,主机接收到握手回复后确认从机完成组网。本发明利用从机的唯一的身份识别编号,产生不同的随机数,再根据随机数产生不同的延时时间,当主机发起组网时,每次只有一个最快的从机进行组网回复,实现从机的依次组网,提高组网的可靠性和稳定性;在通信丢包,主机未收到握手回复时,进行广播命令对应的从机进行解网,避免主机将相同的组网地址分配给多台从机,组网速度快,组网成功率高,组网更稳定。(The invention discloses a method for realizing power line carrier communication ad hoc network, which comprises the steps of sending a networking command through a host, carrying out networking reply by a slave which is not networked, sending a handshake command after the host receives the networking reply, receiving a networking address by the slave after the slave receives the handshake command, carrying out handshake reply, and confirming that the slave completes networking after the host receives the handshake reply. According to the invention, different random numbers are generated by using the unique identification numbers of the slave machines, different delay times are generated according to the random numbers, when the host initiates networking, only one fastest slave machine performs networking reply each time, so that the slave machines are sequentially networked, and the reliability and stability of networking are improved; when the communication packet is lost and the host does not receive the handshake reply, the slave machine corresponding to the broadcast command is disconnected, the host machine is prevented from distributing the same networking address to a plurality of slave machines, the networking speed is high, the networking success rate is high, and the networking is more stable.)

1. A method for realizing power line carrier communication ad hoc network is characterized by comprising the following steps:

s1: the host broadcasts and sends a networking command, and waits for a networking reply of the slave which is not networked;

s2: after the slave machines receive the networking command of the host machine, each slave machine detects the networking state of the slave machine;

s3: if the slave computer detects that the slave computer is not networked, generating a random number according to the MAC address of the slave computer, and setting delay time according to the random number;

s4: the slave machines which are not networked reply the networking after the delay time, wherein the slave machine which firstly replies the networking is the first networking slave machine;

s5: after receiving the networking reply of the first networking slave machine, the host machine sends a handshake command to the first networking slave machine;

s6: after receiving the handshake command, the first networking slave receives and stores the networking address allocated to the first networking slave by the host, and performs handshake reply on the handshake command;

s7: after receiving the handshake reply of the first networking slave, the host saves the MAC address of the slave to the networking MAC address corresponding to the networking address allocated to the first networking slave in the address data list, marks the slave as being already networked and completes the networking of the slave;

s8: and repeating the steps S1-S7, and sequentially networking the slave machines until networking of all the slave machines is completed.

2. The power line carrier communication ad hoc network implementing method of claim 1, wherein each slave includes a MAC address and a networking address; the MAC address is an identity identification number which is unique for each slave machine and different from other slave machines, is composed of 8-bit 16-system data, and has a value range of 0x00000001-0 xFFFFFFFE; when the slave is in a networking state, the networking address is an address allocated to the slave by the host, and the range is 1-60; when the slave is in the non-networking state, the networking address is 0.

3. The method for implementing the power line carrier communication ad hoc network according to claim 2, wherein the step S3 specifically includes: the slave computer generates a random number as a first random number according to the MAC address of the slave computer; setting a random seed, and generating a second random number through the system clock beat; performing superposition operation on the first random number and the second random number to obtain a networking random number; taking the networking random number as the delay time of the slave machine, wherein the unit is millisecond; the formula for calculating networking random numbers is as follows: (MACID > > i) &0x000000F) 60+ Tick 60%, wherein MACID is MAC address of slave machine, the range is 0x00000001-0 xFFFFFFFFFE, i is 0-7, Tick is random seed; the maximum waiting time is 1019 milliseconds, the minimum waiting time is 0 milliseconds, and the time delay time of each slave machine is different from 0 to 1019 milliseconds, so that the slave machines are staggered and sequentially networked.

4. The method for implementing the power line carrier communication ad hoc network according to claim 2, wherein in step S4, the content of the networking reply is the MAC address of the slave, the networking reply is sent in a broadcast manner, if the other slave receives the networking reply of the first networking slave within the delay time, the networking reply is not performed, and if the networking reply of the first networking slave is not received, the networking reply is performed.

5. The power line carrier communication ad hoc network implementing method of claim 2, wherein the address data list of the host stores networking addresses and corresponding networking MAC addresses; when the networking address is allocated to the networking slave machine, the networking MAC address stores the MAC address corresponding to the networking slave machine, and when the networking address is not allocated, the data 0xFFFFFFFF corresponding to the networking address is stored, which represents that the networking address is not occupied.

6. The method according to claim 5, wherein in step S7, if the host loses packet due to the host communication packet and the host does not receive the handshake reply of the first networking slave, the first networking slave fails to perform networking, and the host sends a network release command to perform network release, so that the first networking slave occupying the networking address automatically releases the networking address and enters the networking waiting state.

7. The method for implementing power line carrier communication ad hoc network as claimed in claim 6, wherein said de-networking comprises:

s71: the host searches an index value with a networking MAC address value of 0xFFFFFFFF from the address data list to obtain a networking address corresponding to the networking MAC address, wherein the networking address is the networking address needing to be released by network release;

s72: the host broadcasts for several times by using the networking address and initiates a network release command;

s73: and after receiving the network disconnection command, the slave machine occupying the networking address performs network disconnection, sets the networking address of the slave machine to be 0, restores to the non-networking state, waits for the host machine to send the networking command, and performs networking.

8. The power line carrier communication ad hoc network implementation method of claim 1, wherein the master and the slave form a ring network connected in series after networking is completed.

Technical Field

The invention relates to a networking method, in particular to a method for realizing power line carrier communication ad hoc network.

Background

Power line carrier communication is a communication method specific to a power system, and is a technique for transmitting an analog or digital signal by a carrier method. The power line carrier has the biggest advantages of no need of erecting a network again, low cost and convenient arrangement and maintenance. In a conventional power line carrier system, because a concentrator is far away from a part of sub-nodes, communication can be performed only through one-stage or multi-stage relay, generally, a routing path for communication between all the sub-nodes and a main node is established in advance, and when a communication demand exists, the established path is directly used for data transmission.

However, the power line is not a good communication medium, and the communication link between nodes has asymmetry, that is, the communication quality of the uplink and downlink communication links is related to a specific environment, and there may be a large difference, and particularly, there is a case where the quality of the link from the main node to the sub-node is good, and the communication quality of the reverse link is poor, which results in a data transmission failure when returning along the original path, so it is very necessary to provide a method for implementing the power line carrier communication ad hoc network to improve the reliability and stability of the power line carrier communication network and reduce the network deployment cost.

Disclosure of Invention

The invention provides a method for realizing a power line carrier communication ad hoc network, which generates different random numbers by using unique identification numbers of slave machines, generates different delay time according to the random numbers, and only one fastest slave machine replies the networking each time when a host machine initiates the networking, thereby realizing the sequential networking of the slave machines and improving the reliability and stability of the networking.

The technical scheme adopted by the invention for solving the technical problems is to provide a method for realizing the power line carrier communication ad hoc network, which comprises the following steps: s1: the host broadcasts and sends a networking command, and waits for a networking reply of the slave which is not networked; s2: after the slave machines receive the networking command of the host machine, each slave machine detects the networking state of the slave machine; s3: if the slave computer detects that the slave computer is not networked, generating a random number according to the MAC address of the slave computer, and setting delay time according to the random number; s4: the slave machines which are not networked reply the networking after the delay time, wherein the slave machine which firstly replies the networking is the first networking slave machine; s5: after receiving the networking reply of the first networking slave machine, the host machine sends a handshake command to the first networking slave machine; s6: after receiving the handshake command, the first networking slave receives and stores the networking address allocated to the first networking slave by the host, and performs handshake reply on the handshake command; s7: after receiving the handshake reply of the first networking slave, the host saves the MAC address of the slave to the networking MAC address corresponding to the networking address allocated to the first networking slave in the address data list, marks the slave as being already networked and completes the networking of the slave; s8: and repeating the steps S1-S7, and sequentially networking the slave machines until networking of all the slave machines is completed.

Further, each slave comprises a MAC address and a networking address; the MAC address is an identity identification number which is unique for each slave machine and different from other slave machines, is composed of 8-bit 16-system data, and has a value range of 0x00000001-0 xFFFFFFFE; when the slave is in a networking state, the networking address is an address allocated to the slave by the host, and the range is 1-60; when the slave is in the non-networking state, the networking address is 0.

Further, the step S3 specifically includes: the slave computer generates a random number as a first random number according to the MAC address of the slave computer; setting a random seed, and generating a second random number through the system clock beat; performing superposition operation on the first random number and the second random number to obtain a networking random number; taking the networking random number as the delay time of the slave machine, wherein the unit is millisecond; the formula for calculating networking random numbers is as follows: (MACID > > i) &0x000000F) 60+ Tick 60%, wherein MACID is MAC address of slave machine, the range is 0x00000001-0 xFFFFFFFFFE, i is 0-7, Tick is random seed; the maximum waiting time is 1019 milliseconds, the minimum waiting time is 0 milliseconds, and the time delay time of each slave machine is different from 0 to 1019 milliseconds, so that the slave machines are staggered and sequentially networked.

Further, in step S4, the content of the networking reply is the MAC address of the slave, the networking reply is sent in a broadcast manner, if the other slave receives the networking reply of the first networking slave within the delay time, the networking reply is not performed, and if the networking reply of the first networking slave is not received, the networking reply is performed.

Further, the address data list of the host stores networking addresses and corresponding networking MAC addresses; when the networking address is allocated to the networking slave machine, the networking MAC address stores the MAC address corresponding to the networking slave machine, and when the networking address is not allocated, the data 0xFFFFFFFF corresponding to the networking address is stored, which represents that the networking address is not occupied.

Further, in step S7, if the host loses packet in communication and the host does not receive the handshake reply of the first networking slave, the first networking slave fails to perform networking, and the host sends a network disconnection command to perform network disconnection, so that the first networking slave occupying the networking address automatically releases the networking address and enters the to-be-networked state.

Further, the de-screening tool comprises: s71: the host searches an index value with a networking MAC address value of 0xFFFFFFFF from the address data list to obtain a networking address corresponding to the networking MAC address, wherein the networking address is the networking address needing to be released by network release; s72: the host broadcasts for several times by using the networking address and initiates a network release command; s73: and after receiving the network disconnection command, the slave machine occupying the networking address performs network disconnection, sets the networking address of the slave machine to be 0, restores to the non-networking state, waits for the host machine to send the networking command, and performs networking.

Furthermore, the host and the slave form a serial ring network after networking is completed.

Compared with the prior art, the invention has the following beneficial effects: the invention provides a method for realizing power line carrier communication ad hoc network, which utilizes the unique identification number of a slave machine to generate different random numbers, and then generates different delay time according to the random numbers, when a host initiates networking, only one fastest slave machine carries out networking reply each time, thereby realizing the sequential networking of the slave machines and improving the reliability and stability of the networking; when the communication packet is lost and the host does not receive the handshake reply, the slave machine corresponding to the broadcast command is disconnected, the host machine is prevented from distributing the same networking address to a plurality of slave machines, the networking speed is high, the networking success rate is high, and the networking is more stable.

Drawings

Fig. 1 is a flowchart of a method for implementing a power line carrier communication ad hoc network in an embodiment of the present invention;

fig. 2 is a schematic diagram of a networking structure of a power line carrier communication ad hoc network implementation method in the embodiment of the present invention.

Detailed Description

The invention is further described below with reference to the figures and examples.

Fig. 1 is a flowchart of a method for implementing a power line carrier communication ad hoc network in an embodiment of the present invention.

Referring to fig. 1, a method for implementing a power line carrier communication ad hoc network according to an embodiment of the present invention includes the following steps:

s1: the host broadcasts and sends a networking command, and waits for a networking reply of the slave which is not networked;

s2: after the slave machines receive the networking command of the host machine, each slave machine detects the networking state of the slave machine;

s3: if the slave computer detects that the slave computer is not networked, generating a random number according to the MAC address of the slave computer, and setting delay time according to the random number;

s4: the slave machines which are not networked reply the networking after the delay time, wherein the slave machine which firstly replies the networking is the first networking slave machine;

s5: after receiving the networking reply of the first networking slave machine, the host machine sends a handshake command to the first networking slave machine;

s6: after receiving the handshake command, the first networking slave receives and stores the networking address allocated to the first networking slave by the host, and performs handshake reply on the handshake command;

s7: after receiving the handshake reply of the first networking slave, the host saves the MAC address of the slave to the networking MAC address corresponding to the networking address allocated to the first networking slave in the address data list, marks the slave as being already networked and completes the networking of the slave;

s8: and repeating the steps S1-S7, and sequentially networking the slave machines until networking of all the slave machines is completed.

Each slave machine comprises an MAC address and a networking address; the MAC address is an identity identification number which is unique for each slave machine and different from other slave machines, is composed of 8-bit 16-system data, and has a value range of 0x00000001-0 xFFFFFFFE; when the slave is in a networking state, the networking address is an address allocated to the slave by the host, and the range is 1-60; when the slave is in the non-networking state, the networking address is 0.

The address data list of the host saves the networking address and the corresponding networking MAC address; when the networking address is allocated to the networking slave machine, the networking MAC address stores the MAC address corresponding to the networking slave machine, and when the networking address is not allocated, the data 0xFFFFFFFF corresponding to the networking address is stored, which represents that the networking address is not occupied.

Specifically, in the method for implementing a power line carrier communication ad hoc network according to the embodiment of the present invention, step S3 specifically includes: the slave computer generates a random number as a first random number according to the MAC address of the slave computer; setting a random seed, and generating a second random number through the system clock beat; performing superposition operation on the first random number and the second random number to obtain a networking random number; taking the networking random number as the delay time of the slave machine, wherein the unit is millisecond;

the formula for calculating networking random numbers is as follows:

Rand=((MACID>>i)&0x000000F)*60+Tick%60

wherein, MACID is MAC address of the slave machine, the range is 0x00000001-0xFFFFFFFE, the right shift number i is 0-7, and Tick is random seed;

the maximum waiting time delay is 1019 milliseconds, the range is exceeded, and the networking time is too slow; the minimum waiting time delay is 0 millisecond, the time delay time of each slave machine is different time delays between 0 and 1019 milliseconds, and staggered and sequential networking of the slave machines is realized.

Specifically, in the method for implementing power line carrier communication ad hoc network according to the embodiment of the present invention, in step S4, the content of the networking reply is the MAC address of the slave, the networking reply is sent in a broadcast manner, if the other slave receives the networking reply of the first networking slave within the delay time, the networking reply is not performed, and if the networking reply of the first networking slave is not received, the networking reply is performed.

In step S7, if the host communication packet is lost and the host does not receive the handshake reply of the first networking slave, the first networking slave fails to perform networking, and the host sends a network release command to perform network release, so that the first networking slave occupying the networking address automatically releases the networking address and enters the networking state to be networked.

The de-screening tool includes:

s71: the host searches an index value with a networking MAC address value of 0xFFFFFFFF from the address data list to obtain a networking address corresponding to the networking MAC address, wherein the networking address is the networking address needing to be released by network release;

s72: the host broadcasts for several times by using the networking address and initiates a network release command;

s73: and after receiving the network disconnection command, the slave machine occupying the networking address performs network disconnection, sets the networking address of the slave machine to be 0, restores to the non-networking state, waits for the host machine to send the networking command, and performs networking.

Referring to fig. 2, in the method for implementing the power line carrier communication ad hoc network according to the embodiment of the present invention, after networking of the master and the slave is completed, a serial ring network is formed.

In summary, in the method for implementing the power line carrier communication ad hoc network according to the embodiment of the present invention, different random numbers are generated by using unique identification numbers of the slaves, different delay times are generated according to the random numbers, when the master initiates networking, only one fastest slave performs networking reply each time, so that sequential networking of the slaves is implemented, and reliability and stability of networking are improved; when the communication packet is lost and the host does not receive the handshake reply, the slave machine corresponding to the broadcast command is disconnected, the host machine is prevented from distributing the same networking address to a plurality of slave machines, the networking speed is high, the networking success rate is high, and the networking is more stable.

Although the present invention has been described with respect to the preferred embodiments, it will be understood by those skilled in the art that various changes in form and details may be made therein without departing from the spirit and scope of the invention as defined by the appended claims.

9页详细技术资料下载
上一篇:一种医用注射器针头装配设备
下一篇:NFC装置输出信号控制方法及终端设备、介质和电子设备

网友询问留言

已有0条留言

还没有人留言评论。精彩留言会获得点赞!

精彩留言,会给你点赞!