toeplitz_client.sh 667 B

12345678910111213141516171819202122232425262728
  1. #!/bin/bash
  2. # SPDX-License-Identifier: GPL-2.0
  3. #
  4. # A simple program for generating traffic for the toeplitz test.
  5. #
  6. # This program sends packets periodically for, conservatively, 20 seconds. The
  7. # intent is for the calling program to kill this program once it is no longer
  8. # needed, rather than waiting for the 20 second expiration.
  9. send_traffic() {
  10. expiration=$((SECONDS+20))
  11. while [[ "${SECONDS}" -lt "${expiration}" ]]
  12. do
  13. if [[ "${PROTO}" == "-u" ]]; then
  14. echo "msg $i" | nc "${IPVER}" -u -w 0 "${ADDR}" "${PORT}"
  15. else
  16. echo "msg $i" | nc "${IPVER}" -w 0 "${ADDR}" "${PORT}"
  17. fi
  18. sleep 0.001
  19. done
  20. }
  21. PROTO=$1
  22. IPVER=$2
  23. ADDR=$3
  24. PORT=$4
  25. send_traffic