l8traffic

Traffic

Traffic engineering and SR policy management.

Overview

A UDP/TCP traffic generator for testing Kubernetes Network Policies. Runs in two modes: service mode (listeners) and client mode (traffic generation). Deploy listener pods across a cluster as a DaemonSet, then issue traffic commands from any pod to verify that network policies permit or block the expected traffic.

How It Works

  1. Service pods run on every node via a DaemonSet, each listening on UDP and TCP ports.
  2. A client sends a command via UDP to any service pod, specifying target destination, port, protocol, and packet count.
  3. The service pod generates traffic to the target. UDP mode allocates ephemeral sockets with throttling at 5K packets (250ms pause). TCP mode uses a pool of 100 concurrent HTTP workers.
  4. The service pod reports results back: sent count, OK count, error count, timeout status, and elapsed time.

Usage

Start a Listener

./generator Start Udp_port=15000 Tcp_port=16000

Starts both a UDP listener and a TCP (HTTP) echo server.

Generate Traffic

./generator Do Udp_port=15000 Destination=10.0.0.5 Port=16000 Quantity=1000

Arguments: Udp_port (local service port), Tcp_port (if set, use TCP instead of UDP), Destination (target IP), Port (target port), Quantity (packet count), Timeout (seconds, auto-calculated if 0).

Report Output

Results are reported as: Total UDP Sent:1000 OK:1000 Err:0 Timeout:false Took:2 seconds

Kubernetes Deployment

Apply k8s/deploy.yaml to deploy into namespace traffic-01:

DaemonSet
listener pod on every node (UDP 15000, TCP 16000)
ClusterIP Service
internal access
NodePort Service
external access (ports 30000, 30001)

Testing Network Policies

From any pod, test connectivity to the traffic service. If the NetworkPolicy allows traffic, all packets succeed. If blocked, all packets error with a timeout.

Wire Protocol

Messages use a pipe-delimited format: id|action|dest|port|qty|text|timeout. Actions include sendUdp, sendTcp, request, and response.

Docker

Cross-compiles for linux/amd64. Image: registry.layer-8.dev:44443/traffic/traffic-generator:latest. Run with environment variables CMD=Start, Udp_port, and Tcp_port.