土法炼钢兴趣小组的算法知识备份

【网络工程】网络性能监控体系:指标、探针与告警

文章导航

分类入口
network
标签入口
#network-monitoring#prometheus#blackbox-exporter#smokeping#snmp#netflow#observability

目录

你的服务 SLA 承诺 99.99% 可用性。某天凌晨 3:00,用户报告”访问慢”。等你上线排查时,网络已经恢复,但没有任何历史数据告诉你发生了什么。网络监控不是事后诸葛亮——它是在故障发生的那一秒就告诉你哪里断了、断了多久、影响了谁的系统工程。

一、网络监控指标体系

1.1 网络 RED 指标

借鉴微服务的 RED 方法(Rate / Error / Duration),网络层的核心指标:

指标 含义 采集方式 告警阈值参考
吞吐量(Rate) 接口收发速率 SNMP / node_exporter > 80% 容量
丢包率(Error) 包丢失百分比 SNMP ifInErrors > 0.1%
延迟(Duration) RTT / 单向延迟 ICMP / TCP探针 > 基线 2 倍
重传率 TCP 重传百分比 node_exporter > 1%
连接数 活跃 TCP 连接 ss / conntrack > 预期 3 倍
DNS 延迟 DNS 查询时间 Blackbox Exporter > 100ms
TLS 握手时间 TLS 协商延迟 Blackbox Exporter > 500ms

1.2 分层指标模型

┌─────────────────────────────────────────────────────┐
│  应用层指标                                          │
│  HTTP 状态码、TTFB、请求成功率、gRPC 状态码           │
├─────────────────────────────────────────────────────┤
│  传输层指标                                          │
│  TCP 重传率、连接建立时间、RST 计数、零窗口事件        │
├─────────────────────────────────────────────────────┤
│  网络层指标                                          │
│  RTT、丢包率、路径 MTU、TTL 异常                      │
├─────────────────────────────────────────────────────┤
│  链路层指标                                          │
│  接口错误、CRC 错误、接口利用率、广播风暴              │
└─────────────────────────────────────────────────────┘

1.3 node_exporter 网络指标

# node_exporter 自动采集的网络指标

# 接口级别(来自 /proc/net/dev)
node_network_receive_bytes_total      # 接收字节数
node_network_transmit_bytes_total     # 发送字节数
node_network_receive_packets_total    # 接收包数
node_network_transmit_packets_total   # 发送包数
node_network_receive_errs_total       # 接收错误
node_network_transmit_errs_total      # 发送错误
node_network_receive_drop_total       # 接收丢弃
node_network_transmit_drop_total      # 发送丢弃

# TCP 指标(来自 /proc/net/snmp)
node_netstat_Tcp_CurrEstab           # 当前 ESTABLISHED 连接数
node_netstat_Tcp_RetransSegs         # TCP 重传段数
node_netstat_Tcp_InSegs              # TCP 接收段数
node_netstat_Tcp_OutSegs             # TCP 发送段数
node_netstat_Tcp_ActiveOpens         # 主动打开连接数
node_netstat_Tcp_PassiveOpens        # 被动打开连接数

# conntrack 指标
node_nf_conntrack_entries            # conntrack 当前条目
node_nf_conntrack_entries_limit      # conntrack 最大条目

二、Blackbox Exporter 探针监控

2.1 Blackbox Exporter 架构

Blackbox Exporter 是 Prometheus 生态的网络探针,从外部模拟用户请求检测网络可达性和性能:

# blackbox.yml — Blackbox Exporter 配置

modules:
  # ICMP 探针
  icmp_probe:
    prober: icmp
    timeout: 5s
    icmp:
      preferred_ip_protocol: ip4
      payload_size: 64

  # TCP 探针
  tcp_connect:
    prober: tcp
    timeout: 5s

  # HTTP 探针
  http_2xx:
    prober: http
    timeout: 10s
    http:
      valid_http_versions: ["HTTP/1.1", "HTTP/2.0"]
      valid_status_codes: [200, 301, 302]
      method: GET
      follow_redirects: true
      preferred_ip_protocol: ip4

  # HTTPS + 证书检查
  https_cert:
    prober: http
    timeout: 10s
    http:
      valid_http_versions: ["HTTP/1.1", "HTTP/2.0"]
      method: GET
      fail_if_ssl: false
      tls_config:
        insecure_skip_verify: false

  # DNS 探针
  dns_lookup:
    prober: dns
    timeout: 5s
    dns:
      query_name: "example.com"
      query_type: "A"
      valid_rcodes:
        - NOERROR

2.2 Prometheus 集成

# prometheus.yml — 探针任务配置

scrape_configs:
  # ICMP 探针
  - job_name: 'blackbox-icmp'
    metrics_path: /probe
    params:
      module: [icmp_probe]
    static_configs:
      - targets:
        - 10.0.1.1     # 核心交换机
        - 10.0.2.1     # 接入交换机
        - 8.8.8.8      # 外网 DNS
        - 1.1.1.1      # 外网 DNS
    relabel_configs:
      - source_labels: [__address__]
        target_label: __param_target
      - source_labels: [__param_target]
        target_label: instance
      - target_label: __address__
        replacement: blackbox-exporter:9115

  # HTTP 探针
  - job_name: 'blackbox-http'
    metrics_path: /probe
    params:
      module: [http_2xx]
    static_configs:
      - targets:
        - https://api.example.com/health
        - https://www.example.com
    relabel_configs:
      - source_labels: [__address__]
        target_label: __param_target
      - source_labels: [__param_target]
        target_label: instance
      - target_label: __address__
        replacement: blackbox-exporter:9115

  # DNS 探针
  - job_name: 'blackbox-dns'
    metrics_path: /probe
    params:
      module: [dns_lookup]
    static_configs:
      - targets:
        - 10.0.0.53:53     # 内部 DNS
        - 8.8.8.8:53       # Google DNS
    relabel_configs:
      - source_labels: [__address__]
        target_label: __param_target
      - source_labels: [__param_target]
        target_label: instance
      - target_label: __address__
        replacement: blackbox-exporter:9115

2.3 关键探针指标

# Blackbox Exporter 暴露的指标

# 探针是否成功(最重要)
probe_success                        # 1=成功 0=失败

# 延迟分解
probe_duration_seconds               # 探针总耗时
probe_dns_lookup_time_seconds        # DNS 解析耗时
probe_ip_protocol                    # 使用的 IP 版本
probe_ssl_earliest_cert_expiry       # SSL 证书最早过期时间

# HTTP 相关
probe_http_status_code               # HTTP 状态码
probe_http_duration_seconds{phase="connect"}   # TCP 连接耗时
probe_http_duration_seconds{phase="tls"}       # TLS 握手耗时
probe_http_duration_seconds{phase="processing"} # 服务端处理耗时
probe_http_duration_seconds{phase="transfer"}   # 传输耗时
probe_http_content_length            # 响应体大小
probe_http_version                   # HTTP 版本

# ICMP 相关
probe_icmp_duration_seconds          # ICMP RTT

三、Smokeping 延迟基线

3.1 Smokeping 部署

# Smokeping 是专业的网络延迟监控工具
# 通过持续 ping 建立延迟基线,检测延迟异常和丢包

# 安装
apt-get install smokeping

# 配置 /etc/smokeping/config.d/Targets
# *** Targets ***

+ Network
menu = 网络监控

++ CoreSwitch
host = 10.0.0.1
title = 核心交换机

++ ISP_Gateway
host = 192.168.1.1
title = ISP 网关

++ DNS_Google
host = 8.8.8.8
title = Google DNS

++ DNS_Cloudflare
host = 1.1.1.1
title = Cloudflare DNS

++ CDN_Edge
host = cdn.example.com
title = CDN 边缘节点

# 配置探测参数
# *** Probes ***
+ FPing
binary = /usr/bin/fping
packetsize = 64
pings = 20        # 每次探测发 20 个包
step = 60         # 每 60 秒探测一次

3.2 Smokeping 数据解读

Smokeping 图表包含三种信息:

1. 延迟(中位数)——绿色线
   正常:稳定在基线附近
   异常:突然跳升或持续上升

2. 抖动(延迟变化)——灰色区域
   正常:窄带
   异常:宽带或不对称

3. 丢包——颜色变化
   绿色 = 0% 丢包
   蓝色 = 1/20 丢包(5%)
   深蓝 = 2/20 丢包(10%)
   紫色 = 较多丢包
   红色 = 严重丢包

四、SNMP 监控

4.1 SNMP Exporter 配置

# snmp.yml(使用 snmp_exporter generator 生成)
# 监控网络设备的接口指标

# prometheus.yml
scrape_configs:
  - job_name: 'snmp'
    static_configs:
      - targets:
        - 10.0.0.1    # 核心交换机
        - 10.0.0.2    # 汇聚交换机
        - 10.0.0.3    # 接入交换机
    metrics_path: /snmp
    params:
      module: [if_mib]
    relabel_configs:
      - source_labels: [__address__]
        target_label: __param_target
      - source_labels: [__param_target]
        target_label: instance
      - target_label: __address__
        replacement: snmp-exporter:9116

4.2 关键 SNMP 指标

# 接口状态
ifOperStatus         # 接口状态(up/down/testing)
ifAdminStatus        # 管理状态

# 流量
ifHCInOctets         # 入口字节数(64 位计数器)
ifHCOutOctets        # 出口字节数
ifHCInUcastPkts      # 入口单播包数
ifHCOutUcastPkts     # 出口单播包数

# 错误
ifInErrors           # 入口错误包数
ifOutErrors          # 出口错误包数
ifInDiscards         # 入口丢弃包数
ifOutDiscards        # 出口丢弃包数

# 接口速率
ifHighSpeed          # 接口速率(Mbps)

# PromQL 计算带宽利用率
# rate(ifHCInOctets[5m]) * 8 / (ifHighSpeed * 1000000) * 100

五、NetFlow/sFlow 流量分析

5.1 NetFlow vs sFlow

特性 NetFlow v9 sFlow
采样方式 流级别聚合 包级别采样
开销 较高 较低
实时性 较差(需要流结束) 较好(即时采样)
支持厂商 Cisco 为主 多厂商
精度 完整流统计 统计估算
适用规模 中小规模 大规模

5.2 流量分析实践

# 使用 nfdump 分析 NetFlow 数据

# 查看 Top 10 流量来源
nfdump -R /var/flow -s srcip -n 10

# 查看特定时间段的流量
nfdump -R /var/flow -t '2025/08/01.10:00-2025/08/01.11:00' \
    -s dstport -n 20

# 查找异常大流量
nfdump -R /var/flow -o extended \
    'bytes > 1G and proto tcp'

# 分析 DDoS 攻击流量特征
nfdump -R /var/flow -s srcip -n 50 \
    'dst ip 10.0.1.100 and dst port 80'

# 使用 pmacct 做流量采集和分析
# pmacct 支持 NetFlow/sFlow/IPFIX 输入
# 可以输出到 Prometheus / Kafka / PostgreSQL

六、告警策略设计

6.1 告警层级

# alerting-rules.yml — 网络告警规则

groups:
  - name: network-critical
    rules:
      # P0 — 立即响应
      - alert: NetworkInterfaceDown
        expr: |
          ifOperStatus{ifAlias!~".*unused.*"} != 1
        for: 1m
        labels:
          severity: critical
        annotations:
          summary: "网络接口 {{ $labels.ifDescr }} 宕机"
          
      - alert: HighPacketLoss
        expr: |
          (1 - probe_success) > 0
          and count_over_time(probe_success[5m]) >= 5
        for: 3m
        labels:
          severity: critical
        annotations:
          summary: "探针 {{ $labels.instance }} 连续失败"

  - name: network-warning
    rules:
      # P1 — 30 分钟内响应
      - alert: HighBandwidthUtilization
        expr: |
          rate(ifHCInOctets[5m]) * 8
          / (ifHighSpeed * 1e6) * 100 > 80
        for: 10m
        labels:
          severity: warning
        annotations:
          summary: "接口 {{ $labels.ifDescr }} 带宽使用率 > 80%"

      - alert: HighTcpRetransmission
        expr: |
          rate(node_netstat_Tcp_RetransSegs[5m])
          / rate(node_netstat_Tcp_OutSegs[5m]) * 100 > 1
        for: 10m
        labels:
          severity: warning
        annotations:
          summary: "TCP 重传率 > 1%"

      - alert: ConntrackTableFull
        expr: |
          node_nf_conntrack_entries
          / node_nf_conntrack_entries_limit * 100 > 80
        for: 5m
        labels:
          severity: warning
        annotations:
          summary: "conntrack 表使用率 > 80%"

      - alert: SSLCertExpiringSoon
        expr: |
          probe_ssl_earliest_cert_expiry - time() < 7 * 24 * 3600
        labels:
          severity: warning
        annotations:
          summary: "SSL 证书将在 7 天内过期: {{ $labels.instance }}"

  - name: network-info
    rules:
      # P2 — 工作时间处理
      - alert: LatencyAboveBaseline
        expr: |
          probe_icmp_duration_seconds > 0.05
        for: 30m
        labels:
          severity: info
        annotations:
          summary: "ICMP 延迟 > 50ms: {{ $labels.instance }}"

6.2 告警抑制与聚合

# alertmanager.yml — 告警路由与抑制

route:
  group_by: ['alertname', 'severity']
  group_wait: 30s
  group_interval: 5m
  repeat_interval: 4h
  receiver: 'default'
  routes:
    - match:
        severity: critical
      receiver: 'pager'
      group_wait: 10s
      repeat_interval: 1h
    - match:
        severity: warning
      receiver: 'slack-network'
      repeat_interval: 4h

inhibit_rules:
  # 接口宕机时抑制该接口的其他告警
  - source_match:
      alertname: NetworkInterfaceDown
    target_match_re:
      alertname: High.*
    equal: ['instance']

  # Critical 告警抑制同实例的 Warning
  - source_match:
      severity: critical
    target_match:
      severity: warning
    equal: ['instance']

七、Dashboard 设计

7.1 网络概览面板

# Grafana Dashboard 设计原则
# 1. 从上到下:概览 → 详情
# 2. 从左到右:关键指标 → 趋势 → 分布
# 3. 颜色编码:绿色=正常  黄色=告警  红色=故障

# 第一行:状态面板(Stat Panel)
# - 探针成功率(所有目标的平均值)
# - 活跃告警数
# - TCP 重传率
# - 接口错误率

# 第二行:时序图(Time Series)
# - 带宽利用率趋势(按接口)
# - RTT 延迟趋势(按目标)
# - 连接数趋势

# 第三行:分布图
# - 延迟热力图(Heatmap)
# - 流量 Top-N 表格
# - 错误分类饼图

7.2 关键 PromQL 查询

# 带宽利用率(百分比)
rate(node_network_receive_bytes_total{device="eth0"}[5m]) * 8
/ (node_network_speed_bytes{device="eth0"} * 8) * 100

# TCP 重传率
rate(node_netstat_Tcp_RetransSegs[5m])
/ rate(node_netstat_Tcp_OutSegs[5m]) * 100

# HTTP 探针延迟分解
probe_http_duration_seconds{phase="connect"}   # TCP 连接
probe_http_duration_seconds{phase="tls"}       # TLS 握手
probe_http_duration_seconds{phase="processing"} # 服务端处理
probe_http_duration_seconds{phase="transfer"}   # 传输

# 接口丢包率
rate(node_network_receive_drop_total[5m])
/ rate(node_network_receive_packets_total[5m]) * 100

# conntrack 使用率
node_nf_conntrack_entries / node_nf_conntrack_entries_limit * 100

# 证书剩余天数
(probe_ssl_earliest_cert_expiry - time()) / 86400

# DNS 查询延迟 P99
histogram_quantile(0.99,
  rate(dns_query_duration_seconds_bucket[5m]))

八、端到端可观测性

8.1 网络路径追踪

# 使用 mtr 做持续路径监控
mtr --report --report-cycles 100 --json target.example.com

# 解读 mtr 报告
# Host              Loss%   Snt   Last   Avg  Best  Wrst StDev
# 1. gateway        0.0%   100    1.0    1.1   0.8   2.3   0.2
# 2. isp-router     0.5%   100    5.2    5.5   4.1   8.9   0.8
# 3. backbone       0.0%   100   12.3   12.1  11.5  14.2   0.5
# 4. target         0.0%   100   15.1   15.0  14.2  17.3   0.4

# 异常模式:
# - 某跳丢包但后续正常 → 该设备 ICMP 限速(通常无害)
# - 某跳开始持续丢包 → 真实丢包点
# - 延迟突增且后续累加 → 该跳是瓶颈

8.2 综合监控架构

┌─────────────┐  ┌──────────────┐  ┌─────────────┐
│  Smokeping   │  │  Blackbox    │  │  SNMP       │
│  (延迟基线)  │  │  Exporter    │  │  Exporter   │
│              │  │  (探针监控)   │  │  (设备监控)  │
└──────┬───────┘  └──────┬───────┘  └──────┬──────┘
       │                 │                  │
       └────────┬────────┴─────────┬────────┘
                │                  │
         ┌──────┴──────┐   ┌──────┴──────┐
         │  Prometheus │   │  InfluxDB   │
         │  (指标存储)  │   │  (Smokeping │
         │             │   │   数据)     │
         └──────┬──────┘   └──────┬──────┘
                │                 │
         ┌──────┴─────────────────┴──────┐
         │           Grafana             │
         │     (统一 Dashboard)          │
         └──────────────┬────────────────┘
                        │
                 ┌──────┴──────┐
                 │ Alertmanager │
                 │  (告警路由)   │
                 └──────┬──────┘
                        │
              ┌─────────┼──────────┐
              │         │          │
         PagerDuty   Slack     Email

8.3 监控部署清单

组件 用途 部署位置
node_exporter 主机网络指标 每台服务器
blackbox_exporter 网络探针 每个数据中心
snmp_exporter 网络设备指标 监控服务器
Smokeping 延迟基线 监控服务器
pmacct / nfsen 流量分析 流量采集器
Prometheus 指标存储和告警 监控集群
Grafana 可视化 监控集群
Alertmanager 告警路由 监控集群

九、实战案例

9.1 案例一:间歇性丢包排查

现象:用户反馈每天 14:00-16:00 访问变慢,但服务端指标正常。

# 第一步:查看 Blackbox Exporter 探针数据
# PromQL:probe_success{instance="api.example.com"} 按小时统计
# 发现 14:00-16:00 探针成功率从 100% 降到 97%

# 第二步:查看 ICMP 延迟
# Smokeping 图表显示该时段延迟从 5ms 升至 50ms,丢包 3%

# 第三步:mtr 路径分析(在该时段运行)
mtr --report -c 200 api.example.com
# 发现第 3 跳(ISP 骨干路由器)丢包 5%

# 第四步:查看该路由器的 SNMP 指标
# 接口利用率在 14:00-16:00 达到 95%
# 原因:ISP 骨干链路在该时段拥塞

# 解决:
# 1. 与 ISP 沟通扩容
# 2. 临时方案:将关键流量路由到备用链路
# 3. 部署多 ISP 冗余

9.2 案例二:证书过期告警体系

# 配置 SSL 证书过期监控

# Blackbox Exporter 探针配置
# modules:
#   https_cert_check:
#     prober: http
#     http:
#       method: HEAD
#       fail_if_ssl: false

# 告警规则
# - 30 天前:info 级别通知
# - 14 天前:warning 通知运维
# - 7 天前:critical 值班告警
# - 3 天前:P0 紧急告警

# PromQL 表达式
# probe_ssl_earliest_cert_expiry - time() < 30 * 86400  # 30 天
# probe_ssl_earliest_cert_expiry - time() < 14 * 86400  # 14 天
# probe_ssl_earliest_cert_expiry - time() < 7 * 86400   # 7 天

# 配合 cert-manager 自动续期的监控
# 即使有自动续期,仍需要监控——自动续期也会失败

9.3 案例三:TCP 重传异常定位

现象:TCP 重传率从 0.1% 突然升至 3%,持续 2 小时。

# 第一步:确认影响范围
# PromQL:按目标 IP 分组查看重传率
# rate(node_netstat_Tcp_RetransSegs[5m])
# / rate(node_netstat_Tcp_OutSegs[5m])
# 发现只有与特定子网(10.0.5.0/24)通信时重传率高

# 第二步:检查该子网的网络设备
# SNMP 指标显示 10.0.5.0/24 的接入交换机接口 CRC 错误激增
# ifInErrors 从 0 飙升至数千/秒

# 第三步:物理层检查
# 交换机日志显示该端口频繁协商速率变化
# 原因:光模块老化,导致物理层错误

# 解决:更换光模块后重传率恢复到 0.1%

# 关键学习:
# TCP 重传的根因不一定在 TCP 层
# 需要结合 L2/L3 指标定位

十、监控最佳实践

10.1 黄金信号

网络监控的四个黄金信号:

1. 可达性(Reachability)
   - 探针成功率
   - 接口状态
   - 路由表完整性

2. 延迟(Latency)
   - RTT 基线与偏差
   - DNS 解析延迟
   - TLS 握手延迟

3. 吞吐量(Throughput)
   - 接口带宽利用率
   - 流量模式(峰值/均值/95 分位)
   - 流量方向分布

4. 错误率(Error Rate)
   - 丢包率
   - TCP 重传率
   - 接口错误
   - DNS 查询失败率

10.2 避免告警疲劳

实践 说明
基于基线告警 不用固定阈值,用历史基线的标准差
告警分级 P0/P1/P2/P3,不同级别不同通知方式
告警聚合 同一根因的告警合并为一条
告警抑制 上游故障抑制下游告警
定期审查 每月审查告警规则,清理无效告警
告警 SLO 每周告警不超过 N 条(倒逼优化)

10.3 监控成熟度模型

级别 能力 典型工具
L0 无监控,故障靠用户报告
L1 基础 ping / 端口检测 Nagios / uptime robot
L2 指标采集 + 阈值告警 Prometheus + node_exporter
L3 探针 + 基线 + 分层指标 Blackbox + Smokeping + SNMP
L4 流量分析 + 路径追踪 + 自动修复 NetFlow + mtr + 自动化
L5 AIOps 异常检测 + 根因分析 + 容量预测 自建 ML 或商业方案

从 L1 到 L3 是最关键的提升——覆盖了 90% 的网络故障检测需求。

10.4 多区域探针部署

# 在不同地理位置部署探针,检测区域间连通性

# 区域 A(北京)
# blackbox_exporter 探测:
# - 本区域服务(10.0.1.0/24)
# - 区域 B 服务(10.0.2.0/24)
# - 区域 C 服务(10.0.3.0/24)
# - 公网 DNS / CDN

# 区域 B(上海)
# blackbox_exporter 探测同样的目标列表

# 区域 C(广州)
# 同上

# 通过对比不同区域探针的数据:
# - 所有区域都探测失败 → 目标故障
# - 单个区域探测失败 → 该区域网络问题
# - 延迟差异大 → 路由问题

# Prometheus 联邦集群聚合多区域数据
# 在全局 Prometheus 中:
scrape_configs:
  - job_name: 'federate-network'
    honor_labels: true
    metrics_path: /federate
    params:
      'match[]':
        - '{job="blackbox-icmp"}'
        - '{job="blackbox-http"}'
    static_configs:
      - targets:
        - prometheus-beijing:9090
        - prometheus-shanghai:9090
        - prometheus-guangzhou:9090

参考文献

  1. Prometheus Documentation, “Blackbox Exporter,” prometheus.io/docs.
  2. Oetiker, T., “SmokePing,” oss.oetiker.ch/smokeping.
  3. McCloghrie, K. and Rose, M., “Management Information Base for Network Management of TCP/IP-based internets: MIB-II,” RFC 1213.
  4. Beyer, B. et al., “Site Reliability Engineering,” O’Reilly Media, 2016.
  5. Claise, B., “Cisco Systems NetFlow Services Export Version 9,” RFC 3954.
  6. Phaal, P. et al., “InMon Corporation’s sFlow: A Method for Monitoring Traffic in Switched and Routed Networks,” RFC 3176.

上一篇: 带宽管理与流量整形:tc、QoS 与拥塞管理 下一篇: QUIC 生态与工程部署:从实验到生产

同主题继续阅读

把当前热点继续串成多页阅读,而不是停在单篇消费。

2025-08-04 · network

【网络工程】QUIC 生态与工程部署:从实验到生产

QUIC 已经不是实验性协议——HTTP/3 标准化后,CDN、浏览器和主流服务端框架都在推进 QUIC 支持。本文从工程视角对比主流 QUIC 库的成熟度和性能特征,讲解 CDN/负载均衡器的 QUIC 适配方案、从 TCP 迁移到 QUIC 的渐进路径、QUIC 调试工具链,以及生产环境的部署陷阱和性能调优实践。

2025-08-05 · network

【网络工程】eBPF 可编程网络:从包过滤到流量工程

eBPF 正在重新定义网络工程——从传统的 iptables/netfilter 规则堆砌,到可编程、可观测、高性能的网络数据平面。本文系统讲解 eBPF 网络程序类型(XDP/TC/Socket)、Map 数据结构、Cilium 的 eBPF 数据平面实现,以及 eBPF 在负载均衡、可观测性和网络安全中的工程实践。

2025-08-06 · network

【网络工程】可编程数据平面与 P4:软件定义转发

传统网络设备的转发逻辑固化在硬件中。P4 语言让交换机的转发管线可编程——你可以定义自己的包头解析、匹配规则和转发动作。本文从 P4 语言核心概念出发,讲解 Parser/Match-Action/Deparser 的编程模型、可编程交换机芯片(Tofino)的架构、P4 在数据中心和运营商网络中的应用案例,以及 P4 与 eBPF 的定位差异。

2025-08-07 · network

【网络工程】网络模拟与测试:netem、Mininet 与混沌工程

生产环境的网络条件远比实验室复杂——延迟抖动、随机丢包、带宽突变、链路故障。本文系统讲解 tc netem 的完整用法、Mininet 虚拟网络拓扑搭建、网络层混沌工程(Toxiproxy/Comcast/tc-netem)的实战方法,以及如何在 CI/CD 流水线中集成网络条件测试,确保应用在恶劣网络下的鲁棒性。


By .