Device detection method and apparatus, device, and computer-readable storage medium
Abstract
A device detection method and apparatus, a related device, and a related computer-readable storage medium are disclosed. In the method: A first device obtains, through a DHCP, a first address of a second device and a second address allocated by the second device to the first device, where the second address is an IP address, and the second device is used as a DHCP server; creates a single-ended detection session based on the first address and the second address; sends a single-ended detection packet to the second device, where a source address and a destination address of the single-ended detection packet are the second address; and detects a running status of the second device based on a transmission status of the single-ended detection packet. After the second address is obtained, sending of the single-ended detection packet is automatically triggered, and a detection process does not need to be configured manually.
Claims
exact text as granted — not AI-modified1 . A device detection method, comprising:
obtaining, by a first device through a dynamic host configuration protocol (DHCP), a first address of a second device and a second address allocated by the second device to the first device, wherein the second address is an internet protocol (IP) address allocated by the second device to the first device, and the second device is used as a DHCP server; creating, by the first device, a single-ended detection session based on the first address and the second address; sending, by the first device, a single-ended detection packet to the second device based on establishment of the single-ended detection session, wherein a source address and a destination address of the single-ended detection packet are the second address; and detecting, by the first device, a running status of the second device based on a transmission status of the single-ended detection packet.
2 . The method according to claim 1 , wherein the obtaining a first address of a second device comprises:
receiving a DHCP offer packet sent by the second device, wherein the DHCP offer packet comprises the first address; and extracting the first address from the DHCP offer packet.
3 . The method according to claim 2 , wherein before creating the single-ended detection session, the method further comprises:
returning a request packet to the second device based on the DHCP offer packet, wherein the DHCP offer packet indicates, to the first device, the second address that can be allocated by the second device, and the request packet indicates that the first device selects the second address allocated by the second device; receiving an acknowledgment packet returned by the second device based on the request packet, wherein the acknowledgment packet indicates a duration for using the second address by the first device; verifying the second address based on the acknowledgment packet; and performing, based on that a verification result of the second address indicates that the first device is allowed to use the second address, an operation of creating the single-ended detection session.
4 . The method according to claim 1 , wherein the detecting a running status of the second device based on a transmission status of the single-ended detection packet comprises:
determining, based on that the single-ended detection packet returned by the second device is received in a first time period, that the running status of the second device is normal; or determining, based on that the single-ended detection packet returned by the second device is not received in the first time period, that the running status of the second device is abnormal.
5 . The method according to claim 1 , wherein after detecting the running status of the second device, the method further comprises:
setting the second address as an invalid address based on that the running status of the second device is abnormal.
6 . The method according to claim 5 , wherein after detecting the running status of the second device, the method further comprises:
sending a single-ended detection packet to the second device again based on that the running status of the second device is abnormal; and determining the running status of the second device based on a transmission status of the single-ended detection packet.
7 . The method according to claim 6 , wherein after determining the running status of the second device, the method further comprises:
applying to the second device for a third address based on that the running status of the second device is normal and the second address is the invalid address.
8 . The method according to claim 1 , wherein the first address is a medium access control (MAC) address.
9 . The method according to claim 1 , wherein the single-ended detection packet is a single-ended bidirectional forwarding detection (BFD) packet or a single-ended network quality analysis (NQA) packet.
10 . The method according to claim 1 , wherein the DHCP is a dynamic host configuration protocol for internet protocol version 6 (DHCPv6).
11 . The method according to claim 1 , wherein the second device is further used as a gateway.
12 . The method according to claim 11 , wherein the second device is one of a plurality of gateways, and a virtual router redundancy protocol (VRRP) is deployed between the plurality of gateways.
13 . The method according to claim 1 , wherein the sending, by the first device, a single-ended detection packet to the second device based on establishment of the single-ended detection session comprises:
configuring, by the first device, a session parameter of the single-ended detection session, wherein the session parameter comprises a detection periodicity and a quantity of detection times; and sending the single-ended detection packet based on the session parameter.
14 . A device detection apparatus used in a first device, wherein the apparatus comprises:
a memory storing computer instructions;
at least one processor coupled to the memory, when wherein the computer instructions, when executed by the at least one processor, cause the apparatus to:
obtain, through a dynamic host configuration protocol (DHCP), a first address of a second device and a second address allocated by the second device to the first device, wherein the second address is an internet protocol (IP) address allocated by the second device to the first device, and the second device is used as a DHCP server; create a single-ended detection session based on the first address and the second address; and send a single-ended detection packet to the second device based on establishment of the single-ended detection session, wherein a source address and a destination address of the single-ended detection packet are the second address; and detect a running status of the second device based on a transmission status of the single-ended detection packet.
15 . The apparatus according to claim 14 , wherein the computer instructions, when executed by the at least one processor, further cause the apparatus to:
receive a DHCP offer packet sent by the second device, wherein the DHCP offer packet comprises the first address of the second device; and extract the first address of the second device from the DHCP offer packet.
16 . The apparatus according to claim 15 , wherein the computer instructions, when executed by the at least one processor, further cause the apparatus to:
return a request packet to the second device based on the DHCP offer packet sent by the second device, wherein the DHCP offer packet indicates, to the first device, the second address that can be allocated by the second device, and the request packet indicates that the first device selects the second address allocated by the second device; and receive an acknowledgment packet returned by the second device based on the request packet, wherein the acknowledgment packet indicates a duration for using the second address by the first device; verify the second address based on the acknowledgment packet; and perform, based on that a verification result of the second address indicates that the first device is allowed to use the second address, an operation of creating the single-ended detection session.
17 . The apparatus according to claim 14 , wherein the computer instructions, when executed by the at least one processor, further cause the apparatus to:
determine, based on that the single-ended detection packet returned by the second device is received in a first time period, that the running status of the second device is normal; or determine, based on that the single-ended detection packet returned by the second device is not received in the first time period, that the running status of the second device is abnormal.
18 . The apparatus according to claim 14 , wherein the computer instructions, when executed by the at least one processor, further cause the apparatus to:
set the second address as an invalid address based on that the running status of the second device is abnormal.
19 . The apparatus according to claim 18 , wherein the computer instructions, when executed by the at least one processor, further cause the apparatus to:
send a single-ended detection packet to the second device again based on that the running status of the second device is abnormal; and determine the running status of the second device based on a transmission status of the single-ended detection packet.
20 . The apparatus according to claim 19 , wherein the computer instructions, when executed by the at least one processor, further cause the apparatus to:
apply to the second device for a third address based on that the running status of the second device is normal and the second address is the invalid address.Join the waitlist — get patent alerts
Track US2026032102A1 — get alerts on status changes and closely related new filings.
We store only your email — no account needed. See our privacy policy.