aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorKeith Burns (alagalah) <alagalah@gmail.com>2016-08-07 09:51:05 -0700
committerKeith Burns (alagalah) <alagalah@gmail.com>2016-08-07 09:51:05 -0700
commitbee3dc863f8f2f23b4a35cd0838ba677451b45d7 (patch)
tree7d152917001ffdfed1f57d51a8785223f4604eae
parentf560a490cddc6cd7f97f0693ad5a98f424695422 (diff)
Adding subproject: vpp-userdemo
Change-Id: I79eb30c7a4130d1cf12277a68bb417b5778e9f9c Signed-off-by: Keith Burns (alagalah) <alagalah@gmail.com>
-rw-r--r--vpp-userdemo/.gitignore4
-rw-r--r--vpp-userdemo/README.md58
-rw-r--r--vpp-userdemo/Vagrantfile51
-rw-r--r--vpp-userdemo/bridging60
-rwxr-xr-xvpp-userdemo/clearinterfaces.sh31
-rwxr-xr-xvpp-userdemo/env.sh19
-rwxr-xr-xvpp-userdemo/install.sh26
-rwxr-xr-xvpp-userdemo/netns.sh62
-rw-r--r--vpp-userdemo/routing58
-rwxr-xr-xvpp-userdemo/run16
-rw-r--r--vpp-userdemo/tracing46
-rwxr-xr-xvpp-userdemo/update.sh59
-rwxr-xr-xvpp-userdemo/vmrun77
13 files changed, 567 insertions, 0 deletions
diff --git a/vpp-userdemo/.gitignore b/vpp-userdemo/.gitignore
new file mode 100644
index 0000000..172ba81
--- /dev/null
+++ b/vpp-userdemo/.gitignore
@@ -0,0 +1,4 @@
+.vagrant/
+*~
+*#
+*.cmd
diff --git a/vpp-userdemo/README.md b/vpp-userdemo/README.md
new file mode 100644
index 0000000..2ece28d
--- /dev/null
+++ b/vpp-userdemo/README.md
@@ -0,0 +1,58 @@
+/*
+ *
+ * Copyright (c) 2016 Cisco and/or its affiliates.
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at:
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+# INTRO:
+
+This is a Vagrant based user demo environment for beginners with VPP
+
+It walks a user through
+- each of the commands,
+- the expected output,
+- gives a file of the commands used to try themselves
+
+# REQUIREMENTS
+- vagrant (1.8)
+- virtualbox / vmware fusion
+
+# GETTING STARTED
+- clone the repo
+- modify env.sh if needed and ```source ./env.sh```
+- by default the VM uses 2 x CPUs and 4G RAM
+- ```vagrant up```
+- ... run the demo
+
+# RUNNING DEMOs
+- From the Host, where you ran ```vagrant up``` run ```./run <demoname>```
+
+```./run <demoname>```
+
+# DEMOs
+
+## routing - directly connected routing
+- Creates two network namespaces c1, c2
+- A gateway interface for each on VPP
+- Routes due to directly connected routes inserted into default FIB
+
+## bridging - directly connected interfaces into a bridge-domain
+- Creates two network namespaces c1, c2
+- Adds interfaces to VPP and add them to bridge-domain 1
+- MAC addresses are automatically learned
+
+## tracing - how to show a "day in the life of a packet" in VPP
+- Same environment as "routing" demo
+- How to add a trace
+- View a trace
+- Interpret a trace
+
diff --git a/vpp-userdemo/Vagrantfile b/vpp-userdemo/Vagrantfile
new file mode 100644
index 0000000..32560ef
--- /dev/null
+++ b/vpp-userdemo/Vagrantfile
@@ -0,0 +1,51 @@
+# -*- mode: ruby -*-
+# vi: set ft=ruby :
+
+Vagrant.configure(2) do |config|
+
+ # Pick the right distro and bootstrap, default is ubuntu1404
+ config.vm.box = "puppetlabs/ubuntu-14.04-64-nocm"
+ vmcpu=(ENV['VPP_VAGRANT_VMCPU'] || 2)
+ vmram=(ENV['VPP_VAGRANT_VMRAM'] || 4096)
+
+ # Define some physical ports for your VMs to be used by DPDK
+ config.vm.network "private_network", type: "dhcp"
+
+ config.vm.provision :shell, :path => File.join(File.dirname(__FILE__),"install.sh")
+ config.vm.provision :shell, :path => File.join(File.dirname(__FILE__),"clearinterfaces.sh")
+
+
+ # vagrant-cachier caches apt/yum etc to speed subsequent
+ # vagrant up
+ # to enable, run
+ # vagrant plugin install vagrant-cachier
+ #
+ if Vagrant.has_plugin?("vagrant-cachier")
+ config.cache.scope = :box
+ end
+
+ # use http proxy if avaiable
+ if ENV['http_proxy'] && Vagrant.has_plugin?("vagrant-proxyconf")
+ config.proxy.http = ENV['http_proxy']
+ config.proxy.https = ENV['https_proxy']
+ config.proxy.no_proxy = "localhost,127.0.0.1"
+ end
+
+ config.vm.provider "virtualbox" do |vb|
+ vb.customize ["modifyvm", :id, "--ioapic", "on"]
+ vb.memory = "#{vmram}"
+ vb.cpus = "#{vmcpu}"
+ end
+ config.vm.provider "vmware_fusion" do |fusion,override|
+ fusion.vmx["memsize"] = "#{vmram}"
+ fusion.vmx["numvcpus"] = "#{vmcpu}"
+ end
+ config.vm.provider "libvirt" do |lv|
+ lv.memory = "#{vmram}"
+ lv.cpus = "#{vmcpu}"
+ end
+ config.vm.provider "vmware_workstation" do |vws,override|
+ vws.vmx["memsize"] = "#{vmram}"
+ vws.vmx["numvcpus"] = "#{vmcpu}"
+ end
+end
diff --git a/vpp-userdemo/bridging b/vpp-userdemo/bridging
new file mode 100644
index 0000000..80f29ed
--- /dev/null
+++ b/vpp-userdemo/bridging
@@ -0,0 +1,60 @@
+#!/usr/bin/env bash
+/*
+ *
+ * Copyright (c) 2016 Cisco and/or its affiliates.
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at:
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+C1_IP="172.16.1.2/24"
+C1_GW="172.16.1.1"
+C2_IP="172.16.1.3/24"
+C2_GW="172.16.1.1"
+
+INSTR=()
+CMD=()
+INSTR+=("Welcome to the bridging demo. This will show you some simple commands to connect two
+linux netnamespaces to VPP via an L2 bridge.")
+CMD+=("")
+
+INSTR+=("To show interfaces type:")
+CMD+=("sudo vppctl show inter")
+
+INSTR+=("Lets examine our workloads c1 and c2")
+CMD+=("sudo ip netns exec c1 ip -o a")
+
+INSTR+=("")
+CMD+=("sudo ip netns exec c2 ip -o a")
+
+INSTR+=("To add interfaces, we add the host-side of the veth link pair.")
+CMD+=("ip link")
+
+INSTR+=("The links we need to add are link1 and link2 so lets add them with")
+CMD+=("sudo vppctl create host-interface name link1; sudo vppctl create host-interface name link2; sudo vppctl show inter")
+
+INSTR+=("Change the links state to up")
+CMD+=("sudo vppctl set interface state host-link1 up; sudo vppctl set interface state host-link2 up; sudo vppctl show inter")
+
+INSTR+=("Add IP addresses for the other end of each veth link")
+CMD+=("sudo vppctl set interface l2 bridge host-link1 1; sudo vppctl set interface l2 bridge host-link2 1")
+
+INSTR+=("You can also see the bridge-domain")
+CMD+=("sudo vppctl show bridge-domain 1 detail")
+
+INSTR+=("At long last you probably want to see some pings")
+CMD+=("sudo ip netns exec c1 ping -c3 172.16.1.3")
+
+INSTR+=("")
+CMD+=("sudo ip netns exec c2 ping -c3 172.16.1.2")
+
+INSTR+=("Thanks for doing the bridging demo. To restart this demo and type these commands yourself \nvagrant ssh \nsudo /vagrant/netns.sh \ncat /vagrant/bridging.cmd")
+CMD+=("")
diff --git a/vpp-userdemo/clearinterfaces.sh b/vpp-userdemo/clearinterfaces.sh
new file mode 100755
index 0000000..012c8c3
--- /dev/null
+++ b/vpp-userdemo/clearinterfaces.sh
@@ -0,0 +1,31 @@
+#!/usr/bin/env bash
+
+# Copyright (c) 2016 Cisco and/or its affiliates.
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at:
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+
+
+# Capture all the interface IPs, in case we need them later
+ip -o addr show > ~vagrant/ifconfiga
+chown vagrant:vagrant ~vagrant/ifconfiga
+
+# Disable all ethernet interfaces other than the default route
+# interface so VPP will use those interfaces. The VPP auto-blacklist
+# algorithm prevents the use of any physical interface contained in the
+# routing table (i.e. "route --inet --inet6") preventing the theft of
+# the management ethernet interface by VPP from the kernel.
+for intf in $(ls /sys/class/net) ; do
+ if [ -d /sys/class/net/$intf/device ] &&
+ [ "$(route --inet --inet6 | grep default | grep $intf)" == "" ] ; then
+ ifconfig $intf down
+ fi
+done
diff --git a/vpp-userdemo/env.sh b/vpp-userdemo/env.sh
new file mode 100755
index 0000000..cd212e9
--- /dev/null
+++ b/vpp-userdemo/env.sh
@@ -0,0 +1,19 @@
+#!/usr/bin/env bash
+
+# Copyright (c) 2016 Cisco and/or its affiliates.
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at:
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+
+export VPP_VAGRANT_DISTRO="ubuntu1404"
+export VPP_VAGRANT_NICS=2
+export VPP_VAGRANT_VMCPU=4
+export VPP_VAGRANT_VMRAM=4096
diff --git a/vpp-userdemo/install.sh b/vpp-userdemo/install.sh
new file mode 100755
index 0000000..f9b1422
--- /dev/null
+++ b/vpp-userdemo/install.sh
@@ -0,0 +1,26 @@
+#!/usr/bin/env bash
+
+# Copyright (c) 2016 Cisco and/or its affiliates.
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at:
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+
+sysctl -w vm.nr_hugepages=1024
+HUGEPAGES=`sysctl -n vm.nr_hugepages`
+if [ $HUGEPAGES != 1024 ]; then
+ echo "ERROR: Unable to get 1024 hugepages, only got $HUGEPAGES. Cannot finish."
+ exit
+fi
+
+echo "deb https://nexus.fd.io/content/repositories/fd.io.master.ubuntu.trusty.main/ ./" | sudo tee -a /etc/apt/sources.list.d/99fd.io.list
+apt-get -qq update
+apt-get -qq install -y --force-yes vpp vpp-dpdk-dkms bridge-utils
+service vpp start
diff --git a/vpp-userdemo/netns.sh b/vpp-userdemo/netns.sh
new file mode 100755
index 0000000..05a6605
--- /dev/null
+++ b/vpp-userdemo/netns.sh
@@ -0,0 +1,62 @@
+#!/usr/bin/env bash
+
+# Copyright (c) 2016 Cisco and/or its affiliates.
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at:
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+
+if [ $USER != "root" ] ; then
+ #echo "Restarting script with sudo..."
+ sudo $0 ${*}
+ exit
+fi
+
+C1_IP=$1
+C1_GW=$2
+C2_IP=$3
+C2_GW=$4
+
+# Restart VPP so there is no config
+service vpp restart
+
+# delete previous incarnations if they exist
+ip link del dev veth_link1 &>/dev/null
+ip link del dev veth_link2 &>/dev/null
+ip netns del c1 &>/dev/null
+ip netns del c2 &>/dev/null
+
+#create namespaces
+ip netns add c1 &>/dev/null
+ip netns add c2 &>/dev/null
+
+# create and configure 1st veth pair
+ip link add name veth_link1 type veth peer name link1
+ip link set dev link1 up
+ip link set dev veth_link1 up netns c1
+
+ip netns exec c1 \
+ bash -c "
+ ip link set dev lo up
+ ip addr add ${C1_IP} dev veth_link1
+ ip route add default via ${C1_GW} dev veth_link1
+"
+
+# create and configure 2nd veth pair
+ip link add name veth_link2 type veth peer name link2
+ip link set dev link2 up
+ip link set dev veth_link2 up netns c2
+
+ip netns exec c2 \
+ bash -c "
+ ip link set dev lo up
+ ip addr add ${C2_IP} dev veth_link2
+ ip route add default via ${C2_GW} dev veth_link2
+"
diff --git a/vpp-userdemo/routing b/vpp-userdemo/routing
new file mode 100644
index 0000000..02e3f91
--- /dev/null
+++ b/vpp-userdemo/routing
@@ -0,0 +1,58 @@
+#!/usr/bin/env bash
+
+# Copyright (c) 2016 Cisco and/or its affiliates.
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at:
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+
+C1_IP="172.16.1.2/24"
+C1_GW="172.16.1.1"
+C2_IP="172.16.2.2/24"
+C2_GW="172.16.2.1"
+
+INSTR=()
+CMD=()
+INSTR+=("Welcome to the routing demo. This will show you some simple commands to connect two
+linux netnamespaces to VPP and ping between them.")
+CMD+=("")
+
+INSTR+=("To show interfaces type:")
+CMD+=("sudo vppctl show inter")
+
+INSTR+=("Lets examine our workloads c1 and c2")
+CMD+=("sudo ip netns exec c1 ip -o a")
+
+INSTR+=("")
+CMD+=("sudo ip netns exec c2 ip -o a")
+
+INSTR+=("To add interfaces, we add the host-side of the veth link pair.")
+CMD+=("ip link")
+
+INSTR+=("The links we need to add are link1 and link2 so lets add them with")
+CMD+=("sudo vppctl create host-interface name link1; sudo vppctl create host-interface name link2; sudo vppctl show inter")
+
+INSTR+=("Change the links state to up")
+CMD+=("sudo vppctl set interface state host-link1 up; sudo vppctl set interface state host-link2 up; sudo vppctl show inter")
+
+INSTR+=("Add IP addresses for the other end of each veth link")
+CMD+=("sudo vppctl set interface ip address host-link1 172.16.1.1/24; sudo vppctl set interface ip address host-link2 172.16.2.1/24; sudo vppctl show interface address")
+
+INSTR+=("You can also see the L3 table, or FIB by doing")
+CMD+=("sudo vppctl show ip fib")
+
+INSTR+=("At long last you probably want to see some pings")
+CMD+=("sudo ip netns exec c1 ping -c3 172.16.2.2")
+
+INSTR+=("")
+CMD+=("sudo ip netns exec c2 ping -c3 172.16.1.2")
+
+INSTR+=("Thanks for doing the routing demo. To restart this demo and type these commands yourself \nvagrant ssh \nsudo /vagrant/netns.sh \ncat /vagrant/routing.cmd")
+CMD+=("")
diff --git a/vpp-userdemo/run b/vpp-userdemo/run
new file mode 100755
index 0000000..b3582de
--- /dev/null
+++ b/vpp-userdemo/run
@@ -0,0 +1,16 @@
+#!/usr/bin/env bash
+
+# Copyright (c) 2016 Cisco and/or its affiliates.
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at:
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+
+vagrant ssh -c "/vagrant/vmrun /vagrant/${1}"
diff --git a/vpp-userdemo/tracing b/vpp-userdemo/tracing
new file mode 100644
index 0000000..11b189a
--- /dev/null
+++ b/vpp-userdemo/tracing
@@ -0,0 +1,46 @@
+#!/usr/bin/env bash
+
+# Copyright (c) 2016 Cisco and/or its affiliates.
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at:
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+
+C1_IP="172.16.1.2/24"
+C1_GW="172.16.1.1"
+C2_IP="172.16.2.2/24"
+C2_GW="172.16.2.1"
+
+INSTR=()
+CMD=()
+INSTR+=("Welcome to the tracing demo. This will show you some simple commands to connect two
+linux netnamespaces to VPP and show packet tracing.")
+CMD+=("")
+
+INSTR+=("The links we need to add are link1 and link2 so lets add them with")
+CMD+=("sudo vppctl create host-interface name link1; sudo vppctl create host-interface name link2; sudo vppctl set interface state host-link1 up; sudo vppctl set interface state host-link2 up; sudo vppctl show inter")
+
+INSTR+=("Add IP addresses for the other end of each veth link")
+CMD+=("sudo vppctl set interface ip address host-link1 172.16.1.1/24; sudo vppctl set interface ip address host-link2 172.16.2.1/24; sudo vppctl show interface address")
+
+INSTR+=("Lets add the trace command for the graph-node our type of interface af-packet...")
+CMD+=("sudo vppctl trace add af-packet-input 50")
+
+INSTR+=("At long last you probably want to see some pings")
+CMD+=("sudo ip netns exec c1 ping -c3 172.16.2.2")
+
+INSTR+=("")
+CMD+=("sudo ip netns exec c2 ping -c3 172.16.1.2")
+
+INSTR+=("Viewing the trace:")
+CMD+=("sudo vppctl show trace")
+
+INSTR+=("Thanks for doing the tracing demo. To restart this demo and type these commands yourself \nvagrant ssh \nsudo /vagrant/netns.sh \ncat /vagrant/tracing.cmd")
+CMD+=("")
diff --git a/vpp-userdemo/update.sh b/vpp-userdemo/update.sh
new file mode 100755
index 0000000..9483014
--- /dev/null
+++ b/vpp-userdemo/update.sh
@@ -0,0 +1,59 @@
+#!/bin/bash
+# Copyright (c) 2016 Cisco and/or its affiliates.
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at:
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+
+# Make sure that we get the hugepages we need on provision boot
+# Note: The package install should take care of this at the end
+# But sometimes after all the work of provisioning, we can't
+# get the requested number of hugepages without rebooting.
+# So do it here just in case
+sysctl -w vm.nr_hugepages=1024
+HUGEPAGES=`sysctl -n vm.nr_hugepages`
+if [ $HUGEPAGES != 1024 ]; then
+ echo "ERROR: Unable to get 1024 hugepages, only got $HUGEPAGES. Cannot finish."
+ exit
+fi
+
+exit 0
+
+# Figure out what system we are running on
+if [ -f /etc/lsb-release ];then
+ . /etc/lsb-release
+elif [ -f /etc/redhat-release ];then
+ yum install -y redhat-lsb
+ DISTRIB_ID=`lsb_release -si`
+ DISTRIB_RELEASE=`lsb_release -sr`
+ DISTRIB_CODENAME=`lsb_release -sc`
+ DISTRIB_DESCRIPTION=`lsb_release -sd`
+fi
+
+# Do initial setup for the system
+if [ $DISTRIB_ID == "Ubuntu" ]; then
+ # Fix grub-pc on Virtualbox with Ubuntu
+ export DEBIAN_FRONTEND=noninteractive
+
+ # Standard update + upgrade dance
+ apt-get update
+ apt-get upgrade -y
+
+ # Fix the silly notion that /bin/sh should point to dash by pointing it to bash
+
+ update-alternatives --install /bin/sh sh /bin/bash 100
+
+ # Install useful but non-mandatory tools
+ apt-get install -y emacs git-review gdb gdbserver brctl
+elif [ $DISTRIB_ID == "CentOS" ]; then
+ # Standard update + upgrade dance
+ yum check-update
+ yum update -y
+fi
diff --git a/vpp-userdemo/vmrun b/vpp-userdemo/vmrun
new file mode 100755
index 0000000..25c674e
--- /dev/null
+++ b/vpp-userdemo/vmrun
@@ -0,0 +1,77 @@
+#!/usr/bin/env bash
+# Copyright (c) 2016 Cisco and/or its affiliates.
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at:
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+
+if [ $USER != "root" ] ; then
+ #echo "Restarting script with sudo..."
+ sudo $0 ${*}
+ exit
+fi
+
+if [ -z "$1" ]; then
+ echo "You must specify a demo name"
+ exit 0;
+fi
+
+if [ -f "$1" ]; then
+ DEMO=$1
+else
+ echo "This is not a valid filename"
+ exit 0;
+fi
+
+source $DEMO
+
+RED='\033[0;31m'
+GREEN='\033[0;32m'
+NC='\033[0m'
+
+function pause {
+ echo ""; echo ""
+ read -n1 -r -p "Press space to continue..." key
+ printf "\033c"
+}
+
+function instruction {
+
+ eval INSTR="$1"
+ eval CMD="$2"
+ echo ""
+ echo -e "${RED}********************************************************************************${NC} \n"
+ echo -e "${RED} ${INSTR} ${NC}"
+ echo -e "${GREEN} ${CMD} ${NC} \n"
+ echo -e "${RED}********************************************************************************${NC} \n"
+}
+
+#Clear and set netns and veths
+/vagrant/netns.sh $C1_IP $C1_GW $C2_IP $C2_GW
+
+#Clear the screen
+printf "\033c"
+
+if [ -e $DEMO.cmd ]; then
+ rm $DEMO.cmd
+fi
+
+#Loop through instructions and commands from filename input as $1
+for ((i=0;i<${#INSTR[@]};++i)); do
+ instruction "\${INSTR[i]}" "\${CMD[i]}"
+ eval "${CMD[i]}"
+ echo -e "${CMD[i]}" >> $DEMO.cmd
+ pause
+done
+
+
+exit 0
+
+