Commit 33d490be authored by David Hancock's avatar David Hancock

Add vibrant eval directory with local and remote scripts

parent ee462902
#!/bin/bash
macs=( "00:04:00:00:00:01"
"00:04:00:00:00:02"
"00:04:00:00:00:03"
"00:04:00:00:00:04"
"00:04:00:00:00:05"
"00:04:00:00:00:06")
hnames=( "node-5"
"node-6"
"node-7"
"node-8"
"node-9"
"node-10" )
ips=( "10.10.5.1/16"
"10.10.6.1/16"
"10.10.7.1/16"
"10.10.8.1/16"
"10.10.9.1/16"
"10.10.10.1/16" )
hname="$(hostname | tr "." " " | awk '{print $1}')"
for i in `seq 0 5`; do
if [ "$hname" == ${hnames[$i]} ]
then
ip=${ips[$i]}
mac=${macs[$i]}
break
fi
done
while read x
do
ipaddr="$(echo $x | awk '{print $4}')"
if [ "$ipaddr" == "$ip" ]
then
iface="$(echo $x | awk '{print $2}')"
sudo ifconfig $iface down
sudo ifconfig $iface hw ether $mac
sudo ifconfig $iface up
echo "updated MAC for $ipaddr to $mac"
break
fi
done <<< "$(ip -o -4 addr show)"
#!/bin/bash
#
# iface_setup.sh
#
# Setup a set of interfaces to be used with a model
#
# Usage:
# iface_setup iface_1 [ iface_2 ... ]
#
# The script performs the necessary setup on the interfaces to tbe used with
# a switch model. This typical setup includes the following:
# -- No protocols should be setup on the interface. This means not assigning
# any protocol addresses (neither IPv4, nor IPv6) to the interface.
# -- This will prevent the standard Linux stack from forwarding
# packets between these interfaces (especially if you can't globally
# disable IP routing)
# -- In case of IPv6, this will also prevent Linux stack from
# sending ICMPv6 router advertizement messages periodically
# -- Disable all HW acceleration on the interfaces
# -- This is critical, otherwise you will see strange behavior that
# depends on protocols, packet size and timing. For example, in
# case of TCP, HW acceleration might result in the model receiving
# one huge (e.g. 10K bytes long) TCP packet instead of 10 1K packets
# The problem is that the model will not be able to send such a long
# packet out.
#
# Uncomment for debugging
#set -x
MTU=1600
function print_help() {
cat <<EOF
Usage:
sudo iface_setup.sh [-h] [-m mtu] iface_0 [ iface_1 ... ]
Options:
-h, --help Print this message
-m mtu, --mtu mtu Set the specified MTU on all specified interfaces
EOF
}
function help_mtu() {
cat <<EOF
ERROR: Failed to set MTU to $MTU on interface $iface
Different interfaces support different maximum MTU settings.
Find out what's appropriate for interface $iface and use
-m <mtu> parameter when running this script
EOF
}
function help_root() {
cat <<EOF
ERROR: This script is supposed to be run as root, e.g. using sudo
EOF
}
function interface_configure() {
iface=$1; shift
ip link set dev $iface up
if [ $? -ne 0 ]; then
return 1
fi
ip address flush dev $iface
sysctl net.ipv6.conf.$iface.disable_ipv6=1 &> /dev/null
ip link set dev $iface up mtu $MTU
if [ $? -ne 0 ]; then
help_mtu
return 1
fi
TOE_OPTIONS="rx tx sg tso ufo gso gro lro rxvlan txvlan rxhash"
for TOE_OPTION in $TOE_OPTIONS; do
/sbin/ethtool --offload $iface "$TOE_OPTION" off &> /dev/null
done
return 0
}
#
# Main
#
# Parse options
opts=`getopt -o m:h -l help -lmtu: -- "$@"`
if [ $? != 0 ]; then
# Option parsing failed, probably due to unknown options
print_help
exit 1
fi
eval set -- "$opts"
while true; do
case "$1" in
-h|--help) print_help; exit 0;;
-m|--mtu) MTU=$2; shift 2;;
--) shift; break;;
esac
done
if [ $# -lt 1 ]; then
# No interfaces has been specified
print_help
exit 1
fi
# Check that we are running as root
if [ $UID -ne 0 ]; then
help_root
exit 1
fi
for iface in "$@"; do
interface_configure $iface
if [ $? -ne 0 ]; then
exit 1
fi
echo "Interface $iface configured"
done
#!/bin/bash
controllerpid="$(pgrep -f "hp4controller.controller")"
if [ -n "$controllerpid" ]
then
sudo kill -SIGINT $controllerpid
else
echo "could not find pid"
fi
#!/bin/bash
hp4pid="$(pgrep -f "/simple_switch/simple_switch")"
if [ -n "$hp4pid" ]
then
sudo kill $hp4pid
else
echo "could not find pid"
fi
#!/bin/bash
cd /opt/hp4-src/hp4
./run_cli.sh 9090 < hp4commands.txt
#!/bin/bash
iface1=""
iface2=""
iface3=""
iface4=""
#command="sudo /opt/bmv2/targets/simple_switch/simple_switch "
while read x
do
ipaddr="$(echo $x | awk '{print $4}')"
if [ "$ipaddr" == "10.10.1.2/16" ]
then
iface1="$(echo $x | awk '{print $2}')"
elif [ "$ipaddr" == "10.10.2.2/16" ]
then
iface2="$(echo $x | awk '{print $2}')"
elif [ "$ipaddr" == "10.10.3.2/16" ]
then
iface3="$(echo $x | awk '{print $2}')"
elif [ "$ipaddr" == "10.10.4.2/16" ]
then
iface4="$(echo $x | awk '{print $2}')"
fi
done <<< "$(ip -o -4 addr show)"
if [ -n "$iface1" ]
then
sudo echo $iface1 > iface1
fi
if [ -n "$iface2" ]
then
sudo echo $iface2 > iface2
fi
if [ -n "$iface3" ]
then
sudo echo $iface3 > iface3
fi
if [ -n "$iface4" ]
then
sudo echo $iface4 > iface4
fi
#!/bin/bash
iface0=""
iface1=""
iface2=""
#command="sudo /opt/bmv2/targets/simple_switch/simple_switch "
while read x
do
ipaddr="$(echo $x | awk '{print $4}')"
if [ "$ipaddr" == "10.10.1.1/16" ]
then
iface0="$(echo $x | awk '{print $2}')"
elif [ "$ipaddr" == "10.10.5.2/16" ]
then
iface1="$(echo $x | awk '{print $2}')"
elif [ "$ipaddr" == "10.10.6.2/16" ]
then
iface2="$(echo $x | awk '{print $2}')"
fi
done <<< "$(ip -o -4 addr show)"
if [ -n "$iface0" ]
then
sudo echo $iface0 > iface0
fi
if [ -n "$iface1" ]
then
sudo echo $iface1 > iface1
fi
if [ -n "$iface2" ]
then
sudo echo $iface2 > iface2
fi
#!/bin/bash
iface0=""
iface1=""
iface2=""
#command="sudo /opt/bmv2/targets/simple_switch/simple_switch "
while read x
do
ipaddr="$(echo $x | awk '{print $4}')"
if [ "$ipaddr" == "10.10.2.1/16" ]
then
iface0="$(echo $x | awk '{print $2}')"
elif [ "$ipaddr" == "10.10.7.2/16" ]
then
iface1="$(echo $x | awk '{print $2}')"
elif [ "$ipaddr" == "10.10.8.2/16" ]
then
iface2="$(echo $x | awk '{print $2}')"
fi
done <<< "$(ip -o -4 addr show)"
if [ -n "$iface0" ]
then
sudo echo $iface0 > iface0
fi
if [ -n "$iface1" ]
then
sudo echo $iface1 > iface1
fi
if [ -n "$iface2" ]
then
sudo echo $iface2 > iface2
fi
#!/bin/bash
iface0=""
iface1=""
#command="sudo /opt/bmv2/targets/simple_switch/simple_switch "
while read x
do
ipaddr="$(echo $x | awk '{print $4}')"
if [ "$ipaddr" == "10.10.3.1/16" ]
then
iface0="$(echo $x | awk '{print $2}')"
elif [ "$ipaddr" == "10.10.9.2/16" ]
then
iface1="$(echo $x | awk '{print $2}')"
fi
done <<< "$(ip -o -4 addr show)"
if [ -n "$iface0" ]
then
sudo echo $iface0 > iface0
fi
if [ -n "$iface1" ]
then
sudo echo $iface1 > iface1
fi
#!/bin/bash
iface0=""
iface1=""
#command="sudo /opt/bmv2/targets/simple_switch/simple_switch "
while read x
do
ipaddr="$(echo $x | awk '{print $4}')"
if [ "$ipaddr" == "10.10.4.1/16" ]
then
iface0="$(echo $x | awk '{print $2}')"
elif [ "$ipaddr" == "10.10.10.2/16" ]
then
iface1="$(echo $x | awk '{print $2}')"
fi
done <<< "$(ip -o -4 addr show)"
if [ -n "$iface0" ]
then
sudo echo $iface0 > iface0
fi
if [ -n "$iface1" ]
then
sudo echo $iface1 > iface1
fi
#!/bin/bash
cd /opt
hname="$(hostname | tr "." " " | awk '{print $1}')"
if [ "$hname" == "node-0" ] ||
[ "$hname" == "node-1" ] ||
[ "$hname" == "node-2" ] ||
[ "$hname" == "node-3" ] ||
[ "$hname" == "node-4" ]
then
./start_hp4.sh
elif [ "$hname" == "node-5" ] ||
[ "$hname" == "node-6" ] ||
[ "$hname" == "node-7" ] ||
[ "$hname" == "node-8" ] ||
[ "$hname" == "node-9" ] ||
[ "$hname" == "node-10" ]
then
./h_config.sh
fi
#!/bin/bash
cd /opt
# get and configure interfaces
hname="$(hostname | tr "." " " | awk '{print $1}')"
if [ "$hname" == "node-0" ]
then
sudo ./s0_get_ifaces.sh
elif [ "$hname" == "node-1" ]
then
sudo ./s1_get_ifaces.sh
elif [ "$hname" == "node-2" ]
then
sudo ./s2_get_ifaces.sh
elif [ "$hname" == "node-3" ]
then
sudo ./s3_get_ifaces.sh
elif [ "$hname" == "node-4" ]
then
sudo ./s4_get_ifaces.sh
fi
# start simple switch with hp4
ifacescommand=( sudo ./iface_setup.sh )
hp4command=( sudo nohup /opt/bmv2/targets/simple_switch/simple_switch )
ifaces=(iface0 iface1 iface2 iface3 iface4)
for i in `seq 0 4`; do
if [ -s ${ifaces[$i]} ]
then
ifacescommand+=( "$(cat ${ifaces[$i]})" )
hp4command+=( -i "$i@$(cat ${ifaces[$i]})" )
fi
done
echo "${ifacescommand[@]}"
"${ifacescommand[@]}"
hp4command+=( /opt/hp4-src/hp4/hp4.json )
echo "${hp4command[@]}"
"${hp4command[@]}" 2> /dev/null &
sleep 5
sudo sh -c 'nohup ./prep_hp4.sh > prep_hp4.out 2> /dev/null &'
# Tools
The tools in this directory support hp4 controller execution and analysis:
* gnome_profiles/: Profiles for gnome terminals to visually distinguish windows performing different roles in test runs. **Warning: before executing the next step, you may want to rename the folders so that they do not overwrite the folders that already exist in your ~/.gconf/apps/gnome-terminal/profiles/ directory.** Copy each directory to ~/.gconf/apps/gnome-terminal/profiles/.
* term\_multi.sh: open seven terminals, each at a different screen location, and five of which use a specific gnome terminal profile.
* terminals\_to\_front.sh: bring all gnome terminal windows to foreground
* terminals\_close.sh: close all gnome terminal windows
Recommendation: map the shell scripts to custom keyboard shortcuts.
#!/bin/bash
cd /home/ubuntu/hp4-src/hp4
gnome-terminal --window-with-profile=mininet --geometry=80x20+0+0 --command="bash -c \"tty > /tmp/pts_mininet; exec bash\"" &
sleep 0.2
cd /home/ubuntu/hp4-ctrl
gnome-terminal --window-with-profile=controller --geometry=90x30+800+0 --command="bash -c \"tty > /tmp/pts_controller; exec bash\"" &
sleep 0.2
gnome-terminal --window-with-profile=admin --geometry=80x20+0+415 --command="bash -c \"tty > /tmp/pts_admin; exec bash\"" &
sleep 0.2
cd /home/ubuntu/hp4-src/hp4
gnome-terminal --window-with-profile=bmv2_CLI --geometry=80x20+0+805 --command="bash -c \"tty > /tmp/pts_bmv2_cli; exec bash\"" &
sleep 0.2
cd /home/ubuntu/hp4-ctrl
gnome-terminal --geometry=90x30+800+600 --command="bash -c \"tty > /tmp/pts_slice_manager; exec bash\"" &
sleep 0.2
cd /home/ubuntu/hp4-ctrl/tests
gnome-terminal --window-with-profile=tests --geometry=80x20+1200+400 &
sleep 0.2
cd /home/ubuntu/hp4-ctrl
gnome-terminal --geometry=90x30+1000+800 --command="bash -c \"tty > /tmp/pts_slice_manager_saturn; exec bash\"" &
#!/bin/bash
pids=" $(pidof gnome-terminal) "
if [ "$pids" = " " ]; then
echo "There is no program named '$0' opened at the moment."
exit 1
fi
wmctrl -lp | while read identity desktop_number PID window_title; do
if [ "${pids/ $PID }" != "$pids" ]; then
wmctrl -ic $identity
fi
done
#!/bin/bash
pids=" $(pidof gnome-terminal) "
if [ "$pids" = " " ]; then
echo "There is no program named '$0' opened at the moment."
exit 1
fi
wmctrl -lp | while read identity desktop_number PID window_title; do
if [ "${pids/ $PID }" != "$pids" ]; then
wmctrl -ia $identity
fi
done
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment