Back to home page

OSCL-LXR

 
 

    


0001 #!/bin/bash
0002 # SPDX-License-Identifier: GPL-2.0
0003 #
0004 # A simple program for generating traffic for the toeplitz test.
0005 #
0006 # This program sends packets periodically for, conservatively, 20 seconds. The
0007 # intent is for the calling program to kill this program once it is no longer
0008 # needed, rather than waiting for the 20 second expiration.
0009 
0010 send_traffic() {
0011         expiration=$((SECONDS+20))
0012         while [[ "${SECONDS}" -lt "${expiration}" ]]
0013         do
0014                 if [[ "${PROTO}" == "-u" ]]; then
0015                         echo "msg $i" | nc "${IPVER}" -u -w 0 "${ADDR}" "${PORT}"
0016                 else
0017                         echo "msg $i" | nc "${IPVER}" -w 0 "${ADDR}" "${PORT}"
0018                 fi
0019                 sleep 0.001
0020         done
0021 }
0022 
0023 PROTO=$1
0024 IPVER=$2
0025 ADDR=$3
0026 PORT=$4
0027 
0028 send_traffic