#! /bin/bash

# check pre errors
echo "Lidar 1"
./run_switch_cmd.exp corner-switch-q3 "port show statistics 14"
echo "Lidar 2"
./run_switch_cmd.exp corner-switch-q4 "port show statistics 15"
echo "Lidar 3 / PTPG 3"
./run_switch_cmd.exp corner-switch-q3 "port show statistics 15"
echo "Lidar 4 / PTPG 4"
./run_switch_cmd.exp corner-switch-q4 "port show statistics 16"
echo "Lidar 5"
./run_switch_cmd.exp corner-switch-q1 "port show statistics 14"
echo "Lidar 6"
./run_switch_cmd.exp corner-switch-q2 "port show statistics 14"
echo "Lidar 7 / PTPG 7"
./run_switch_cmd.exp corner-switch-q1 "port show statistics 15"
echo "Lidar 8 / PTPG 8"
./run_switch_cmd.exp corner-switch-q2 "port show statistics 15"

# run traffic
pushd ~/driving
set -o xtrace
bazel run //experimental/ihartwig/icmptraffic -- 192.168.10.20 -n 6250000 -s 1000 -r 100000 -i 60 # Lidar 1
bazel run //experimental/ihartwig/icmptraffic -- 192.168.11.20 -n 6250000 -s 1000 -r 100000 -i 60 # Lidar 2
bazel run //experimental/ihartwig/icmptraffic -- 192.168.10.21 -n 6250000 -s 1000 -r 3000 -i 60 # Lidar 3
bazel run //experimental/ihartwig/icmptraffic -- 192.168.11.21 -n 6250000 -s 1000 -r 3000 -i 60 # Lidar 4
bazel run //experimental/ihartwig/icmptraffic -- 192.168.8.20 -n 6250000 -s 1000 -r 100000 -i 60 # Lidar 5
bazel run //experimental/ihartwig/icmptraffic -- 192.168.9.20 -n 6250000 -s 1000 -r 100000 -i 60 # Lidar 6
bazel run //experimental/ihartwig/icmptraffic -- 192.168.8.21 -n 6250000 -s 1000 -r 3000 -i 60 # Lidar 7
bazel run //experimental/ihartwig/icmptraffic -- 192.168.9.21 -n 6250000 -s 1000 -r 3000 -i 60 # Lidar 8
set +o xtrace
popd

# check post errors
echo "Lidar 1"
./run_switch_cmd.exp corner-switch-q3 "port show statistics 14"
echo "Lidar 2"
./run_switch_cmd.exp corner-switch-q4 "port show statistics 15"
echo "Lidar 3 / PTPG 3"
./run_switch_cmd.exp corner-switch-q3 "port show statistics 15"
echo "Lidar 4 / PTPG 4"
./run_switch_cmd.exp corner-switch-q4 "port show statistics 16"
echo "Lidar 5"
./run_switch_cmd.exp corner-switch-q1 "port show statistics 14"
echo "Lidar 6"
./run_switch_cmd.exp corner-switch-q2 "port show statistics 14"
echo "Lidar 7 / PTPG 7"
./run_switch_cmd.exp corner-switch-q1 "port show statistics 15"
echo "Lidar 8 / PTPG 8"
./run_switch_cmd.exp corner-switch-q2 "port show statistics 15"
