CN111817885B - Network-based master-slave machine distinguishing and switching method and device - Google Patents
Network-based master-slave machine distinguishing and switching method and device Download PDFInfo
- Publication number
- CN111817885B CN111817885B CN202010595240.6A CN202010595240A CN111817885B CN 111817885 B CN111817885 B CN 111817885B CN 202010595240 A CN202010595240 A CN 202010595240A CN 111817885 B CN111817885 B CN 111817885B
- Authority
- CN
- China
- Prior art keywords
- host
- slave
- current
- machine
- master
- 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.)
- Active
Links
Images
Classifications
-
- H—ELECTRICITY
- H04—ELECTRIC COMMUNICATION TECHNIQUE
- H04L—TRANSMISSION OF DIGITAL INFORMATION, e.g. TELEGRAPHIC COMMUNICATION
- H04L41/00—Arrangements for maintenance, administration or management of data switching networks, e.g. of packet switching networks
- H04L41/06—Management of faults, events, alarms or notifications
- H04L41/0654—Management of faults, events, alarms or notifications using network fault recovery
- H04L41/0663—Performing the actions predefined by failover planning, e.g. switching to standby network elements
-
- H—ELECTRICITY
- H04—ELECTRIC COMMUNICATION TECHNIQUE
- H04L—TRANSMISSION OF DIGITAL INFORMATION, e.g. TELEGRAPHIC COMMUNICATION
- H04L1/00—Arrangements for detecting or preventing errors in the information received
- H04L1/004—Arrangements for detecting or preventing errors in the information received by using forward error control
- H04L1/0056—Systems characterized by the type of code used
- H04L1/0061—Error detection codes
Landscapes
- Engineering & Computer Science (AREA)
- Computer Networks & Wireless Communication (AREA)
- Signal Processing (AREA)
- Small-Scale Networks (AREA)
- Computer And Data Communications (AREA)
- Data Exchanges In Wide-Area Networks (AREA)
Abstract
The invention discloses a master-slave machine distinguishing and switching method and a master-slave machine distinguishing and switching device based on a network, wherein the method comprises the following steps: the current slave machine sends communication information to the current host machine based on network communication according to the head address of the host machine queue; if the current slave receives the feedback message of the host within the preset time and the feedback message passes the verification, judging that the current host is in a normal working state, otherwise, judging that the current host is in a fault working state; if the current host is in a fault working state, the current slave dequeues the head of line address in the host queue, and sends a host switching message to the alternative slave according to the new head of line address, and the alternative slave is switched to the new host; and the new host broadcasts host change information to the network, and the slave receiving the host change information updates the host queue, so that the address of the new host is positioned at the head of the host queue. By adopting the scheme, the performance and normal operation of the network system can be ensured.
Description
Technical Field
The invention relates to the field of network communication, in particular to a master-slave machine distinguishing and switching method and device based on a network.
Background
In engineering applications, a single computer has limited performance and resources, so a plurality of computers are usually configured to cooperate with each other through network communication, wherein one computer is a master computer and the other computer is a slave computer.
When a network system normally operates, the master and the slave, and the slave, generally communicate with each other, so that the identities of the two communication parties need to be determined to correctly transmit information. The scheme adopted in the prior art is judged through the IP address of the host, but when the host fails, the slave waits for the response of the host all the time, so that the phenomenon of no host exists in a network system, and the performance and the normal operation of the network system are influenced.
Disclosure of Invention
The invention aims to: the invention aims to provide a method and a device for distinguishing and switching a master machine and a slave machine based on a network.
The technical scheme is as follows: the invention provides a master-slave machine distinguishing and switching method based on a network, which comprises the following steps: the current slave machine sends communication information to the current host machine based on network communication according to the head address of the host machine queue; the head address of the host queue is the current host address, and the queue addresses are slave addresses in the network in sequence; if the current slave receives the feedback message of the host within the preset time and the feedback message passes the verification, judging that the current host is in a normal working state, otherwise, judging that the current host is in a fault working state; if the current host is in a fault working state, the current slave dequeues the head address in the host queue, and sends a host switching message to the alternative slave according to the new head address, and the alternative slave is switched to the new host; and the new host broadcasts host change information to the network, and the slave receiving the host change information updates the host queue so that the address of the new host is positioned at the head of the host queue.
Specifically, the current master machine adds the CRC field of the feedback message to the feedback message, the current slave machine calculates the CRC field of the feedback message, compares the calculated CRC field with the received CRC field, and if the calculated CRC field is the same as the received CRC field, the verification is passed; if not, waiting for the current host to resend the message.
Specifically, if the current slave receives the response message of the candidate slave within the predetermined time and the response message passes verification, otherwise, the current slave dequeues the head-of-line address in the master queue again and sends the master switching message to the second candidate slave according to the new head-of-line address.
Specifically, if a new device or a device whose working state is recovered to a normal working state is added to the network, a request is sent to the master, the master broadcasts an addition message to the network, and the slave receiving the addition message adds a device address to the master queue.
The invention provides a master-slave machine distinguishing and switching device based on a network, which comprises: communication unit, verification unit, switching unit, update unit, wherein:
the communication unit is used for sending communication information to the current host by the current slave machine based on network communication according to the head address of the host queue; the head address of the host queue is the current host address, and the queue addresses are slave addresses in the network in sequence;
the verification unit is used for judging that the current host is in a normal working state if the current slave receives the feedback message of the host within the preset time and the feedback message passes verification, and otherwise, judging that the current host is in a fault working state;
the switching unit is used for dequeuing the head address in the host queue by the current slave if the current host is in a fault working state, and sending a host switching message to the alternative slave according to the new head address, wherein the alternative slave is switched to the new host;
and the updating unit is used for broadcasting the host change information to the network by the new host, and updating the host queue by the slave receiving the host change information so that the address of the new host is positioned at the head of the host queue.
Specifically, the verification unit is configured to add a CRC field of the feedback message to the feedback message by the current master, calculate a CRC field of the feedback message by the current slave, compare the calculated CRC field with the received CRC field, and if the calculated CRC field is the same as the received CRC field, pass verification; if not, waiting for the current host to resend the message.
Specifically, the switching unit is configured to, if the current slave receives the response message of the candidate slave within the predetermined time and the response message passes verification, if the current slave does not receive the response message, the current slave dequeues the head-of-line address in the master queue again and sends the master switching message to the second candidate slave according to the new head-of-line address.
Specifically, the updating unit is configured to send a request to the master if a new device or a device whose faulty working state is recovered to a normal working state joins the network, the master broadcasts a join message to the network, and the slave that receives the join message joins the device address to the master queue.
Has the advantages that: compared with the prior art, the invention has the following remarkable advantages: the performance and normal operation of the network system can be ensured.
Drawings
Fig. 1 is a schematic flow chart of a master-slave machine discrimination and switching method based on a network according to the present invention.
Detailed Description
The technical scheme of the invention is further explained by combining the attached drawings.
Fig. 1 is a schematic flow chart of a method for determining and switching a master/slave device based on a network according to the present invention.
Step 1, the current slave machine sends communication information to the current host machine based on network communication according to the head address of the host machine queue.
In the embodiment of the invention, the head address of the host queue is the current host address, and the queue addresses are slave addresses in the network in sequence.
In a specific implementation, the host queue includes addresses of a plurality of computer devices in the network system, wherein the computer device address at the head of the queue is the address of the computer device which is the host of the network system at the moment, and the queue is the addresses of the slaves in the network system in turn. Therefore, the host identity is judged, and the performance and normal operation of the network system can be ensured.
And 2, if the current slave machine receives the feedback message of the host machine in the preset time and the feedback message passes verification, judging that the current host machine is in a normal working state, otherwise, judging that the current host machine is in a fault working state.
In the embodiment of the invention, the current host adds the CRC field of the feedback message into the feedback message, the current slave calculates the CRC field of the feedback message and compares the CRC field with the received CRC field, and if the CRC fields are the same, the verification is passed; if not, waiting for the current host to resend the message.
In specific implementation, the fault detection set for host fault discrimination includes timeout detection and CRC detection, where the timeout detection is to configure a predefined timeout interval (predetermined time) for the slave, and the time interval may be long enough to enable any device to respond normally, when the current host detects a transmission error or a fault, the communication information sent by the slave will not be received, and the slave will not respond to the slave, and such a timeout event will trigger the slave to determine that the current host is in a fault working state, and in addition, an address sent to the non-existing host will also generate timeout; and CRC detection, wherein the CRC field is a byte, the content of the whole feedback message is detected, the CRC field is added into the feedback message after being calculated by the current host, the slave can recalculate the CRC of the feedback message and compare the CRC with the value in the received CRC field, if the two values are different, the verification is failed, the slave waits for the current host to retransmit the message, if the message retransmitted by the host is not received again in preset time, and the current host can be judged to be in a fault working state according to overtime detection. Therefore, the performance and normal operation of the network system can be ensured.
And 3, if the current host is in a fault working state, the current slave dequeues the head of line address in the host queue, and sends a host switching message to the alternative slave according to the new head of line address, and the alternative slave is switched to the new host.
In a specific implementation, after the current master is determined to be in the fault working state, the current slave removes the address of the current master from the head of the queue from the master queue, and at this time, the address of the slave becomes a new head of the queue address instead of the address of the slave which becomes the head of the queue and is one bit behind the original head of the queue.
In the embodiment of the invention, if the current slave receives the response message of the alternative slave within the preset time and the response message passes the verification, otherwise, the current slave dequeues the head of line address in the master queue again and sends the master switching message to the second alternative slave according to the new head of line address.
In specific implementation, fault detection including timeout detection and CRC detection is also required for the candidate slave, and after all the fault detection passes, the current slave determines that the candidate slave is in a normal working state, and does not continue to send the master switching message from the address of the next slave in the master queue, but the candidate slave is switched to the new master. Therefore, the performance and normal operation of the network system can be ensured.
And 4, broadcasting the host change information to the network by the new host, and updating the host queue by the slave receiving the host change information so that the address of the new host is positioned at the head of the host queue.
In specific implementation, in order to ensure real-time performance of the network system, the slave machines in the network system need to update the master queue, the address of the new master is set at the head of the master queue, and the addresses of the devices in the original master queue before the new master are removed from the queue. At which point the system may resume normal operation.
In the embodiment of the invention, if a new device or a device with a fault working state recovered to a normal working state joins the network, a request is sent to the host, the host broadcasts a joining message to the network, and the slave receiving the joining message joins the device address to the host queue.
In particular implementations, the address of the new device is typically added to the tail of the host queue.
The invention also provides a master-slave machine distinguishing and switching device based on the network, which comprises: communication unit, verification unit, switching unit, update unit, wherein:
the communication unit is used for sending communication information to the current host by the current slave machine based on network communication according to the head address of the host queue; in the host queue, the head address is the current host address, and the queue addresses are slave addresses in the network in sequence;
the verification unit is used for judging that the current host is in a normal working state if the current slave receives the feedback message of the host within the preset time and the feedback message passes verification, and otherwise, judging that the current host is in a fault working state;
the switching unit is used for dequeuing the head address in the host queue by the current slave if the current host is in a fault working state, and sending a host switching message to the alternative slave according to the new head address, wherein the alternative slave is switched to the new host;
and the updating unit is used for broadcasting the host change information to the network by the new host, and updating the host queue by the slave receiving the host change information so that the address of the new host is positioned at the head of the host queue.
In the embodiment of the present invention, the verification unit is configured to add a CRC field of the feedback message to the feedback message by the current master, calculate a CRC field of the feedback message by the current slave, compare the calculated CRC field with the received CRC field, and if the calculated CRC field is the same as the received CRC field, pass the verification; if not, waiting for the current host to resend the message.
In the embodiment of the present invention, the switching unit is configured to, if the current slave receives the response message of the candidate slave within the predetermined time and the response message passes verification, if the response message passes verification, dequeue the head-of-line address in the master queue again by the current slave, and send the master switching message to the second candidate slave according to the new head-of-line address.
In the embodiment of the present invention, the updating unit is configured to send a request to the host if a new device or a device whose failure working state is recovered to a normal working state joins the network, where the host broadcasts a join message to the network, and the slave that receives the join message joins the device address to the host queue.
Claims (8)
1. A master-slave machine distinguishing and switching method based on a network is characterized by comprising the following steps:
the current slave machine sends communication information to the current host machine based on network communication according to the head address of the host machine queue; the head address of the host queue is the current host address, and the queue addresses are slave addresses in the network in sequence;
if the current slave receives the feedback message of the host within the preset time and the feedback message passes the verification, judging that the current host is in a normal working state, otherwise, judging that the current host is in a fault working state;
if the current host is in a fault working state, the current slave dequeues the head of line address in the host queue, and sends a host switching message to the alternative slave according to the new head of line address, and the alternative slave is switched to the new host;
and the new host broadcasts host change information to the network, and the slave receiving the host change information updates the host queue, so that the address of the new host is positioned at the head of the host queue.
2. The network-based master-slave discrimination and handover method of claim 1, wherein the feedback message authentication is successful, comprising:
the current host adds the CRC field of the feedback message into the feedback message, the current slave calculates the CRC field of the feedback message and compares the CRC field with the received CRC field, and if the CRC fields are the same, the verification is passed; if not, waiting for the current host to resend the message.
3. The network-based master-slave machine distinguishing and switching method according to claim 1, wherein the sending of the master machine switching message to the alternative slave machine, the alternative slave machine switching to the new master machine, comprises:
and if the current slave receives the response message of the alternative slave within the preset time and the response message passes verification, the alternative slave is switched to the new master, otherwise, the current slave dequeues the head address in the master queue again and sends the master switching message to the second alternative slave according to the new head address.
4. The method according to claim 1, wherein if a new device or a device whose working state is recovered to a normal working state due to a failure joins the network, the request is sent to the master, the master broadcasts a join message to the network, and the slave receiving the join message joins the device address to the master queue.
5. A master-slave machine distinguishing and switching device based on a network is characterized by comprising: communication unit, verification unit, switching unit, update unit, wherein:
the communication unit is used for sending communication information to the current host by the current slave machine based on network communication according to the head address of the host queue; the head address of the host queue is the current host address, and the queue addresses are slave addresses in the network in sequence;
the verification unit is used for judging that the current host is in a normal working state if the current slave machine receives the feedback message of the host in the preset time and the feedback message passes verification, and otherwise, judging that the current host is in a fault working state;
the switching unit is used for dequeuing the head of line address in the host queue by the current slave machine if the current host machine is in a fault working state, sending a host switching message to the alternative slave machine according to the new head of line address, and switching the alternative slave machine into a new host machine;
and the updating unit is used for broadcasting the host change information to the network by the new host, and updating the host queue by the slave which receives the host change information so that the address of the new host is positioned at the head of the host queue.
6. The network-based master-slave machine distinguishing and switching device according to claim 5, wherein the verification unit is configured to add a CRC field of the feedback message to the feedback message by the current master machine, calculate the CRC field of the feedback message by the current slave machine, compare the calculated CRC field with the received CRC field, and if the calculated CRC field is the same as the received CRC field, pass the verification; if not, waiting for the current host to resend the message.
7. The network-based master-slave machine distinguishing and switching device according to claim 5, wherein the switching unit is configured to switch the candidate slave machine to the new master machine if the current slave machine receives the response message of the candidate slave machine within the predetermined time and the response message is verified to be passed, and otherwise, the current slave machine dequeues the head-of-line address in the master machine queue again and sends the master machine switching message to the second candidate slave machine according to the new head-of-line address.
8. The device for judging and switching between master and slave machines based on network as claimed in claim 5, wherein the updating unit is configured to send a request to the master machine if a new device or a device whose working status is recovered to the normal working status joins the network, the master machine broadcasts a join message to the network, and the slave machine which receives the join message joins the device address to the master machine queue.
Priority Applications (1)
Application Number | Priority Date | Filing Date | Title |
---|---|---|---|
CN202010595240.6A CN111817885B (en) | 2020-06-28 | 2020-06-28 | Network-based master-slave machine distinguishing and switching method and device |
Applications Claiming Priority (1)
Application Number | Priority Date | Filing Date | Title |
---|---|---|---|
CN202010595240.6A CN111817885B (en) | 2020-06-28 | 2020-06-28 | Network-based master-slave machine distinguishing and switching method and device |
Publications (2)
Publication Number | Publication Date |
---|---|
CN111817885A CN111817885A (en) | 2020-10-23 |
CN111817885B true CN111817885B (en) | 2022-07-26 |
Family
ID=72855429
Family Applications (1)
Application Number | Title | Priority Date | Filing Date |
---|---|---|---|
CN202010595240.6A Active CN111817885B (en) | 2020-06-28 | 2020-06-28 | Network-based master-slave machine distinguishing and switching method and device |
Country Status (1)
Country | Link |
---|---|
CN (1) | CN111817885B (en) |
Families Citing this family (4)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
CN112404656B (en) * | 2020-11-11 | 2022-09-23 | 唐山松下产业机器有限公司 | Multi-welder coordinated control method and system |
CN113048615B (en) * | 2021-03-29 | 2022-04-22 | 珠海格力电器股份有限公司 | Air conditioning system, communication control method and device thereof, storage medium and processor |
CN113271223B (en) * | 2021-05-13 | 2022-06-21 | 石家庄通合电子科技股份有限公司 | Unified communication management method for charging module and terminal equipment |
CN115277285B (en) * | 2022-05-26 | 2024-04-09 | 广东逸动科技有限公司 | Communication method, communication device, communication system, and computer-readable storage medium |
Citations (2)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
CN104410557A (en) * | 2014-12-25 | 2015-03-11 | 深圳中科讯联科技有限公司 | Dynamic networking method and communication method based on RS-485 |
CN107682247A (en) * | 2017-09-15 | 2018-02-09 | 广东芬尼克兹节能设备有限公司 | A kind of high efficiency communication method of main frame and multiple slaves |
Family Cites Families (1)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
US8135025B2 (en) * | 2009-06-03 | 2012-03-13 | Microsoft Corporation | Asynchronous communication in an unstable network |
-
2020
- 2020-06-28 CN CN202010595240.6A patent/CN111817885B/en active Active
Patent Citations (2)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
CN104410557A (en) * | 2014-12-25 | 2015-03-11 | 深圳中科讯联科技有限公司 | Dynamic networking method and communication method based on RS-485 |
CN107682247A (en) * | 2017-09-15 | 2018-02-09 | 广东芬尼克兹节能设备有限公司 | A kind of high efficiency communication method of main frame and multiple slaves |
Also Published As
Publication number | Publication date |
---|---|
CN111817885A (en) | 2020-10-23 |
Similar Documents
Publication | Publication Date | Title |
---|---|---|
CN111817885B (en) | Network-based master-slave machine distinguishing and switching method and device | |
EP1919138B1 (en) | A method for implementing backup of the uplink | |
US6760766B1 (en) | Data transmission method and device | |
CN110661702B (en) | Link backup method and device and computer readable storage medium | |
CN106817264B (en) | Method, device and system for detecting link fault | |
US7522598B2 (en) | System and method of protecting an IGMP proxy | |
KR101419579B1 (en) | Method for enabling faster recovery of client applications in the event of server failure | |
JP2004032224A (en) | Server takeover system and method thereof | |
JP5363658B1 (en) | RELAY DEVICE, RELAY DEVICE CONTROL METHOD, AND NETWORK SYSTEM | |
US8243736B2 (en) | Packet capturing device | |
US20190166042A1 (en) | Method for data transmitting, centralized controller, forwarding plane device and communication apparatus | |
CN101808021A (en) | Fault detection method, device and system, message statistical method and node equipment | |
CN111585797B (en) | Ethernet link switching method, device, equipment and computer readable storage medium | |
CN111682982A (en) | Path fault detection method, device, equipment, system and storage medium | |
CN109104319B (en) | Data storage device and method | |
CN104104596A (en) | Intelligent resilient framework (IRF) split processing method and device | |
EP1901497A1 (en) | Apparatus for low latency communications through an alternate path | |
CN109495311B (en) | Network fault detection method and device | |
US6724731B1 (en) | Radio communication system and control method, and information processing apparatus used therein | |
CN109428814B (en) | Multicast traffic transmission method, related equipment and computer readable storage medium | |
CN106992878B (en) | Multicast detection method and device | |
CN112468363B (en) | Method and device for detecting link connectivity | |
CN115152192A (en) | PCE controlled network reliability | |
CN110011914B (en) | Management message forwarding method and device | |
JP7120678B1 (en) | Communication processing device, communication processing system, failure notification method and failure notification 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 | ||
GR01 | Patent grant | ||
GR01 | Patent grant |