Back to series
· 17 min read

Network Performance: Latency, Bandwidth, Packet Loss, and Congestion Control


I. What Is Network Performance?

Network performance is a set of metrics that measure a network's transmission capability and quality of service. It describes how long data takes to travel from the sender to the receiver, how much data can be transmitted, and whether the transmission process is stable and reliable.

Network performance is not a single speed metric, but the combined result of multiple factors.

Common network performance metrics include:

Metric English Meaning Focus
Latency Latency The time required for data to travel from one end to the other How fast the response is
Round-trip time RTT The time from sending data to the peer until a response is received Interaction time
Bandwidth Bandwidth The theoretical maximum transmission capacity of a link How much can be transmitted
Throughput Throughput The amount of data actually and successfully transmitted per unit time Actual transmission speed
Packet loss rate Packet Loss The proportion of packets lost during transmission Whether transmission is stable
Jitter Jitter The degree to which latency varies over time Whether latency is stable
Error rate Error Rate The proportion of data that becomes erroneous during transmission Data quality
Availability Availability The proportion of time a network or service operates normally Whether the service is accessible

These metrics influence one another, but they should not be conflated.

For example:

  • High bandwidth does not mean low latency.
  • Low latency does not mean high throughput.
  • A low packet loss rate does not mean the network is not congested.
  • Stable RTT does not mean bandwidth is sufficient.
  • High network throughput does not mean user requests are answered quickly either.

1. The Difference Between Latency and Bandwidth

Think of network transmission as a highway:

  • Latency: How long a vehicle takes to travel from the start to the destination.
  • Bandwidth: The maximum number of vehicles the highway can carry per second.
  • Throughput: The number of vehicles that actually pass per second.
  • Packet loss: Goods that are lost or fail to be delivered during transport.
  • Congestion: Too many vehicles on the road, causing queuing and reduced traffic efficiency.

A highway may have a huge traffic capacity, but if the distance is great, vehicles still take a long time to arrive.

Likewise, a high-bandwidth network link may still have high network latency.

II. Network Latency: Why Does Data Take Time to Arrive?

Network latency refers to the time required for data to travel across a network.

It is usually necessary to distinguish between one-way delay and round-trip time.

1. One-Way Delay

One-way delay is the time data takes to travel from the sender to the receiver.

For example:

  • A client sends a request to the server.
  • The data passes through multiple routers and network links.
  • The server finally receives the request.

This period is the one-way delay.

One-way delay usually requires reliable clock synchronization between the sender and the receiver; otherwise, it is difficult to measure accurately.

2. Round-Trip Time (RTT)

RTT (Round-Trip Time) is the total time data takes to travel from the sender to the receiver and back to the sender.

For example:

  1. The client sends a request.
  2. The server receives the request.
  3. The server returns a response.
  4. The client receives the response.

If the request takes 30 ms to reach the server, the server takes 20 ms to process it, and the response takes 30 ms to return, then:

RTT = 30 + 20 + 30 = 80ms

Note that RTT is not necessarily twice the one-way delay.

Reasons include:

  • The request and response may take different network paths.
  • The uplink and downlink quality may differ.
  • Server processing time may be included in the measurement.
  • Queuing, scheduling, and link load may change over time.

3. Components of Network Latency

Network latency can usually be broken down into four main parts:

Processing Delay

The time routers, switches, and hosts need to process a packet.

For example:

  • Inspecting the packet header.
  • Looking up the routing table.
  • Applying access control rules.
  • Computing checksum information.

Queuing Delay

The time a packet spends waiting in a network device's queue to be forwarded.

As network traffic increases, queuing delay typically rises significantly.

Transmission Delay

The time required to push all the bits of a packet onto the link.

The formula is:

T_{trans} = \frac{L}{R}

Where:

  • L: The packet length in bits.
  • R: The link transmission rate in bit/s.

For example, sending a 1500-byte packet over a 100 Mbps link:

T_{trans} = \frac{1500 \times 8}{100 \times 10^6}
T_{trans} = 0.12ms

Propagation Delay

The time a signal takes to propagate through the physical medium from the sender to the receiver.

The formula is:

T_{prop} = \frac{D}{V}

Where:

  • D: transmission distance.
  • V: the propagation speed of the signal in the medium.

For example, the propagation speed of an optical signal in fiber is about 200,000 kilometers per second.

If the link length is 1000 kilometers:

T_{prop} \approx \frac{1000}{200000} = 5ms

This calculates one-way propagation time only, excluding device processing and queuing time.

4. Total Network Latency

When a data packet passes through multiple network nodes, the total latency can be approximated as:

T_{total} = \sum_{i=1}^{n} (T_{processing,i}+ T_{queuing,i}+ T_{trans,i}+ T_{prop,i})

In real networks, these stages may occur in parallel, and different measurement tools cover different time ranges, so this must be understood in light of the specific protocol and measurement method.

5. Types of Network Latency

Type Description Common Contributing Factors
LAN latency Latency within a local area network Switches, NICs, load
WAN latency Wide area network latency Distance, carrier networks
Internet latency End-to-end internet latency Routing path, cross-network interconnection
DNS latency Time taken for domain name resolution DNS servers, caching
TCP connection latency Time taken to establish a TCP connection RTT, packet loss, handshake
TLS handshake latency Time taken to establish a secure connection RTT, certificate validation, protocol version
Application processing latency Time taken by the server to process a request CPU, database, business logic

The overall response time of a single HTTPS request may include stages such as DNS, connection establishment, TLS handshake, request transmission, server processing, and response download.

Therefore, you cannot conclude that the network link is slow just because a request takes a long time.

III. Bandwidth: How Much Data Can the Network Transmit Per Second?

Bandwidth refers to the maximum data transmission capacity a network link can carry per unit of time.

Common units:

Unit Meaning
bps bit per second, bits per second
Kbps kilobits per second
Mbps megabits per second
Gbps gigabits per second
Tbps terabits per second

Note:

  • b stands for bit.
  • B stands for Byte.
  • 1 Byte = 8 bit.

For example:

100 Mbps is theoretically equivalent to:

100 \div 8 = 12.5MB/s

This is only the ideal-case bit-to-byte conversion result; actual application throughput is also affected by protocol headers, retransmissions, congestion, device performance, and other traffic.

1. Bandwidth and Throughput

Bandwidth is the link's theoretical transmission capacity; throughput is the amount of data actually transmitted.

For example:

A 1 Gbps network link can theoretically transmit 1 Gbit of data per second.

But actual transmission may be limited by the following factors:

  • TCP congestion window.
  • Receive window.
  • Network packet loss.
  • Protocol header overhead.
  • Server disk read/write speed.
  • Client processing capacity.
  • Other traffic on the shared link.

As a result, actual throughput might be only 600 Mbps.

2. Throughput and Goodput

Throughput usually refers to the amount of data actually and successfully transmitted within a given period of time.

Goodput goes a step further, focusing on the payload actually delivered to the application layer, excluding extra overhead such as protocol headers and retransmitted data.

For example:

A TCP connection transmitted 100 MB of TCP data within 1 second, of which:

  • 90 MB is application payload.
  • 10 MB is retransmission or other transmission overhead.

Then:

Throughput = 100MB/s
Goodput = 90MB/s

Different monitoring systems may measure throughput differently, so you need to confirm whether they are counting link traffic, network-layer bytes, transport-layer data, or application payload.

3. Bandwidth-Delay Product (BDP)

The bandwidth-delay product (BDP) is the amount of in-flight data a network link can hold within one RTT.

Formula:

BDP = Bandwidth \times RTT

For example:

  • Bandwidth: 100 Mbps.
  • RTT: 100ms.

Then:

BDP = 100 \times 10^6 \times 0.1
BDP = 10Mbit

Converted to bytes:

10Mbit \div 8 = 1.25MB

This means that to fully utilize this link, the sender needs to allow about 1.25 MB of data to be in transit across the network.

If the send window is significantly smaller than the BDP, the sender may be unable to keep the link full.

4. TCP Window and Bandwidth Utilization

TCP uses a window mechanism to control how much unacknowledged data the sender can send.

It mainly involves:

  • Receive window rwnd: the amount of unacknowledged data that the receiver can receive.
  • Congestion window cwnd: the amount of data that the sender is allowed to send based on network congestion conditions.
  • Send window: the amount of data actually allowed to be sent is jointly limited by both.

It can usually be approximated as:

SendWindow = \min(rwnd,cwnd)

When there are no other constraints, TCP throughput can be roughly estimated as:

Throughput \approx \frac{Window}{RTT}

For example:

With a window of 256 KB and an RTT of 100ms:

Throughput \approx \frac{256KB}{0.1s}
Throughput \approx 2.56MB/s

This is only a simplified estimate; in practice, it is also affected by congestion control, packet loss, ACK behavior, sending pacing, and protocol overhead.

5. Why Can High-Bandwidth Networks Also Be Slow?

Suppose there are two network links:

Metric Link A Link B
Bandwidth 1 Gbps 100 Mbps
RTT 10ms 10ms
Packet loss rate 0.01% 0.01%
Theoretical transmission capability High Relatively low

If an application needs to transfer large amounts of data, Link A is usually more advantageous.

However, if an application only needs to execute many short requests, RTT may be more important than bandwidth.

For example, if a business request needs to execute 10 remote RPCs sequentially, and each must wait for the previous result, then even with high bandwidth, a lot of time may be spent due to round-trip latency.

IV. Packet Loss: Why Do Packets Disappear?

Packet loss means that sent packets fail to successfully reach the intended receiver, or fail to be correctly processed by the receiver.

The packet loss rate is usually expressed as:

LossRate = \frac{LostPackets}{SentPackets} \times 100\%

For example:

If 10,000 packets are sent and 10 are lost:

LossRate = \frac{10}{10000}\times100\%=0.1\%

1. Causes of Packet Loss

Network congestion

When the rate at which network devices receive data exceeds their forwarding capacity, queues gradually fill up.

If a queue reaches its limit, newly arriving packets may be dropped.

Link quality issues

For example:

  • Weak wireless signal.
  • Electromagnetic interference.
  • Fiber or Ethernet cable faults.
  • Physical interface abnormalities.
  • Hardware failures in network devices.

Insufficient device resources

For example:

  • Router CPU overload.
  • Insufficient switch buffer.
  • NIC receive queue overflow.
  • Insufficient OS network buffer.

Configuration errors

For example:

  • MTU mismatch.
  • Incorrect firewall rules.
  • Abnormal routing configuration.
  • Unreasonable QoS policy.
  • Network ACL dropping traffic.

Security policies

Firewalls, WAFs, and DDoS protection devices may actively drop packets according to security rules.

2. Impact of Packet Loss on TCP

TCP provides reliable transmission mechanisms.

When the sender detects that packets may have been lost, it attempts to recover the lost data.

The main mechanisms include:

  • Retransmission timeout (RTO).
  • Fast retransmit.
  • Duplicate ACKs.
  • SACK selective acknowledgment.
  • Congestion control response.

Packet loss not only means data needs to be retransmitted, but may also trigger congestion window reduction, lowering the subsequent sending rate.

Therefore, even a small amount of packet loss can significantly affect the throughput of long-distance, high-bandwidth network connections.

3. Impact of Packet Loss on UDP

UDP itself does not provide reliable transmission guarantees.

If a UDP packet is lost, the protocol does not automatically retransmit it.

Applications need to design the following themselves according to business needs:

  • Sequence numbers.
  • Packet loss detection.
  • Retransmission mechanisms.
  • Forward error correction (FEC).
  • Redundant data.
  • Bitrate adjustment.

For example, real-time voice and video usually place more emphasis on real-time performance.

For voice packets that are already expired, even successful retransmission may be worthless.

Therefore, real-time media systems usually need to choose packet loss recovery strategies based on the latency budget, rather than unconditionally retransmitting all data.

4. Packet Loss Rate Does Not Equal User Experience

The same packet loss rate may have different business impacts.

For example:

  • File downloads: packet loss can cause retransmissions and reduced throughput.
  • Online gaming: losing a small number of critical state packets may cause visual or input anomalies.
  • Video conferencing: continuous packet loss may cause audio and video stuttering.
  • DNS: loss of critical queries may cause resolution timeouts.
  • API: loss of requests or responses may lead to retries, timeouts, and the risk of duplicate execution.

When analyzing packet loss, you should also consider where the loss occurs, how long it lasts, whether it is continuous, and which protocols are affected.

V. Network Jitter: Why Does Latency Fluctuate?

Network jitter refers to the degree to which packet latency varies over time.

For example:

The continuously measured latencies were:

20ms
21ms
19ms
22ms
80ms
25ms
21ms

Although most packet latencies were around 20ms, one suddenly reached 80ms, indicating significant latency variation in the network.

1. Causes of Jitter

  • Bursts in network traffic.
  • Changes in routing paths.
  • Changes in queuing time on network devices.
  • Unstable wireless link signals.
  • Different packets take different paths.
  • Operating system scheduling and device resource contention.

2. How Is Jitter Calculated?

A simple statistical method is to calculate the absolute value of the latency difference between adjacent packets:

J_i = |D_i-D_{i-1}|

Where:

  • D_i: latency of the i-th packet.
  • J_i: latency change between adjacent packets.

For example:

Packet 1: 20ms
Packet 2: 25ms
Packet 3: 30ms

Then:

J_2 = |25-20|=5ms
J_3 = |30-25|=5ms

In engineering practice, there are also methods such as mean absolute difference, standard deviation, and jitter estimation based on smoothing filters in RTP.

Different monitoring tools may use different calculation methods, so jitter data cannot be compared directly unless the algorithms are standardized.

3. Impact of Jitter on Real-Time Applications

Real-time voice and video are highly sensitive to jitter.

If packet arrival times are unstable, the receiver may be unable to play continuously at the expected times.

To solve this problem, real-time media systems usually use a jitter buffer.

Its basic operation is as follows:

  1. The receiver buffers a certain number of packets.
  2. It arranges playback order based on timestamps and sequence numbers.
  3. It plays data at stable time intervals.
  4. It applies drop or recovery policies to packets that arrive too late.

A jitter buffer can reduce playback stuttering, but it also increases playback latency.

Therefore, the buffer size must strike a balance between smoothness and real-time responsiveness.

VI. Network Congestion: Why Does the Network Slow Down When It Gets Busier?

Network congestion refers to when data traffic in a network exceeds what some links or devices can currently handle, causing queues to grow, latency to rise, packet loss to increase, or throughput to decline.

1. How Does Congestion Occur?

Suppose:

  • The sender sends 100 MB of data per second.
  • The intermediate link can forward only 60 MB of data per second.

Then 40 MB of data per second cannot be forwarded in time.

This data queues in the buffers of network devices.

As the buffers gradually fill up, new packets may be dropped.

Typical signs of congestion:

  • Increased RTT.
  • Increased queuing delay.
  • Increased packet loss rate.
  • Increased TCP retransmissions.
  • Decreased throughput.
  • More request timeouts.

2. Difference Between Congestion Control and Flow Control

Flow control and congestion control both limit the data sending rate, but they solve different problems.

Comparison Aspect Flow Control Congestion Control
English Flow Control Congestion Control
Problem addressed The receiver cannot keep up The network cannot carry excessive traffic
Focus Receiver Entire network path
Primary mechanism Receive window rwnd Congestion window cwnd
Typical goal Prevent receiver buffer overflow Prevent network overload

The TCP sender is usually limited by both the receive window and the congestion window.

Amount of data allowed to be sent
        |
        v
Compare receive window rwnd with congestion window cwnd
        |
        v
Take the smaller of the two
        |
        v
Determine the current send window

3. Congestion Control and Congestion Avoidance

Congestion control is a broader system of mechanisms.

It includes:

  • Congestion detection.
  • Sending rate adjustment.
  • Packet loss recovery.
  • Congestion avoidance.
  • Congestion recovery.

Congestion avoidance, by contrast, is a phase or strategy within congestion control, intended to control the growth of the sending rate before severe congestion occurs in the network.

The two cannot be regarded as completely equivalent.

VII. TCP Congestion Control: How Does the Sender Determine Whether the Network Is Congested?

TCP cannot directly observe the state of all devices across the entire network.

The sender usually infers network conditions from signals such as ACKs, packet loss, and RTT, and dynamically adjusts the congestion window cwnd.

1. Congestion Window cwnd

The congestion window is a logical window maintained by the TCP sender to limit the amount of unacknowledged data in the network.

Together with the receive window, it determines the sending limit:

FlightSize \leq \min(cwnd,rwnd)

Here, FlightSize denotes the amount of data that has been sent but not yet acknowledged.

cwnd is usually managed in bytes.

2. Slow Start

Slow start is the congestion control phase used at the beginning of a TCP connection.

It does not make the network send slowly; rather, it probes available network capacity through relatively rapid growth.

Ideally, as ACKs arrive, cwnd approximately doubles every RTT.

For example:

Initial cwnd: 1 MSS
RTT 1: 2 MSS
RTT 2: 4 MSS
RTT 3: 8 MSS
RTT 4: 16 MSS

Here, MSS (Maximum Segment Size) denotes the maximum amount of TCP data that can be carried in a single TCP segment.

The actual initial window is determined by the TCP implementation and configuration, and is not fixed at 1 MSS.

Slow-start growth usually continues until:

  • The slow start threshold ssthresh is reached.
  • A congestion signal is detected.
  • Other constraints such as the receive window apply.

3. Congestion Avoidance

When cwnd reaches the slow start threshold, TCP usually enters the congestion avoidance phase.

The additive growth of classic TCP Reno is approximately as follows:

cwnd increases by about 1 MSS per RTT.

This growth rate is slower than slow start, which helps gradually probe network capacity.

4. Fast Retransmit

When the sender receives multiple duplicate ACKs, it may infer that a segment has been lost.

Classic TCP Reno typically triggers fast retransmit after receiving 3 duplicate ACKs.

Fast retransmit can resend the suspected lost data before waiting for the RTO timeout.

Note that modern TCP may use more refined packet-loss detection methods in combination with mechanisms such as SACK and RACK, and may not rely entirely on the traditional 3 duplicate ACKs.

5. Fast Recovery

Fast recovery is used to handle partial packet-loss scenarios, avoiding a complete return to slow start every time packet loss occurs.

After fast retransmit, classic Reno typically adjusts:

  • ssthresh.
  • cwnd.

It then enters the congestion avoidance phase.

The specific window adjustment rules depend on the congestion control algorithm.

6. Overall TCP Reno Flow

flowchart TD
    A["TCP connection establishment"] --> B["Slow Start"]
    B --> C{"Reached ssthresh?"}
    C -->|No| B
    C -->|Yes| D["Congestion Avoidance"]
    D --> E{"Packet loss detected?"}
    E -->|No| D
    E -->|Duplicate ACK| F["Fast Retransmit"]
    F --> G["Fast Recovery"]
    G --> D
    E -->|RTO timeout| H["Reduce congestion window"]
    H --> B

    style A fill:#E0F0FE,stroke:#93BCE8,color:#1E4976
    style B fill:#DCEFE5,stroke:#8EBFA5,color:#24563F
    style C fill:#FFF2CC,stroke:#E7C76A,color:#72551B
    style D fill:#EAE4FA,stroke:#B8A5E5,color:#514078
    style E fill:#FFF2CC,stroke:#E7C76A,color:#72551B
    style F fill:#E0F0FE,stroke:#93BCE8,color:#1E4976
    style G fill:#DCEFE5,stroke:#8EBFA5,color:#24563F
    style H fill:#FCE8E8,stroke:#D99A9A,color:#803C3C

This diagram describes the classic Reno approach and does not represent the internal implementation of all modern TCP algorithms.

8. Common TCP Congestion Control Algorithms

Different congestion control algorithms use different approaches to infer network state and different window growth strategies.

1. TCP Reno

Reno is the classic loss-based congestion control algorithm.

Main characteristics:

  • Slow start.
  • Congestion avoidance.
  • Fast retransmit.
  • Fast recovery.
  • Infers network congestion from packet loss.

The advantage is that the mechanism is relatively simple.

The disadvantage is that in high-bandwidth, long-RTT networks, even a small amount of packet loss can significantly affect throughput.

2. CUBIC

CUBIC is a TCP congestion control algorithm widely used in systems such as Linux.

It adjusts the congestion window using a cubic function:

W(t)=C(t-K)^3+W_{max}

Where:

  • W(t): current congestion window.
  • C: growth parameter.
  • t: time since the last congestion event.
  • W_{max}: the window at the last congestion event.
  • K: time parameter required for the function to reach the historical window value.

CUBIC's growth strategy no longer simply relies on increasing the window by a fixed amount every RTT; instead, it adjusts the window based on the passage of time.

Main characteristics:

  • Suitable for high-bandwidth, long-RTT networks.
  • Recovers throughput near the historical window faster after congestion.
  • Uses a more cautious growth strategy near the historical window.
  • Widely adopted by systems such as Linux.

3. BBR

BBR (Bottleneck Bandwidth and Round-trip propagation time) is a congestion control algorithm proposed by Google.

Unlike traditional loss-based algorithms, BBR primarily attempts to estimate:

  • The bottleneck bandwidth, BtlBw.
  • The minimum round-trip propagation time, RTprop.

BBR aims to find the available transmission capacity of the network path and to control the sending rate and the amount of data in flight.

Core idea:

BDP = BtlBw \times RTprop

BBR estimates an appropriate amount of data in flight based on bandwidth and propagation delay, rather than treating packet loss as the sole indicator of congestion.

Main characteristics:

  • Focuses on bottleneck bandwidth and propagation delay.
  • Attempts to reduce unnecessary queuing delay.
  • Suitable for some high-bandwidth, long-RTT scenarios.
  • May have varying effects on other traffic and on queue management policies in the network.

BBR also has multiple versions and implementation differences, so not all BBR deployments should be assumed to behave identically.

4. Algorithm Comparison

Algorithm Primary Basis Main Characteristics Typical Focus
Reno Packet loss Classic additive increase, multiplicative decrease Basic TCP scenarios
CUBIC Packet loss and a time function Good recovery capability in high-speed networks High-bandwidth networks
BBR Bandwidth and RTT estimation Model-driven rate control High bandwidth, long RTT, queuing delay

5. Viewing and Adjusting the Congestion Control Algorithm on Linux

View the current algorithm:

sysctl net.ipv4.tcp_congestion_control

View the algorithms supported by the system:

sysctl net.ipv4.tcp_available_congestion_control

View the available algorithm modules in the kernel:

ls /lib/modules/$(uname -r)/kernel/net/ipv4/

Change the algorithm temporarily:

sudo sysctl -w net.ipv4.tcp_congestion_control=cubic

For a permanent change, edit:

sudo vim /etc/sysctl.d/99-network.conf

Add:

net.ipv4.tcp_congestion_control=cubic

Load the configuration:

sudo sysctl --system

In a production environment, you should not switch algorithms simply because a name sounds more advanced.

You should conduct stress testing based on network RTT, packet loss rate, link bandwidth, the number of concurrent connections, and actual business traffic.

IX. Active Queue Management: How Do Network Devices Handle Congestion in Advance?

Traditional network devices often use a Tail Drop policy.

When the queue is full, new packets are simply dropped.

This policy is simple to implement, but it can lead to:

  • Multiple TCP connections experiencing packet loss at the same time.
  • The queue remaining at a high level for extended periods.
  • A noticeable increase in queuing delay.
  • TCP flows reducing their sending rates in synchronization.

To address these problems, network devices can use Active Queue Management (AQM).

1. RED

RED (Random Early Detection) dynamically decides whether to drop or mark packets early based on queue length.

When the average queue length exceeds a certain threshold, the packet drop probability gradually increases.

Its goal is to provide a congestion signal to the sender before the queue becomes completely full.

2. CoDel

CoDel (Controlled Delay) focuses on the time packets spend waiting in the queue.

It aims to control queuing delay and prevent the buffer from accumulating a large amount of data over long periods.

3. FQ-CoDel

FQ-CoDel classifies traffic into multiple queues and uses CoDel to manage queue delay.

Main goals:

  • Reduce bufferbloat.
  • Reduce the impact of a single large flow on other flows.
  • Improve the responsiveness of interactive applications.
  • Improve fairness among different flows.

4. ECN

ECN (Explicit Congestion Notification) allows network devices, where ECN is supported, to notify the sender of network congestion by marking IP packets, without necessarily having to drop packets directly.

Basic process:

  1. The sender sends packets with ECN support.
  2. A network device detects congestion.
  3. The network device sets the congestion marking.
  4. The receiver feeds back the congestion information through the transport layer.
  5. The sender reduces its sending rate.

ECN requires support from both communicating endpoints and the network path, and its specific behavior depends on the protocol version and implementation.

X. QoS: How Are Network Resources Prioritized?

QoS (Quality of Service) is a set of mechanisms for managing network resources and traffic priority.

It can classify and schedule packets based on service type, traffic characteristics, or policy.

For example:

  • Voice communication: prioritize low latency and low jitter.
  • Video conferencing: guarantee a certain bandwidth and real-time performance.
  • File downloads: allowed to use the remaining bandwidth.
  • Background backups: lower priority when the network is busy.

1. Common QoS Mechanisms

Mechanism Function
Classification Identify different types of service traffic
Marking Set priority markings for packets
Queuing Place traffic into different queues
Scheduling Determine the sending order of different queues
Policing Limit traffic that exceeds the specified rate
Shaping Smooth bursty traffic to the specified rate

2. Common Scheduling Algorithms

FIFO

Packets that enter the queue first are sent first.

The advantage is simplicity.

The disadvantage is the lack of priority control between different types of traffic.

Priority Queuing

Priority queuing allows high-priority traffic to be sent first.

If high-priority traffic continuously occupies the link, low-priority traffic may go unserved for a long time.

Weighted Fair Queuing

WFQ allocates link resources according to traffic weights, so different types of traffic can be served in proportion to their weights.

Deficit Round Robin

DRR allocates transmission opportunities through polling and a quota mechanism, making it suitable for handling packets of different lengths.

3. QoS Processing Flow

flowchart TD
    A["Packets enter the network device"] --> B["Traffic classification"]
    B --> C["Set DSCP or other markings"]
    C --> D["Match QoS policy"]
    D --> E["Enter the corresponding queue"]
    E --> F["Perform queue scheduling"]
    F --> G["Policing or shaping"]
    G --> H["Send from the egress link"]

    style A fill:#E0F0FE,stroke:#93BCE8,color:#1E4976
    style B fill:#DCEFE5,stroke:#8EBFA5,color:#24563F
    style C fill:#EAE4FA,stroke:#B8A5E5,color:#514078
    style D fill:#FFF2CC,stroke:#E7C76A,color:#72551B
    style E fill:#E0F0FE,stroke:#93BCE8,color:#1E4976
    style F fill:#DCEFE5,stroke:#8EBFA5,color:#24563F
    style G fill:#F6FAF7,stroke:#DCE9E0,color:#334155
    style H fill:#DCEFE5,stroke:#8EBFA5,color:#24563F

QoS cannot increase physical bandwidth out of thin air; it can only help the system allocate limited resources more rationally.

11. How Do Different Network Protocols Handle Performance Issues?

1. TCP

TCP provides:

  • Reliable transmission.
  • In-order delivery.
  • Flow control.
  • Congestion control.
  • Retransmission mechanisms.

Suitable for:

  • Web pages.
  • File transfer.
  • Database connections.
  • Most traditional API communication.

TCP's reliability mechanisms can introduce performance impacts such as retransmissions and head-of-line blocking.

2. UDP

UDP provides:

  • Connectionless datagram transmission.
  • A smaller protocol header.
  • No guaranteed delivery.
  • No guaranteed ordering.
  • No built-in congestion control.

Suitable for:

  • Real-time audio and video.
  • DNS.
  • Some online games.
  • Some low-latency communication systems.

UDP does not mean that applications do not need congestion control. Internet-facing UDP applications still need to design reasonable congestion response mechanisms.

3. QUIC

QUIC is a modern transport protocol built on UDP. It integrates TLS 1.3 security mechanisms and supports multiple independent logical streams.

HTTP/3 uses QUIC to transport HTTP data.

Main features of QUIC:

  • Combines connection establishment with the encrypted handshake.
  • Supports multiplexing.
  • Avoids TCP-level head-of-line blocking between different streams.
  • Supports connection migration.
  • Includes transport-layer congestion control.

Note that QUIC does not eliminate all head-of-line blocking. Data order still needs to be maintained within a single QUIC stream.

4. Protocol Performance Comparison

Dimension TCP UDP QUIC
Underlying transport TCP UDP UDP
Reliability Built-in Not guaranteed Built-in
Ordered delivery Guarantees byte-stream order Not guaranteed Guaranteed within a single stream
Congestion control Built-in Requires application design Built-in
Encryption Usually combined with TLS Can be implemented by the application Integrated TLS 1.3
Multiplexing Implemented at the application or protocol layer Designed by the application itself Native multi-stream
Typical applications HTTP/1.1, HTTP/2 DNS, real-time media HTTP/3

12. Network Performance Measurement and Diagnostics

Network optimization must be based on measurement.

You cannot judge whether the network has slowed down based only on subjective perception, nor should you focus on only one metric.

1. Ping: Testing RTT and Connectivity

ping example.com

Continuous testing:

ping -c 20 example.com

The output usually includes:

  • Minimum RTT.
  • Average RTT.
  • Maximum RTT.
  • RTT standard deviation.
  • Packet loss rate.

Windows:

ping -n 20 example.com

Note:

Ping uses ICMP. Some servers or network devices may restrict ICMP responses, so a failed Ping does not necessarily mean that TCP or HTTP services are unavailable.

2. Traceroute: Observing the Network Path

Linux:

traceroute example.com

Windows: