Patent Description:
A distributed denial of service (DDoS, distributed denial of service) attack is a persistent problem that destroys network availability, mainly including two types of attacks: a DRDoS attack and flooding (flooding). Costs of the DRDoS attack are very low and an attack capability is very strong. Traffic of a single attack may be amplified tens or even hundreds of thousands of times by a public server that functions as a reflector, making the DRDoS attack a common attack method for intruders. Currently, a proportion of DRDoS attack events in DDoS attack events is higher than that of flooding attack events in DDoS attack events.

The DRDoS attack is used as an example. An intruder may use, by using a controlled device controlled by the intruder, an internet protocol (IP, internet protocol) address of a target device as a source IP address, and send a service request with small traffic to a large number of distributedly deployed reflectors, so that each reflector uses the IP address of the target device as a destination IP address to send a data packet with large traffic to the target device. In this way, a large quantity of data packets with large traffic are aggregated to the target device, which occupies resources of the target device and affects services that can be provided by the target device. This forms the distributed reflection denial of service (DRDoS, distributed reflection denial of service) attack.

A conventional anti-DDoS attack solution cannot quickly determine validity of a data packet directed to the target device. As a result, a valid data packet that is not used to attack the target device cannot reach the target device in time or even cannot reach the target device. Therefore, it is desirable to improve the solution to determine validity of a data packet more quickly.

The document <NPL> shows different strategies for recognizing spoofed packets.

The document <NPL> shows a method for recognizing spoofed packets.

The document <NPL> shows different strategies for recognizing spoofed packets in communication networks.

Further advantageous developments are shown in the dependent claims.

Embodiments of this application provide a data processing method and a device, to quickly determine validity of a data packet in a network device.

The following briefly describes the accompanying drawings used in describing the embodiments or the conventional technology.

The following describes technical solutions in embodiments of this application with reference to accompanying drawings in the embodiments of this application.

<FIG> is a schematic diagram of a service scenario to which an embodiment of this application is applicable. As shown in <FIG>, a controlled device is a device directly controlled by an intruder. After learning of an IP address of a target device (for example, a server), the intruder may control a plurality of controlled devices to send service requests to a large quantity of distributedly deployed reflectors by using the IP address of the target device as a source IP address. The large quantity of distributedly deployed reflectors include but are not limited to a DNS, an NTP server, an SSDP server, and a simple network management protocol (SNMP, simple network management protocol) server. For example, the reflectors may further include a lightweight directory access protocol (LDAP, lightweight directory access protocol) server. After receiving the service request from the controlled device, each reflector may send, to the target device, a data packet used to attack the target device. In this way, a DDoS attack is formed. However, when the target device is under the DDoS attack, data packets sent by the reflector to the target device may not only include the data packet used to attack the target device, but also include a valid data packet not used to attack the target device, for example, a response data packet sent by the reflector in response to a service request from the target device, and a request data packet actively sent by the reflector and used to request the target device to provide a specific service to the reflector.

In an anti-DDoS attack solution, a specified server may predistribute a token to a client, to distinguish a valid data packet and a data packet used to attack the target device, and valid traffic is sent to the target device. As shown in <FIG>, each independent autonomous domain (AS) includes an RTS server configured to manage each server included in the AS, each AS further includes a verification node (VP) that cooperates with the RTS server of the AS, and a device that needs to access the server is a client. When the client needs to access one server, the client first needs to access an RTS of an AS to which the server belongs, to obtain a token. A data packet sent by the client to the server needs to carry the obtained token. After the data packet sent by the client to the server reaches the AS to which the server belongs, a VP in the AS in which the server is located may verify the token carried in the data packet. If and only if verification of the token succeeds, for example, when the token carried in the data packet is the same as a token provided by the RTS server of the AS to which the VP belongs for the client, and a quantity of times that the token is used does not exceed a maximum quantity of times, the data packet may be further forwarded to the server. This solution depends on cooperation between a plurality of ASs. RTS servers need to be deployed in all the ASs. A system framework and a border gateway protocol (BGP, border gateway protocol) need to be modified. Therefore, this solution is difficult to be applied to the foregoing service scenario.

In another anti-DDoS attack solution, when the target device is under the DDoS attack, a data packet that needs to be sent to the target device may be introduced into a blackhole route by using a network device, so that traffic that needs to be sent to the target device is no longer forwarded by the network device to a protected device. This solution can ensure that another device that shares a communication link with the target device can provide services properly. However, this causes a case in which a valid data packet that is not used to attack the target device cannot reach the protected device.

In another anti-DDoS attack solution, a traffic cleaning center may be set. When the target device is under the DDoS attack, a data packet that needs to be sent to the target device is forwarded to the traffic cleaning center by using a network device directly connected to the target device. The traffic cleaning center may perform upper-layer protocol parsing, attack feature identification, and corresponding calculation processing on the received data packet, to determine whether the received data packet is valid. A valid data packet is forwarded to the target device, and an invalid data packet is not forwarded to the target device. In this solution, it takes a long time for the traffic cleaning center to determine validity of each data packet, which causes a case in which a valid data packet that is not used to attack the target device cannot reach the target device in time. In addition, the traffic cleaning center depends on a specially deployed hardware device, for example, needs to be deployed on a dedicated DDoS firewall device or another dedicated device. This is costly and difficult to implement.

<FIG> is a schematic diagram of a system framework according to an embodiment of this application. As shown in <FIG>, a device that needs to defend against a DDoS attack is usually a server or a personal computer, and each server or personal computer usually does not exist independently, but cooperates with another device. For example, a plurality of servers that need to defend against the DDoS attack may form a server cluster (or is referred to as a security domain, a subnet, an autonomous domain, or a data center) that can provide one or more services. For ease of description, the device that needs to defend against the DDoS attack is referred to as a first device in this embodiment of this application, and the technical solution provided in this embodiment of this application is mainly described by using an example in which the first device is a server. A device that may send, to the first device, a data packet used to attack the first device, to form the DDoS attack on the first device is referred to as a second device. It may be understood that the second device includes but is not limited to various public servers that may be used as a reflector. Usually, each server that forms a server cluster or a LAN may be hosted by a same service provider. Each server in the server cluster may be connected to a same network device, for example, connected to a same border gateway, so that the service provider centrally manages data packets received or sent by each server in the server cluster.

For a plurality of second devices that may send, to the first device, a data packet used to attack the first device, any two second devices usually have different IP addresses. Therefore, different first verification codes may be generated for different second devices by using IP addresses of the second devices, so that data packets exchanged by the different second devices to the first device separately include the different first verification codes. The network device may verify accuracy of a first verification code included in a first data packet from the second device, to determine validity of the data packet from the second device, so as to quickly determine validity of a data packet in the network device. Specifically, the network device located between the first device and the second device may generate a second verification code based on a corresponding first key and a source IP address included in the first data packet received by the network device. If the second verification code is different from the first verification code, it indicates that the second device fails to exchange the data packet with the first device by using the correct first verification code, that is, the first data packet may be a data packet used to attack the first device. On the contrary, if the second verification code is the same as the first verification code, it indicates that the first data packet may be a valid data packet that is not used to attack the first device.

In this embodiment of this application, for each first device, for example, for each server in the server cluster, an identifier may be allocated to the first device by using an identifier management center. For example, specifically, a locator and/or a service identifier are/is allocated. The locator allocated by the identifier management center to one first device may be used at least by the network device to address the first device, for example, used as an IP address or a part of the IP address of the first device, so that the second device and the first device may exchange a data packet by using the network device. For example, the locator may include a network routable prefix, an identifier of a subnet in which the first device is located, and an identifier of the first device in the subnet. A service identifier allocated by the identifier management center to one first device may be used as at least an identifier of a service provided by the first device. It may be understood that,locator any two servers in a same server cluster have different locators. However, a service may require a plurality of different servers to cooperate with each other, and therefore a same service identifier may be allocated to different servers.

It should be noted that a locator and a service identifier of each first device may be further used to implement other service purposes. For details, refer to example description in the following embodiments.

In this embodiment of this application, a first key may be allocated by using a key management center to each first device, for example, for each server in one server cluster. In addition, to improve algorithm security, the key management center may allocate different first keys to different first devices. Alternatively, a second key may be allocated to each first device by using the key management center, and each first device may obtain the first key through derivation calculation based on the second key allocated by the key management center to the first device and another parameter associated with the first device. In addition, prefixes of locators of a plurality of first devices in a same server cluster may be aggregated to allocate a same second key to the plurality of first devices.

The following example describes data processing processes separately performed by the network device, the first device, and the second device when the first device and the second device exchange a data packet by using the network device.

<FIG> is a flowchart of a data processing method applied to a network device. As shown in <FIG>, the method may include at least the following step <NUM> to step <NUM>. Step <NUM>: Receive a first data packet, where the first data packet includes a source IP address and a first verification code. Step <NUM>: Obtain a first key. Step <NUM>: Generate a second verification code based on the source IP address and the first key. Step <NUM>: If the second verification code is the same as the first verification code, determine that the first data packet is valid.

First, in step <NUM>, the first data packet is received, where the first data packet includes the source IP address and the first verification code.

The first data packet may be a data packet sent by one second device to one first device, and the source IP address included in the first data packet is an IP address of the second device.

The first data packet may be a data packet used to attack the first device, or may be a valid data packet, for example, a response data packet sent by the second device to respond to a second data packet from the first device, and a request data packet used by the second device to request the first device to provide a specific service to the second device.

It should be noted that the first verification code may be generated by the first device, and when generating the first verification code, the first device should use at least the first key and the IP address of the second device. In this way, one first device may separately generate different first verification codes for a plurality of different second devices.

It may be understood that the first data packet is transmitted on a communication link between the first device and the second device, and a network device is a node device on the communication link. Therefore, the first data packet should include at least a network layer protocol header and a transport layer protocol header.

In a possible implementation, the transport layer protocol header of the first data packet includes but is not limited to a TCP header, or may be, for example, a user datagram protocol (UDP, user datagram protocol) header.

In a more specific example, the first verification code may be located in an optional field of the TCP header.

In a possible implementation, the network layer protocol header of the first data packet includes an IPv4 header or an IPv6 header.

<FIG> is a schematic diagram of a structure of an IPv4 header. As shown in <FIG>, the IPv4 header may sequentially include the following fields: a version number, a header length, a service type, a total length of a data packet, a reorganization identifier, a flag, a segment offset, time to live, a protocol code, a header checksum, a source IP address, a destination IP address, and an optional item. In a more specific example, the first verification code may be located in the optional item field of the IPv4 header.

<FIG> is a schematic diagram of a structure of an IPv6 header. As shown in <FIG>, the IPv6 header sequentially includes the following fields: a version number, a traffic class, a traffic label, a payload length, an extension header, a hop limit, a source IP address, and a destination IP address. In a more specific example, the first verification code may be located in the extension header or the destination IP address of the IPv6 header.

In a possible implementation, a locator, a service identifier, and the first verification code included in the first data packet may be all located in a destination IP address of the first data packet, and the locator, the service identifier, and the first verification code form the destination IP address included in the first data packet. In this way, the network device only needs to extract a source IP address and a destination IP address from a network layer protocol header included in the second data packet, to quickly obtain parameters used to calculate the second verification code.

Then, in step <NUM>, the first key is obtained.

In a possible implementation, the first data packet may further include the locator.

Correspondingly, in a more specific example, the network device may obtain the first key based on the locator included in the first data packet. As described above, the locator may be an IP address of the first device, or may be a part of an IP address of the first device. To be specific, the locator may be the destination IP address included in the first data packet, or may be a part of the destination IP address included in the first data packet.

In a more specific example, before the network device obtains the first key based on the locator, the network device may further receive first key allocation information including the locator and the first key. In this way, the network device may extract, based on the locator included in the first data packet, the first key from the first key allocation information including the locator.

Specifically, the first key allocation information may be from a key management center, from the first device, or from a security device in a server cluster in which the first device is located.

In a possible implementation, the first data packet further includes the service identifier.

Correspondingly, in another more specific example, before the network device obtains the first key based on the locator, the network device may further receive second key allocation information including the locator and a second key. In this way, the network device may extract, based on the locator included in the first data packet, the second key from the second key allocation information including the locator, and obtain the first key through calculation based on the second key and the service identifier.

Specifically, the second key allocation information may be from the key management center, from the first device, or from the security device in the server cluster in which the first device is located.

Further, in step <NUM>, the second verification code is generated based on the source IP address and the first key.

It should be noted that the source IP address and the first key included in the first data packet are required parameters for generating the second verification code. In a specific service scenario, one or more optional parameters may be further used. In conclusion, an algorithm and a parameter used by the network device to generate the second verification code for one first data packet received by the network device are the same as an algorithm and a parameter used by the first device to generate the first verification code for the second device that sends the first data packet.

In a more specific example, when generating the second verification code, in addition to using the source IP address and the first key, the network device may further use any one or more of the locator, the service identifier, and a first dynamic parameter. It should be noted that the first dynamic parameter may be included in the first data packet. Alternatively, the first dynamic parameter may be a parameter obtained by the network device in real time, for example, a time parameter with specific precision.

Then, in step <NUM>, if the second verification code is the same as the first verification code, it is determined that the first data packet is valid.

The algorithm and the parameter used by the network device to generate the second verification code for one first data packet received by the network device are the same as the algorithm and the parameter used by the first device to generate the first verification code for the second device that sends the first data packet. Therefore, if the first verification code included in the first data packet is the same as the second verification code generated by the network device, it indicates that the first data packet is the response data packet sent by the second device to respond to the second data packet from the first device, or the request data packet used by the second device to request the first device to provide the specific service to the second device, and the first data packet is not a data packet used to attack the first device.

On the contrary, if the second verification code is different from the first verification code, it indicates that the second device fails to exchange the data packet with the first device by using the correct first verification code, and the first data packet may be a service request sent by an intruder to the second device by using a controlled device, so that the second device sends, to the first device, the data packet used to attack the first device.

The data packet used to attack the first device is usually a response data packet. Therefore, in a possible implementation, before obtaining a corresponding first key for the first data packet received by the network device, the network device may further detect whether the first data packet received by the network device is a response data packet, and if the first data packet is not the response data packet, directly determine that the first data packet is valid. Alternatively, the network device may send a first data packet that is not the response data packet to another security device, for example, send the first data packet that is not the response data packet to a traffic cleaning center. The traffic cleaning center performs upper-layer protocol parsing and attack feature identification on the first data packet, to determine whether the first data packet is the data packet used to attack the first device.

The intruder may learn of, by listening to the data packet received by the second device from the first device, the first verification code that needs to be used when the second device and the first device exchange the data packet, to continuously send service requests to the second device within short time by using the correct first verification code and the IP address of the first device, so that the second device continuously sends a large number of response data packets with large traffic to the first device within the short time. The response data packets may be determined as valid data packets. If the response data packets are sent by the network device to the first device, a replay attack may be formed on the first device.

Therefore, in a possible implementation, when the first data packet received by the network device is the response data packet, the network device may determine, based on a source IP address included in each data packet received by the network device, a quantity of data packets that are received per unit time and that are from the second device corresponding to the source IP address included in the first data packet. When the quantity is not less than a first preset threshold, the source IP address included in the first data packet may be marked as an untrusted IP address.

In another possible implementation, when the first data packet received by the network device is the response data packet, the network device may determine, based on a source IP address included in each data packet received by the network device, a total data volume of data packets that are received per unit time and that are from the second device corresponding to the source IP address included in the first data packet. When the total data volume is not less than a second preset threshold, the source IP address included in the first data packet may be marked as an untrusted IP address.

Correspondingly, when the first data packet is determined as a valid data packet, the network device may further determine whether marked untrusted IP addresses include the source IP address included in the first data packet, and sends the first data packet based on the locator included in the first data packet only when the marked untrusted IP addresses do not include the source IP address included in the first data packet. This avoids sending a first data packet used to form a replay attack on the first device to the first device.

In another more specific example, when the source IP address included in the first data packet is marked as the untrusted IP address, even if the first data packet is determined as a valid data packet, the network device may discard the first data packet, or perform traffic limiting on each first data packet corresponding to the source IP address included in the first data packet.

In this embodiment of this application, if the second verification code is different from the first verification code, the network device may discard the first data packet, and a data packet that may be used to attack the first device does not reach the first device. The data packet used to attack the first device is blocked, to prevent the first device from being under a DDoS attack, especially a DRDoS attack.

In this embodiment of this application, if the first data packet is valid, the network device may further send the first data packet based on the locator included in the first data packet. The valid data packet is not discarded, which ensures service availability of the first device. In addition, because the network device can quickly determine validity of the first data packet, the valid data packet can quickly reach the first device, and a delay is very low.

In this embodiment of this application, a communication link between the first device and the second device does not need to be changed, an application layer protocol of a data packet does not need to be parsed based on different reflector types, and only a network device of an existing network needs to be improved to filter out the data packet used to attack the first device. This is more applicable.

It should be noted that, if an SSDP server sends, to the first device by using a multicast address, the data packet used to attack the first device, a service provided by the server may be disabled in a local area network to which the first device belongs, to prevent the server from sending, to the first device, the data packet used to attack the first device.

In a possible implementation, the network device may continuously perform, for each first device, the data processing process performed by the network device in the foregoing embodiments, or when receiving indication information sent by a first device or a security device in a server cluster in which the first device is located, for the specific first device corresponding to a locator included in the indication information, the network device may start to perform or stop performing the data processing process performed by the network device in the foregoing embodiments.

It should be noted that the security device in the server cluster in which the first device is located may monitor a status of each first device in the server cluster, so that when any first device in the server cluster is under the DDoS attack, a corresponding security measure is performed, for example, sending indication information to the network device, so that the network device performs the foregoing data processing process performed by the network device for the first device under the DDoS attack.

Correspondingly, an embodiment of this application provides a data processing method applied to a first device. As shown in <FIG>, the method may include at least the following step <NUM> and step <NUM>.

Step <NUM>: Generate a second data packet, where the second data packet includes a destination IP address and a first verification code, and the first verification code is generated by the first device based on the destination IP address and a first key.

It may be understood that the destination IP address is an IP address of a second device that receives the second data packet.

In a possible implementation, the first key may be from a key management center.

In another possible implementation method, the first key may be obtained by the first device through calculation based on a second key and a service identifier. The second key is from the key management center, and the service identifier is from an identifier management center.

As described above, the destination IP address and the first key may be used as required parameters for generating the first verification code. In a process of generating the first verification code, one or more optional parameters may be further used. The optional parameter include but is not limited to a locator and a service identifier that are allocated by the identifier management center to the first device.

In a more specific example, the optional parameter may further include a second dynamic parameter, so that the first verification code used when the first device and the second device exchange a data packet dynamically changes. Therefore, an intruder is prevented from performing a DDoS attack on the first device after collecting a large number of first verification codes that need to be used by the second device serving as a reflector after long time.

In a specific example, the second dynamic parameter may be a time parameter, and precision of the time parameter may be adjusted, so that the first device generates different first verification codes for the second device in different time periods. In the different time periods, the different first verification codes are used as identifiers of data packets exchanged between the first device and the second device. The precision of the time parameter may be an empirical value, for example, <NUM> hour. In this way, in any two adjacent time periods whose time length is <NUM> hour, the first device and the second device exchange a data packet by using different first verification codes.

In another specific example, the second dynamic parameter may alternatively be a periodically generated random number, so that the first device generates different first verification codes for the second device in different time periods.

It may be understood that a type of the second dynamic parameter includes but is not limited to the time parameter and the random number.

In a specific example, the first device may generate the first verification code based on the first key, the destination IP address, the locator and the service identifier allocated by the identifier management center to the first device, and the second dynamic parameter by using a unidirectional security algorithm. The security algorithm may be a hashing algorithm using a symmetric encryption algorithm.

A structure of a second data packet sent by the first device to one second device should be the same as a structure of the first data packet sent by the second device to the first device. Therefore, parameters used by the first device to generate a second verification code for one second device should be able to be learned by a network device, so that the network device performs, based on the parameters used by the first device to generate the second verification code for the second device, accuracy verification on the first verification code included in the first data packet sent by the second device to the first device. Specifically, the parameter used by the first device to generate the first verification code for the second device may be included in the second data packet. For example, when the first device generates the first verification code, the locator and the service identifier allocated by the identifier management center to the first device are used. In this case, the locator and the service identifier may be included in the second data packet.

It should be noted that when the type of the second dynamic parameter is the time parameter, the second data may not include the second dynamic parameter. When the second dynamic parameter is the random number or another type of parameter, the second data packet should include the second dynamic parameter.

Step <NUM>: Send the second data packet.

It may be understood that the network device is used as a node device on the communication link between the first device and the second device corresponding to the destination IP address included in the second data packet. The second data packet sent by the first device may first reach the network device, and the network device sends the second data packet to the second device corresponding to the destination IP address.

To enable the network device to learn of the first key used by the first device to generate the first verification code, in a possible implementation, the first device may further send first key allocation information to the network device, the key management center, or a security device in a server cluster in which the first device is located. The first key allocation information includes the locator of the first device and the first key.

When the first device uses the service identifier when generating the first verification code, in a possible implementation, the first key may be generated by the first device based on the service identifier and the second key from the key management center.

Correspondingly, the first device may further send second key allocation information to the network device, the key management center, or the security device in the server cluster in which the first device is located. The second key allocation information includes the locator of the first device and the first key.

In this embodiment of this application, when the first device is under the DDoS attack, the first device may further send, to the network device, indication information including the locator of the first device, to trigger the network device to perform, for the first device, the data processing process performed by the network device in the foregoing embodiments.

Based on a same idea as the foregoing embodiments, this application further provides a data processing method applied to a second device. As shown in <FIG>, the method may include at least the following step <NUM> to step <NUM>.

Step <NUM>: Receive a second data packet, where the second data packet includes an IP address of the second device and a first verification code, and the first verification code is generated based on the IP address of the second device and a first key by a first device that sends the second data packet, and is used by a network device to verify validity of a first data packet sent by the second device.

Step <NUM>: Generate the first data packet, where the first data packet includes a source IP address and the first verification code, and the source IP address is the IP address of the second device.

Step <NUM>: Send the first data packet to the network device.

In this embodiment of this application, the first data packet generated by the second device and the second data packet correspondingly received by the second device should have a same structure, and the first data packet should have at least the first verification code included in the second data packet, so that the network device determines validity of the first data packet sent by the second device.

The following example describes a specific process in which the first device and the second device exchange a data packet by using the network device. As shown in <FIG>, a specific process in which a first device and a second device exchange a data packet by using a network device may include the following step <NUM> to step <NUM>. Step numbers are not used to limit a sequence of performing steps, and steps separately performed by the first device, the second device, and the network device are examples. In a process in which the first device and the second device exchange a data packet by using the network device, other steps may be further performed. Alternatively, each step may be split into a plurality of substeps.

Step <NUM>: The first device generates a first verification code.

For example, the first device may generate the first verification code based on an IP address of the second device, a first key allocated by a key management center to the first device, a locator and a service identifier allocated by an identifier management center to the first device, and a timestamp with specific precision.

Step <NUM>: The first device generates a second data packet.

A destination IP address included in the second data packet is the IP address of the second device. A source IP address included in the second data packet may include the locator, the service identifier, and the first verification code, or the source IP address included in the second data packet is the locator, and the first verification code and the locator are located in a network layer protocol header or a transport layer protocol header of the second data packet.

Step <NUM>: The first device sends the second data packet to the second device.

It may be understood that the network device is used as a node device on a communication link between the first device and the second device. The second data packet may first reach the network device, and then the network device forwards the second data packet to the second device.

Step <NUM>: The second device generates a first data packet.

If the first data packet generated by the second device is, a response data packet generated based on the second data packet sent by the first device to the second data packet, a source IP address included in the first data packet is the IP address of the second device, and the locator, the service identifier, and the first verification code included in the second data packet may be included in the first data packet.

The second device may buffer the locator, the service identifier, and the first verification code included in the first data packet sent by the first device to the second device. When the second device needs to actively send, to the first device, a request data packet used to request the first device to provide the second device with a specific service, the second device may generate the first data packet by using the locator, the service identifier, and the first verification code included in the second data packet buffered by the second device.

If the first data packet generated by the second device is a data packet that is generated based on a service request sent by a controlled device controlled by an intruder to the second device and that is used to attack the first device, because the intruder cannot correctly learn of the first verification code that needs to be used when the first device and the second device exchange a data packet, the first verification code included in the first data packet generated by the second device is different from the first verification code included in the first data packet. In other words, the first verification code included in the first data packet is different from a first verification code that is generated by the first device by using the IP address of the second device and another parameter and that is used by the first device and the second device to exchange a data packet.

Step <NUM>: The second device sends the first data packet to the network device.

Step <NUM>: The network device determines whether the first data packet is the response data packet.

The network device may distinguish a transport layer protocol and a port number of the first data packet, to identify whether the data packet is the response data packet. Alternatively, a packet type included in an application layer protocol of the first data packet may be identified, to determine whether the first data packet is the response data packet.

If the first data packet is not the response data packet, the network device may perform step <NUM>.

If the first data packet is the response data packet, the network device may perform step <NUM>.

Step <NUM>: The network device determines a quantity and a total data volume of first data packets from the second device per unit time.

If the quantity is less than a first preset threshold and the total data volume is less than a second preset threshold, the network device may perform step <NUM>.

If the quantity reaches the first preset threshold, or the total data volume reaches the second preset threshold, it indicates that the intruder may know the first verification code that needs to be used when the first device and the second device exchange a data packet. The intruder may trigger, by using the controlled device, the second device to continuously send a large number of response data packets and/or response data packets with a large total data volume to the first device within very short time, to form a replay attack on the first device. In this case, the network device may discard the first data packet or perform traffic limiting on each data packet from the second device, and mark the IP address of the second device included in the first data packet as an untrusted IP address.

Step <NUM>: The network device obtains the first key based on the locator included in the first data packet.

It should be noted that, before step <NUM>, the network device may receive first key allocation information including the locator of the first device and the first key. The network device may receive a plurality pieces of first key allocation information including different locators, and the network device may extract, based on a locator included in the first data packet, a corresponding first key from the first key allocation information including the locator.

Step <NUM>: The first device generates a second verification code.

For example, the network device may generate the first verification code based on the first key obtained by the network device, the source IP address, the locator, and the service identifier that are included in the first data packet, and a corresponding timestamp with specific precision corresponding to the first data packet when the network device receives the first data packet.

Step <NUM>: When the first verification code is the same as the second verification code, the network device determines that the first data packet is valid.

If the first verification code is different from the second verification code, it indicates that the first data packet may be a response data packet used to attack the first device, and the first data packet may be discarded.

Step <NUM>: When the first data packet is valid, the network device determines whether the source IP address included in the first data packet is an untrusted IP address.

The network device may query whether marked untrusted IP addresses include the source IP address included in the first data packet. If the marked IP addresses include the source IP address included in the first data packet, it indicates that the second device corresponding to the source IP address included in the first data packet may have been controlled by the intruder, or the intruder has attempted to send, to the first device by using the second device corresponding to the source IP address included in the first data packet, the response data packet used to attack the first device, and the source IP address is untrusted. On the contrary, when determining that the source IP address included in the first data packet is trusted, the network device may perform the following step <NUM>.

Step <NUM>: The network device sends the first data packet.

The network device may send the first data packet to the first device based on the locator of the first device included in the first data packet.

As shown in <FIG>, an embodiment of this application provides a network device <NUM>. The network device <NUM> includes:.

As shown in <FIG>, in a possible implementation, the network device <NUM> further includes a second interface unit <NUM>.

The first data packet further includes a locator of a first device.

The processing unit <NUM> is further configured to trigger the second interface unit <NUM> when the first data packet is valid.

The second interface unit <NUM> is configured to send the first data packet to the first device based on the locator when being triggered by the processing unit <NUM>.

In a possible implementation, the first data packet further includes a service identifier.

In a possible implementation, the processing unit <NUM> is specifically configured to generate the second verification code based on the source IP address, the first key, and any one or more of the locator, the service identifier, and a first dynamic parameter.

In a possible implementation, the first verification code is located in a network layer protocol header included in the first data packet.

In a possible implementation, the first verification code is located in a destination IP address included in the first data packet.

In a possible implementation, the first data packet further includes the locator and the service identifier, and the locator and the service identifier are located in the destination IP address.

In a possible implementation, the network layer protocol header includes an IPv6 header, and the first verification code is located in an extension header of the IPv6 header.

In a possible implementation, the first verification code is located in a transport layer protocol header included in the first data packet.

In a possible implementation, the transport layer protocol header includes a TCP header, and the first verification code is located in an optional field of the TCP header.

In a possible implementation, the first data packet further includes the locator.

The processing unit <NUM> is specifically configured to obtain the first key based on the locator.

In a possible implementation,
the network device <NUM> further includes the second interface unit <NUM>, configured to receive first key allocation information, where the first key allocation information includes the locator and the first key.

The processing unit <NUM> is specifically configured to extract the first key from the first key allocation information based on the locator.

The network device <NUM> further includes the second interface unit <NUM>, configured to receive second key allocation information, where the second key allocation information includes the locator and a second key.

The processing unit <NUM> is specifically configured to: extract the second key from the second key allocation information based on the locator; and calculate the first key based on the second key and the service identifier.

In a possible implementation, the processing unit <NUM> is further configured to: detect whether the first data packet is a response data packet; and if the first data packet is the response data packet, determine whether the first data packet is a packet from a reflector.

In a possible implementation, the processing unit <NUM> is further configured to: determine a quantity of data packets that are received per unit time and that are from a second device corresponding to the source IP address; and if the quantity is not less than a first preset threshold, mark the source IP address as an untrusted IP address.

In a possible implementation, the processing unit <NUM> is further configured to: determine a total data volume of data packets that are received per unit time and that are from the second device corresponding to the source IP address; and if the total data volume is not less than a second preset threshold, mark the source IP address as an untrusted IP address.

In a possible implementation,
the processing unit <NUM> is further configured to: determine whether marked untrusted addresses include the source IP address; and if the untrusted addresses do not include the source IP address, trigger the second interface unit.

As shown in <FIG>, an embodiment of this application provides a first device <NUM>. The first device <NUM> includes:.

In a possible implementation, the first verification code is generated by the processing unit <NUM> based on the destination IP address, the first key, and any one or more of a locator, a service identifier, and a second dynamic parameter.

In a possible implementation, the first verification code is located in a network layer protocol header included in the second data packet.

In a possible implementation, the first verification code is located in a source IP address included in the second data packet.

In a possible implementation, the second data packet further includes the locator and the service identifier, and the locator and the service identifier are located in the source IP address.

In a possible implementation, the first verification code is located in a transport layer protocol header included in the second data packet.

In a possible implementation, the second data packet further includes the locator.

The interface unit <NUM> is further configured to send first key allocation information to a network device, where the first key allocation information includes the locator and the first key.

In a possible implementation, the second data packet further includes the service identifier.

The first key is generated by the processing unit <NUM> based on the service identifier and a second key.

In a possible implementation,
the interface unit <NUM> is further configured to send second key allocation information to the network device, where the second key allocation information includes the locator and the second key.

As shown in <FIG>, an embodiment of this application provides a second device <NUM>. The second device <NUM> includes:.

The interface unit <NUM> is configured to send the first data packet to the network device.

In a possible implementation, the first verification code is located in a network layer protocol header or a transport layer protocol header included in the first data packet.

In a possible implementation, the first data packet further includes a locator and a service identifier, and the locator and the service identifier are located in the destination IP address.

An embodiment of this application provides a network device. The network device includes a transceiver, a memory, and a processor. The memory stores one or more programs, and the one or more programs include instructions. When the instructions are executed by the network device, the network device is enabled to perform the data processing method performed by the network device provided in any embodiment.

An embodiment of this application further provides a first device. The first device includes a transceiver, a memory, and a processor. The memory stores one or more programs, and the one or more programs include instructions. When the instructions are executed by the first device, the first device is enabled to perform the data processing method performed by the first device provided in any embodiment.

An embodiment of this application further provides a second device. The second device includes a transceiver, a memory, and a processor. The memory stores one or more programs, and the one or more programs include instructions. When the instructions are executed by the second device, the second device is enabled to perform the data processing method performed by the second device provided in any embodiment.

An embodiment of this application provides a computer-readable storage medium, configured to store instructions. When the instructions are executed, a data processing method performed by a network device is implemented.

An embodiment of this application provides a computer-readable storage medium, configured to store instructions. When the instructions are executed, a data processing method performed by a first device is implemented.

An embodiment of this application provides a computer-readable storage medium, configured to store instructions. When the instructions are executed, a data processing method performed by a second device is implemented.

An embodiment of this application provides a communication apparatus. The communication apparatus has functions of implementing the network device in any one of the embodiments of this application. The functions may be implemented by hardware, or may be implemented by hardware executing corresponding software. The hardware or the software includes one or more units corresponding to the foregoing function.

An embodiment of this application provides a communication apparatus. The communication apparatus has functions of implementing the first device in any one of the embodiments of this application. The functions may be implemented by hardware, or may be implemented by hardware executing corresponding software. The hardware or the software includes one or more units corresponding to the foregoing function.

An embodiment of this application provides a communication apparatus. The communication apparatus has functions of implementing the second device in any one of the embodiments of this application. The functions may be implemented by hardware, or may be implemented by hardware executing corresponding software. The hardware or the software includes one or more units corresponding to the foregoing function.

An embodiment of this application provides a communication apparatus. The communication apparatus may be the network device in any of the embodiments of this application, or may be a chip disposed in the network device. The communication apparatus includes a memory, a communication interface, and a processor. The memory is configured to store a computer program or instructions. The processor is coupled to the memory and the communication interface. When the processor executes the computer program or the instructions, the communication apparatus performs the method performed by the network device in any one of the embodiments of this application.

An embodiment of this application provides a communication apparatus. The communication apparatus may be the first device in any one of the embodiments of this application, or may be a chip disposed in the first device. The communication apparatus includes a memory, a communication interface, and a processor. The memory is configured to store a computer program or instructions. The processor is coupled to the memory and the communication interface. When the processor executes the computer program or the instructions, the communication apparatus performs the method performed by the first device in any one of the embodiments of this application.

An embodiment of this application provides a communication apparatus. The communication apparatus may be the second device in any one of the embodiments of this application, or may be a chip disposed in the second device. The communication apparatus includes a memory, a communication interface, and a processor. The memory is configured to store a computer program or instructions. The processor is coupled to the memory and the communication interface. When the processor executes the computer program or the instructions, the communication apparatus performs the method performed by the second device in any one of the embodiments of this application.

An embodiment of this application provides a computer program product. The computer program product includes computer program code, and when the computer program code is run on a computer, the computer performs the method performed by the network device, the method performed by the first device, or the method performed by the second device in any one of the embodiments of this application.

An embodiment of this application provides a chip system. The chip system includes a processor, configured to implement functions of the network device in the method provided in any one of the embodiments of this application, for example, receiving or processing data and/or information in the method performed by the network device. In a possible design, the chip system further includes a memory. The memory is configured to store program instructions and/or data. The chip system may include a chip, or may include a chip and another discrete device.

An embodiment of this application provides a chip system. The chip system includes a processor, configured to implement functions of the first device in the method provided in any one of the embodiments of this application, for example, receiving or processing data and/or information in the method performed by the first device. In a possible design, the chip system further includes a memory. The memory is configured to store program instructions and/or data. The chip system may include a chip, or may include a chip and another discrete device.

An embodiment of this application provides a chip system. The chip system includes a processor, configured to implement functions of the second device in the method provided in any one of the embodiments of this application, for example, receiving or processing data and/or information in the method performed by the second device. In a possible design, the chip system further includes a memory. The memory is configured to store program instructions and/or data. The chip system may include a chip, or may include a chip and another discrete device.

A person of ordinary skill in the art may be aware that, in combination with the examples described in the embodiments disclosed in this specification, units and algorithm steps can be implemented by electronic hardware or a combination of computer software and electronic hardware. A person skilled in the art may use different methods to implement the described functions for each particular application, but it should not be considered that the implementation goes beyond the scope of the embodiments of this application.

It may be clearly understood by a person skilled in the art that, for convenience and brevity, for a specific working process of the foregoing network device, refer to a corresponding process in the foregoing method embodiments, and details are not described herein again.

It may be understood that the described apparatus embodiment is merely an example. For example, the division into units is merely logical function division and may be other division in actual implementation. For example, a plurality of units or parts may be combined or integrated into another system, or some features may be ignored or not performed. In addition, the displayed or discussed mutual couplings or direct couplings or communication connections may be implemented through some interfaces.

Claim 1:
A data processing method, applied to a network device, wherein the method comprises:
receiving (<NUM>) a first data packet, wherein the first data packet comprises a source internet protocol IP address and a first verification code;
obtaining (<NUM>) a first key;
generating (<NUM>) a second verification code based on the source IP address and the first key; and
if the second verification code is the same as the first verification code, determining (<NUM>) that the first data packet is valid,
wherein the generating a second verification code based on the source IP address and the first key comprises: generating the second verification code based on the source IP address, the first key, and any one or more of a locator, a service identifier, and a first dynamic parameter.