Network packet loss is a common network failure. Network congestion, hardware failures, link interference, and other situations can cause network packet loss. This drill scenario verifies system alerts and recovery when network packet loss occurs.
Limits
This drill scenario requires the tc Traffic Control (TC) utility and its dependent kernel Network Emulator (NetEm) component.
If the system lacks the
tcutility, run theyum install -y iproute-tcorapt-get install -y iproute2command to install it, or specify relevant parameters to automatically install it when you run theACS-ECS-NetDelayplugin.If the system kernel lacks the NetEm component, such as in CentOS, run the
yum install kernel-modules-extracommand to install the component package and restart the system.WarningNote that installing the
kernel-modules-extrapackage changes the kernel version. Proceed with caution. We recommend that you do the drill using Elastic Compute Service (ECS) instances running other operating systems.
Implementation
This solution uses the Cloud Assistant plug-in ACS-ECS-NetLoss, which uses the tc utility and netem component to add specific rules to the network interface card, implementing TC for the Linux kernel. This plug-in can restrict either all IP addresses globally or target a single IP address. The Cloud Assistant network segment 100.100.0.0/16 will not be affected.
User guide
Prerequisites
Cloud Assistant Agent is installed on the ECS instance for which you want to perform a drill.
The status of Cloud Assistant is Normal on the ECS instance. For more information, see View the status of Cloud Assistant and handle anomalies.
Fault injection
Log on to the ECS instance as a user with sudo privileges.
For more information, see Use Workbench to connect to a Linux instance over SSH.
Run the Cloud Assistant plug-in
ACS-ECS-NetLoss.sudo acs-plugin-manager --exec --plugin ACS-ECS-NetLoss --params inject,dev=eth0,[rate=paramA],[target-ip=paramB],[replace=paramC],[duration=paramD],[install-tc=paramF]Parameters in
[]are optional fault injection parameters. See the following parameter descriptions:dev (required): The network interface card into which to inject faults, such as eth0. You can use
ifconfigto view the current system's network interface cards.rate (optional): Packet loss percentage. The default is 10 (%).
target-ip (optional): The target IP address expected to be affected. The default is empty, indicating packet loss rules will be added for all IP addresses. If a target IP address is specified, only that IP address will be affected.
replace (optional): If the network interface card already has configured TC rules, injection will fail due to conflicts. If you want to overwrite the existing rules, you can set this value to true.
duration (optional): Duration in seconds. The default is 300.
install-tc (optional): If the system lacks the
tcutility, you can set this parameter totruefor automatic installation. The default isfalse.The following command output indicates that the Cloud Assistant plug-in
ACS-ECS-NetLossis run successfully.
Check if the fault injection was successful.
Ping the target network to check the network packet loss situation. As shown in the figure below, you can see that network packet loss is occurring, with an average packet loss of approximately 44%.

Fault recovery
Method 1: Wait for automatic recovery after timeout.
Method 2: Run the following fault recovery command:
sudo acs-plugin-manager --exec --plugin ACS-ECS-NetLoss --params recover