Skip to main content

Linux network rate limit

Linux network rate limit injects chaos to slow down the network connectivity on the Linux machine by limiting the network bandwidth to process fixed number of network packets per unit time.

Linux network rate limit

Use cases

Linux network rate limit:

  • Induces network rate limit on the target Linux machines.
  • Simulates loss of connectivity access by blocking the network requests on the machine.
note
  • This fault can be executed on Ubuntu 16 or higher, Debian 10 or higher, CentOS 7 or higher, RHEL 7 or higher, Fedora 30 or higher, and openSUSE LEAP 15.4 or higher.
  • The linux-chaos-infrastructure systemd service should be in an active state, and the infrastructure should be in CONNECTED state.

Fault permissions

The fault uses the root Linux user and root user group.

Mandatory tunables

Tunable Description Notes
networkInterfaces Comma-separated values of target network interfaces. For example, eth0,ens192

Optional tunables

Tunable Description Notes
destinationHosts List of the target host names or keywords. For example, google.com,litmuschaos.io If neither destinationHosts nor destinationIPs is provided, all host names/domains are targeted.
destinationIPs List of comma-separated target IPs. Also supports a list of target destination ports for a given IP, that are separated by a pipe (|). For example, 1.1.1.1,35.24.108.92|3000|8080. If neither destinationHosts nor destinationIPs is provided, all host names/domains are targeted.
networkBandwidth Specify the network bandwidth rate limit. Defaults to 1mbit
burst Size of bucket, in bytes. The maximum amount of bytes for which tokens can be instantaneously available. Default: 2kb
limit Limit on the number of bytes that can be queued while waiting for tokens to become available. Defaults to 2kb
minBurst Size of the peak rate bucket. For example, 1kb.
peakRate Maximum depletion rate of the bucket. For example, 1mbit.
sourcePorts Source ports to be filtered for chaos. For example, 5000,8080 Alternatively, the ports that can be whitelisted, that is, filtered to be exempt from chaos. Prepend a ! to the list of ports to be exempted. For example, !5000,8080
destinationPorts Destination ports to be filtered for chaos. For example, 5000,8080 Alternatively, the ports can be whitelisted, that is, filtered to be exempt from chaos. Prepend a ! to the list of ports to be exempted. For example, !5000,8080 .
whitelistSSH Specifies whether the SSH connectivity should be retained during the chaos in the target machine. Default: true. Supports one of: true, false
duration Duration through which chaos is injected into the target resource (in seconds). Default: 30s
rampTime Period to wait before and after injecting chaos (in seconds). Default: 0s

Destination hosts

Comma-separated names of the target hosts that are subject to chaos. Tune it using the destinationHosts input variable.

The following YAML snippet illustrates the use of this input variable:

apiVersion: litmuchaos.io/v1alpha1
kind: LinuxFault
metadata:
name: linux-network-rate-limit
labels:
name: network-rate-limit
spec:
networkChaos/inputs:
destinationHosts: 'google.com'
networkInterfaces: "eth0"

Destination IPs

The destinationIPs input variable subjects the comma-separated names of the target IPs to chaos. You can specify the ports to be targeted for an IP by using a pipe (|) as a separator. While providing ports is optional, omitting them will affect all the ports associated with the destination IPs.

The following YAML snippet illustrates the use of this input variable:

apiVersion: litmuchaos.io/v1alpha1
kind: LinuxFault
metadata:
name: linux-network-rate-limit
labels:
name: network-rate-limit
spec:
networkChaos/inputs:
destinationIPs: '1.1.1.1,192.168.5.6|80|8080'
networkInterfaces: "eth0"

Network bandwidth

Network bandwidth injected during chaos. Tune it by using the networkBandwidth input variable.

Following YAML snippet illustrates the use of this input variable:

apiVersion: litmuchaos.io/v1alpha1
kind: LinuxFault
metadata:
name: linux-network-rate-limit
labels:
name: network-rate-limit
spec:
networkChaos/inputs:
destinationIPs: '1.1.1.1'
networkInterfaces: "eth0"
networkBandwidth: 1mbit

Burst

Size of the bucket, in bytes. It is the maximum number of bytes for which tokens can be instantaneously available. Tune it by using the burst input variable.

Following YAML snippet illustrates the use of this input variable:

apiVersion: litmuchaos.io/v1alpha1
kind: LinuxFault
metadata:
name: linux-network-rate-limit
labels:
name: network-rate-limit
spec:
networkChaos/inputs:
destinationIPs: '1.1.1.1'
networkInterfaces: "eth0"
burst: 2kb

Limit

Limit on the number of bytes that can be queued while waiting for tokens to become available. Tune it by using the limit input variable.

Following YAML snippet illustrates the use of this input variable:

apiVersion: litmuchaos.io/v1alpha1
kind: LinuxFault
metadata:
name: linux-network-rate-limit
labels:
name: network-rate-limit
spec:
networkChaos/inputs:
destinationIPs: '1.1.1.1'
networkInterfaces: "eth0"
limit: 2kb