A method and device for switching between master and standby
By negotiating decision-making APs between on-board APs on the train and determining the operating role based on the scanned signal strength and timestamp, automatic main and backup switching when the train is turned back is achieved, and the problems of manual switching and high cost in the existing technology are solved, reducing deployment costs and improving efficiency.
Patent Information
- Application Number
- CN202210738495.2
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2022-06-27
- Publication Date
- 2025-05-02
- Estimated Expiration
- 2042-06-27
AI Technical Summary
In the prior art, subway trains need to manually switch the front AP and rear AP when turning back, resulting in high network deployment costs and different on-board systems need to be developed to adapt to subway lines in each city.
By broadcasting negotiation messages between on-board APs, the decision AP is negotiated. At the beginning, the decision AP is the primary AP and a Socket connection is established with another on-board AP to notify it to be a backup AP. After that, the decision AP scans the signal strength and timestamp according to the set period, determines its own running role (front AP or rear AP), and automatically switches the main and backup.
Automatic master-shop switching without R&D personnel developing specific vehicle systems is realized, reducing network deployment costs and improving switching efficiency.
Smart Images

Figure CN115277374B_ABST
Abstract
Description
Technical Field
[0001] The present application relates to the field of wireless technology, and in particular to a method and device for active / standby switching. Background Art
[0002] Mesh networks can provide wireless access, and multi-hop Mesh links can be established through access points (APs) in Mesh networks. Based on this feature of Mesh networks, Mesh networks are widely used in subways, railways and other scenarios.
[0003] Taking the subway scenario as an example, several trackside APs are deployed beside the subway tracks, and a vehicle-mounted AP is deployed at both ends of each train. Along the direction of the train, the vehicle-mounted AP deployed at the rear of the train (here it can be called the rear AP) is usually used as the main AP, and Mesh links can be established with multiple trackside APs. One of the Mesh links with the best link quality is used as the main Mesh link for related data transmission, and the other Mesh links are used as backup Mesh links.
[0004] When the train needs to turn back, the original main AP needs to be switched to the backup AP (which can be called the front AP at this time), and the original backup AP needs to be switched to the main AP. At present, the driver and passengers usually trigger the on-board system manually to complete the switching operation between the front AP and the rear AP. For example, the driver and passengers trigger the on-board system by inserting a key to complete the switching operation between the front AP and the rear AP.
[0005] Since each subway line in each city uses a different on-board system, the above-mentioned active-standby switching method requires R&D personnel to develop different on-board systems, which leads to higher network deployment costs. Summary of the invention
[0006] In order to overcome the problems existing in the related art, the present application provides a primary-standby switching method and device.
[0007] According to a first aspect of an embodiment of the present application, a primary-standby switching method is provided, the method being applied to a vehicle-mounted AP, the method comprising:
[0008] After power-on, broadcast the first negotiation message carrying its own MAC address;
[0009] Upon receiving a second negotiation message broadcasted by another onboard AP on the train where the AP is located after being powered on, judging whether the AP is a decision-making AP according to the MAC address and the MAC address of the other onboard AP carried in the second negotiation message;
[0010] When the judgment result is yes, determine that the AP is the main AP, work on the Mesh link established between the AP and the main trackside AP, and establish a Socket connection with the other vehicle-mounted AP, and notify the other vehicle-mounted AP to be the backup AP;
[0011] According to the set period, obtain the locally recorded MAC addresses of all first trackside APs whose signal strengths are not less than the set threshold scanned by the self within the set period and the first timestamp when the self scans each first trackside AP, as well as the MAC addresses of all second trackside APs whose signal strengths are not less than the set threshold scanned by the other vehicle-mounted AP within the set period and sent by the other vehicle-mounted AP and the second timestamp when the self receives the MAC address of each second trackside AP;
[0012] Determine its own operation role according to the acquired MAC addresses and first timestamps of all first trackside APs and the MAC addresses and second timestamps of all second trackside APs;
[0013] When the determined running role is the vehicle head AP, if it is the main AP, it notifies the other vehicle-mounted AP to upgrade to the main AP, and downgrades itself to the backup AP, disconnects the currently working Mesh link, and does not perform any operation if it is the backup AP;
[0014] When the determined operating role is the rear AP, if it is the main AP, no operation is performed; if it is the backup AP, the other vehicle-mounted AP is notified to downgrade to the backup AP, and the AP is upgraded to the main AP, working on the Mesh link established between the AP and the currently determined main trackside AP.
[0015] According to a second aspect of an embodiment of the present application, a master-slave switching device is provided, the device being applied to a vehicle-mounted AP, the device comprising:
[0016] A broadcast module, used for broadcasting a first negotiation message carrying its own MAC address after power-on;
[0017] A judgment module, configured to judge whether the AP is a decision-making AP according to the MAC address and the MAC address of the other on-board AP carried in the second negotiation message when receiving a second negotiation message broadcasted by another on-board AP on the train where the AP is located after being powered on;
[0018] The first processing module is used to determine that the first processing module is a main AP when the judgment result of the judgment module is yes, work on the Mesh link established between the first processing module and the determined main trackside AP, and establish a Socket connection with the other vehicle-mounted AP to notify the other vehicle-mounted AP to be a backup AP;
[0019] An acquisition module is used to acquire, according to a set period, the locally recorded MAC addresses of all first trackside APs scanned by itself within the set period and whose signal strength is not less than a set threshold and a first timestamp when each first trackside AP is scanned by itself, as well as the MAC addresses of all second trackside APs scanned by the other vehicle-mounted AP within the set period and whose signal strength is not less than the set threshold and a second timestamp when each second trackside AP is received by itself;
[0020] A determination module, used to determine its own operation role according to the acquired MAC addresses and all first timestamps of all first trackside APs, and the MAC addresses and all second timestamps of all second trackside APs;
[0021] The first switching module is used for, when the operating role determined by the determination module is the vehicle head AP, if the vehicle head AP is the main AP, notifying the other vehicle-mounted AP to upgrade to the main AP, and downgrading itself to the backup AP, disconnecting the currently working Mesh link, and if the vehicle head AP is the backup AP, not performing any operation;
[0022] The second switching module is used to, when the determined operating role is the rear AP, if it is the main AP, do not perform any operation; if it is the backup AP, notify the other vehicle-mounted AP to downgrade to the backup AP, and upgrade itself to the main AP, working on the Mesh link established between itself and the currently determined main trackside AP.
[0023] The technical solution provided by the embodiments of the present application may have the following beneficial effects:
[0024] In an embodiment of the present application, two on-board APs deployed on a train negotiate a decision-making AP through negotiation messages broadcast to each other. Initially, the decision-making AP serves as the main AP, and the decision-making AP establishes a Socket connection with the other on-board AP to notify the other on-board AP to serve as the backup AP; thereafter, the decision-making AP decides its own operating role (front AP or rear AP) according to a set period and based on the locally recorded MAC address of at least one first trackside AP scanned by itself within the set period with a signal strength not less than a set threshold and the first timestamp when it scans each first trackside AP, as well as the MAC address of at least one second trackside AP scanned by another on-board AP within the set period with a signal strength not less than the set threshold and the second timestamp when it receives the MAC address of each second trackside AP; finally, based on the operating role, decides whether to perform master-slave switching.
[0025] In the above-mentioned active-standby switching mode, the decision-making AP automatically implements the active-standby switching, without the need for R&D personnel to develop corresponding vehicle-mounted systems, which greatly saves network deployment costs.
[0026] It should be understood that the foregoing general description and the following detailed description are exemplary and explanatory only and are not restrictive of the present application. BRIEF DESCRIPTION OF THE DRAWINGS
[0027] The accompanying drawings, which are incorporated in the specification and constitute a part of this application, illustrate embodiments consistent with the application and, together with the description, serve to explain the principles of the application.
[0028] Figure 1 A schematic diagram of a process flow of a master-slave switching method provided in an embodiment of the present application;
[0029] Figure 2 A schematic diagram of the Mesh network architecture provided in the embodiment of the present application;
[0030] Figure 3 A schematic diagram of the structure of a master-slave switching device provided in an embodiment of the present application;
[0031] Figure 4 A schematic diagram of the structure of an electronic device provided in an embodiment of the present application. DETAILED DESCRIPTION
[0032] Exemplary embodiments will be described in detail herein, examples of which are shown in the accompanying drawings. When the following description refers to the drawings, the same numbers in different drawings represent the same or similar elements unless otherwise indicated. The implementations described in the following exemplary embodiments do not represent all implementations consistent with the present application. Instead, they are merely examples of devices and methods consistent with some aspects of the present application as detailed in the appended claims.
[0033] The terms used in this application are for the purpose of describing specific embodiments only and are not intended to limit this application. The singular forms of "a", "said" and "the" used in this application and the appended claims are also intended to include plural forms unless the context clearly indicates other meanings. It should also be understood that the term "and / or" used herein refers to and includes any or all possible combinations of one or more associated listed items.
[0034] It should be understood that, although the terms first, second, third, etc. may be used in the present application to describe various information, these information should not be limited to these terms. These terms are only used to distinguish the same type of information from each other. For example, without departing from the scope of the present application, the first information may also be referred to as the second information, and similarly, the second information may also be referred to as the first information. Depending on the context, the words "if" or "if" as used herein may be interpreted as "at the time of" or "when...".
[0035] Next, the embodiments of the present application are described in detail.
[0036] The present application embodiment provides a primary-standby switching method, which is applied to a vehicle-mounted AP, such as Figure 1 As shown, the method may include the following steps:
[0037] S11. After power-on, broadcast a first negotiation message carrying its own MAC address.
[0038] S12. When receiving the second negotiation message broadcasted by another onboard AP on the train where the AP is located after power-on, determine whether the AP is the decision-making AP based on its own MAC address and the MAC address of the other onboard AP carried in the second negotiation message; when the judgment result is yes, execute steps S13 to S16, or execute steps S13, 14, S15 and S17; when the judgment result is no, execute step S18.
[0039] S13, determine itself as the main AP, work on the Mesh link established between itself and the determined main trackside AP, and establish a Socket connection with another vehicle-mounted AP, and notify the other vehicle-mounted AP to serve as the backup AP.
[0040] S14. According to the set period, obtain the locally recorded MAC addresses of all first trackside APs scanned by itself within the set period and whose signal strength is not less than the set threshold and the first timestamp when itself scans each first trackside AP, as well as the MAC addresses of all second trackside APs scanned by another vehicle-mounted AP within the set period and whose signal strength is not less than the set threshold and the second timestamp when itself receives the MAC address of each second trackside AP.
[0041] S15. Determine its own operating role according to the acquired MAC addresses and first timestamps of all first trackside APs and the acquired MAC addresses and second timestamps of all second trackside APs.
[0042] S16. When the determined running role is the vehicle-mounted AP, if it is the main AP, it notifies another vehicle-mounted AP to upgrade to the main AP, and downgrades itself to the backup AP, disconnecting the currently working Mesh link. If it is the backup AP, it does not perform any operation.
[0043] S17. When the determined operating role is the rear AP, if it is the main AP, no operation is performed; if it is the backup AP, another vehicle-mounted AP is notified to downgrade to the backup AP, and it is upgraded to the main AP, working on the Mesh link established between itself and the currently determined main trackside AP.
[0044] S18, waiting for another vehicle-mounted AP to establish a Socket connection with itself, and when establishing a Socket connection with another vehicle-mounted AP and being notified by the other vehicle-mounted AP that it is a backup AP, sending the MAC address of the second trackside AP scanned by itself and whose signal strength is not less than the set threshold to the other vehicle-mounted AP, and when being notified by the other vehicle-mounted AP that it has been upgraded to the main AP, upgrading itself to the main AP and working on the Mesh link established between itself and the currently determined main trackside AP, or when being notified by the other vehicle-mounted AP that it has been downgraded to the backup AP, downgrading itself to the backup AP and disconnecting the currently working Mesh link.
[0045] It should be noted that, in the embodiment of the present application, after the vehicle-mounted AP executes the above step S11, another vehicle-mounted AP will subsequently receive the first negotiation message, and the subsequent processing flow is similar to the processing flow after the vehicle-mounted AP receives the second negotiation message, which will not be described in detail here.
[0046] Specifically, in the above step S12, the vehicle-mounted AP can determine whether it is a decision-making AP in the following manner:
[0047] Determine whether its own MAC address is greater than the MAC address of another vehicle-mounted AP carried in the second negotiation message;
[0048] When the judgment result is yes, determine itself as a decision-making AP;
[0049] When the judgment result is no, it is determined that the AP itself is not a decision-making AP.
[0050] It should be noted that, in the embodiment of the present application, the first negotiation message and the second negotiation message may both be data messages or may both be control messages.
[0051] In the above step S13, when establishing a socket connection with another vehicle-mounted AP, the vehicle-mounted AP may first send a Socket connection request to the other vehicle-mounted AP; then, upon receiving a Socket connection response sent by the other vehicle-mounted AP, the vehicle-mounted AP determines that the Socket connection has been successfully established with the other vehicle-mounted AP.
[0052] Moreover, in the above step S13, when the vehicle-mounted AP notifies another vehicle-mounted AP that it is a standby AP, it can specifically send a first notification message to the other vehicle-mounted AP through a Socket connection to indicate that the other vehicle-mounted AP is a standby AP. Subsequently, when the other vehicle-mounted AP receives the first notification message, it determines that it is a standby AP.
[0053] It should be noted that in the above step S13, how the onboard AP determines the AP beside the main track is a prior art and will not be described in detail here. In the above step S14, the above setting period can be set according to the operation of the train where the onboard AP is located, for example, the duration of the setting period is 1 minute.
[0054] It should be noted that in the embodiment of the present application, for the vehicle-mounted AP, after determining that it is the main AP, it will record the MAC address of the first trackside AP whose signal strength is not less than the set threshold and the first timestamp when it scans the first trackside AP. For example, the vehicle-mounted AP can record the MAC address of the relevant first trackside AP and the relevant first timestamp in the form of a list.
[0055] For another vehicle-mounted AP, after determining that it is a backup AP, once it finds that it has scanned a second trackside AP with a signal strength not less than a set threshold, it will send the MAC address of the second trackside AP to the vehicle-mounted AP, and the vehicle-mounted AP will record the MAC address of the second trackside AP and the second timestamp when the MAC address of the second trackside AP is received. Here, another vehicle-mounted AP can carry the MAC address of the second trackside AP in a notification message and send it to the vehicle-mounted AP via a Socket connection. The vehicle-mounted AP can also record the MAC address of the relevant second trackside AP and the relevant second timestamp in a list.
[0056] In this way, once the set period is reached, the vehicle-mounted AP will obtain the locally recorded MAC address of at least one first trackside AP scanned by itself within the set period and whose signal strength is not less than the set threshold and the first timestamp when it scans each first trackside AP, as well as the MAC address of at least one second trackside AP scanned by another vehicle-mounted AP within the set period and whose signal strength is not less than the set threshold and the second timestamp when it receives the MAC address of each second trackside AP, so as to facilitate the subsequent vehicle-mounted AP to decide its own operating role (front AP or rear AP) and perform relevant master-slave switching operations based on the operating role.
[0057] Here, the threshold value may be set by an administrator based on an experience value and configured in advance on the vehicle-mounted AP and another vehicle-mounted AP.
[0058] Specifically, in the above step S15, the vehicle-mounted AP can determine its own operating role in the following manner:
[0059] For the MAC address of the first trackside AP currently traversed, determine whether there is a MAC address that is the same as the MAC address of the first trackside AP currently traversed among all the MAC addresses of the second trackside APs;
[0060] When the judgment result is yes, if the first timestamp corresponding to the MAC address of the first trackside AP currently traversed is earlier than the second timestamp corresponding to the MAC address that is the same as the MAC address of the first trackside AP currently traversed among all the MAC addresses of the second trackside APs, then the own role evaluation variable is increased by 1;
[0061] If the first timestamp corresponding to the MAC address of the first trackside AP currently traversed is later than the second timestamp corresponding to the MAC address that is the same as the MAC address of the first trackside AP currently traversed among all the MAC addresses of the second trackside APs, then the role evaluation variable of another vehicle-mounted AP is increased by 1;
[0062] When the judgment result is no, no operation is performed;
[0063] Determine its own running role based on its own role evaluation variable obtained after traversing all the MAC addresses of the first trackside APs and the role evaluation variable of another vehicle-mounted AP;
[0064] When the MAC address of the first trackside AP currently traversed is the first MAC address, its own role evaluation variable and the role evaluation variable of another vehicle-mounted AP are both 0.
[0065] Here, the role evaluation variable is mainly used to evaluate the operation role of the corresponding vehicle-mounted AP.
[0066] More specifically, in this determination method, the vehicle-mounted AP can determine its own operating role in any of the following ways:
[0067] The first method: compare the size of its own role evaluation variable with the role evaluation variable of another vehicle-mounted AP; if its own role evaluation variable is greater than the role evaluation variable of another vehicle-mounted AP, determine its own operating role as the front AP; if its own role evaluation variable is less than the role evaluation variable of another vehicle-mounted AP, determine its own operating role as the rear AP; if its own role evaluation variable is equal to the role evaluation variable of another vehicle-mounted AP, determine that its own operating role is the same as the operating role determined last time.
[0068] The second method: calculate the difference between its own role evaluation variable and the role evaluation variable of another vehicle-mounted AP to obtain a first operation result; perform a quotient operation on the first operation result and its own role evaluation variable to obtain a second operation result; determine whether the second operation result is not less than a set value; when the judgment result is yes, determine its own operating role as the front AP; when the judgment result is no, determine its own operating role as the rear AP.
[0069] It should be noted that, in the second method, the above-mentioned setting value can be set by the administrator according to the actual scanning conditions of the vehicle-mounted AP and another vehicle-mounted AP and configured in advance on the vehicle-mounted AP.
[0070] It should be further explained that in an embodiment of the present application, after the vehicle-mounted AP executes the above-mentioned step S15, in order to save the storage resources of the vehicle-mounted AP, the vehicle-mounted AP can delete the MAC address and the related first timestamp of the relevant first trackside AP recorded within the current set period, as well as the MAC address and the related second timestamp of the relevant second trackside AP after determining its own operating role.
[0071] Specifically, in the above step S16, when the vehicle-mounted AP notifies another vehicle-mounted AP to upgrade to the main AP, it can send a second notification message to the other vehicle-mounted AP through a Socket connection to instruct the other vehicle-mounted AP to upgrade to the main AP. Subsequently, when the other vehicle-mounted AP receives the second notification message, it will upgrade itself to the main AP.
[0072] In the above step S17, when the vehicle-mounted AP notifies another vehicle-mounted AP to downgrade to a standby AP, it can specifically send a third notification message to the other vehicle-mounted AP through a Socket connection to instruct the other vehicle-mounted AP to downgrade to a standby AP. Subsequently, when the other vehicle-mounted AP receives the third notification message, it will downgrade itself to a standby AP.
[0073] The above-mentioned active / standby switching method is described in detail below with reference to specific embodiments.
[0074] like Figure 2 As shown, it is assumed that onboard AP1 and onboard AP2 are deployed at both ends of train 1, and the corresponding trackside APs include trackside AP1, trackside AP2, trackside AP3, trackside AP4, etc. ( Figure 2 Only 4 trackside APs are shown).
[0075] After being powered on, both the vehicle-mounted AP1 and the vehicle-mounted AP2 will broadcast a negotiation message carrying their respective MAC addresses.
[0076] For example, vehicle AP1 broadcasts negotiation message 1 carrying its own MAC address (eg, MAC1); vehicle AP2 broadcasts negotiation message 2 carrying its own MAC address (eg, MAC2). Here, negotiation message 1 and negotiation message 2 are both data messages.
[0077] Taking the vehicle-mounted AP1 as an example, when receiving the negotiation message 2 broadcast by AP2, it determines whether its own MAC address (ie, MAC1) is greater than the MAC address of the vehicle-mounted AP2 (ie, MAC2) carried in the negotiation message 2.
[0078] Assuming that MAC1 is greater than MAC2, the judgment result is yes. At this time, the vehicle-mounted AP1 determines itself as the decision-making AP, and also determines itself as the main AP. It works on the Mesh link established between itself and the determined main trackside AP, and establishes a Socket connection with the vehicle-mounted AP2, notifying the vehicle-mounted AP2 to be the backup AP.
[0079] Afterwards, the vehicle-mounted AP1 will record the MAC address of the first trackside AP whose signal strength is not less than a set threshold (for example, 30DB) and the first timestamp when it scans the first trackside AP.
[0080] Assuming that the first set period is reached (for example, the corresponding duration is 1 minute), the on-board AP1 will obtain the locally recorded MAC addresses of all first trackside APs whose signal strength is not less than the set threshold scanned by itself within the first set period and the first timestamp when it scans each first trackside AP (as shown in Table 1 below), as well as the MAC addresses of all second trackside APs whose signal strength is not less than the set threshold scanned by on-board AP2 within the first set period and the second timestamp when it receives the MAC address of each second trackside AP (as shown in Table 2 below).
[0081] Timestamp MAC address of the trackside AP 09:21:35 Trackside AP1-MAC address 09:21:40 Trackside AP2-MAC address 09:21:50 Trackside AP3-MAC address
[0082] Table 1
[0083] Timestamp MAC address of the trackside AP 09:21:41 Trackside AP1-MAC address 09:21:49 Trackside AP2-MAC address 09:21:56 Trackside AP3-MAC address
[0084] Table 2
[0085] Here, the MAC addresses of these second trackside APs are sent by the vehicle-mounted AP2 after establishing a Socket connection with the vehicle-mounted AP and being notified by the vehicle-mounted AP1 that it is a backup AP.
[0086] Next, the vehicle-mounted AP1 will traverse the MAC addresses in Table 1. Every time it traverses to a MAC address in Table 1, it will perform the following operations:
[0087] Determine whether there is a MAC address in Table 2 that is the same as the currently traversed MAC address;
[0088] When the judgment result is yes, if the first timestamp corresponding to the currently traversed MAC address is earlier than the second timestamp corresponding to the MAC address in Table 2 that is the same as the currently traversed MAC address, then add 1 to the own role evaluation variable;
[0089] If the first timestamp corresponding to the currently traversed MAC address is later than the second timestamp corresponding to the MAC address in Table 2 that is the same as the currently traversed MAC address, then the role evaluation variable of the vehicle-mounted AP2 is increased by 1;
[0090] When the judgment result is no, no operation is performed;
[0091] When the currently traversed MAC address is the first MAC address, the role evaluation variable of the vehicle-mounted AP1 and the role evaluation variable of the vehicle-mounted AP2 are both 0.
[0092] After traversing all the MAC addresses in Table 1, the vehicle-mounted AP1 can obtain its own role evaluation variable as 3, and the role evaluation variable of the vehicle-mounted AP2 is 0.
[0093] The vehicle-mounted AP1 will compare the size of its own role assessment variable with that of the vehicle-mounted AP2, and find that the comparison result is that its own role assessment variable is greater than the role assessment variable of the vehicle-mounted AP2. At this time, it is determined that it is the front AP, and the above Tables 1 and 2 are deleted. In addition, since it is the main AP, the vehicle-mounted AP1 will notify the vehicle-mounted AP2 to upgrade to the main AP, and downgrade itself to the backup AP, disconnecting the currently working Mesh link.
[0094] Subsequently, it is assumed that a certain set period has been reached, and it is assumed that the on-board AP1 determines its own operating role as the rear AP based on the acquired local records of the MAC addresses of all the first trackside APs scanned by itself within the set period and the first timestamp when it scans each first trackside AP, and the MAC addresses of all the second trackside APs scanned by on-board AP2 within the set period and the second timestamp when it receives the MAC address of each second trackside AP, then the on-board AP1 will delete the relevant MAC addresses and relevant timestamps recorded within this period, and if it is a backup AP, the on-board AP1 will notify the on-board AP2 to downgrade to a backup AP, and upgrade itself to a main AP, working on the Mesh link established between itself and the currently determined main trackside AP.
[0095] It can be seen from the above technical scheme that in the embodiment of the present application, the two on-board APs deployed on the train negotiate a decision-making AP through negotiation messages broadcast to each other. Initially, the decision-making AP serves as the main AP, and the decision-making AP establishes a Socket connection with the other on-board AP to notify the other on-board AP to be the backup AP; thereafter, the decision-making AP decides its own operating role (front AP or rear AP) according to the set period and based on the locally recorded MAC address of at least one first trackside AP scanned by itself within the set period with a signal strength not less than a set threshold and the first timestamp when it scans each first trackside AP, as well as the MAC address of at least one second trackside AP scanned by another on-board AP within the set period with a signal strength not less than a set threshold and the second timestamp when it receives the MAC address of each second trackside AP; finally, based on the operating role, decide whether to perform master-slave switching.
[0096] In the above-mentioned active-standby switching mode, the decision-making AP automatically implements the active-standby switching, without the need for R&D personnel to develop corresponding vehicle-mounted systems, which greatly saves network deployment costs.
[0097] Based on the same inventive concept, the present application also provides a master-slave switching device, which is applied to a vehicle-mounted AP, and its structural diagram is shown as follows: Figure 3 As shown, specifically including:
[0098] A broadcast module 31, configured to broadcast a first negotiation message carrying its own MAC address after power-on;
[0099] The judging module 32 is used to judge whether the AP is a decision-making AP according to the MAC address and the MAC address of the other on-board AP carried in the second negotiation message when receiving the second negotiation message broadcasted by another on-board AP on the train where the AP is located after being powered on;
[0100] The first processing module 33 is used to determine that it is a main AP when the judgment result of the judgment module is yes, work on the Mesh link established between itself and the determined main trackside AP, and establish a Socket connection with the other vehicle-mounted AP to notify the other vehicle-mounted AP to be a backup AP;
[0101] The acquisition module 34 is used to acquire, according to a set period, the locally recorded MAC addresses of all first trackside APs whose signal strengths are not less than a set threshold scanned by the self within the set period and the first timestamp when the self scans each first trackside AP, as well as the MAC addresses of all second trackside APs whose signal strengths are not less than the set threshold scanned by the another vehicle-mounted AP within the set period and sent by the another vehicle-mounted AP and the second timestamp when the self receives the MAC address of each second trackside AP;
[0102] A determination module 35, configured to determine its own operation role according to the acquired MAC addresses and first timestamps of all first trackside APs, and the MAC addresses and second timestamps of all second trackside APs;
[0103] The first switching module 36 is used for notifying the other vehicle-mounted AP to upgrade to the main AP and downgrading itself to the standby AP when the operating role determined by the determining module is the vehicle head AP, if it is the main AP, and disconnecting the currently working Mesh link; if it is the standby AP, no operation is performed;
[0104] The second switching module 37 is used to, when the determined operating role is the rear AP, if it is the main AP, do not perform any operation; if it is the backup AP, notify the other vehicle-mounted AP to downgrade to the backup AP, and upgrade itself to the main AP, working on the Mesh link established between itself and the currently determined main trackside AP.
[0105] Preferably, the judging module 32 is specifically configured to judge whether it is a decision-making AP in the following manner:
[0106] Determine whether the MAC address is greater than the MAC address of the other vehicle-mounted AP carried in the second negotiation message;
[0107] When the judgment result is yes, determine itself as a decision-making AP;
[0108] When the judgment result is no, it is determined that the AP itself is not a decision-making AP.
[0109] Preferably, the device further comprises:
[0110] The second processing module ( Figure 3 ), which is used to wait for the other vehicle-mounted AP to establish a Socket connection with itself when the judgment result of the judgment module is no; after establishing a Socket connection with the other vehicle-mounted AP and being notified by the other vehicle-mounted AP that it is a backup AP, send the MAC address of the second trackside AP scanned by itself and the signal strength of which is not less than the set threshold to the other vehicle-mounted AP; when being notified by the other vehicle-mounted AP to upgrade to the main AP, upgrade itself to the main AP and work on the Mesh link established between itself and the currently determined main trackside AP, or, when being notified by the other vehicle-mounted AP to downgrade to the backup AP, downgrade itself to the backup AP and disconnect the currently working Mesh link.
[0111] Preferably, the determining module 35 is specifically used for:
[0112] For the MAC address of the first trackside AP currently traversed, determine whether there is a MAC address that is the same as the MAC address of the first trackside AP currently traversed among all the MAC addresses of the second trackside APs;
[0113] When the judgment result is yes, if the first timestamp corresponding to the MAC address of the first trackside AP currently traversed is earlier than the second timestamp corresponding to the MAC address that is the same as the MAC address of the first trackside AP currently traversed among all the MAC addresses of the second trackside APs, then the own role evaluation variable is increased by 1;
[0114] If the first timestamp corresponding to the MAC address of the first trackside AP currently traversed is later than the second timestamp corresponding to the MAC address that is the same as the MAC address of the first trackside AP currently traversed among all the MAC addresses of the second trackside APs, then the role evaluation variable of the other vehicle-mounted AP is increased by 1;
[0115] When the judgment result is no, no operation is performed;
[0116] Determine its own operation role according to its own role evaluation variable obtained when traversing all MAC addresses of the first trackside APs and the role evaluation variable of the other vehicle-mounted AP;
[0117] When the MAC address of the first trackside AP currently traversed is the first MAC address, its own role evaluation variable and the role evaluation variable of another vehicle-mounted AP are both 0.
[0118] Preferably, the determining module 35 is specifically used for:
[0119] comparing the magnitudes of the own role assessment variable and the role assessment variable of the other vehicle-mounted AP;
[0120] If the comparison result is that the role evaluation variable of the own vehicle is greater than the role evaluation variable of the other vehicle-mounted AP, then the own operating role is determined to be the vehicle-front AP;
[0121] If the comparison result is that the role evaluation variable of the own AP is less than the role evaluation variable of the other vehicle-mounted AP, then the own operating role is determined to be the rear AP;
[0122] If the comparison result is that the own role evaluation variable is equal to the role evaluation variable of the other vehicle-mounted AP, it is determined that the own operating role is the same as the operating role determined last time.
[0123] Preferably, the determining module 35 is specifically used for:
[0124] Calculating a difference between the role evaluation variable of the own AP and the role evaluation variable of the other vehicle-mounted AP to obtain a first operation result;
[0125] Performing a quotient operation on the first operation result and the own role evaluation variable to obtain a second operation result;
[0126] Determine whether the second operation result is not less than a set value;
[0127] When the judgment result is yes, the operating role of the vehicle is determined to be the front AP;
[0128] When the judgment result is no, the operating role of the vehicle is determined to be the rear AP.
[0129] It can be seen from the above technical scheme that in the embodiment of the present application, the two on-board APs deployed on the train negotiate a decision-making AP through negotiation messages broadcast to each other. Initially, the decision-making AP serves as the main AP, and the decision-making AP establishes a Socket connection with the other on-board AP to notify the other on-board AP to be the backup AP; thereafter, the decision-making AP decides its own operating role (front AP or rear AP) according to the set period and based on the locally recorded MAC address of at least one first trackside AP scanned by itself within the set period with a signal strength not less than a set threshold and the first timestamp when it scans each first trackside AP, as well as the MAC address of at least one second trackside AP scanned by another on-board AP within the set period with a signal strength not less than a set threshold and the second timestamp when it receives the MAC address of each second trackside AP; finally, based on the operating role, decide whether to perform master-slave switching.
[0130] In the above-mentioned active-standby switching mode, the decision-making AP automatically implements the active-standby switching, without the need for R&D personnel to develop corresponding vehicle-mounted systems, which greatly saves network deployment costs.
[0131] The present application also provides an electronic device, such as Figure 4 As shown, it includes a processor 41 and a machine-readable storage medium 42, wherein the machine-readable storage medium 42 stores machine-executable instructions that can be executed by the processor 41, and the processor 41 is prompted by the machine-executable instructions to implement the steps of the above-mentioned active-standby switching method.
[0132] The machine-readable storage medium may include a random access memory (RAM) or a non-volatile memory (NVM), such as at least one disk storage. Optionally, the machine-readable storage medium may also be at least one storage device located away from the processor.
[0133] The above-mentioned processor can be a general-purpose processor, including a central processing unit (CPU), a network processor (NP), etc.; it can also be a digital signal processor (DSP), an application specific integrated circuit (ASIC), a field programmable gate array (FPGA) or other programmable logic devices, discrete gate or transistor logic devices, discrete hardware components.
[0134] In another embodiment provided in the present application, a computer-readable storage medium is provided, in which a computer program is stored. When the computer program is executed by a processor, the steps of the above-mentioned active-standby switching method are implemented.
[0135] The above description is only a preferred embodiment of the present application and is not intended to limit the present application. Any modifications, equivalent substitutions, improvements, etc. made within the spirit and principles of the present application shall be included in the scope of protection of the present application.
Claims
1. A method for switching between active and standby devices, characterized in that: The method is applied to a vehicle-mounted AP, and the method includes: After power-on, broadcast the first negotiation message carrying its own MAC address; Upon receiving a second negotiation message broadcasted by another onboard AP on the train where the AP is located after being powered on, judging whether the AP is a decision-making AP according to the MAC address and the MAC address of the other onboard AP carried in the second negotiation message; When the judgment result is yes, determine that the AP is the main AP, work on the Mesh link established between the AP and the main trackside AP, and establish a Socket connection with the other vehicle-mounted AP, and notify the other vehicle-mounted AP to be the backup AP; According to the set period, obtain the locally recorded MAC addresses of all first trackside APs scanned by the self within the set period whose signal strength is not less than the set threshold and the first timestamp when the self scans each first trackside AP, as well as the MAC addresses of all second trackside APs scanned by the other vehicle-mounted AP within the set period whose signal strength is not less than the set threshold and the second timestamp when the self receives the MAC address of each second trackside AP; Determine its own operation role according to the acquired MAC addresses and first timestamps of all first trackside APs and the MAC addresses and second timestamps of all second trackside APs; When the determined running role is the vehicle head AP, if it is the main AP, it notifies the other vehicle-mounted AP to upgrade to the main AP, and downgrades itself to the backup AP, disconnects the currently working Mesh link, and does not perform any operation if it is the backup AP; When the determined operating role is the rear AP, if it is the main AP, no operation is performed; if it is the backup AP, the other vehicle-mounted AP is notified to downgrade to the backup AP, and the AP is upgraded to the main AP, working on the Mesh link established between the AP and the currently determined main trackside AP.
2. The method according to claim 1, characterized in that Determine whether it is a decision-making AP by the following methods: Determine whether the MAC address is greater than the MAC address of the other vehicle-mounted AP carried in the second negotiation message; When the judgment result is yes, determine itself as a decision-making AP; When the judgment result is no, it is determined that the AP itself is not a decision-making AP.
3. The method according to claim 1 or 2, characterized in that: The method further comprises: When the judgment result is no, wait for the other vehicle-mounted AP to establish a Socket connection with itself; After establishing a Socket connection with the other vehicle-mounted AP and being notified by the other vehicle-mounted AP that it is a backup AP, sending the MAC address of the second trackside AP whose signal strength scanned by itself is not less than the set threshold to the other vehicle-mounted AP; When notified by the other vehicle-mounted AP to upgrade itself to the main AP, it upgrades itself to the main AP and works on the Mesh link established between itself and the currently determined main trackside AP, or, When notified by the other vehicle-mounted AP to downgrade itself to a standby AP, it downgrades itself to a standby AP and disconnects the currently working Mesh link.
4. The method according to claim 1, characterized in that: Determine its own operation role according to the acquired MAC addresses and first timestamps of all first trackside APs and the MAC addresses and second timestamps of all second trackside APs, specifically including: For the MAC address of the first trackside AP currently traversed, determine whether there is a MAC address that is the same as the MAC address of the first trackside AP currently traversed among all the MAC addresses of the second trackside APs; When the judgment result is yes, if the first timestamp corresponding to the MAC address of the first trackside AP currently traversed is earlier than the second timestamp corresponding to the MAC address that is the same as the MAC address of the first trackside AP currently traversed among all the MAC addresses of the second trackside APs, then the own role evaluation variable is increased by 1; If the first timestamp corresponding to the MAC address of the first trackside AP currently traversed is later than the second timestamp corresponding to the MAC address that is the same as the MAC address of the first trackside AP currently traversed among all the MAC addresses of the second trackside APs, then the role evaluation variable of the other vehicle-mounted AP is increased by 1; When the judgment result is no, no operation is performed; Determine its own operation role according to its own role evaluation variable obtained when traversing all MAC addresses of the first trackside APs and the role evaluation variable of the other vehicle-mounted AP; When the MAC address of the first trackside AP currently traversed is the first MAC address, its own role evaluation variable and the role evaluation variable of another vehicle-mounted AP are both 0.
5. The method according to claim 4, characterized in that Determining the operation role of the self according to the self role evaluation variable obtained when traversing all the MAC addresses of the first trackside APs and the role evaluation variable of the other vehicle-mounted AP specifically includes: comparing the magnitudes of the own role assessment variable and the role assessment variable of the other vehicle-mounted AP; If the comparison result is that the role evaluation variable of the own vehicle is greater than the role evaluation variable of the other vehicle-mounted AP, then the own operating role is determined to be the vehicle-front AP; If the comparison result is that the role evaluation variable of the own AP is less than the role evaluation variable of the other vehicle-mounted AP, then the own operating role is determined to be the rear AP; If the comparison result is that the own role evaluation variable is equal to the role evaluation variable of the other vehicle-mounted AP, it is determined that the own operating role is the same as the operating role determined last time.
6. The method according to claim 4, characterized in that Determining the operation role of the self according to the self role evaluation variable obtained when traversing all the MAC addresses of the first trackside APs and the role evaluation variable of the other vehicle-mounted AP specifically includes: Calculating a difference between the role evaluation variable of the own AP and the role evaluation variable of the other vehicle-mounted AP to obtain a first operation result; Performing a quotient operation on the first operation result and the own role evaluation variable to obtain a second operation result; Determine whether the second operation result is not less than a set value; When the judgment result is yes, the operating role of the vehicle is determined to be the front AP; When the judgment result is no, the operating role of the vehicle is determined to be the rear AP.
7. A master-slave switching device, characterized in that: The device is applied to a vehicle-mounted AP, and the device includes: A broadcast module, used for broadcasting a first negotiation message carrying its own MAC address after power-on; A judgment module, configured to judge whether the AP is a decision-making AP according to the MAC address and the MAC address of the other on-board AP carried in the second negotiation message when receiving a second negotiation message broadcasted by another on-board AP on the train where the AP is located after being powered on; The first processing module is used to determine that the first processing module is a main AP when the judgment result of the judgment module is yes, work on the Mesh link established between the first processing module and the determined main trackside AP, and establish a Socket connection with the other vehicle-mounted AP to notify the other vehicle-mounted AP to be a backup AP; An acquisition module is used to acquire, according to a set period, the locally recorded MAC addresses of all first trackside APs scanned by itself within the set period and whose signal strength is not less than a set threshold and a first timestamp when each first trackside AP is scanned by itself, as well as the MAC addresses of all second trackside APs scanned by the other vehicle-mounted AP within the set period and whose signal strength is not less than the set threshold and a second timestamp when each second trackside AP is received by itself; A determination module, used to determine its own operation role according to the acquired MAC addresses and all first timestamps of all first trackside APs, and the MAC addresses and all second timestamps of all second trackside APs; The first switching module is used for, when the operating role determined by the determination module is the vehicle head AP, if the vehicle head AP is the main AP, notifying the other vehicle-mounted AP to upgrade to the main AP, and downgrading itself to the backup AP, disconnecting the currently working Mesh link, and if the vehicle head AP is the backup AP, not performing any operation; The second switching module is used to, when the determined operating role is the rear AP, if it is the main AP, do not perform any operation; if it is the backup AP, notify the other vehicle-mounted AP to downgrade to the backup AP, and upgrade itself to the main AP, working on the Mesh link established between itself and the currently determined main trackside AP.
8. The device according to claim 7, characterized in that The determination module is specifically used to determine whether it is a decision-making AP in the following manner: Determine whether the MAC address is greater than the MAC address of the other vehicle-mounted AP carried in the second negotiation message; When the judgment result is yes, determine itself as a decision-making AP; When the judgment result is no, it is determined that the AP itself is not a decision-making AP.
9. The device according to claim 7 or 8, characterized in that The device also includes: The second processing module is used to wait for the other vehicle-mounted AP to establish a Socket connection with itself when the judgment result of the judgment module is no; after establishing a Socket connection with the other vehicle-mounted AP and being notified by the other vehicle-mounted AP that it is a backup AP, send to the other vehicle-mounted AP the MAC address of the second trackside AP whose signal strength scanned by itself is not less than the set threshold; when being notified by the other vehicle-mounted AP that it is upgraded to a main AP, upgrade itself to the main AP and work on the Mesh link established between itself and the currently determined main trackside AP, or, when being notified by the other vehicle-mounted AP that it is downgraded to a backup AP, downgrade itself to a backup AP and disconnect the currently working Mesh link.
10. The device according to claim 7, characterized in that The determination module is specifically used for: For the MAC address of the first trackside AP currently traversed, determine whether there is a MAC address that is the same as the MAC address of the first trackside AP currently traversed among all the MAC addresses of the second trackside APs; When the judgment result is yes, if the first timestamp corresponding to the MAC address of the first trackside AP currently traversed is earlier than the second timestamp corresponding to the MAC address that is the same as the MAC address of the first trackside AP currently traversed among all the MAC addresses of the second trackside APs, then the own role evaluation variable is increased by 1; If the first timestamp corresponding to the MAC address of the first trackside AP currently traversed is later than the second timestamp corresponding to the MAC address that is the same as the MAC address of the first trackside AP currently traversed among all the MAC addresses of the second trackside APs, then the role evaluation variable of the other vehicle-mounted AP is increased by 1; When the judgment result is no, no operation is performed; Determine its own operation role according to its own role evaluation variable obtained when traversing all MAC addresses of the first trackside APs and the role evaluation variable of the other vehicle-mounted AP; When the MAC address of the first trackside AP currently traversed is the first MAC address, its own role evaluation variable and the role evaluation variable of another vehicle-mounted AP are both 0.
11. The device according to claim 10, characterized in that The determination module is specifically used for: comparing the magnitudes of the own role assessment variable and the role assessment variable of the other vehicle-mounted AP; If the comparison result is that the role evaluation variable of the own vehicle is greater than the role evaluation variable of the other vehicle-mounted AP, then the own operating role is determined to be the vehicle-front AP; If the comparison result is that the role evaluation variable of the own AP is less than the role evaluation variable of the other vehicle-mounted AP, then the own operating role is determined to be the rear AP; If the comparison result is that the own role evaluation variable is equal to the role evaluation variable of the other vehicle-mounted AP, it is determined that the own operating role is the same as the operating role determined last time.
12. The device according to claim 10, characterized in that The determination module is specifically used for: Calculating a difference between the role evaluation variable of the own AP and the role evaluation variable of the other vehicle-mounted AP to obtain a first operation result; Performing a quotient operation on the first operation result and the own role evaluation variable to obtain a second operation result; Determine whether the second operation result is not less than a set value; When the judgment result is yes, the operating role of the vehicle is determined to be the front AP; When the judgment result is no, the operating role of the vehicle is determined to be the rear AP.
Citation Information
Patent Citations
Arrival reminding method and device
CN106303975A
Channel switching method and device
CN109195188A