29 lines · bash
1#!/bin/bash2# SPDX-License-Identifier: GPL-2.03#4# A simple program for generating traffic for the toeplitz test.5#6# This program sends packets periodically for, conservatively, 20 seconds. The7# intent is for the calling program to kill this program once it is no longer8# needed, rather than waiting for the 20 second expiration.9 10send_traffic() {11 expiration=$((SECONDS+20))12 while [[ "${SECONDS}" -lt "${expiration}" ]]13 do14 if [[ "${PROTO}" == "-u" ]]; then15 echo "msg $i" | nc "${IPVER}" -u -w 0 "${ADDR}" "${PORT}"16 else17 echo "msg $i" | nc "${IPVER}" -w 0 "${ADDR}" "${PORT}"18 fi19 sleep 0.00120 done21}22 23PROTO=$124IPVER=$225ADDR=$326PORT=$427 28send_traffic29