Raw TCP & UDP

Protocols

Go below HTTP: open a raw TCP or UDP socket, write bytes, read the reply and assert on it — for custom or binary protocols.

Browse all 52 demos 12 categories
Run it
$ loadr run examples/12-tcp-udp.yaml
examples/12-tcp-udp.yaml
# Raw socket load: TCP request/response and UDP datagrams, with hex payloads.
name: raw-sockets
description: TCP and UDP round trips

scenarios:
  tcp_echo:
    executor: constant-vus
    vus: 10
    duration: 1m
    flow:
      - request:
          name: tcp ping
          url: tcp://echo.example.com:7000
          socket:
            send_text: "PING ${vu}\n"
            read_bytes: 64
            read_timeout: 2s
          checks:
            - { type: body_contains, value: PONG }

  udp_metrics:
    executor: constant-arrival-rate
    rate: 500
    duration: 1m
    pre_allocated_vus: 20
    flow:
      - request:
          name: udp probe
          url: udp://stats.example.com:8125
          socket:
            send_hex: "deadbeef 0102 0304"
            read_timeout: 500ms

thresholds:
  tcp_req_duration: [ "p(99)<50" ]

View raw: examples/12-tcp-udp.yaml

What it shows

  • Raw TCP + UDP
  • Byte-level send / match
  • Custom protocol load