#! /bin/bash
set -o xtrace

# check pre errors
ethtool -S wall | grep _errors
ssh vision1 "ethtool -S wall | grep _errors"

# determine the remote address
VISION_WALL_IP=$(ssh vision1 "ifconfig wall | grep -oP \"(?<=inet addr:).*(?= Bcast)\"")

# open server
# echo "On main ai, run: iperf3 -s -i 60"
# read -n 1 -p "Hit any key to continue..."

# run traffic
ssh -q vision1 "iperf3 -s -D -i 60"
iperf3 -i 60 -n 625000000000 -c $VISION_WALL_IP
iperf3 -i 60 -n 625000000000 -c $VISION_WALL_IP -R
ssh -q vision1 "pkill -TERM iperf3"

# check post errors
ethtool -S wall | grep _errors
ssh vision1 "ethtool -S wall | grep _errors"
