Compute
Elastic Cloud Server
Huawei Cloud Flexus
Bare Metal Server
Auto Scaling
Image Management Service
Dedicated Host
FunctionGraph
Cloud Phone Host
Huawei Cloud EulerOS
Networking
Virtual Private Cloud
Elastic IP
Elastic Load Balance
NAT Gateway
Direct Connect
Virtual Private Network
VPC Endpoint
Cloud Connect
Enterprise Router
Enterprise Switch
Global Accelerator
Management & Governance
Cloud Eye
Identity and Access Management
Cloud Trace Service
Resource Formation Service
Tag Management Service
Log Tank Service
Config
OneAccess
Resource Access Manager
Simple Message Notification
Application Performance Management
Application Operations Management
Organizations
Optimization Advisor
IAM Identity Center
Cloud Operations Center
Resource Governance Center
Migration
Server Migration Service
Object Storage Migration Service
Cloud Data Migration
Migration Center
Cloud Ecosystem
KooGallery
Partner Center
User Support
My Account
Billing Center
Cost Center
Resource Center
Enterprise Management
Service Tickets
HUAWEI CLOUD (International) FAQs
ICP Filing
Support Plans
My Credentials
Customer Operation Capabilities
Partner Support Plans
Professional Services
Analytics
MapReduce Service
Data Lake Insight
CloudTable Service
Cloud Search Service
Data Lake Visualization
Data Ingestion Service
GaussDB(DWS)
DataArts Studio
Data Lake Factory
DataArts Lake Formation
IoT
IoT Device Access
Others
Product Pricing Details
System Permissions
Console Quick Start
Common FAQs
Instructions for Associating with a HUAWEI CLOUD Partner
Message Center
Security & Compliance
Security Technologies and Applications
Web Application Firewall
Host Security Service
Cloud Firewall
SecMaster
Anti-DDoS Service
Data Encryption Workshop
Database Security Service
Cloud Bastion Host
Data Security Center
Cloud Certificate Manager
Edge Security
Managed Threat Detection
Blockchain
Blockchain Service
Web3 Node Engine Service
Media Services
Media Processing Center
Video On Demand
Live
SparkRTC
MetaStudio
Storage
Object Storage Service
Elastic Volume Service
Cloud Backup and Recovery
Storage Disaster Recovery Service
Scalable File Service Turbo
Scalable File Service
Volume Backup Service
Cloud Server Backup Service
Data Express Service
Dedicated Distributed Storage Service
Containers
Cloud Container Engine
SoftWare Repository for Container
Application Service Mesh
Ubiquitous Cloud Native Service
Cloud Container Instance
Databases
Relational Database Service
Document Database Service
Data Admin Service
Data Replication Service
GeminiDB
GaussDB
Distributed Database Middleware
Database and Application Migration UGO
TaurusDB
Middleware
Distributed Cache Service
API Gateway
Distributed Message Service for Kafka
Distributed Message Service for RabbitMQ
Distributed Message Service for RocketMQ
Cloud Service Engine
Multi-Site High Availability Service
EventGrid
Dedicated Cloud
Dedicated Computing Cluster
Business Applications
Workspace
ROMA Connect
Message & SMS
Domain Name Service
Edge Data Center Management
Meeting
AI
Face Recognition Service
Graph Engine Service
Content Moderation
Image Recognition
Optical Character Recognition
ModelArts
ImageSearch
Conversational Bot Service
Speech Interaction Service
Huawei HiLens
Video Intelligent Analysis Service
Developer Tools
SDK Developer Guide
API Request Signing Guide
Terraform
Koo Command Line Interface
Content Delivery & Edge Computing
Content Delivery Network
Intelligent EdgeFabric
CloudPond
Intelligent EdgeCloud
Solutions
SAP Cloud
High Performance Computing
Developer Services
ServiceStage
CodeArts
CodeArts PerfTest
CodeArts Req
CodeArts Pipeline
CodeArts Build
CodeArts Deploy
CodeArts Artifact
CodeArts TestPlan
CodeArts Check
CodeArts Repo
Cloud Application Engine
MacroVerse aPaaS
KooMessage
KooPhone
KooDrive

Using Watermarks to Defend Against CC Attacks

Updated on 2025-02-08 GMT+08:00

CNAD supports the sharing of watermark algorithms and keys with the service end. All packets sent by the client are embedded with watermarks, which can effectively defend against layer-4 CC attacks.

There are generally two modes of defending against UDP floods: dynamic fingerprint learning and UDP traffic limiting. The former may mistakenly learn normal service payloads as attack fingerprints, leading to false positives. The latter may block both normal and attack traffic, affecting your service.

Figure 1 Device protection principles

As shown in Figure 2, the Huawei cloud solution adds watermark header information to UDP packets to identify normal service packets. After receiving a UDP packet, the offline Anti-DDoS service device checks whether the UDP watermark is correct to efficiently and accurately permit normal service packets and block attack packets.

Figure 2 Watermarking solution

The client and Anti-DDoS device need to use the same information structure and calculation rule. The calculation rule refers to the hash factor and hash algorithm for calculating the watermark value. In this solution, the hash factor uses: the destination IP address, destination port, user identifier, and the watermark keyword; and the hash algorithm uses the CRC32.

Limitations and Constraints

  • This function needs to be developed on the client. To use this function, submit a service ticket.
  • Up to two keys can be configured for a watermark.

Enabling Watermark Protection

You can set a watermark protection policy on the console and configure watermarks on the client.

  1. Log in to the management console.
  2. Select a region in the upper part of the page, click in the upper left corner of the page, and choose Security & Compliance > Anti-DDoS Service. The Anti-DDoS Service Center page is displayed.
  3. In the navigation pane on the left, choose Cloud Native Anti-DDoS Advanced > Protection Policies. The Protection Policies page is displayed.
  4. Click Create Protection Policy.
  5. In the displayed dialog box, set the policy name, select an instance, and click OK.

    Figure 3 Creating a policy

  6. In the row containing the target policy, click Set Protection Policy in the Operation column.
  7. In the Watermark configuration area, click Set.

    Figure 4 Watermarking

  8. On the displayed Watermark Configuration page, click Create.
  9. In the Create Watermark dialog box, set watermark parameters.

    Figure 5 Create Watermark
    Table 1 Watermark parameters

    Parameter

    Description

    Watermark Name

    Watermark name

    Protocol

    Currently, only UDP is supported.

    Key

    Keyword. Up to two keywords are supported.

    Port Range

    The supported port number ranges from 1 to 65535.

  10. Click OK.

This section uses the C language as an example to describe how to calculate and add UDP watermarks on the client. Developers can adjust the code based on the development platform.

  1. Initialize the CRC table:

    unsigned int g_szCRCTable[256];
    void CRC32TableInit(void)
    {
        unsigned int c;
        int n, k;
        for (n = 0; n < 256; n++) {
            c = (unsigned int)n;
            for (k = 0; k < 8; k++) {
                if (c & 1) {
                    c = 0xedb88320 ^ (c >> 1);
                }
                else {
                    c = c >> 1;
                }
            }
            g_szCRCTable[n] = c;
        }
    }

  2. Interface for calculating the CRC hash value. The first parameter crc is set to 0 by default.

    unsigned int CRC32Hash(unsigned int crc, unsigned char* buf, int len)
    {
        unsigned int c = crc ^ 0xFFFFFFFF;
        int n; 
        for (n = 0; n < len; n++) {
            c = g_szCRCTable[(c ^ buf[n]) & 0xFF] ^ (c >> 8);
        } 
        return c ^ 0xFFFFFFFF;
    }

  3. Example Code for Calculating the Watermark Value of a Packet Figure 6 shows the watermark structure for compute

    Figure 6 Watermark structure for compute
    • The watermark data structure is defined as follows:
      CAUTION:
      • The byte order needs to use the network byte order.
      • If the service payload is less than four bytes, you can use 0s to fill it up.
      typedef struct {
      unsigned int userId; /*User ID*/
      unsigned int payload; /*Service payload*/
      unsigned short destPort; /*Service destination port*/
      unsigned short rsv; /*Reserved field, 2-byte filling*/
      unsigned int destIp; /*Service destination IP address*/
      unsigned int key; /*Watermark keyword*/
      } UdpWatermarkInfo;
    • The CPU hardware acceleration interface can be used to calculate the CRC hash value to improve the processing performance.
      unsigned int UdpFloodWatermarkHashGet(unsigned int userId, unsigned int payload, unsigned short destPort, unsigned int destIp, unsigned int key)
      {
          UdpWatermarkInfo stWaterInfo;
      
          stWaterInfo.destIp   = destIp;
          stWaterInfo.destPort = destPort;
          stWaterInfo.userId   = userId;
          stWaterInfo.payload  = payload;
          stWaterInfo.key      = key;
          stWaterInfo.rsv      = 0;
      
          return CRC32Hash(0, (UCHAR *)&stWaterInfo, sizeof(stWaterInfo));
      }

  4. The packet is filled with the calculated CRC hash value according to the structure in Figure 7 and then sent out.

    Figure 7 Filling UDP Watermarks

  1. Log in to the management console.
  2. Select a region in the upper part of the page, click in the upper left corner of the page, and choose Security & Compliance > Anti-DDoS Service. The Anti-DDoS Service Center page is displayed.
  3. In the navigation pane on the left, choose Cloud Native Anti-DDoS Advanced > Protection Policies. The Protection Policies page is displayed.
  4. Click Create Protection Policy.
  5. In the displayed dialog box, set the policy name, select an instance, and click OK.

    Figure 3 Creating a policy

  6. In the row containing the target policy, click Set Protection Policy in the Operation column.
  7. In the Watermark configuration area, click Set.

    Figure 4 Watermarking

  8. On the displayed Watermark Configuration page, click Create.
  9. In the Create Watermark dialog box, set watermark parameters.

    Figure 5 Create Watermark
    Table 1 Watermark parameters

    Parameter

    Description

    Watermark Name

    Watermark name

    Protocol

    Currently, only UDP is supported.

    Key

    Keyword. Up to two keywords are supported.

    Port Range

    The supported port number ranges from 1 to 65535.

  10. Click OK.

This section uses the C language as an example to describe how to calculate and add UDP watermarks on the client. Developers can adjust the code based on the development platform.

  1. Initialize the CRC table:

    unsigned int g_szCRCTable[256];
    void CRC32TableInit(void)
    {
        unsigned int c;
        int n, k;
        for (n = 0; n < 256; n++) {
            c = (unsigned int)n;
            for (k = 0; k < 8; k++) {
                if (c & 1) {
                    c = 0xedb88320 ^ (c >> 1);
                }
                else {
                    c = c >> 1;
                }
            }
            g_szCRCTable[n] = c;
        }
    }

  2. Interface for calculating the CRC hash value. The first parameter crc is set to 0 by default.

    unsigned int CRC32Hash(unsigned int crc, unsigned char* buf, int len)
    {
        unsigned int c = crc ^ 0xFFFFFFFF;
        int n; 
        for (n = 0; n < len; n++) {
            c = g_szCRCTable[(c ^ buf[n]) & 0xFF] ^ (c >> 8);
        } 
        return c ^ 0xFFFFFFFF;
    }

  3. Example Code for Calculating the Watermark Value of a Packet Figure 6 shows the watermark structure for compute

    Figure 6 Watermark structure for compute
    • The watermark data structure is defined as follows:
      CAUTION:
      • The byte order needs to use the network byte order.
      • If the service payload is less than four bytes, you can use 0s to fill it up.
      typedef struct {
      unsigned int userId; /*User ID*/
      unsigned int payload; /*Service payload*/
      unsigned short destPort; /*Service destination port*/
      unsigned short rsv; /*Reserved field, 2-byte filling*/
      unsigned int destIp; /*Service destination IP address*/
      unsigned int key; /*Watermark keyword*/
      } UdpWatermarkInfo;
    • The CPU hardware acceleration interface can be used to calculate the CRC hash value to improve the processing performance.
      unsigned int UdpFloodWatermarkHashGet(unsigned int userId, unsigned int payload, unsigned short destPort, unsigned int destIp, unsigned int key)
      {
          UdpWatermarkInfo stWaterInfo;
      
          stWaterInfo.destIp   = destIp;
          stWaterInfo.destPort = destPort;
          stWaterInfo.userId   = userId;
          stWaterInfo.payload  = payload;
          stWaterInfo.key      = key;
          stWaterInfo.rsv      = 0;
      
          return CRC32Hash(0, (UCHAR *)&stWaterInfo, sizeof(stWaterInfo));
      }

  4. The packet is filled with the calculated CRC hash value according to the structure in Figure 7 and then sent out.

    Figure 7 Filling UDP Watermarks

We use cookies to improve our site and your experience. By continuing to browse our site you accept our cookie policy. Find out more

Feedback

Feedback

Feedback

0/500

Selected Content

Submit selected content with the feedback