# lab11 iperf3 옵션 모음

# ─── 서버 ────────────────────────────────────────────────────
iperf3 -s                              # 5201 리스닝
iperf3 -s -p 5202                      # 포트 변경
iperf3 -s -D                           # 데몬 모드
iperf3 -s -B 10.20.0.10                # 특정 IP 만 바인드
iperf3 -s -J                           # JSON 출력

# ─── 클라이언트 기본 ─────────────────────────────────────────
iperf3 -c SERVER                       # 10초 TCP 기본
iperf3 -c SERVER -t 30                 # 30초
iperf3 -c SERVER -t 60 -i 5            # 60초, 5초마다 리포트
iperf3 -c SERVER -p 5202               # 포트 지정

# ─── 병렬 / 양방향 / 역방향 ──────────────────────────────────
iperf3 -c SERVER -P 4                  # 4 병렬 스트림
iperf3 -c SERVER -R                    # Reverse (다운로드 측정)
iperf3 -c SERVER --bidir               # 동시 양방향

# ─── UDP ────────────────────────────────────────────────────
iperf3 -c SERVER -u -b 100M            # UDP 100 Mbps
iperf3 -c SERVER -u -b 1G              # UDP 1 Gbps (회선 한계 측정)
iperf3 -c SERVER -u -b 0               # UDP 무제한 (보낼 수 있는 만큼)

# ─── 윈도우 / MSS / DSCP / Cubic ─────────────────────────────
iperf3 -c SERVER -w 1M                 # TCP 윈도우 사이즈
iperf3 -c SERVER -M 1400               # MSS
iperf3 -c SERVER -S 0x10               # DSCP (low delay)
iperf3 -c SERVER --congestion bbr      # BBR 사용
iperf3 -c SERVER --congestion cubic    # Cubic (기본)

# ─── 출력 / 후처리 ───────────────────────────────────────────
iperf3 -c SERVER --json > out.json
iperf3 -c SERVER --logfile /var/log/iperf.log

# ─── jq 후처리 1-liner ───────────────────────────────────────
# TCP 처리량 (Mbps)
jq '.end.sum_received.bits_per_second / 1e6' out.json

# 재전송 횟수
jq '.end.sum_received.retransmits' out.json

# UDP 손실율
jq '.end.sum.lost_percent' out.json

# UDP 지터 (ms)
jq '.end.sum.jitter_ms' out.json

# ─── 운영 모니터 (cron) ──────────────────────────────────────
# 매시간 5초 측정 + 처리량 로깅
# 0 * * * *  iperf3 -c SERVER -t 5 --json | jq '.end.sum_received.bits_per_second' >> /var/log/iperf_mbps.log
