# Network Conditions

> Slow matching requests down with added latency, limited upload and download speed, and packet loss. Every preset from 100% Loss to Wi-Fi, with exact values.

Source: https://docs.subcloak.com/cloak-proxy/tools/network-conditions/

Network Conditions makes matching requests behave as if they went over a slower or less reliable network. You can add latency, limit upload and download speed, and drop a share of requests. Use it to see loading states, timeouts and retry logic on a fast office connection, for one API or the whole Mac.

## Slow down an API

1. Right-click a request from the host you want to slow down and choose **Tools › Network Conditions…**.

   Cloak Proxy creates a rule named after the host that matches every request to it, picks the **3G** profile, turns Network Conditions on and opens the rule. To start from scratch, choose **Tools › Edit Network Conditions Rules…** (<kbd>⌥</kbd> <kbd>⌘</kbd> <kbd>T</kbd>) and click **+**.

2. Pick a profile from the menu under **Profile**, or type your own values.

3. Use your app. Slowed requests show a `Network Conditions` badge in the traffic list, and their duration includes the added delay.

To slow down everything Cloak Proxy handles, use a matcher such as `*` in **Wildcard** mode.

*[Screenshot: A Network Conditions rule for api.example.com using the 3G profile: latency 300 ms, download 780 kbps, upload 330 kbps, packet loss 0. A Network Conditions rule using the 3G preset.]*

## Profiles

Choosing a preset fills in all four values. Network Conditions is off by default, and new rules start with **3G**.

| Preset | Latency | Download | Upload | Packet loss |
|---|---|---|---|---|
| **100% Loss** | 0 ms | Unlimited (0) | Unlimited (0) | 100% |
| **Very Bad Network** | 500 ms | 1,000 kbps | 1,000 kbps | 10% |
| **Edge** | 400 ms | 240 kbps | 200 kbps | 0% |
| **3G** | 300 ms | 780 kbps | 330 kbps | 0% |
| **DSL** | 50 ms | 2,000 kbps | 256 kbps | 0% |
| **LTE** | 50 ms | 50,000 kbps | 10,000 kbps | 0% |
| **Wi-Fi** | 2 ms | 40,000 kbps | 33,000 kbps | 0% |

When you change a value so the profile no longer matches a preset, its name becomes **Custom**.

### Fields

| Field | Unit | What it does |
|---|---|---|
| **Latency** | ms | Added round-trip time. Half is added before the request is sent and half before the response reaches the app. |
| **Download** | kbps (0 = unlimited) | Speed for response bodies, in kilobits per second (1 kbps = 1,000 bits per second). |
| **Upload** | kbps (0 = unlimited) | Speed for request bodies. |
| **Packet loss** | % of requests dropped | The chance, from 0 to 100, that a request fails as if the network dropped it. |

## How the delay is calculated

For each matching request:

- **Before sending:** half the latency, plus the request body size divided by the upload speed.
- **Before delivering the response:** half the latency, plus the response body size divided by the download speed.

A speed of 0 adds no transfer time. Cloak Proxy holds the whole response for the computed time, then sends it to the app in one go; it doesn't trickle the bytes. Streamed responses (SSE, JSON lines) are slowed down part by part: the latency before the first part, then each part at the download speed, so the app still sees events arrive one at a time.

> **Break specific requests instead:**
> (added in Cloak Proxy 0.4.0) To break specific requests in specific ways (fail the first two, time out, reset, drop or truncate a body, serve stale data), use [Failure scenarios](https://docs.subcloak.com/cloak-proxy/tools/failure-scenarios/).

For example, with **3G** a `GET` with no body and a 100 KB response is delayed by:

| Part | Calculation | Delay |
|---|---|---|
| Upload | 300 ms ÷ 2, no body | 150 ms |
| Download | 300 ms ÷ 2 + (100,000 bytes × 8) ÷ 780,000 bits per second | 150 ms + 1,026 ms |
| Total added | | about 1.33 s, plus the server's own time |

### Packet loss

Each matching request has the **Packet loss** percentage as its chance of being dropped. A dropped request waits for the profile's full latency, then Cloak Proxy closes the app's connection without a response. The traffic list shows it as failed with `Dropped by Network Conditions (<profile name>)`.

With **100% Loss**, every matching request fails. Use it to test an app's offline mode for one API while the rest of the Mac stays online.

## How Network Conditions works with other tools

- Only the first matching rule applies to a request.
- The packet-loss check runs right after the [Block List](https://docs.subcloak.com/cloak-proxy/tools/block-list/) and before scripts and breakpoints, so a dropped request never reaches them.
- Responses from [Map Local](https://docs.subcloak.com/cloak-proxy/tools/map-local/) and [Mock Sets](https://docs.subcloak.com/cloak-proxy/tools/mock-sets/) skip the upload delay but still get the download delay, so mocked data loads at the simulated speed.
- Time you spend paused at a [breakpoint](https://docs.subcloak.com/cloak-proxy/tools/breakpoint/) is separate from, and added to, the simulated delay.

> **What gets slowed:**
> Network Conditions applies to HTTP requests Cloak Proxy can read: plain HTTP, and HTTPS to hosts or apps with [SSL Proxying](https://docs.subcloak.com/cloak-proxy/capture/ssl-proxying/) on. Encrypted tunnels it doesn't decrypt and WebSocket messages run at full speed. Latency is added to every request, not once per connection.

> **Caution:**
> Network Conditions stays on until you turn it off, including after a restart. If everything feels slow, check the **N tools on** button in the bottom bar: hover it to see the tools with active rules, or click it to turn Network Conditions off.

## Related

  - [Test on a slow network](https://docs.subcloak.com/cloak-proxy/guides/test-on-a-slow-network/): A step-by-step guide to testing loading states and retries.
  - [Block List](https://docs.subcloak.com/cloak-proxy/tools/block-list/): Fail every matching request instead of a share of them.
  - [Insights: performance](https://docs.subcloak.com/cloak-proxy/insights/performance/): Find slow and large responses in your traffic.
  - [Rules and matching](https://docs.subcloak.com/cloak-proxy/tools/rules-and-matching/): Match one endpoint, a host or everything.
