#! /bin/bash

# check pre errors
echo "EMU ETH1"
ssh root@emu "/proc/boot/bcmutil43 -c 0 switch port mibs 0" | grep "pkt.*Err:\|Consider"
./run_switch_cmd.exp corner-switch-q1 "port show statistics 1"
echo "EMU ETH2"
ssh root@emu "/proc/boot/bcmutil43 -c 0 switch port mibs 1" | grep "pkt.*Err:\|Consider"
./run_switch_cmd.exp corner-switch-q2 "port show statistics 1"
echo "EMU ETH3"
ssh root@emu "/proc/boot/bcmutil43 -c 1 switch port mibs 0" | grep "pkt.*Err:\|Consider"
./run_switch_cmd.exp corner-switch-q3 "port show statistics 1"
echo "EMU ETH4"
ssh root@emu "/proc/boot/bcmutil43 -c 1 switch port mibs 1" | grep "pkt.*Err:\|Consider"
./run_switch_cmd.exp corner-switch-q4 "port show statistics 1"

# run traffic
pushd ~/driving
set -o xtrace
bazel run //experimental/ihartwig/icmptraffic -- 192.168.8.5 -n 6250000 -s 1000 -r 100000 -i 60 # ETH1
bazel run //experimental/ihartwig/icmptraffic -- 192.168.9.5 -n 6250000 -s 1000 -r 100000 -i 60 # ETH2
bazel run //experimental/ihartwig/icmptraffic -- 192.168.10.5 -n 6250000 -s 1000 -r 100000 -i 60 # ETH3
bazel run //experimental/ihartwig/icmptraffic -- 192.168.11.5 -n 6250000 -s 1000 -r 100000 -i 60 # ETH4
set +o xtrace
popd

# check post errors
echo "EMU ETH1"
ssh root@emu "/proc/boot/bcmutil43 -c 0 switch port mibs 0" | grep "pkt.*Err:\|Consider"
./run_switch_cmd.exp corner-switch-q1 "port show statistics 1"
echo "EMU ETH2"
ssh root@emu "/proc/boot/bcmutil43 -c 0 switch port mibs 1" | grep "pkt.*Err:\|Consider"
./run_switch_cmd.exp corner-switch-q2 "port show statistics 1"
echo "EMU ETH3"
ssh root@emu "/proc/boot/bcmutil43 -c 1 switch port mibs 0" | grep "pkt.*Err:\|Consider"
./run_switch_cmd.exp corner-switch-q3 "port show statistics 1"
echo "EMU ETH4"
ssh root@emu "/proc/boot/bcmutil43 -c 1 switch port mibs 1" | grep "pkt.*Err:\|Consider"
./run_switch_cmd.exp corner-switch-q4 "port show statistics 1"
