Skip to content

Instantly share code, notes, and snippets.

@williamcaban
Created August 2, 2020 22:22
Show Gist options
  • Save williamcaban/b898c5b599bf179d45a5f1b16bc982e4 to your computer and use it in GitHub Desktop.
Save williamcaban/b898c5b599bf179d45a5f1b16bc982e4 to your computer and use it in GitHub Desktop.
Using client/server iperf pods

Using iperf Pods

  • Create namespace or project for running iperf tests:
oc new-project iperf-test
  • Create server Pod
rm -f pod-iperf-server.yaml 
cat >> pod-iperf-server.yaml <<EOL
apiVersion: v1
kind: Pod
metadata:
  name: iperf-server
  namespace: iperf-test
spec:
  containers:
  - name: net-toolbox
    image: quay.io/wcaban/net-toolbox:latest
    command:
      - iperf3
      - "-s"
      - "-B"
      - "0.0.0.0"
      - "-V"
      - "-i"
      - "1"
      - --forceflush
    ports:
      - containerPort: 5201
        name: iperf
        protocol: TCP
EOL

oc delete -f pod-iperf-server.yaml
oc create -f pod-iperf-server.yaml
  • Create client Pod
export IPERF_SERVER=`oc get pods iperf-server -n iperf-test -o=jsonpath="{['status.podIP']}"`

rm -f pod-iperf-client.yaml 
cat >> pod-iperf-client.yaml <<EOL
apiVersion: v1
kind: Pod
metadata:
  name: iperf-client
  namespace: iperf-test
spec:
  containers:
  - name: net-toolbox
    image: quay.io/wcaban/net-toolbox:latest
    command:
      - iperf3
      - "-c"
      - "$IPERF_SERVER"
      - "-V"
      - "-t"
      - "0"
      - "--forceflush"
EOL

oc delete -f pod-iperf-client.yaml
oc create -f pod-iperf-client.yaml
  • (alternate) Create a client Pod to connect to it to run random tests
rm -f pod-iperf-client2.yaml 
cat >> pod-iperf-client2.yaml <<EOL
apiVersion: v1
kind: Pod
metadata:
  name: iperf-client2
  namespace: iperf-test
spec:
  containers:
  - name: net-toolbox
    image: quay.io/wcaban/net-toolbox:latest
    command:
      - sleep
      - infinity
    env:
      - name: IPERF_SERVER
        value: ${IPERF_SERVER}
EOL

oc delete -f pod-iperf-client2.yaml
oc create -f pod-iperf-client2.yaml
  • NOTE:
    • If need to use privileged sockets or privileged network capabilities:
    # To add SCC to ServiceAccount
    oc adm policy add-scc-to-user privileged -z default
    
    • If need to remove privileges from a ServiceAccount:
    # To remove SCC from ServiceAccount
    oc adm policy remove-scc-from-user privileged -z default
    

IPERF3 flags

# iperf3 --help
Usage: iperf3 [-s|-c host] [options]
       iperf3 [-h|--help] [-v|--version]

Server or Client:
  -p, --port      #         server port to listen on/connect to
  -f, --format   [kmgtKMGT] format to report: Kbits, Mbits, Gbits, Tbits
  -i, --interval  #         seconds between periodic throughput reports
  -F, --file name           xmit/recv the specified file
  -A, --affinity n/n,m      set CPU affinity
  -B, --bind      <host>    bind to the interface associated with the address <host>
  -V, --verbose             more detailed output
  -J, --json                output in JSON format
  --logfile f               send output to a log file
  --forceflush              force flushing output at every interval
  -d, --debug               emit debugging output
  -v, --version             show version information and quit
  -h, --help                show this message and quit
Server specific:
  -s, --server              run in server mode
  -D, --daemon              run the server as a daemon
  -I, --pidfile file        write PID file
  -1, --one-off             handle one client connection then exit
Client specific:
  -c, --client    <host>    run in client mode, connecting to <host>
  -u, --udp                 use UDP rather than TCP
  --connect-timeout #       timeout for control connection setup (ms)
  -b, --bitrate #[KMG][/#]  target bitrate in bits/sec (0 for unlimited)
                            (default 1 Mbit/sec for UDP, unlimited for TCP)
                            (optional slash and packet count for burst mode)
  --pacing-timer #[KMG]     set the timing for pacing, in microseconds (default 1000)
  --fq-rate #[KMG]          enable fair-queuing based socket pacing in
                            bits/sec (Linux only)
  -t, --time      #         time in seconds to transmit for (default 10 secs)
  -n, --bytes     #[KMG]    number of bytes to transmit (instead of -t)
  -k, --blockcount #[KMG]   number of blocks (packets) to transmit (instead of -t or -n)
  -l, --length    #[KMG]    length of buffer to read or write
                            (default 128 KB for TCP, dynamic or 1460 for UDP)
  --cport         <port>    bind to a specific client port (TCP and UDP, default: ephemeral port)
  -P, --parallel  #         number of parallel client streams to run
  -R, --reverse             run in reverse mode (server sends, client receives)
  -w, --window    #[KMG]    set window size / socket buffer size
  -C, --congestion <algo>   set TCP congestion control algorithm (Linux and FreeBSD only)
  -M, --set-mss   #         set TCP/SCTP maximum segment size (MTU - 40 bytes)
  -N, --no-delay            set TCP/SCTP no delay, disabling Nagle's Algorithm
  -4, --version4            only use IPv4
  -6, --version6            only use IPv6
  -S, --tos N               set the IP type of service, 0-255.
                            The usual prefixes for octal and hex can be used,
                            i.e. 52, 064 and 0x34 all specify the same value.
  --dscp N or --dscp val    set the IP dscp value, either 0-63 or symbolic.
                            Numeric values can be specified in decimal,
                            octal and hex (see --tos above).
  -L, --flowlabel N         set the IPv6 flow label (only supported on Linux)
  -Z, --zerocopy            use a 'zero copy' method of sending data
  -O, --omit N              omit the first n seconds
  -T, --title str           prefix every output line with this string
  --get-server-output       get results from server
  --udp-counters-64bit      use 64-bit counters in UDP test packets

[KMG] indicates options that support a K/M/G suffix for kilo-, mega-, or giga-

iperf3 homepage at: http://software.es.net/iperf/
Report bugs to:     https://github.com/esnet/iperf
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment