WO2022170791A1 - 一种状态上报方法、装置、设备和计算机可读存储介质 - Google Patents
一种状态上报方法、装置、设备和计算机可读存储介质 Download PDFInfo
- Publication number
- WO2022170791A1 WO2022170791A1 PCT/CN2021/128480 CN2021128480W WO2022170791A1 WO 2022170791 A1 WO2022170791 A1 WO 2022170791A1 CN 2021128480 W CN2021128480 W CN 2021128480W WO 2022170791 A1 WO2022170791 A1 WO 2022170791A1
- Authority
- WO
- WIPO (PCT)
- Prior art keywords
- grouping
- reporting
- state
- target device
- devices
- Prior art date
Links
- 238000000034 method Methods 0.000 title claims abstract description 83
- 238000004891 communication Methods 0.000 claims description 43
- 238000004590 computer program Methods 0.000 claims description 9
- 230000002452 interceptive effect Effects 0.000 claims description 3
- 238000012545 processing Methods 0.000 abstract description 3
- 238000010586 diagram Methods 0.000 description 5
- 230000005540 biological transmission Effects 0.000 description 4
- 238000005516 engineering process Methods 0.000 description 2
- 230000010365 information processing Effects 0.000 description 2
- 230000001934 delay Effects 0.000 description 1
- 230000003993 interaction Effects 0.000 description 1
- 238000012986 modification Methods 0.000 description 1
- 230000004048 modification Effects 0.000 description 1
- 238000012360 testing method Methods 0.000 description 1
Images
Classifications
-
- H—ELECTRICITY
- H04—ELECTRIC COMMUNICATION TECHNIQUE
- H04L—TRANSMISSION OF DIGITAL INFORMATION, e.g. TELEGRAPHIC COMMUNICATION
- H04L43/00—Arrangements for monitoring or testing data switching networks
- H04L43/10—Active monitoring, e.g. heartbeat, ping or trace-route
-
- G—PHYSICS
- G16—INFORMATION AND COMMUNICATION TECHNOLOGY [ICT] SPECIALLY ADAPTED FOR SPECIFIC APPLICATION FIELDS
- G16Y—INFORMATION AND COMMUNICATION TECHNOLOGY SPECIALLY ADAPTED FOR THE INTERNET OF THINGS [IoT]
- G16Y40/00—IoT characterised by the purpose of the information processing
- G16Y40/10—Detection; Monitoring
Definitions
- the present application relates to the field of communication technologies, and in particular, to a state reporting method, apparatus, device, and computer-readable storage medium.
- the IoT device needs to send a heartbeat packet to the server at regular intervals. During this process, the server needs to interact with each IoT device and process The heartbeat packets sent by the IoT devices, however, due to the large number of IoT devices, the pressure on the server to process the heartbeat packets is too great.
- the present application provides a status reporting method, apparatus, device and computer-readable storage medium, so as to solve the problem that in the case of a large number of IoT devices, the server receives and processes the heartbeat packets sent by each IoT device, causing the server to Deal with stressful problems.
- An embodiment of the present application provides a state reporting method, and the steps performed on the target device side include: after each device grouping period starts, reading the information of multiple devices to be selected returned by the server; Among the multiple candidate devices, a grouping device is selected; among the target device and the grouping device, a reporting device is determined, so that within the device grouping period, the reporting device is sent to the device through the reporting device.
- the server reports the status of the target device and the grouping device.
- the method before the reading the information of the multiple candidate devices returned by the server, the method further includes: sending the location information of the target device to the server, so that the server can go online according to the location information of the target device.
- a preset number of devices are selected as candidate devices; wherein, the distance between the selected device and the target device is smaller than the distance between the unselected device and the target device; receiving and storing Information about multiple candidate devices returned by the server.
- the selecting a grouping device among the multiple devices to be selected according to the information of the multiple devices to be selected includes: according to the information of the multiple devices to be selected, and each device to be selected establishing a communication connection; determining the network delay of each of the candidate devices based on the communication connection with each of the candidate devices; according to the network delay of each of the candidate devices, In Devices, select Group Devices.
- selecting a grouping device among the plurality of devices to be selected includes: according to the order of network delay from small to large, to each device in order.
- the candidate device sends a grouping request; receives a grouping approval message or a grouping rejection message returned by each candidate device; selects the candidate device that returns the consent grouping message as the grouping device, so as to The target device and the selected grouping device form a group; wherein, the consent grouping message is returned when the device to be selected does not belong to other groups; or, the device to be selected belongs to other groups and the first Returned when the network delay is less than the second network delay; the first network delay is the network delay between the device to be selected and the target device; the second network delay is the delay between the device to be selected and the target device.
- the network delay between the interactive devices in the other groups; the group rejection message is returned when the candidate device belongs to other groups and the first network delay is greater than or equal to the second network delay .
- the method further includes: before determining the reporting device, in the case of receiving a grouping request from other devices, returning an agreeing grouping message to the other devices, so that the target device enters the group where the other devices are located; After the reporting device is determined, the third network delay and the fourth network delay are determined when a grouping request from other devices is received; wherein, the third network delay is the difference between the target device and the other device.
- the network delay between devices; the fourth network delay is the network delay between the target device and the reporting device; when the third network delay is less than the fourth network delay Under the condition that the third network delay is greater than or equal to the fourth network delay, the other device is sent to the other device. Returns a reject packet message.
- the information of multiple devices to be selected returned by the server is recorded in the list of devices to be selected; after receiving the grouping request from other devices, the method further includes: in the grouping request, Extract the information of the other devices; in the case of determining that the information of the other devices is not included in the list of devices to be selected, determine the network delay of each device to be selected in the list of devices to be selected ; In the network delay of each said device to be selected in the device list to be selected, determine the maximum network delay; in the case that the third network delay is less than the maximum network delay, The information of the device to be selected corresponding to the maximum network delay is deleted from the list of devices to be selected, and the information of the other devices is added to the list of devices to be selected.
- determining the reporting device in the target device and the grouping device includes: determining the online duration of the target device; sending the online duration of the target device to the grouping device, and receiving the online duration of the target device.
- the online duration of the grouping device sent by the grouping device among the target device and the grouping device, determine the device with the longest online duration as the reporting device; wherein the grouping device also determines the longest online duration device as the reporting device.
- the reporting the status of the target device and the grouping device to the server through the reporting device within the device grouping period includes: when the target device is determined to be a reporting device, Every preset reporting time period, receive the heartbeat package reported by the grouping device, and determine the state of the grouping device according to the received heartbeat package; send the state of the target device and the state of the grouping device to the The server reports; when the grouping device is determined to be a reporting device, the target device sends a heartbeat packet to the reporting device every time period of the reporting period, so that the reporting device can send a heartbeat packet to the reporting device according to the target The heartbeat packet reported by the device determines the state of the target device and reports it to the server.
- the method further includes: starting from not receiving a heartbeat packet reported by a grouping device, within the preset first waiting time period, still not receiving In the case of a heartbeat packet reported by the grouping device, the information of the grouping device is deleted.
- the method further includes: in the case that the communication connection with the server is determined to be disconnected, in the target device and the grouping device, re-determining Report the device.
- the embodiment of the present application provides a state reporting method, and the steps performed on the server side include: receiving the state of the target device and the state of the grouping device reported by the reporting device; wherein, the reporting device is after the device grouping period starts, A device determined from the target device and the grouping device; the grouping device is selected by the target device among multiple candidate devices, and the information of the multiple candidate devices is the information sent by the server to the Sent by the target device; updating the current state of the target device according to the state of the target device; and updating the current state of the grouping device according to the state of the grouping device.
- the types of the states include: online state and offline state; before the state of the target device and the state of the grouping device reported by the receiving and reporting device, it also includes: receiving location information from the target device; The location information of the target device.
- a preset number of devices are selected as the devices to be selected; wherein, the distance between the selected device and the target device is smaller than the distance between the unselected device and the target device.
- the distance of the target device return the information of the multiple candidate devices to the target device, so that the target device can select a group from the multiple candidate devices according to the information of the multiple candidate devices equipment.
- the method further includes: starting from not receiving the state of the target device and the state of the grouping device reported by the reporting device, within a preset second waiting time period, still not receiving the state of the target device reported by the reporting device In the case of the state of the target device and the state of the grouping device, both the current state of the target device and the current state of the grouping device are updated to the offline state.
- An embodiment of the present application provides a state reporting device, which is set on the side of a target device and includes: a reading module, configured to read information of multiple devices to be selected returned by the server after each device grouping period starts; selecting a module, configured to select a grouping device from among the plurality of devices to be selected according to the information of a plurality of the devices to be selected; a determining module, configured to determine the reporting device in the target device and the grouping device device, so as to report the state of the target device and the grouping device to the server through the reporting device within the device grouping period.
- An embodiment of the present application provides a state reporting device, which is set on the server side and includes: a receiving module configured to receive the state of the target device and the state of the grouping device reported by the reporting device; wherein the reporting device is in the device grouping After the cycle starts, a device determined in the target device and the grouping device; the grouping device is selected by the target device among multiple candidate devices, and the information of the multiple candidate devices is Sent by the server to the target device; an update module configured to update the current state of the target device according to the state of the target device; and update the current state of the grouping device according to the state of the grouping device .
- An embodiment of the present application provides an electronic device, including a processor, a communication interface, a memory, and a communication bus, wherein the processor, the communication interface, and the memory communicate with each other through the communication bus; the memory is configured to store a computer program; The processor is configured to, when executing the program stored in the memory, implement the steps of the state reporting method described in any one of the above, or implement the steps of any one of the above state reporting methods.
- An embodiment of the present application provides a computer-readable storage medium, on which a computer program is stored, and when the computer program is executed by a processor, implements the steps of any of the above-mentioned status reporting methods, or implements any of the above-mentioned methods.
- the target device determines the group to which it belongs and determines the reporting device in the group, and the reporting device collects the status of each device in the group and reports it to the server.
- the application does not require each client to establish a communication connection with the server and report heartbeat packets, nor does the server need to receive a large number of heartbeat packets sent by devices and process a large number of heartbeat packets, which effectively improves the state reporting efficiency of the device and reduces the heartbeat packet processing of the server. pressure.
- FIG. 1 is a flowchart of a state reporting method performed on a target device side according to an embodiment of the present application
- FIG. 2 is a flowchart of a state reporting method executed on the server side according to an embodiment of the present application
- FIG. 3 is a flowchart of a state reporting method according to an embodiment of the present application.
- FIG. 4 is a structural diagram of a state reporting device provided on a target device according to an embodiment of the present application.
- FIG. 5 is a structural diagram of a state reporting device provided on a server according to an embodiment of the present application.
- FIG. 6 is a schematic structural diagram of an electronic device according to an embodiment of the present application.
- FIG. 1 is a schematic flowchart of a state reporting method executed on a target device according to an embodiment of the present application.
- the target device refers to the device registered with the server.
- Each device that has completed registration at the server can execute the state reporting method of this embodiment, so as to report the state in the form of a group.
- Step S110 after each device grouping period starts, read the information of the multiple candidate devices returned by the server.
- the device grouping period refers to the time period during which the status is reported to the server in units of groups.
- Each group includes at least one device.
- the types of devices include but are not limited to: smart home appliances.
- the server configured to record the status of each device registered with the server.
- the status of the device includes: online status and offline status.
- the device to be selected refers to the device provided by the server for the target device that can be selected by group.
- the information of the device to be selected including but not limited to: the code and communication address of the device to be selected. Further, in some implementations, the information of the multiple candidate devices returned by the server is stored in a candidate device list.
- Step S120 according to the information of the multiple candidate devices, among the multiple candidate devices, select a grouping device.
- the grouping device is configured as a candidate device to form a grouping with the target device.
- the grouping device and the target device form a group, so that the status of each device in the group is reported to the server in units of the group.
- the number of grouped devices is not limited. For example, the number of devices to be selected is greater than or equal to the number of grouped devices.
- Selecting a grouping device includes: selecting the information of all the devices to be selected from the information of the multiple devices to be selected, and using all the devices to be selected as the grouping device; or, in the information of the multiple devices to be selected, randomly selecting Preset the information of the first number of devices to be selected, and use the device to be selected corresponding to the information of the selected device to be selected as the grouping device; or, according to the information of multiple devices to be selected, determine the target device and each device to be selected the network delay, sort the devices to be selected according to the order of network delay from small to large, starting from the candidate device with the smallest network delay, and select the preset first number of candidate devices as the grouping device; Starting from the selected device, at most the preset first number of candidate devices that agree to form a group with the target device are selected as grouped devices.
- Step S130 in the target device and the grouping device, determine a reporting device, so as to report the status of the target device and the grouping device to the server through the reporting device within the device grouping period.
- the reporting device refers to the device that reports the status of each device in the group to the server.
- Determining the reporting device includes: randomly determining a device in the target device and the grouping device as the reporting device; or determining one device as the reporting device in the target device and the grouping device through a consensus algorithm.
- the consensus algorithm mainly performs negotiation and communication with the grouping device, and determines one device as the reporting device among the target device and the grouping device.
- Negotiation communication refers to the exchange of negotiation information between the target device and the grouping device, and the target device and the grouping device jointly select and report the device according to the received negotiation information.
- negotiation information refers to the information of the device selected to be reported.
- the types of negotiation information include: the online duration of the current device, the network delay from the current device to other devices in the group, and the average network delay from the current device to other devices in the group. For example, among the target device and the grouping device, the device with the smallest average network delay is determined as the reporting device.
- the reporting device is made to send the information of each device in the group to the server, so that the server can learn the information of each device in the group.
- the target device determines the group it belongs to, and determines the reporting device in the group, and the reporting device collects the status of each device in the group and reports it to the server.
- the application does not require each client to establish a communication connection with the server and report heartbeat packets, nor does the server need to receive a large number of heartbeat packets sent by devices and process a large number of heartbeat packets, which effectively improves the state reporting efficiency of the device and reduces the heartbeat packet processing of the server. pressure. Based on the above state reporting method performed on the target device side, the following describes the status reporting method performed on the server side.
- FIG. 2 it is a flowchart of a state reporting method executed on the server side according to an embodiment of the present application.
- Step S210 receiving the state of the target device and the state of the grouping device reported by the reporting device.
- the reporting device is a device determined from the target device and the grouping device after the device grouping period starts. That is to say, the reporting device is included in the target device and the grouping device, and the state of the reporting device is included in the state of the target device and the state of the grouping device.
- the grouping device is selected by the target device among multiple candidate devices, and the information of the multiple candidate devices is sent by the server to the target device.
- the types of the states include: online state and offline state.
- Step S220 update the current state of the target device according to the state of the target device; and update the current state of the grouping device according to the state of the grouping device.
- an online device list is provided on the server side, and information of devices in an online state is recorded in the online device list. According to the current state of the target device and the current state of the grouped devices, the information of the device in the offline state is removed from the online device list.
- the location information from the target device is also received; according to the location information of the target device, among the devices in the online state , select a preset number of devices as candidate devices; wherein, the distance between the selected device and the target device is smaller than the distance between the unselected device and the target device; return to the target device information of each of the candidate devices, so that the target device selects a grouping device among the plurality of candidate devices according to the information of the plurality of candidate devices.
- the server in order to send the information of clients near the target device to the target device and determine the distance between the target device and other devices in the online state, obtains multiple device, as a candidate device for the target device. For example, in the order of distance from small to large, acquire 50 devices as candidates for the target device, and send the information of the 50 devices to the target device.
- the number of target devices registered by the server is multiple.
- the information of multiple candidate devices sent by the server to each target device is repeated.
- the server sends each target device information.
- the information of multiple candidate devices sent by the target device is also not repeated. For example: when the target device goes online, the target device sends location information to the server, and the server sends the information of multiple candidate devices to the target device according to the location information of the target device; wherein, the multiple candidate devices sent to the target device
- the information of the device is allowed to be repeated with the information of the candidate device sent to other devices. In this way, the target device selects the grouped device among the multiple candidate devices by request, avoiding the repetition of devices in different groups.
- the target device sends location information to the server, and the server allocates multiple non-repeated candidate devices to each target device according to the location information of each target device, and assigns each target device The information of the corresponding multiple candidate devices is sent to the target device, so that the target device selects the information of all the candidate devices returned by the server, and uses all the candidate devices as grouping devices.
- the state of the target device and the state of the grouping device reported by the reporting device are never received, within the preset second waiting time period, if the state of the target device and the state of the grouping device reported by the reporting device are still not received, the current state of the target device and the current state of the grouping device are Update offline status.
- the duration of the second waiting period is greater than the duration of the reporting period of the reporting device.
- the server receives the state of the target device and the state of the grouping device reported by the reporting device, and does not need to establish a communication connection with all devices in the group where the reporting device is located, and does not need to receive the heartbeat sent by each device in the group where the reporting device is located. It is only necessary to complete the state update of each device according to the state group reported by the reporting device (the state of the target device and the state of the grouped device), the state update efficiency is high, and the information processing pressure is small.
- FIG. 3 it is a flowchart of a state reporting method according to an embodiment of the present application.
- Step S310 after each device grouping period starts, the target device reads the information of multiple candidate devices returned by the server.
- the duration of the device grouping cycle is greater than the duration of the device reporting heartbeat packets.
- the location information of the target device Before reading the information of multiple devices to be selected, the location information of the target device needs to be sent to the server, so that the server can select a preset number of devices as the device to be selected among the devices in the online state according to the location information of the target device. ; wherein, the distance between the selected device and the target device is smaller than the distance between the unselected device and the target device; receiving and storing the information of a plurality of the candidate devices returned by the server.
- the location of the target device is fixed, after the target device goes online, a communication connection is established with the server and the location information of the target device is sent to the server.
- the location information of the target device is sent to the server at regular intervals.
- the information of the multiple candidate devices returned by the server is recorded in the candidate device list.
- the target device only needs to maintain the list of devices to be selected, and the target device adds or deletes device information from the list of devices to be selected according to requirements.
- Step S320 the target device establishes a communication connection with each of the candidate devices according to the information of the plurality of candidate devices.
- the information of the device to be selected includes the communication address of the device to be selected; the target device establishes a TCP (Transmission Control Protocol, Transmission Control Protocol) communication connection with the device to be selected according to the communication address of the device to be selected.
- TCP Transmission Control Protocol, Transmission Control Protocol
- Step S330 the target device determines the network delay of each of the candidate devices based on the communication connection with each of the candidate devices.
- the target device uses the ICMP (Internet Control Message Protocol, Internet Control Message Protocol) protocol to test the network delay with each candidate device.
- ICMP Internet Control Message Protocol, Internet Control Message Protocol
- Step S340 the target device selects a grouping device from among the plurality of candidate devices according to the network delay of each of the candidate devices.
- the device to be selected since the device to be selected may have formed a group with other devices, so that the devices in different groups are not repeated, a grouping request is sent to each of the devices to be selected in order according to the order of network delay from small to large. ; Receive the agreed grouping message or reject the grouping message returned by each described device to be selected; Select the device to be selected that returns the agreed grouping message as the grouping device, so as to combine the target device and the selected
- the grouping devices described above form a group.
- the number of grouping devices is at least one. For example, among the 50 candidate devices for the target device, the 10 devices with the shortest round-trip time of the message are determined as the grouping devices.
- the group approval message is returned when the device to be selected does not belong to other groups; or, it is returned when the device to be selected belongs to other groups and the first network delay is less than the second network delay; the first network delay time is the network delay between the candidate device and the target device; the second network delay is the network delay between the candidate device and the interaction devices in the other groups.
- the group rejection message is returned when the device to be selected belongs to another group and the first network delay is greater than or equal to the second network delay.
- Step S350 the target device determines the online duration of the target device (target device itself); sends the online duration of the target device to the grouping device, and receives the online duration of the grouping device sent by the grouping device.
- the target device and the grouping device form a group.
- a reporting device is elected in the group.
- the grouping device sends negotiation information to the target device after returning an agree-to-group message to the target device.
- the negotiation information includes the online duration of the grouping device.
- Step S360 the target device determines, among the target device and the grouping device, the device with the longest online duration as the reporting device; wherein the grouping device also determines the device with the longest online duration as the reporting device.
- the target device sends negotiation information to the grouping device, and the grouping device also sends negotiation information to the target device, the negotiation information of the target device and the grouping device are equal, and the determined reporting device is the same, and there is no need to notify each other of the information of the reporting device .
- the role of the reporting device is the leader, and the other devices are followers.
- Step S370 the target device reports the state of the target device and the grouping device to the server through the reporting device within the device grouping period.
- the target device When the target device is determined to be a reporting device, receive heartbeat packets reported by the grouping device every preset reporting time period, and determine the status of the grouping device according to the received heartbeat packets; The state of the device and the state of the grouping device are reported to the server.
- the reporting time period is the status reporting period.
- the reporting time period is the empirical value or the experimental value.
- the state of the grouping device corresponding to the received heartbeat packet is determined to be an online state, and the state of the remaining grouping devices is determined to be an offline state.
- the grouping device is determined to be the reporting device, make the target device send a heartbeat packet to the reporting device every time period of the reporting period, so that the reporting device can send a heartbeat packet to the reporting device according to the heartbeat packet reported by the target device, The state of the target device is determined and reported to the server.
- the target device is determined to be the reporting device, starting from not receiving a heartbeat packet reported by a grouping device, within the preset first waiting time period, still not receiving the heartbeat packet reported by the grouping device Next, delete the information of the grouping device; wherein, the duration of the first waiting period is greater than the duration of the reporting period. If a heartbeat packet reported by a device is not received within a certain period of time, it means that a communication failure has occurred between the target device and the grouping device or the grouping device has gone offline.
- the state of the grouping device is marked as the offline state, so that the server updates the state of the grouping device to the offline state, and after the grouping device resumes communication or goes online, the server is restored to go online again in the form of regrouping state.
- Step S380 the server receives the state of the target device and the state of the grouping device reported by the reporting device.
- the current status of each device is recorded on the server side in order to communicate with devices that are online.
- the server In order to know whether the status of each device changes in time, the server needs to update the status of each device every preset reporting period. Therefore, the server receives the status of the target device and the status of the grouping device reported by the reporting device every reporting period. .
- Step S390 the server updates the current state of the target device according to the state of the target device; and updates the current state of the grouping device according to the state of the grouping device.
- the devices in the group communicate with each other to confirm the status of each other, and then select a reporter and the server to deliver the status of each device in the group every other grouping period. , which relieves the pressure on the server to keep heartbeat packets connected to multiple devices at the same time in order to confirm whether the device is online.
- the server provides the target device according to the location information of the target device. communication efficiency between them.
- the target device selects the candidate device with the smallest network delay to form a group. In this way, the communication timeliness between devices in the same group is high, which ensures that The timeliness of the status of the devices in the group reported to the server is improved.
- the reporting device is determined through a consensus algorithm.
- the negotiation information used by the consensus algorithm is the online duration, and the device with the longest online duration is selected as the reporting device to ensure the stability of the reporting device, that is, the stability of the status report is guaranteed.
- the reporting of device status will be affected due to frequent changes of reporting devices.
- the reporting device only needs to maintain a communication connection with the server, and it is not necessary for each device to maintain a communication connection with the server and report the heartbeat packet.
- the method effectively reduces the number of communication connections of the server, reduces the amount of information processing of the server, and improves the efficiency of status reporting.
- the reporting device In the case that the target device is determined to be the reporting device, and in the case that the communication connection with the server is determined to be disconnected, the reporting device is re-determined in the target device and the grouping device. When the reporting device is disconnected from the server, the status of all devices in the group cannot be reported to the server. In this case, the reporting device needs to be re-elected, and the new reporting device reports the status of all devices in the group.
- the target device is not a newly added device of the server
- the information of the target device may be sent by the server to other devices, so when other devices determine the grouping device, they may receive grouping requests sent by other devices.
- this implementation For example, the following steps can be performed:
- the target device Before determining the reporting device, in the case of receiving a grouping request from another device, return an agree-grouping message to the other device, so that the target device enters the group where the other device is located. In this case, the target device does not belong to any group and can first agree to join other customers' groups.
- the third network delay and the fourth network delay are determined when a grouping request from other devices is received; wherein, the third network delay is the difference between the target device and the other device. network delay between devices; the fourth network delay is the network delay between the target device and the reporting device.
- the third network delay is smaller than the fourth network delay, a grouping approval message is returned to the other device, and a grouping rejection message is sent to the target device.
- the third network delay is greater than or equal to the fourth network delay, a packet rejection message is returned to the other device.
- the grouping principle of this embodiment is that the network delay between the devices in the group is small, so after the grouping request from other devices is received, the information of the other devices is extracted in the grouping request ;
- determine the network delay of each of the devices to be selected in the list of devices to be selected Among the network delays of each candidate device in the list, determine the maximum network delay; in the case that the third network delay is less than the maximum network delay, set the maximum network delay.
- the information of the corresponding device to be selected is deleted from the list of devices to be selected, and the information of the other devices is added to the list of devices to be selected. In this way, the list of devices to be selected changes dynamically with the increase or decrease of device information.
- FIG. 4 is a structural diagram of a state reporting apparatus provided on a target device according to an embodiment of the present application.
- the device for reporting the status of the target device includes: a reading module 410 , a selection module 420 and a determination module 430 .
- the reading module 410 is configured to read the information of the plurality of candidate devices returned by the server after each device grouping period starts.
- the selection module 420 is configured to select a grouping device from among the plurality of candidate devices according to the information of the plurality of candidate devices.
- the determining module 430 is configured to determine a reporting device in the target device and the grouping device, so as to report the target device and the grouping device to the server through the reporting device within the device grouping period Status of the device.
- FIG. 5 is a structural diagram of a state reporting device provided on a server according to an embodiment of the present application.
- This setting is in the status reporting device of the server, including:
- the receiving module 510 is configured to receive the state of the target device and the state of the grouping device reported by the reporting device; wherein, the reporting device is determined from the target device and the grouping device after the device grouping cycle starts A device; the grouping device is selected by the target device among multiple candidate devices, and the information of the multiple candidate devices is sent by the server to the target device.
- the updating module 520 is configured to update the current state of the target device according to the state of the target device; and update the current state of the grouping device according to the state of the grouping device.
- an embodiment of the present application provides an electronic device, including a processor 610 , a communication interface 620 , a memory 630 and a communication bus 640 , wherein the processor 610 , the communication interface 620 , and the memory 630 are completed through the communication bus 640 communication with each other.
- the memory 630 is configured to store computer programs.
- the processor 610 is configured to implement any of the foregoing status reporting methods executed on the target device or status reporting methods executed on the server when executing the program stored in the memory 630 .
- the processor 610 executes the program stored in the memory 630, it is configured to implement the method steps of reporting the state executed by the target device: after each device grouping cycle starts, read the information of the multiple candidate devices returned by the server; The information of a plurality of the devices to be selected, among the plurality of devices to be selected, a grouping device is selected; among the target device and the grouping device, a reporting device is determined, so that within the device grouping period, the The reporting device reports the state of the target device and the grouping device to the server.
- the method before the reading the information of the multiple candidate devices returned by the server, the method further includes: sending the location information of the target device to the server, so that the server can go online according to the location information of the target device.
- a preset number of devices are selected as candidate devices; wherein, the distance between the selected device and the target device is smaller than the distance between the unselected device and the target device; receiving and storing Information about multiple candidate devices returned by the server.
- the selecting a grouping device among the multiple devices to be selected according to the information of the multiple devices to be selected includes: according to the information of the multiple devices to be selected, and each device to be selected establishing a communication connection; determining the network delay of each of the candidate devices based on the communication connection with each of the candidate devices; according to the network delay of each of the candidate devices, In Devices, select Group Devices.
- selecting a grouping device among the plurality of devices to be selected includes: according to the order of network delay from small to large, to each device in order.
- the candidate device sends a grouping request; receives a grouping approval message or a grouping rejection message returned by each candidate device; selects the candidate device that returns the consent grouping message as the grouping device, so as to The target device and the selected grouping device form a group; wherein, the consent grouping message is returned when the device to be selected does not belong to other groups; or, the device to be selected belongs to other groups and the first Returned when the network delay is less than the second network delay; the first network delay is the network delay between the device to be selected and the target device; the second network delay is the delay between the device to be selected and the target device.
- the network delay between the interactive devices in the other groups; the group rejection message is returned when the candidate device belongs to other groups and the first network delay is greater than or equal to the second network delay .
- the method further includes: before determining the reporting device, in the case of receiving a grouping request from other devices, returning an agreeing grouping message to the other devices, so that the target device enters the group where the other devices are located; After the reporting device is determined, the third network delay and the fourth network delay are determined when a grouping request from other devices is received; wherein, the third network delay is the difference between the target device and the other device.
- the network delay between devices; the fourth network delay is the network delay between the target device and the reporting device; when the third network delay is less than the fourth network delay Under the condition that the third network delay is greater than or equal to the fourth network delay, the other device is sent to the other device. Returns a reject packet message.
- the information of multiple devices to be selected returned by the server is recorded in the list of devices to be selected; after receiving the grouping request from other devices, the method further includes: in the grouping request, Extract the information of the other devices; in the case of determining that the information of the other devices is not included in the list of devices to be selected, determine the network delay of each device to be selected in the list of devices to be selected ; In the network delay of each said device to be selected in the device list to be selected, determine the maximum network delay; in the case that the third network delay is less than the maximum network delay, The information of the device to be selected corresponding to the maximum network delay is deleted from the list of devices to be selected, and the information of the other devices is added to the list of devices to be selected.
- determining the reporting device in the target device and the grouping device includes: determining the online duration of the target device; sending the online duration of the target device to the grouping device, and receiving the online duration of the target device.
- the online duration of the grouping device sent by the grouping device among the target device and the grouping device, determine the device with the longest online duration as the reporting device; wherein the grouping device also determines the longest online duration device as the reporting device.
- the reporting the status of the target device and the grouping device to the server through the reporting device within the device grouping period includes: when the target device is determined to be a reporting device, Every preset reporting time period, receive the heartbeat package reported by the grouping device, and determine the state of the grouping device according to the received heartbeat package; send the state of the target device and the state of the grouping device to the The server reports; in the case that the grouping device is determined as a reporting device, make the target device send a heartbeat packet to the reporting device every time period of the reporting period, so that the reporting device can send a heartbeat packet to the reporting device according to the target
- the heartbeat packet reported by the device determines the state of the target device and reports it to the server.
- the method further includes: starting from not receiving a heartbeat packet reported by a grouping device, within the preset first waiting time period, still not receiving In the case of a heartbeat packet reported by the grouping device, the information of the grouping device is deleted.
- the method further includes: in the case that the communication connection with the server is determined to be disconnected, in the target device and the grouping device, re-determining Report the device.
- the processor 610 executes the program stored in the memory 630, it is used to realize the state reporting method steps performed by the server: receiving the state of the target device and the state of the grouping device reported by the reporting device; After the cycle starts, a device determined in the target device and the grouping device; the grouping device is selected by the target device among multiple candidate devices, and the information of the multiple candidate devices is Sent by the server to the target device; updating the current state of the target device according to the state of the target device; and updating the current state of the grouping device according to the state of the grouping device.
- the types of the states include: online state and offline state; before the state of the target device and the state of the grouping device reported by the receiving and reporting device, it also includes: receiving location information from the target device; The location information of the target device.
- a preset number of devices are selected as the devices to be selected; wherein, the distance between the selected device and the target device is smaller than the distance between the unselected device and the target device.
- the distance of the target device return the information of the multiple candidate devices to the target device, so that the target device can select a group from the multiple candidate devices according to the information of the multiple candidate devices equipment.
- the method further includes: starting from not receiving the state of the target device and the state of the grouping device reported by the reporting device, within a preset second waiting time period, still not receiving the state of the target device reported by the reporting device In the case of the state of the target device and the state of the grouping device, both the current state of the target device and the current state of the grouping device are updated to the offline state.
- Embodiments of the present application further provide a computer-readable storage medium, on which a computer program is stored, and when the computer program is executed by a processor, implements the steps of the status reporting method provided by any one of the foregoing method embodiments.
Landscapes
- Engineering & Computer Science (AREA)
- Health & Medical Sciences (AREA)
- Cardiology (AREA)
- General Health & Medical Sciences (AREA)
- Computer Networks & Wireless Communication (AREA)
- Signal Processing (AREA)
- Computing Systems (AREA)
- Mobile Radio Communication Systems (AREA)
Abstract
本申请公开了一种状态上报方法、装置、设备和计算机可读存储介质。该方法在目标设备侧包括:在每个设备分组周期开始之后,读取服务器返回的多个待选设备的信息;根据多个待选设备的信息,在多个待选设备中,选择分组设备;在目标设备和分组设备中,确定上报设备,以便在设备分组周期内,通过上报设备向服务器上报目标设备和分组设备的状态。该方法在服务器侧包括:接收上报设备上报的目标设备的状态和分组设备的状态;根据目标设备的状态更新目标设备的当前状态;根据分组设备的状态更新分组设备的当前状态。本申请无需服务器接收大量设备分别发送的心跳包并且处理大量的心跳包,有效提高了设备的状态上报效率,降低了服务器的心跳包处理压力。
Description
本申请以2021年02月09日递交的、申请号为202110181924.6且名称为“一种状态上报方法、装置、设备和计算机可读存储介质”的专利文件为优先权文件,其全部内容通过引用结合在本申请中。
本申请涉及通信技术领域,尤其涉及一种状态上报方法、装置、设备和计算机可读存储介质。
随着物联网技术的不断普及,越来越多的物联网设备进入人们的生活,尤其在智能家居领域,智能家电的数量飞速增加。在发明人知晓的一些方案中,为了获知物联网设备是否在线,需要物联网设备每隔一段时间向服务器发送一次心跳包,在这过程中,服务器需要与每个物联网设备进行交互,并且处理物联网设备发送的心跳包,但是,由于物联网设备的数量较多,导致服务器处理心跳包的压力过大。
发明内容
本申请提供了一种状态上报方法、装置、设备和计算机可读存储介质,以解决在物联网设备数量较多的情况下,服务器接收并处理每个物联网设备发送的心跳包,导致服务器的处理压力较大的问题。
针对上述技术问题,本申请是通过以下技术方案来实现的:
本申请实施例提供了一种状态上报方法,在目标设备侧执行的步骤,包括:在每个设备分组周期开始之后,读取服务器返回的多个待选设备的信息;根据多个所述待选设备的信息,在多个所述待选设备中,选择分组设备;在所述目标设备和所述分组设备中,确定上报设备,以便在所述设备分组周期内,通过所述上报设备向所述服务器上报所述目标设备和所述分组设备的状态。
其中,在所述读取服务器返回的多个待选设备的信息之前,还包括:向所述服务器发送所述目标设备的位置信息,以便所述服务器根据所述目标设备的位置信息,在上线状态的设备中,选择预设数量的设备作为待选设备;其中,被选择的所述设备与所述目标设备的距离小于未被选择的所述设备与所述目标设备的距离;接收并存储所述服务器返回的多个所述待选设备的信息。
其中,所述根据多个所述待选设备的信息,在多个所述待选设备中,选择分组设备,包括:根据多个所述待选设备的信息,与每个所述待选设备建立通信连接;基于与每个所述待选设备的通信连接,确定每个所述待选设备的网络延时;根据每个所述待选设备的网络延时,在多个所述待选设备中,选择分组设备。
其中,所述根据与每个所述待选设备之间的网络延时,在多个所述待选设备中,选择分组设备,包括:按照网络延时从小到大的顺序,顺序向每个所述待选设备发送分组请求;接收每个所述待选设备返回的同意分组消息或者拒绝分组消息;选择返回所述同意分组消息的所述待选设备,作为所述分组设备,以便将所述目标设备和选择出的所述分组设备组成一个分组;其中,所述同意分组消息是所述待选设备不属于其他分组时返回的;或者,是所述待选设备属于其他分组并且第一网络延时小于第二网络延时时返回的;第一网络延时是所述待选设备与所述目标设备之间的网络延时;所述第二网络延时是所述待选设备与所述其他分组中的交互设备之间的网络延时;所述拒绝分组消息是所述待选设备属于其他分组并且所述第一网络延时大于或者等于所述第二网络延时时返回的。
其中,所述方法还包括:在确定上报设备之前,接收到来自于其他设备的分组请求的情况下,向所述其他设备返回同意分组消息,以便所述目标设备进入所述其他设备所在分组;在确定上报设备之后,接收到来自于其他设备的分组请求的情况下,确定第三网络延时和第四网络延时;其中,所述第三网络延时是所述目标设备与所述其他设备之间的网络延时;所述第四网络延时是所述目标设备与所述上报设备之间的网络延时;在所述第三网络延时小于所述第四网络延时的情况下,向所述其他设备返回同意分组消息,并向所述目标设备发送拒绝分组消息;在所述第三网络延时大于或者等于所述第四网络延时的情况下,向所述其他设备返回拒绝分组消息。
其中,所述服务器返回的多个待选设备的信息被记录在待选设备列表中;在所述接收到来自于其他设备的分组请求之后,所述方法还包括:在所述分组请求中,提取所述其他设备的信息;在确定所述其他设备的信息未包含在所述待选设备列表中的情况下,确定所述待选设备列表中的每个所述待选设备的网络延时;在所述待选设备列表中的每个所述待选设备的网络延时中,确定最大的网络延时;在所述第三网络延时小于所述最大的网络延时的情况下,将所述最大的网络延时对应的待选设备的信息从所述待选设备列表中删除,并且将所述其他设备的信息添加到所述待选设备列表中。
其中,所述在所述目标设备和所述分组设备中,确定上报设备,包括:确定所述目标设备的在线时长;将所述目标设备的在线时长向所述分组设备发送,并且接收所述分组设备发送的所述分组设备的在线时长;在所述目标设备和所述分组设备中,确定在线时长最长的设备作为所述上报设备;其中,所述分组设备也确定在线时长最长的设备作为所述上报设备。
其中,所述在所述设备分组周期内,通过所述上报设备向所述服务器上报所述目标设备和所述分组设备的状态,包括:在所述目标设备被确定为上报设备的情况下,每隔预设上报时间段,接收所述分组设备上报的心跳包,并根据接收到的心跳包,确定所述分组设备的状态;将所述目标设备的状态以及所述分组设备的状态向所述服务器上报;在所述分组设备被确定为上报设备的情况下,每隔所述上报时间段,使所述目标设备向所述上报设备发送一次心跳包,以便所述上报设备根据所述目标设备上报的心跳包,确定所述目标设备的状态并向所述服务器上报。
其中,在所述目标设备被确定为上报设备的情况下,所述方法还包括:从未接收到一个分组设备上报的心跳包开始,在预设的第一等待时间段内,依旧未接收到所述分组设备上报的心跳包的情况下,删除所述分组设备的信息。
其中,在所述目标设备被确定为上报设备的情况下,所述方法还包括:在确定与所述服务器断开通信连接的情况下,在所述目标设备和所述分组设备中,重新确定上报设备。
本申请实施例提供了一种状态上报方法,在服务器侧执行的步骤,包括:接收上报设备上报的目标设备的状态和分组设备的状态;其中,所述上报设备是在设备分组周期开始之后,在所述目标设备和所述分组设备中确定出的一个设备;所述分组设备是所述目标设备在多个待选设备中选择的,多个所述待选设备的信息是所述服务器向所述目标设备发送的;根据所述目标设备的状态更新所述目标设备的当前状态;并且,根据所述分组设备的状态更新所述分组设备的当前状态。
其中,所述状态的种类包括:上线状态和下线状态;在所述接收上报设备上报的目标设备的状态和分组设备的状态之前,还包括:接收来自于所述目标设备的位置信息;根据所述目标设备的位置信息,在上线状态的设备中,选择预设数量的设备作为待选设备;其中,被选择的所述设备与所述目标设备的距离小于未被选择的所述设备与所述目标设备的距离;向所述目标设备返回多个所述待选设备的信息,以便所述目标设备根据多个所述待选设备的信息,在多个所述待选设备中选择分组设备。
其中,所述方法还包括:从未接收到所述上报设备上报的目标设备的状态和分组设备的状态开始,在预设的第二等待时间段内,依旧未收到所述上报设备上报的目标设备的状态和分组设备的状态的情况下,将所述目标设备的当前状态和所述分组设备的当前状态都更新下线状态。
本申请实施例提供了一种状态上报装置,设置在目标设备侧,包括:读取模块,被配置为在每个设备分组周期开始之后,读取服务器返回的多个待选设备的信息;选择模块,被配置为根据多个所述待选设备的信息,在多个所述待选设备中,选择分组设备;确定模块,被配置为在所述目标设备和所述分组设备中,确定上报设备,以便在所述设备分组周期内,通过所述上报设备向所述服务器上报所述目标设备和所述分组设备的状态。
本申请实施例提供了一种状态上报装置,设置在服务器侧,包括:接收模块,被配置为接收上报设备上报的目标设备的状态和分组设备的状态;其中,所述上报设备是在设备分组周期开始之后,在所述目标设备和所述分组设备中确定出的一个设备;所述分组设备是所述目标设备在多个待选设备中选择的,多个所述待选设备的信息是所述服务器向所述目标设备发送的;更新模块,被配置为根据所述目标设备的状态更新所述目标设备的当前状态;并且,根据所述分组设备的状态更新所述分组设备的当前状态。
本申请实施例提供了一种电子设备,包括处理器、通信接口、存储器和通信总线,其中,处理器,通信接口,存储器通过通信总线完成相互间的通信;存储器,被配置为存放计算机程序;处理器,被配置为执行存储器上所存放的程序时,实现上述任一项所述的状态上报方法的步骤,或者,实现上述任一项所述的状态上报方法的步骤。
本申请实施例提供了一种计算机可读存储介质,其上存储有计算机程序,所述计算机程序被处理器执行时,实现上述任一项所述的状态上报方法的步骤,或者,实现上述任一项所述的状态上报方法的步骤。
本申请实施例提供的上述技术方案与现有技术相比具有如下优点:
在本申请实施例中,目标设备在每个设备分组周期内,确定所属的分组并且确定分组内 的上报设备,上报设备收集分组内的各个设备的状态并上报给服务器。本申请无需各个客户分别与服务器建立通信连接并且上报心跳包,也无需服务器接收大量设备分别发送的心跳包并且处理大量的心跳包,有效提高了设备的状态上报效率,降低了服务器的心跳包处理压力。
此处的附图被并入说明书中并构成本说明书的一部分,示出了符合本申请的实施例,并与说明书一起用于解释本申请的原理。
为了更清楚地说明本申请实施例或现有技术中的技术方案,下面将对实施例或现有技术描述中所需要使用的附图作简单地介绍,显而易见地,对于本领域普通技术人员而言,在不付出创造性劳动性的前提下,还可以根据这些附图获得其他的附图。
图1是根据本申请一实施例的在目标设备侧执行的状态上报方法的流程图;
图2是根据本申请一实施例的在服务器侧执行的状态上报方法的流程图;
图3是根据本申请一实施例的状态上报方法的流程图;
图4是根据本申请一实施例的设置在目标设备的状态上报装置的结构图;
图5是根据本申请一实施例的设置在服务器的状态上报装置的结构图;
图6为本申请实施例提供的一种电子设备的结构示意图。
为使本申请实施例的目的、技术方案和优点更加清楚,下面将结合本申请实施例中的附图,对本申请实施例中的技术方案进行清楚、完整地描述,显然,所描述的实施例是本申请的一部分实施例,而不是全部的实施例。基于本申请中的实施例,本领域普通技术人员在没有做出创造性劳动的前提下所获得的所有其他实施例,都属于本申请保护的范围。
本申请实施例提供了一种状态上报方法。图1为本申请实施例提供的一种在目标设备执行的状态上报方法的流程示意图。目标设备是指在服务器完成注册的设备。在服务器完成注册的每个设备都可以执行本实施例的状态上报方法,以便以分组的形式上报状态。
步骤S110,在每个设备分组周期开始之后,读取服务器返回的多个待选设备的信息。
设备分组周期,是指以分组为单位向服务器上报状态的时间段。每个分组包括至少一个设备。设备的种类包括但不限于:智能家电设备。
服务器,被配置为记录在服务器注册过的每个设备的状态。移动终端设备。设备的状态包括:上线状态和下线状态。
待选设备,是指服务器为目标设备提供的可供分组选择的设备。
待选设备的信息,包括但不限于:待选设备的编码和通信地址。进一步地,在一些实施方式中,服务器返回的多个待选设备的信息存储在待选设备列表中。
步骤S120,根据多个所述待选设备的信息,在多个所述待选设备中,选择分组设备。
分组设备,被配置为与目标设备组成一个分组的待选设备。分组设备和目标设备组成一个分组,以便以该分组为单位向服务器上报分组内每个设备的状态。分组设备的数量不做限定。例如:待选设备的数量大于或者等于分组设备的数量。
选择分组设备,包括:在多个待选设备的信息中,选择所有的待选设备的信息,将所有的待选设备都作为分组设备;或者,在多个待选设备的信息中,随机选择预设第一数量的待选设备的信息,将被选择的待选设备的信息对应的待选设备作为分组设备;或者,根据多个 待选设备的信息,确定目标设备与每个待选设备的网络延迟,按照网络延迟从小到大的顺序对待选设备进行排序,从网络延迟最小的待选设备开始,选择预设第一数量的待选设备作为分组设备;或者,从网络延迟最小的待选设备开始,最多选择预设第一数量并且同意与目标设备组成一个分组的待选设备作为分组设备。
步骤S130,在所述目标设备和所述分组设备中,确定上报设备,以便在所述设备分组周期内,通过所述上报设备向所述服务器上报所述目标设备和所述分组设备的状态。
上报设备,是指向服务器上报分组内各个设备的状态的设备。
确定上报设备,包括:在所述目标设备和所述分组设备中,随机确定一个设备作为上报设备;或者,通过共识算法在所述目标设备和所述分组设备中,确定一个设备作为上报设备。
进一步地,所述共识算法主要是通过与所述分组设备进行协商通信,在所述目标设备和所述分组设备中,确定一个设备作为上报设备。
协商通信,是指目标设备和分组设备之间交互协商信息,目标设备和分组设备根据接收到的协商信息,共同选择上报设备。协商信息是指选择上报设备的信息。
进一步地,协商信息的种类包括:当前设备的在线时长,当前设备到分组内其他设备的网络延时,当前设备到分组内其他设备的平均网络延时。例如:在所述目标设备和所述分组设备中,将网络延时平均值最小的设备确定为上报设备。
在一些实施例中,在确定上报设备之后,使上报设备将分组内的各个设备的信息发送给服务器,以便服务器获知该分组内的各个设备的信息。
在本实施例中,目标设备在每个设备分组周期内,确定所属的分组,并且确定分组内的上报设备,上报设备收集分组内的各个设备的状态并上报给服务器。本申请无需各个客户分别与服务器建立通信连接并且上报心跳包,也无需服务器接收大量设备分别发送的心跳包并且处理大量的心跳包,有效提高了设备的状态上报效率,降低了服务器的心跳包处理压力。基于上述在目标设备侧执行的状态上报方法,下面针对在服务器侧执行的状态上报方法进行描述。
如图2所示,是根据本申请一实施例的在服务器侧执行的状态上报方法的流程图。
步骤S210,接收上报设备上报的目标设备的状态和分组设备的状态。
上报设备是在设备分组周期开始之后,在所述目标设备和所述分组设备中确定出的一个设备。也即是说,上报设备包括在目标设备和分组设备中,上报设备的状态包括在目标设备的状态和分组设备的状态中。
分组设备是所述目标设备在多个待选设备中选择的,多个所述待选设备的信息是所述服务器向所述目标设备发送的。
所述状态的种类包括:上线状态和下线状态。
步骤S220,根据所述目标设备的状态更新所述目标设备的当前状态;并且,根据所述分组设备的状态更新所述分组设备的当前状态。
在一些实施例中,在服务器侧设置有在线设备列表,在该在线设备列表中记录在线状态的设备的信息。在根据目标设备的当前状态和分组设备的当前状态时,在该在线设备列表中移除下线状态的设备的信息。
在本实施例中,在接收上报设备上报的目标设备的状态和分组设备的状态之前,还接收 来自于所述目标设备的位置信息;根据所述目标设备的位置信息,在上线状态的设备中,选择预设数量的设备作为待选设备;其中,被选择的所述设备与所述目标设备的距离小于未被选择的所述设备与所述目标设备的距离;向所述目标设备返回多个所述待选设备的信息,以便所述目标设备根据多个所述待选设备的信息,在多个所述待选设备中选择分组设备。
进一步地,在一些实施例中,服务器为了向目标设备发送该目标设备附近的客户端的信息,并确定目标设备与其他在线状态的设备之间的距离,按照距离从小到大的顺序,获取多个设备,作为目标设备的待选设备。例如:按照距离从小到大的顺序,获取50个设备,作为目标设备的待选设备,并将这50个设备的信息发送给目标设备。
进一步地,在服务器注册的目标设备的数量为多个,在一些实施例中,服务器向每个目标设备发送的多个待选设备信息之间重复,在另外一些实施例中,服务器向每个目标设备发送的多个待选设备信息也不重复。例如:在目标设备上线时,目标设备向服务器发送位置信息,服务器根据该目标设备的位置信息,向该目标设备发送多个待选设备的信息;其中,向该目标设备发送的多个待选设备的信息允许与发送给其他设备的待选设备的信息重复,这样,该目标设备通过请求的方式在多个待选设备中选择分组设备,避免不同分组中的设备出现重复。又如:在每个设备分组周期开始时,目标设备向服务器发送位置信息,服务器根据各个目标设备的位置信息,为各个目标设备分别分配不重复的多个待选设备,并将每个目标设备对应的多个待选设备的信息向目标设备发送,使目标设备选择服务器返回的所有待选设备的信息,并将该所有待选设备都作为分组设备。
在本实施例中,在接收上报设备上报的目标设备的状态和分组设备的状态之前,还接受来自于上报设备发送的分组内的各个设备的信息。在当前设备分组周期内,维护该分组的信息。
在本实施例中,由于上报设备和服务器之间的网络连接可能会出现网络故障的问题,针对这种情况,从未接收到所述上报设备上报的目标设备的状态和分组设备的状态开始,在预设的第二等待时间段内,依旧未收到所述上报设备上报的目标设备的状态和分组设备的状态的情况下,将所述目标设备的当前状态和所述分组设备的当前状态都更新下线状态。第二等待时间段的时长大于上报设备的上报时间段的时长。
在本实施例中,服务器接收上报设备上报的目标设备的状态以及分组设备的状态,无需与上报设备所在分组内的所有设备建立通信连接,也无需接收上报设备所在分组内每个设备发送的心跳包,仅根据上报设备上报的状态组(目标设备的状态以及分组设备的状态),完成各个设备的状态更新即可,状态更新效率高,并且信息处理压力较小。
为了使本实施例更加清楚,下面对本实施例的状态上报方法进行进一步地描述。如图3所示,是根据本申请一实施例的状态上报方法的流程图。
步骤S310,目标设备在每个设备分组周期开始之后,读取服务器返回的多个待选设备的信息。
设备分组周期的时长大于设备上报心跳包的周期时长。
在读取多个待选设备的信息之前,需要向服务器发送目标设备的位置信息,以便服务器根据所述目标设备的位置信息,在上线状态的设备中,选择预设数量的设备作为待选设备;其中,被选择的所述设备与所述目标设备的距离小于未被选择的所述设备与所述目标设备的 距离;接收并存储所述服务器返回的多个所述待选设备的信息。
进一步地,在目标设备的位置固定的情况下,在目标设备上线后,与服务器建立通信连接并向服务器发送目标设备的位置信息。在目标设备的位置为移动状态的情况下,每隔一段时间向服务器发送一次目标设备的位置信息。
进一步地,在一些实施例中,服务器返回的多个待选设备的信息被记录在待选设备列表中。目标设备维护该待选设备列表即可,目标设备根据需求在待选设备列表中增加或者删除设备的信息。
步骤S320,目标设备根据多个所述待选设备的信息,与每个所述待选设备建立通信连接。
在一些实施例中,待选设备的信息包括待选设备的通信地址;目标设备根据待选设备的通信地址,与待选设备建立TCP(Transmission Control Protocol,传输控制协议)通信连接。
步骤S330,目标设备基于与每个所述待选设备的通信连接,确定每个所述待选设备的网络延时。
在一些实施例中,目标设备利用ICMP(Internet Control Message Protocol,Internet控制报文协议)协议,测试与每个待选设备之间的网络延时。
步骤S340,目标设备根据每个所述待选设备的网络延时,在多个所述待选设备中,选择分组设备。
在一些实施例中,由于待选设备可能已经与其他设备组成分组,所以为了不同分组中的设备不重复,按照网络延时从小到大的顺序,顺序向每个所述待选设备发送分组请求;接收每个所述待选设备返回的同意分组消息或者拒绝分组消息;选择返回所述同意分组消息的所述待选设备,作为所述分组设备,以便将所述目标设备和选择出的所述分组设备组成一个分组。其中,分组设备的数量为至少一个。例如:目标设备在50个待选设备中,确定消息往返时间最短的10个设备作为分组设备。
所述同意分组消息是所述待选设备不属于其他分组时返回的;或者,是所述待选设备属于其他分组并且第一网络延时小于第二网络延时时返回的;第一网络延时是所述待选设备与所述目标设备之间的网络延时;所述第二网络延时是所述待选设备与所述其他分组中的交互设备之间的网络延时。
所述拒绝分组消息是所述待选设备属于其他分组并且所述第一网络延时大于或者等于所述第二网络延时时返回的。
步骤S350,目标设备确定所述目标设备(目标设备自身)的在线时长;将所述目标设备的在线时长向所述分组设备发送,并且接收所述分组设备发送的所述分组设备的在线时长。
在选出分组设备之后,目标设备和分组设备形成一个分组。在一些实施例中,为了以分组为单位向服务器上报分组内各个客户的状态,在分组内选举出一个上报设备。
进一步地,针对每个分组设备而言,分组设备在向目标设备返回同意分组消息之后,向目标设备发送协商信息。该协商信息包括分组设备的在线时长。
步骤S360,目标设备在所述目标设备和所述分组设备中,确定在线时长最长的设备作为所述上报设备;其中,所述分组设备也确定在线时长最长的设备作为所述上报设备。
由于目标设备向分组设备发送协商信息,分组设备同样要向目标设备发送协商信息,所 以,目标设备和分组设备的协商信息对等,确定出的上报设备为同一个,无需互相通知上报设备的信息。
在本实施例中,在一个分组中,上报设备的角色为leader,其他设备为follower。
步骤S370,目标设备在所述设备分组周期内,通过所述上报设备向所述服务器上报所述目标设备和所述分组设备的状态。
在目标设备被确定为上报设备的情况下,每隔预设上报时间段,接收所述分组设备上报的心跳包,并根据接收到的心跳包,确定所述分组设备的状态;将所述目标设备的状态以及所述分组设备的状态向所述服务器上报。其中,上报时间段为状态上报周期。上报时间段为经验值或者实验值。
进一步地,将接收到的心跳包对应的所述分组设备的状态确定为上线状态,将剩余所述分组设备的状态确定为下线状态。
在分组设备被确定为上报设备的情况下,每隔所述上报时间段,使所述目标设备向所述上报设备发送一次心跳包,以便所述上报设备根据所述目标设备上报的心跳包,确定所述目标设备的状态并向所述服务器上报。
在目标设备被确定为上报设备的情况下,从未接收到一个分组设备上报的心跳包开始,在预设的第一等待时间段内,依旧未接收到所述分组设备上报的心跳包的情况下,删除所述分组设备的信息;其中,所述第一等待时间段的时长大于上报时间段的时长。如果在一定时长内没有收到一个设备上报的心跳包,则说明目标设备和该分组设备之间已经出现通信故障或者该分组设备已经下线。本实施例将该分组设备的状态标记为下线状态,以便服务器将该分组设备的状态更新为下线状态,在该分组设备恢复通信或者上线之后,通过重新分组的形式,再次在服务器恢复上线状态。
步骤S380,服务器接收上报设备上报的目标设备的状态和分组设备的状态。
在服务器侧记录了每个设备的当前状态,以便与在线状态的设备进行通信。
服务器为了及时获知各个设备的状态是否发生变化,需要每隔预设的上报时间段更新一次各个设备的状态,因此,服务器每隔上报时间段接收上报设备上报的目标设备的状态和分组设备的状态。
步骤S390,服务器根据所述目标设备的状态,更新所述目标设备的当前状态;并且,根据所述分组设备的状态更新所述分组设备的当前状态。
在本实施例中,通过将需要保持在线状态的设备分组,组内设备之间互相通信确认彼此状态,然后在每隔一个分组周期选出一位上报者与服务器交付组内每个设备的状态,这样就减轻了服务器为了确认设备是否在线,而与多个设备同时保持心跳包连接的压力。
进一步地,因为电磁波传播速度一定的情况下,网络延时越小,消息传输越快,所以服务器根据目标设备的位置信息,提供可供目标设备选择的待选设备,提高目标设备和待选设备之间的通信效率。
进一步地,目标设备基于与每个待选设备之间的网络延时,选择与网络延时小的待选设备组成一个分组,这样,同一分组内的设备之间通信时效性较高,这样保证了向服务器上报的分组内的设备的状态的时效性。
进一步地,通过共识算法确定上报设备,该共识算法使用的协商信息为在线时长,选择 在线时长最长的设备作为上报设备,以保证上报设备的稳定性,即保证了状态上报的稳定性,不会因为上报设备的频繁变化,而影响设备状态的上报。
进一步地,通过上报设备上报其所在分组内各个设备的状态,这样,仅需上报设备与服务器保持通信连接即可,无需每个设备都与服务器保持通信连接并且上报心跳包,通过本实施例的方式,有效降低了服务器的通信连接数量,降低了服务器的信息处理数量,提高了状态上报效率。
在执行本实施例的过程中,需要注意以下几点:
在所述目标设备被确定为上报设备的情况下,在确定与所述服务器断开通信连接的情况下,在所述目标设备和所述分组设备中,重新确定上报设备。上报设备与服务器断开通信连接的情况下,将无法将分组内所有设备的状态上报给服务器,在这种情况下,需要重新选举上报设备,通过新的上报设备上报分组内所有设备的状态。
如果目标设备并非服务器的新增设备,那么目标设备的信息可能被服务器发送给其他设备,那么在其他设备确定分组设备时,可能会接收到其他设备发送的分组请求,针对这种情况,本实施例可以执行如下步骤:
在确定上报设备之前,接收到来自于其他设备的分组请求的情况下,向所述其他设备返回同意分组消息,以便所述目标设备进入所述其他设备所在分组。在这种情况下,目标设备不属于任何分组,可先同意加入其他客户的分组。
在确定上报设备之后,接收到来自于其他设备的分组请求的情况下,确定第三网络延时和第四网络延时;其中,所述第三网络延时是所述目标设备与所述其他设备之间的网络延时;所述第四网络延时是所述目标设备与所述上报设备之间的网络延时。在所述第三网络延时小于所述第四网络延时的情况下,向所述其他设备返回同意分组消息,并向所述目标设备发送拒绝分组消息。在所述第三网络延时大于或者等于所述第四网络延时的情况下,向所述其他设备返回拒绝分组消息。
本实施例的分组的原则是分组内的设备之间的网络延时较小,所以在所述接收到来自于其他设备的分组请求之后,在所述分组请求中,提取所述其他设备的信息;在确定所述其他设备的信息未包含在所述待选设备列表中的情况下,确定所述待选设备列表中的每个所述待选设备的网络延时;在所述待选设备列表中的每个所述待选设备的网络延时中,确定最大的网络延时;在所述第三网络延时小于所述最大的网络延时的情况下,将所述最大的网络延时对应的待选设备的信息从所述待选设备列表中删除,并且将所述其他设备的信息添加到所述待选设备列表中。这样待选设备列表随着设备信息的增减进行动态地变化。
本申请实施例还提供一种设置在目标设备的状态上报装置。如图4所示是根据本申请一实施例的设置在目标设备的状态上报装置的结构图。
该设置在目标设备的状态上报装置,包括:读取模块410,选择模块420和确定模块430。
读取模块410,被配置为在每个设备分组周期开始之后,读取服务器返回的多个待选设备的信息。
选择模块420,被配置为根据多个所述待选设备的信息,在多个所述待选设备中,选择分组设备。
确定模块430,被配置为在所述目标设备和所述分组设备中,确定上报设备,以便在所 述设备分组周期内,通过所述上报设备向所述服务器上报所述目标设备和所述分组设备的状态。
本申请实施例还提供一种设置在服务器的状态上报装置。如图5所示是根据本申请一实施例的设置在服务器的状态上报装置的结构图。
该设置在服务器的状态上报装置,包括:
接收模块510,被配置为接收上报设备上报的目标设备的状态和分组设备的状态;其中,所述上报设备是在设备分组周期开始之后,在所述目标设备和所述分组设备中确定出的一个设备;所述分组设备是所述目标设备在多个待选设备中选择的,多个所述待选设备的信息是所述服务器向所述目标设备发送的。
更新模块520,被配置为根据所述目标设备的状态更新所述目标设备的当前状态;并且,根据所述分组设备的状态更新所述分组设备的当前状态。
如图6所示,本申请实施例提供了一种电子设备,包括处理器610、通信接口620、存储器630和通信总线640,其中,处理器610,通信接口620,存储器630通过通信总线640完成相互间的通信。
存储器630,被配置为存放计算机程序。
在本申请一个实施例中,处理器610,被配置为执行存储器630上所存放的程序时,实现前述任意在目标设备执行的状态上报方法或者在服务器执行的状态上报方法。
处理器610执行存储器630上所存放的程序时,被配置为实现在目标设备执行的状态上报方法步骤:在每个设备分组周期开始之后,读取服务器返回的多个待选设备的信息;根据多个所述待选设备的信息,在多个所述待选设备中,选择分组设备;在所述目标设备和所述分组设备中,确定上报设备,以便在所述设备分组周期内,通过所述上报设备向所述服务器上报所述目标设备和所述分组设备的状态。
其中,在所述读取服务器返回的多个待选设备的信息之前,还包括:向所述服务器发送所述目标设备的位置信息,以便所述服务器根据所述目标设备的位置信息,在上线状态的设备中,选择预设数量的设备作为待选设备;其中,被选择的所述设备与所述目标设备的距离小于未被选择的所述设备与所述目标设备的距离;接收并存储所述服务器返回的多个所述待选设备的信息。
其中,所述根据多个所述待选设备的信息,在多个所述待选设备中,选择分组设备,包括:根据多个所述待选设备的信息,与每个所述待选设备建立通信连接;基于与每个所述待选设备的通信连接,确定每个所述待选设备的网络延时;根据每个所述待选设备的网络延时,在多个所述待选设备中,选择分组设备。
其中,所述根据与每个所述待选设备之间的网络延时,在多个所述待选设备中,选择分组设备,包括:按照网络延时从小到大的顺序,顺序向每个所述待选设备发送分组请求;接收每个所述待选设备返回的同意分组消息或者拒绝分组消息;选择返回所述同意分组消息的所述待选设备,作为所述分组设备,以便将所述目标设备和选择出的所述分组设备组成一个分组;其中,所述同意分组消息是所述待选设备不属于其他分组时返回的;或者,是所述待选设备属于其他分组并且第一网络延时小于第二网络延时时返回的;第一网络延时是所述待选设备与所述目标设备之间的网络延时;所述第二网络延时是所述待选设备与所述其他分组 中的交互设备之间的网络延时;所述拒绝分组消息是所述待选设备属于其他分组并且所述第一网络延时大于或者等于所述第二网络延时时返回的。
其中,所述方法还包括:在确定上报设备之前,接收到来自于其他设备的分组请求的情况下,向所述其他设备返回同意分组消息,以便所述目标设备进入所述其他设备所在分组;在确定上报设备之后,接收到来自于其他设备的分组请求的情况下,确定第三网络延时和第四网络延时;其中,所述第三网络延时是所述目标设备与所述其他设备之间的网络延时;所述第四网络延时是所述目标设备与所述上报设备之间的网络延时;在所述第三网络延时小于所述第四网络延时的情况下,向所述其他设备返回同意分组消息,并向所述目标设备发送拒绝分组消息;在所述第三网络延时大于或者等于所述第四网络延时的情况下,向所述其他设备返回拒绝分组消息。
其中,所述服务器返回的多个待选设备的信息被记录在待选设备列表中;在所述接收到来自于其他设备的分组请求之后,所述方法还包括:在所述分组请求中,提取所述其他设备的信息;在确定所述其他设备的信息未包含在所述待选设备列表中的情况下,确定所述待选设备列表中的每个所述待选设备的网络延时;在所述待选设备列表中的每个所述待选设备的网络延时中,确定最大的网络延时;在所述第三网络延时小于所述最大的网络延时的情况下,将所述最大的网络延时对应的待选设备的信息从所述待选设备列表中删除,并且将所述其他设备的信息添加到所述待选设备列表中。
其中,所述在所述目标设备和所述分组设备中,确定上报设备,包括:确定所述目标设备的在线时长;将所述目标设备的在线时长向所述分组设备发送,并且接收所述分组设备发送的所述分组设备的在线时长;在所述目标设备和所述分组设备中,确定在线时长最长的设备作为所述上报设备;其中,所述分组设备也确定在线时长最长的设备作为所述上报设备。
其中,所述在所述设备分组周期内,通过所述上报设备向所述服务器上报所述目标设备和所述分组设备的状态,包括:在所述目标设备被确定为上报设备的情况下,每隔预设上报时间段,接收所述分组设备上报的心跳包,并根据接收到的心跳包,确定所述分组设备的状态;将所述目标设备的状态以及所述分组设备的状态向所述服务器上报;在所述分组设备被确定为上报设备的情况下,每隔所述上报时间段,使所述目标设备向所述上报设备发送一次心跳包,以便所述上报设备根据所述目标设备上报的心跳包,确定所述目标设备的状态并向所述服务器上报。
其中,在所述目标设备被确定为上报设备的情况下,所述方法还包括:从未接收到一个分组设备上报的心跳包开始,在预设的第一等待时间段内,依旧未接收到所述分组设备上报的心跳包的情况下,删除所述分组设备的信息。
其中,在所述目标设备被确定为上报设备的情况下,所述方法还包括:在确定与所述服务器断开通信连接的情况下,在所述目标设备和所述分组设备中,重新确定上报设备。
处理器610执行存储器630上所存放的程序时,用于实现在服务器执行的状态上报方法步骤:接收上报设备上报的目标设备的状态和分组设备的状态;其中,所述上报设备是在设备分组周期开始之后,在所述目标设备和所述分组设备中确定出的一个设备;所述分组设备是所述目标设备在多个待选设备中选择的,多个所述待选设备的信息是所述服务器向所述目标设备发送的;根据所述目标设备的状态更新所述目标设备的当前状态;并且,根据所述分组 设备的状态更新所述分组设备的当前状态。
其中,所述状态的种类包括:上线状态和下线状态;在所述接收上报设备上报的目标设备的状态和分组设备的状态之前,还包括:接收来自于所述目标设备的位置信息;根据所述目标设备的位置信息,在上线状态的设备中,选择预设数量的设备作为待选设备;其中,被选择的所述设备与所述目标设备的距离小于未被选择的所述设备与所述目标设备的距离;向所述目标设备返回多个所述待选设备的信息,以便所述目标设备根据多个所述待选设备的信息,在多个所述待选设备中选择分组设备。
其中,所述方法还包括:从未接收到所述上报设备上报的目标设备的状态和分组设备的状态开始,在预设的第二等待时间段内,依旧未收到所述上报设备上报的目标设备的状态和分组设备的状态的情况下,将所述目标设备的当前状态和所述分组设备的当前状态都更新下线状态。
本申请实施例还提供了一种计算机可读存储介质,其上存储有计算机程序,所述计算机程序被处理器执行时实现如前述任意一个方法实施例提供的状态上报方法的步骤。
需要说明的是,在本文中,诸如“第一”和“第二”等之类的关系术语仅仅用来将一个实体或者操作与另一个实体或操作区分开来,而不一定要求或者暗示这些实体或操作之间存在任何这种实际的关系或者顺序。而且,术语“包括”、“包含”或者其任何其他变体意在涵盖非排他性的包含,从而使得包括一系列要素的过程、方法、物品或者设备不仅包括那些要素,而且还包括没有明确列出的其他要素,或者是还包括为这种过程、方法、物品或者设备所固有的要素。在没有更多限制的情况下,由语句“包括一个……”限定的要素,并不排除在包括所述要素的过程、方法、物品或者设备中还存在另外的相同要素。
以上所述仅是本申请的具体实施方式,使本领域技术人员能够理解或实现本申请。对这些实施例的多种修改对本领域的技术人员来说将是显而易见的,本文中所定义的一般原理可以在不脱离本申请的精神或范围的情况下,在其它实施例中实现。因此,本申请将不会被限制于本文所示的这些实施例,而是要符合与本文所申请的原理和新颖特点相一致的最宽的范围。
Claims (17)
- 一种状态上报方法,其中,在目标设备侧执行的步骤,包括:在每个设备分组周期开始之后,读取服务器返回的多个待选设备的信息;根据多个所述待选设备的信息,在多个所述待选设备中,选择分组设备;在所述目标设备和所述分组设备中,确定上报设备,以便在所述设备分组周期内,通过所述上报设备向所述服务器上报所述目标设备和所述分组设备的状态。
- 根据权利要求1所述的方法,其中,在所述读取服务器返回的多个待选设备的信息之前,还包括:向所述服务器发送所述目标设备的位置信息,以便所述服务器根据所述目标设备的位置信息,在上线状态的设备中,选择预设数量的设备作为待选设备;其中,被选择的所述设备与所述目标设备的距离小于未被选择的所述设备与所述目标设备的距离;接收并存储所述服务器返回的多个所述待选设备的信息。
- 根据权利要求1所述的方法,其中,所述根据多个所述待选设备的信息,在多个所述待选设备中,选择分组设备,包括:根据多个所述待选设备的信息,与每个所述待选设备建立通信连接;基于与每个所述待选设备的通信连接,确定每个所述待选设备的网络延时;根据每个所述待选设备的网络延时,在多个所述待选设备中,选择分组设备。
- 根据权利要求3所述的方法,其中,所述根据与每个所述待选设备之间的网络延时,在多个所述待选设备中,选择分组设备,包括:按照网络延时从小到大的顺序,顺序向每个所述待选设备发送分组请求;接收每个所述待选设备返回的同意分组消息或者拒绝分组消息;选择返回所述同意分组消息的所述待选设备,作为所述分组设备,以便将所述目标设备和选择出的所述分组设备组成一个分组;其中,所述同意分组消息是所述待选设备不属于其他分组时返回的;或者,是所述待选设备属于其他分组并且第一网络延时小于第二网络延时时返回的;第一网络延时是所述待选设备与所述目标设备之间的网络延时;所述第二网络延时是所述待选设备与所述其他分组中的交互设备之间的网络延时;所述拒绝分组消息是所述待选设备属于其他分组并且所述第一网络延时大于或者等于所述第二网络延时时返回的。
- 根据权利要求1所述的方法,其中,所述方法还包括:在确定上报设备之前,接收到来自于其他设备的分组请求的情况下,向所述其他设备返回同意分组消息,以便所述目标设备进入所述其他设备所在分组;在确定上报设备之后,接收到来自于其他设备的分组请求的情况下,确定第三网络延时和第四网络延时;其中,所述第三网络延时是所述目标设备与所述其他设备之间的网络延时;所述第四网络延时是所述目标设备与所述上报设备之间的网络延时;在所述第三网络延时小于所述第四网络延时的情况下,向所述其他设备返回同意分组消息,并向所述目标设备发送拒绝分组消息;在所述第三网络延时大于或者等于所述第四网络延时的情况下,向所述其他设备返回拒绝分组消息。
- 根据权利要求5所述的方法,其中,所述服务器返回的多个待选设备的信息被记录在待选设备列表中;在所述接收到来自于其他设备的分组请求之后,所述方法还包括:在所述分组请求中,提取所述其他设备的信息;在确定所述其他设备的信息未包含在所述待选设备列表中的情况下,确定所述待选设备列表中的每个所述待选设备的网络延时;在所述待选设备列表中的每个所述待选设备的网络延时中,确定最大的网络延时;在所述第三网络延时小于所述最大的网络延时的情况下,将所述最大的网络延时对应的待选设备的信息从所述待选设备列表中删除,并且将所述其他设备的信息添加到所述待选设备列表中。
- 根据权利要求1所述的方法,其中,所述在所述目标设备和所述分组设备中,确定上报设备,包括:确定所述目标设备的在线时长;将所述目标设备的在线时长向所述分组设备发送,并且接收所述分组设备发送的所述分组设备的在线时长;在所述目标设备和所述分组设备中,确定在线时长最长的设备作为所述上报设备;其中,所述分组设备也确定在线时长最长的设备作为所述上报设备。
- 根据权利要求1所述的方法,其中,所述在所述设备分组周期内,通过所述上报设备向所述服务器上报所述目标设备和所述分组设备的状态,包括:在所述目标设备被确定为上报设备的情况下,每隔预设上报时间段,接收所述分组设备上报的心跳包,并根据接收到的心跳包,确定所述分组设备的状态;将所述目标设备的状态以及所述分组设备的状态向所述服务器上报;在所述分组设备被确定为上报设备的情况下,每隔所述上报时间段,使所述目标设备向所述上报设备发送一次心跳包,以便所述上报设备根据所述目标设备上报的心跳包,确定所述目标设备的状态并向所述服务器上报。
- 根据权利要求8所述的方法,其中,在所述目标设备被确定为上报设备的情况下,所述方法还包括:从未接收到一个分组设备上报的心跳包开始,在预设的第一等待时间段内,依旧未接收到所述分组设备上报的心跳包的情况下,删除所述分组设备的信息。
- 根据权利要求8所述的方法,其中,在所述目标设备被确定为上报设备的情况下,所述方法还包括:在确定与所述服务器断开通信连接的情况下,在所述目标设备和所述分组设备中,重新确定上报设备。
- 一种状态上报方法,其中,在服务器侧执行的步骤,包括:接收上报设备上报的目标设备的状态和分组设备的状态;其中,所述上报设备是 在设备分组周期开始之后,在所述目标设备和所述分组设备中确定出的一个设备;所述分组设备是所述目标设备在多个待选设备中选择的,多个所述待选设备的信息是所述服务器向所述目标设备发送的;根据所述目标设备的状态更新所述目标设备的当前状态;并且,根据所述分组设备的状态更新所述分组设备的当前状态。
- 根据权利要求11所述的方法,其中,所述状态的种类包括:上线状态和下线状态;在所述接收上报设备上报的目标设备的状态和分组设备的状态之前,还包括:接收来自于所述目标设备的位置信息;根据所述目标设备的位置信息,在上线状态的设备中,选择预设数量的设备作为待选设备;其中,被选择的所述设备与所述目标设备的距离小于未被选择的所述设备与所述目标设备的距离;向所述目标设备返回多个所述待选设备的信息,以便所述目标设备根据多个所述待选设备的信息,在多个所述待选设备中选择分组设备。
- 根据权利要求11所述的方法,其中,所述方法还包括:从未接收到所述上报设备上报的目标设备的状态和分组设备的状态开始,在预设的第二等待时间段内,依旧未收到所述上报设备上报的目标设备的状态和分组设备的状态的情况下,将所述目标设备的当前状态和所述分组设备的当前状态都更新下线状态。
- 一种状态上报装置,其中,设置在目标设备侧,包括:读取模块,被配置为在每个设备分组周期开始之后,读取服务器返回的多个待选设备的信息;选择模块,被配置为根据多个所述待选设备的信息,在多个所述待选设备中,选择分组设备;确定模块,被配置为在所述目标设备和所述分组设备中,确定上报设备,以便在所述设备分组周期内,通过所述上报设备向所述服务器上报所述目标设备和所述分组设备的状态。
- 一种状态上报装置,其中,设置在服务器侧,包括:接收模块,被配置为接收上报设备上报的目标设备的状态和分组设备的状态;其中,所述上报设备是在设备分组周期开始之后,在所述目标设备和所述分组设备中确定出的一个设备;所述分组设备是所述目标设备在多个待选设备中选择的,多个所述待选设备的信息是所述服务器向所述目标设备发送的;更新模块,被配置为根据所述目标设备的状态更新所述目标设备的当前状态;并且,根据所述分组设备的状态更新所述分组设备的当前状态。
- 一种电子设备,其中,包括处理器、通信接口、存储器和通信总线,其中,处理器,通信接口,存储器通过通信总线完成相互间的通信;存储器,被配置为存放计算机程序;处理器,被配置为执行存储器上所存放的程序时,实现权利要求1-10任一项所述 的状态上报方法的步骤,或者,实现权利要求11-13任一项所述的状态上报方法的步骤。
- 一种计算机可读存储介质,其上存储有计算机程序,其中,所述计算机程序被处理器执行时,实现权利要求1-10任一项所述的状态上报方法的步骤,或者,实现权利要求11-13任一项所述的状态上报方法的步骤。
Applications Claiming Priority (2)
Application Number | Priority Date | Filing Date | Title |
---|---|---|---|
CN202110181924.6 | 2021-02-09 | ||
CN202110181924.6A CN112910740A (zh) | 2021-02-09 | 2021-02-09 | 一种状态上报方法、装置、设备和计算机可读存储介质 |
Publications (1)
Publication Number | Publication Date |
---|---|
WO2022170791A1 true WO2022170791A1 (zh) | 2022-08-18 |
Family
ID=76123352
Family Applications (1)
Application Number | Title | Priority Date | Filing Date |
---|---|---|---|
PCT/CN2021/128480 WO2022170791A1 (zh) | 2021-02-09 | 2021-11-03 | 一种状态上报方法、装置、设备和计算机可读存储介质 |
Country Status (2)
Country | Link |
---|---|
CN (1) | CN112910740A (zh) |
WO (1) | WO2022170791A1 (zh) |
Families Citing this family (2)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
CN112910740A (zh) * | 2021-02-09 | 2021-06-04 | 珠海格力电器股份有限公司 | 一种状态上报方法、装置、设备和计算机可读存储介质 |
CN115714776B (zh) * | 2023-01-09 | 2023-05-09 | 杭州涂鸦信息技术有限公司 | 从设备接收上报数据的方法、设备上报数据的方法 |
Citations (4)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
US20140181295A1 (en) * | 2012-12-21 | 2014-06-26 | Tanium Inc. | Creation and Maintenance of Self-Organizing Communication Orbits in Distributed Networks |
CN104270466A (zh) * | 2014-10-22 | 2015-01-07 | 中国建设银行股份有限公司 | 数据上报方法及相关设备 |
CN108055321A (zh) * | 2017-12-11 | 2018-05-18 | 中国电子科技集团公司第二十八研究所 | 基于国产化平台的高可靠集群构建方法 |
CN112910740A (zh) * | 2021-02-09 | 2021-06-04 | 珠海格力电器股份有限公司 | 一种状态上报方法、装置、设备和计算机可读存储介质 |
Family Cites Families (9)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
CN105553685B (zh) * | 2015-10-13 | 2019-06-28 | 福州开发区慧聚通信技术有限公司 | 一种监控网络设备是否在线的系统和方法 |
US10565227B1 (en) * | 2016-08-31 | 2020-02-18 | Amazon Technologies, Inc. | Leadership lease protocol for data replication groups |
CN109005528A (zh) * | 2018-07-06 | 2018-12-14 | 杭州涂鸦信息技术有限公司 | 一种蓝牙mesh网关数据聚合上报方法 |
CN109150588A (zh) * | 2018-07-25 | 2019-01-04 | 河北华沃通信科技有限公司 | 设备管理方法及装置 |
CN111343218A (zh) * | 2018-12-18 | 2020-06-26 | 杭州光启人工智能研究院 | 基于心跳报文数据发送和接收方法、存储介质及处理器 |
CN109788068B (zh) * | 2019-02-14 | 2020-11-03 | 腾讯科技(深圳)有限公司 | 心跳状态信息上报方法、装置和设备及计算机存储介质 |
CN110798349B (zh) * | 2019-10-28 | 2023-02-28 | 国家计算机网络与信息安全管理中心 | 一种配置分发、接收方法、设备及计算机可读存储介质 |
CN111130920B (zh) * | 2019-11-26 | 2022-03-11 | 网宿科技股份有限公司 | 硬件信息获取方法、装置、服务器及存储介质 |
CN112073473B (zh) * | 2020-08-18 | 2023-03-24 | 浙江鸿城科技有限责任公司 | 一种物联网设备心跳包数据采集方法 |
-
2021
- 2021-02-09 CN CN202110181924.6A patent/CN112910740A/zh active Pending
- 2021-11-03 WO PCT/CN2021/128480 patent/WO2022170791A1/zh active Application Filing
Patent Citations (4)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
US20140181295A1 (en) * | 2012-12-21 | 2014-06-26 | Tanium Inc. | Creation and Maintenance of Self-Organizing Communication Orbits in Distributed Networks |
CN104270466A (zh) * | 2014-10-22 | 2015-01-07 | 中国建设银行股份有限公司 | 数据上报方法及相关设备 |
CN108055321A (zh) * | 2017-12-11 | 2018-05-18 | 中国电子科技集团公司第二十八研究所 | 基于国产化平台的高可靠集群构建方法 |
CN112910740A (zh) * | 2021-02-09 | 2021-06-04 | 珠海格力电器股份有限公司 | 一种状态上报方法、装置、设备和计算机可读存储介质 |
Also Published As
Publication number | Publication date |
---|---|
CN112910740A (zh) | 2021-06-04 |
Similar Documents
Publication | Publication Date | Title |
---|---|---|
WO2022170791A1 (zh) | 一种状态上报方法、装置、设备和计算机可读存储介质 | |
US8838703B2 (en) | Method and system for message processing | |
CN103780679A (zh) | 基于http协议的长延时远程调用方法 | |
CN115004673B (zh) | 消息推送方法、装置、电子设备及计算机可读介质 | |
US9965213B2 (en) | IP hard disk and storage system, and data operation methods therefor | |
US20090049172A1 (en) | Concurrent Node Self-Start in a Peer Cluster | |
WO2017128789A1 (zh) | 一种通信方法及系统 | |
CN113656176B (zh) | 云设备的分配方法、装置、系统、电子设备、介质及产品 | |
US20200389863A1 (en) | Method and system for processing node registration notification | |
US20170126828A1 (en) | Sending Method and Apparatus and Computer Storage Medium of Notification Message | |
WO2020098435A1 (zh) | 一种数据报文发送和接收方法、存储介质及处理器 | |
WO2020057368A1 (zh) | 网络状态测量方法、设备及系统 | |
US20120265871A1 (en) | Multicast, client/service-attribute resolution | |
CN113810511B (zh) | Arp表的更新方法及装置 | |
CN109120556B (zh) | 一种云主机访问对象存储服务器的方法及系统 | |
CN103986710A (zh) | 一种消息传输的方法、装置及系统 | |
CN110109933B (zh) | 信息维护方法、配置管理数据库系统及存储介质 | |
CN110661836B (zh) | 消息路由方法、装置及系统、存储介质 | |
CN110995413A (zh) | 一种防止伪节点攻击的联盟链共识节点管理方法 | |
TWI477113B (zh) | Information processing methods and systems | |
WO2014180286A1 (zh) | 一种m2m应用请求的发送方法、cse和系统 | |
WO2016110099A1 (zh) | 组资源的管理方法及装置 | |
CN111641698B (zh) | 一种数据统计方法、系统、设备及存储介质 | |
CN115002020B (zh) | 基于ospf的数据处理方法及装置 | |
WO2017012315A1 (zh) | 业务监听控制方法及装置 |
Legal Events
Date | Code | Title | Description |
---|---|---|---|
NENP | Non-entry into the national phase |
Ref country code: DE |
|
122 | Ep: pct application non-entry in european phase |
Ref document number: 21925438 Country of ref document: EP Kind code of ref document: A1 |