Arcade Simulator: Site Reliability Engineer | GSP161
Solution for Arcade Simulator: Site Reliability Engineer | GSP161. 1 lab: GSP161. Fast copy-paste commands for Google Cloud.
GSP161 — Test Network Latency Between VMs
Estimated time: 15 minutes
# 🚀 Test Network Latency Between VMs | GSP161 > ⚠️ **Disclaimer:** This is an independent, community-made walkthrough created for educational purposes, hands-on practice, and Google Cloud certification preparation. This guide is designed to help learners understand Compute Engine networking, VM placement, and network performance testing. Always attempt the lab yourself first and follow Google Cloud Skills Boost / Qwiklabs Terms of Service. This walkthrough is not affiliated with or endorsed by
clear
# Professional ANSI Color Variables
CYAN='\033[1;36m'
GREEN='\033[1;32m'
YELLOW='\033[1;33m'
BLUE='\033[1;34m'
RESET='\033[0m'
BOLD='\033[1m'
echo -e "${CYAN}${BOLD}"
echo " ____ _ _ _ __ ___ "
echo " / __ \ | | (_) | / _| / _ \ "
echo " | | | |_ __| |__ _| |_ ___ | |_ | | | |_ __ ___ "
echo " | | | | '__| '_ \| | __| / _ \ | _|| | | | '_ \ / __| "
echo " | |__| | | | |_) | | |_ | (_) || | | |_| | |_) \__ \ "
echo " \____/|_| |_.__/|_|\__| \___/ |_| \___/| .__/|___/ "
echo " | | "
echo " |_| "
echo -e "${RESET}"
echo -e "${YELLOW}▶ Detecting existing subnet regions...${RESET}"
REGIONS=$(gcloud compute networks subnets list --network=taw-custom-network --format="value(region)" | awk -F/ '{print $NF}' | sort -u)
REGION_ARRAY=($REGIONS)
# Assign regions found in the VPC to variables
export REGION_1=${REGION_ARRAY[0]}
export REGION_2=${REGION_ARRAY[1]}
export REGION_3=${REGION_ARRAY[2]}
# Fetch the first available zone in each region
export ZONE_1=$(gcloud compute zones list --filter="region:($REGION_1)" --format="value(name)" --limit=1)
export ZONE_2=$(gcloud compute zones list --filter="region:($REGION_2)" --format="value(name)" --limit=1)
export ZONE_3=$(gcloud compute zones list --filter="region:($REGION_3)" --format="value(name)" --limit=1)
echo -e "${BLUE}▶ Creating us-test-01 in ${ZONE_1}...${RESET}"
gcloud compute instances create us-test-01 \
--subnet subnet-$REGION_1 \
--zone $ZONE_1 \
--machine-type e2-standard-2 \
--tags ssh,http,rules
echo -e "${BLUE}▶ Creating us-test-02 in ${ZONE_2}...${RESET}"
gcloud compute instances create us-test-02 \
--subnet subnet-$REGION_2 \
--zone $ZONE_2 \
--machine-type e2-standard-2 \
--tags ssh,http,rules
echo -e "${BLUE}▶ Creating us-test-03 in ${ZONE_3}...${RESET}"
gcloud compute instances create us-test-03 \
--subnet subnet-$REGION_3 \
--zone $ZONE_3 \
--machine-type e2-standard-2 \
--tags ssh,http,rules
echo -e "${BLUE}▶ Creating us-test-04 in ${ZONE_1}...${RESET}"
gcloud compute instances create us-test-04 \
--subnet subnet-$REGION_1 \
--zone $ZONE_1 \
--machine-type e2-standard-2 \
--tags ssh,http
echo -e "${GREEN}✓ All test instances deployed. You may check your first progress objective.${RESET}"CYAN='\033[1;36m'
GREEN='\033[1;32m'
YELLOW='\033[1;33m'
BLUE='\033[1;34m'
RESET='\033[0m'
BOLD='\033[1m'
echo -e "${YELLOW}▶ Generating testing scripts...${RESET}"
cat > prepare_test1.sh <<EOF_END
sudo apt-get update
sudo apt-get -y install traceroute mtr tcpdump iperf whois host dnsutils siege
nohup iperf -s > iperf-server.log 2>&1 &
timeout 10 traceroute -m 8 www.icann.org
EOF_END
cat > prepare_test2.sh <<EOF_END
sudo apt-get update
sudo apt-get -y install traceroute mtr tcpdump iperf whois host dnsutils siege
timeout 10 traceroute -m 8 www.icann.org
iperf -c us-test-01.${ZONE_1}
EOF_END
cat > prepare_test4.sh <<EOF_END
sudo apt-get update
sudo apt-get -y install traceroute mtr tcpdump iperf whois host dnsutils siege
EOF_END
echo -e "${BLUE}▶ Waiting for SSH propagation...${RESET}"
sleep 15
echo -e "${CYAN}▶ Executing setup and server daemon on us-test-01...${RESET}"
gcloud compute scp prepare_test1.sh us-test-01:/tmp --zone=$ZONE_1 --quiet
gcloud compute ssh us-test-01 --zone=$ZONE_1 --quiet --command="bash /tmp/prepare_test1.sh"
echo -e "${CYAN}▶ Executing setup, traceroute, and iperf client on us-test-02...${RESET}"
gcloud compute scp prepare_test2.sh us-test-02:/tmp --zone=$ZONE_2 --quiet
gcloud compute ssh us-test-02 --zone=$ZONE_2 --quiet --command="bash /tmp/prepare_test2.sh"
echo -e "${CYAN}▶ Executing setup on us-test-04...${RESET}"
gcloud compute scp prepare_test4.sh us-test-04:/tmp --zone=$ZONE_1 --quiet
gcloud compute ssh us-test-04 --zone=$ZONE_1 --quiet --command="bash /tmp/prepare_test4.sh"
echo -e "${GREEN}✓ Performance testing sequence complete! You may now check your final progress objectives.${RESET}"