TECHNICAL FIELD

This application relates to the field of communications technologies, and in particular, to a data packet detection method, a device, and a system.

BACKGROUND

Operation, administration, and maintenance (operation administration and maintenance, OAM) is a technology providing transmission path status detection for a network. Network devices that communicate with each other detect, by using a sent OAM packet, whether a data packet transmission path is normal. Specifically, a first network device may construct an OAM detection packet based on the OAM technology, and the first network device sends the OAM detection packet to a second network device through a to-be-detected transmission path. After receiving the OAM detection packet, the second network device determines a status of the transmission path by analyzing the OAM detection packet.

However, it cannot be ensured that a transmission path of a conventional OAM detection packet is consistent with a transmission path of a data flow. When load sharing is performed on the to-be-detected transmission path, the transmission path of the OAM detection packet is less consistent with the transmission path of the data flow.

Internet protocol (Internet Protocol, IP) flow performance measurement (Flow Performance Measurement, FPM) is a measurement method for obtaining a network performance indicator, such as packet loss statistics or a service path delay, by directly measuring a data flow between a plurality of nodes. In the IP FPM technology, a data packet included in a data flow is colored, to carry and transmit detection information. Specifically, the first network device colors a specific data bit included in the data packet in the data flow, and then the first network device sends the data packet carrying a color flag to the second network device. The second network device identifies and counts the received data packet carrying the color flag, to determine performance of a transmission path.

However, the IP FPM technology provides coloring for only a data packet. Consequently, in the IP FPM technology, a data transmission path cannot be identified. In addition, in the IP FPM technology, only per-flow detection can be implemented, but per-packet detection cannot be implemented.

SUMMARY

In view of this, embodiments of this application provide a data packet detection method, a device, and a system, to implement information telemetry on a data packet on a transmission path by encapsulating detection information into the data packet on the transmission path, thereby implementing information collection on the data packet on the transmission path while ensuring packet forwarding performance.

Technical solutions provided in the embodiments of this application are as follows.

According to a first aspect, a data packet detection method is provided. The method includes: receiving, by a first network device, first control information sent by a controller, where the first control information includes a detection task type, and the detection task type indicates a detection task that the controller requires the first network device to perform; receiving, by the first network device, a first data packet sent by a previous-hop network device of the first network device, where the first data packet includes first detection information, the first detection information includes a first detection node identifier, a first sequence number, and first collection information, the first detection node identifier indicates a location, in a detection domain, of a network device processing the first detection information, the first sequence number indicates a sequence number of the first data packet including the first detection information, the first collection information indicates collection information corresponding to the detection task type, the detection domain is a detection range determined by the controller, the detection domain includes a plurality of network devices, and the plurality of network devices include the first network device; determining, by the first network device based on the first collection information, first collected data corresponding to the first collection information, and updating, by the first network device, the first detection node identifier; and sending, by the first network device to a next-hop network device of the first network device, the first data packet carrying the updated first detection information.

According to the solution provided in this embodiment, network devices in the detection domain may implement, based on control information delivered by the controller and by using detection information included in a data packet, information collection for a detection task required by the controller, thereby implementing in-situ collection on a data packet on a transmission path and transmission path detection while ensuring packet forwarding performance.

In a possible implementation of the first aspect, the first network device is a head node device in the detection domain, and after the receiving, by the first network device, a first data packet sent by a previous-hop network device of the first network device, the method further includes: encapsulating, by the first network device, the first detection information into the first data packet.

In another possible implementation of the first aspect, the first network device is an end node device in the detection domain, and before the sending, by the first network device to a next-hop network device of the first network device, the first data packet carrying the updated first detection information, the method further includes: deleting, by the first network device, the first detection information from the first data packet.

In still another possible implementation of the first aspect, the method further includes: sending, by the first network device, first reported detection information to the controller, where the first reported detection information includes the updated first detection node identifier, the first sequence number, and the first collected data.

In still another possible implementation of the first aspect, the detection task type is packet loss detection, the first control information further includes a detection start moment and a detection end moment, the first network device is the head node device in the detection domain, the first data packet is the 1stdata packet sent, in a time period starting from the detection start moment, by the first network device to the next-hop network device of the first network device, the first collected data includes a device identifier of the first network device, and the method further includes: receiving, by the first network device, a second data packet sent by the previous-hop network device of the first network device; encapsulating, by the first network device, second detection information into the second data packet, where the second detection information includes a second detection node identifier, a second sequence number, and second collection information; determining, by the first network device based on the second collection information, second collected data corresponding to the second collection information, and updating, by the first network device, the second detection node identifier, where the second collected data includes the device identifier of the first network device, the second sequence number is greater than the first sequence number, and the second detection node identifier is the same as the first detection node identifier; sending, by the first network device to the next-hop network device of the first network device, the second data packet carrying the updated second detection information, where the second data packet is the last data packet sent by the first network device to the next-hop network device of the first network device before the detection end moment; and sending, by the first network device, first reported detection information and second reported detection information to the controller, where the first reported detection information includes the updated first detection node identifier, the first sequence number, and the first collected data, and the second reported detection information includes the updated second detection node identifier, the second sequence number, and the second collected data.

In still another possible implementation of the first aspect, the detection task type is packet loss detection, the first control information further includes a detection start moment and a detection end moment, the first network device is an intermediate node device or an end node device in the detection domain, the first collected data includes a device identifier of the first network device, and the method further includes: extending, by the first network device, a value of the detection end moment by preset duration, and updating the value of the detection end moment; receiving, by the first network device in a time period from the detection start moment to the updated detection end moment, a second data packet sent by the previous-hop network device of the first network device, where the second data packet includes second detection information, and the second detection information includes a second detection node identifier, a second sequence number, and second collection information; determining, by the first network device based on the second collection information, second collected data corresponding to the second collection information, and updating, by the first network device, the second detection node identifier, where the second collected data includes the device identifier of the first network device, the second sequence number is a largest sequence number in sequence numbers of a plurality of data packets that are received by the first network device in the time period, the first data packet is a data packet received by the first network device in the time period, and the first sequence number is a smallest sequence number in the sequence numbers of the plurality of data packets that are received by the first network device in the time period; sending, by the first network device to the next-hop network device of the first network device, the second data packet carrying the updated second detection information; generating, by the first network device, third reported detection information, where the third reported detection information includes a third detection node identifier, a third sequence number, and third collected data, the third detection node identifier is the same as the updated second detection node identifier, the third collected data includes the device identifier of the first network device, the third sequence number is a sequence number missing from the sequence numbers of the plurality of data packets that are received by the first network device in the time period, and the third sequence number is greater than the first sequence number and less than the second sequence number; and sending, by the first network device, first reported detection information, second reported detection information, and the third reported detection information to the controller, where the first reported detection information includes the updated first detection node identifier, the first sequence number, and the first collected data, and the second reported detection information includes the updated second detection node identifier, the second sequence number, and the second collected data.

According to a second aspect, a data packet detection method is provided. The method includes: determining, by a controller, a detection domain, where the detection domain is a detection range determined by the controller, and the detection domain includes a plurality of network devices; sending, by the controller, first control information to the plurality of network devices, where the first control information includes a detection task type, and the detection task type indicates a detection task that the controller requires the plurality of network devices to perform; and receiving, by the controller, first reported detection information sent by a first network device, where the first reported detection information is determined by the first network device based on first detection information, the first detection information is detection information obtained by the first network device from a first data packet before the first network device sends the first data packet to a next-hop network device of the first network device, the first reported detection information includes a first detection node identifier, a first sequence number, and first collected data, the first detection node identifier indicates a location, in the detection domain, of a network device processing the first detection information, the first sequence number indicates a sequence number of the first data packet including the first detection information, the first collected data is collected data, corresponding to first collection information, that is determined by the first network device based on the first collection information in the first detection information, the first collection information indicates collection information corresponding to the detection task type, and the plurality of network devices include the first network device.

According to the solution provided in this embodiment, network devices in the detection domain may implement, based on control information delivered by the controller and by using detection information included in a data packet, information collection for a detection task required by the controller, thereby implementing in-situ collection on a data packet on a transmission path and transmission path detection while ensuring packet forwarding performance.

In a possible implementation of the second aspect, the detection task type is packet loss detection, the first control information further includes a detection start moment and a detection end moment, the first network device is a head node device in the detection domain, the first data packet is the 1stdata packet sent, in a time period starting from the detection start moment, by the first network device to the next-hop network device of the first network device, the first collected data includes a device identifier of the first network device, and the method further includes: receiving, by the controller, second reported detection information sent by the first network device, where the second reported detection information is determined by the first network device based on second detection information, the second detection information is detection information obtained by the first network device from a second data packet before the first network device sends the second data packet to the next-hop network device of the first network device, the second reported detection information includes a second detection node identifier, a second sequence number, and second collected data, the second collected data includes the device identifier of the first network device, the second sequence number is greater than the first sequence number, the second detection node identifier is the same as the first detection node identifier, and the second data packet is the last data packet sent by the first network device to the next-hop network device of the first network device before the detection end moment.

In another possible implementation of the second aspect, the method further includes: receiving, by the controller, third reported detection information sent by a second network device, where the third reported detection information includes a third detection node identifier and third collected data, the third detection node identifier indicates a location of the second network device in the detection domain, the third collected data includes a device identifier of the second network device, the third reported detection information further includes a third sequence number, a fourth sequence number, and a fifth sequence number, the third sequence number is a smallest sequence number in sequence numbers of a plurality of data packets received by the second network device in a time period from the detection start moment to a moment obtained by extending the detection end moment by preset duration, the fourth sequence number is a sequence number missing from the sequence numbers of the plurality of data packets received by the second network device in the time period, the fifth sequence number is a largest sequence number in the sequence numbers of the plurality of data packets received by the second network device in the time period, the second network device is an intermediate node device or an end node device in the detection domain, and the plurality of network devices include the second network device.

In still another possible implementation of the second aspect, the method further includes: determining, by the controller, a packet loss rate based on the first reported detection information, the second reported detection information, and the third reported detection information.

In still another possible implementation of the second aspect, the method further includes: determining, by the controller, fourth reported detection information based on the fourth sequence number, where a value of a fourth detection node identifier included in the fourth reported detection information is smallest in all reported detection information, including the fourth sequence number, that is received by the controller; and determining, by the controller, a packet loss locating node based on fourth collected data included in the fourth reported detection information.

In any one of the first aspect and the possible implementations of the first aspect, or in any one of the second aspect and the possible implementations of the second aspect, optionally, the first detection information further includes a flow identifier, and the flow identifier indicates a data flow to which the first data packet belongs.

In any one of the first aspect and the possible implementations of the first aspect, or in any one of the second aspect and the possible implementations of the second aspect, optionally, the first detection information further includes a first length and a first version number, the first length indicates a length of the first detection information, and the first version number indicates a protocol version of the first detection information.

According to a third aspect, a first network device is provided. The first network device has a function of implementing behavior of the first network device in the foregoing method. The function may be implemented based on hardware, or may be implemented based on hardware executing corresponding software. The hardware or software includes one or more modules corresponding to the foregoing function.

In a possible design, a structure of the first network device includes a processor and an interface. The processor is configured to support the first network device in performing a corresponding function in the foregoing method. The interface is configured to: support communication between the first network device and a second network device; and send information or an instruction in the foregoing method to the second network device, or receive information or an instruction in the foregoing method from the second network device. The first network device may further include a memory. The memory is configured to be coupled to the processor, and stores a program instruction and data that are necessary for the first network device.

In another possible design, the first network device includes a processor, a transmitter, a receiver, a random access memory, a read-only memory, and a bus. The processor is coupled to the transmitter, the receiver, the random access memory, and the read-only memory through the bus. When the first network device needs to run, a bootloader in a basic input/output system or an embedded system that is built into the read-only memory is used to boot a system to start, and boot the first network device to enter a normal running state. After entering the normal running state, the first network device runs an application program and an operating system in the random access memory, so that the processor performs the method in any one of the first aspect and the possible implementations of the first aspect.

According to a fourth aspect, a first network device is provided. The first network device includes a main control board and an interface board, and may further include a switching board. The first network device is configured to perform the method in any one of the first aspect and the possible implementations of the first aspect. Specifically, the first network device includes a module configured to perform the method in any one of the first aspect and the possible implementations of the first aspect.

According to a fifth aspect, a first network device is provided. The first network device includes a controller and a first forwarding sub-device. The first forwarding sub-device includes an interface board, and may further include a switching board. The first forwarding sub-device is configured to perform a function of the interface board in the fourth aspect, and may further perform a function of the switching board in the fourth aspect. The controller includes a receiver, a processor, a transmitter, a random access memory, a read-only memory, and a bus. The processor is coupled to the receiver, the transmitter, the random access memory, and the read-only memory through the bus. When the controller needs to run, a bootloader in a basic input/output system or an embedded system that is built into the read-only memory is used to boot a system to start, and boot the controller to enter a normal running state. After entering the normal running state, the controller runs an application program and an operating system in the random access memory, so that the processor performs a function of the main control board in the fourth aspect.

According to a sixth aspect, a computer storage medium is provided and is configured to store a program, code, or an instruction used by the foregoing first network device. When executing the program, code, or instruction, a processor or a hardware device may perform a function or a step of the first network device in the foregoing aspects.

According to a seventh aspect, a controller is provided. The controller has a function of implementing behavior of the controller in the foregoing method. The function may be implemented based on hardware, or may be implemented based on hardware executing corresponding software. The hardware or software includes one or more modules corresponding to the foregoing function.

In a possible design, a structure of the controller includes a processor and an interface. The processor is configured to support the controller in performing a corresponding function in the foregoing method. The interface is configured to: support communication between the controller and a second network device, and send information or an instruction in the foregoing method to the second network device, or receive information or an instruction in the foregoing method from the second network device. The controller may further include a memory. The memory is configured to be coupled to the processor, and stores a program instruction and data that are necessary for the controller.

In another possible design, the controller includes a processor, a transmitter, a receiver, a random access memory, a read-only memory, and a bus. The processor is coupled to the transmitter, the receiver, the random access memory, and the read-only memory through the bus. When the controller needs to run, a bootloader in a basic input/output system or an embedded system that is built into the read-only memory is used to boot a system to start, and boot the controller to enter a normal running state. After entering the normal running state, the controller runs an application program and an operating system in the random access memory, so that the processor performs the method in any one of the second aspect and the possible implementations of the second aspect.

According to an eighth aspect, a controller is provided. The controller includes a main control board and an interface board, and may further include a switching board. The controller is configured to perform the method in any one of the second aspect and the possible implementations of the second aspect. Specifically, the controller includes a module configured to perform the method in any one of the first aspect and the possible implementations of the second aspect.

According to a ninth aspect, a controller is provided. The controller includes a main control device and a first forwarding sub-device. The first forwarding sub-device includes an interface board, and may further include a switching board. The first forwarding sub-device is configured to perform a function of the interface board in the eighth aspect, and may further perform a function of the switching board in the eighth aspect. The main control device includes a receiver, a processor, a transmitter, a random access memory, a read-only memory, and a bus. The processor is coupled to the receiver, the transmitter, the random access memory, and the read-only memory through the bus. When the main control device needs to run, a bootloader in a basic input/output system or an embedded system that is built into the read-only memory is used to boot a system to start, to boot the main control device to enter a normal running state. After entering the normal running state, the main control device runs an application program and an operating system in the random access memory, so that the processor performs a function of the main control board in the eighth aspect.

According to a tenth aspect, a computer storage medium is provided and is configured to store a program, code, or an instruction used by the foregoing controller. When executing the program, code, or instruction, a processor or a hardware device may perform a function or a step of the controller in the foregoing aspects.

According to an eleventh aspect, a network system is provided. The network system includes a first network device and a controller. The first network device is the first network device in the third aspect, the fourth aspect, or the fifth aspect. The controller is the controller in the seventh aspect, the eighth aspect, or the ninth aspect.

According to the data packet detection method provided in the embodiments of this application, specifically, the embodiments of this application provide an in-situ flow information telemetry (in-situ flow information telemetry or in-band flow information telemetry) method. Network devices in the detection domain may implement, based on control information delivered by the controller and by using detection information included in a data packet, information collection for a detection task required by the controller, thereby implementing in-situ collection on a data packet on a transmission path and transmission path detection while ensuring packet forwarding performance.

