Skip to content

Commit f28c9cb

Browse files
committed
Add vagrant files for the testbed
1 parent 24dba49 commit f28c9cb

File tree

9 files changed

+432
-0
lines changed

9 files changed

+432
-0
lines changed
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
#!/bin/bash
2+
3+
# This script configures the egress node for testbed1
4+
# Testbed1 represents the use-case of chaining of SR-unaware SFs
5+
# This script deos the following
6+
### Creates a network namespace which is used as a server
7+
### Adds an SFC SRv6 policy for traffic to be sent to the client
8+
### Uses srext to add an End.DX6 localsid which decapsulate...
9+
### ... traffic sent by client before being sent to the server
10+
11+
# Create server
12+
sudo ./vnf-single_iface.sh add server veth1_3 inet6 b::1/64 b::2/64
13+
14+
# Configure SFC SRv6 policy
15+
sudo ip -6 route add a::/64 via 2:3::2 encap seg6 mode encap segs 2::,1::D6
16+
17+
# Configure localsids
18+
sudo modprobe srext
19+
sudo srconf localsid add 3::d6 end.dx6 ip b::2 veth1_3
20+
21+
exit
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
#!/bin/bash
2+
3+
# This script configures the ingress node for testbed1
4+
# Testbed1 represents the use-case of chaining of SR-unaware SFs
5+
# This script deos the following
6+
### Creates a network namespace which is used as a client
7+
### Adds an SFC SRv6 policy for traffic to be sent to the server
8+
### Uses srext to add an End.DX6 localsid which decapsulate...
9+
### ... traffic sent by server before being sent to the client
10+
11+
# Create client
12+
./vnf-single_iface.sh add client veth1_1 inet6 a::1/64 a::2/64
13+
14+
# Configure SFC SRv6 policy
15+
sudo ip -6 route add b::/64 via 1:2::2 encap seg6 mode encap segs 2::AD6:F1,2::AD6:F2,2::AD6:F3,3::D6
16+
17+
# Configure localsids
18+
sudo modprobe srext
19+
sudo srconf localsid add 1::d6 end.dx6 ip a::2 veth1_1
20+
21+
exit
Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
#!/bin/bash
2+
3+
# This script configures the nfv node for testbed1
4+
# Testbed1 represents the use-case of chaining of SR-unaware SFs
5+
# This script deos the following
6+
### Creates three network namespace which are used as SR-unaware VNFS(SFs)
7+
### Uses srext to add an End.AD6 localsid for each VNF which handles...
8+
### ...the processing of SRv6 encapsulation in behalf of the SR-unaware VNFs
9+
### For simplicity, End.AD6 (proxy behavior) uses the same interface as ...
10+
### ...Target (OIF) and source (IIF) interface
11+
### Uses srext to add an End localsid which is used by traffic coming...
12+
### ... from the server towards the client
13+
14+
# Create VNFS
15+
sudo ./vnf-single_iface.sh add vnf1 veth1_2 inet6 2:f1::1/64 2:f1::f1/64
16+
sudo ./vnf-single_iface.sh add vnf2 veth2_2 inet6 2:f2::1/64 2:f2::f2/64
17+
sudo ./vnf-single_iface.sh add vnf3 veth3_2 inet6 2:f3::1/64 2:f3::f3/64
18+
19+
# Configure localsids
20+
sudo modprobe srext
21+
sudo srconf localsid add 2::AD6:F1 end.ad6 ip 2:f1::f1 veth1_2 veth1_2
22+
sudo srconf localsid add 2::AD6:F2 end.ad6 ip 2:f2::f2 veth2_2 veth2_2
23+
sudo srconf localsid add 2::AD6:F3 end.ad6 ip 2:f3::f3 veth3_2 veth3_2
24+
sudo srconf localsid add 2:: end
25+
26+
exit
Lines changed: 211 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,211 @@
1+
#!/bin/bash
2+
3+
# This script adds or cleans a network namespace
4+
# it can create a name IPv4, IPv6, or dual network stack.
5+
# it can be used as follows
6+
# ./vnf-single_iface.sh add VNF_NAME NFV_IFACE MODE [--vnf-mac VNF_MAC_ADDR]
7+
# MODE := inet NFV_IPv4_ADDR VNF_IPv4_ADDR
8+
# inet6 NFV_IPv6_ADDR VNF_IPv6_ADDR
9+
# dual NFV_IPv4_ADDR VNF_IPv4_ADDR NFV_IPv6_ADDR VNF_IPv6_ADDR
10+
# ./vnf-single_iface.sh del VNF_NAME NFV_IFACE
11+
# N.B:
12+
# All IP addresses should be in the form of IP/mask "10.0.0.1/24" -- "A::2/64"
13+
# IF anything goes wrong while adding a VNF please do ./vnf-single_iface.sh del VNF_NAME NFV_IFACE before re-trying!
14+
15+
#usage
16+
NEWLINE=$'\n'
17+
usage="$0 add VNF_NAME NFV_IFACE MODE [--vnf-mac VNF_MAC_ADDR]${NEWLINE}"
18+
usage="${usage}MODE := inet NFV_IPv4_ADDR VNF_IPv4_ADDR ${NEWLINE}"
19+
usage="${usage} inet6 NFV_IPv6_ADDR VNF_IPv6_ADDR ${NEWLINE}"
20+
usage="${usage} dual NFV_IPv4_ADDR VNF_IPv4_ADDR NFV_IPv6_ADDR VNF_IPv6_ADDR ${NEWLINE}"
21+
usage="${usage}$0 del VNF_NAME NFV_IFACE ${NEWLINE}"
22+
usage="${usage}N.B:${NEWLINE}All IP addresses should be in the form of IP/mask \"10.0.0.1/24\" -- \"A::2/64\" ${NEWLINE}"
23+
usage="${usage}IF anything goes wrong while adding a VNF please do $0 del VNF_NAME NFV_IFACE before re-trying!"
24+
25+
if [ $# -eq 0 ]
26+
then
27+
echo "${usage}"
28+
exit
29+
fi
30+
31+
if [ $1 = "help" ]
32+
then
33+
echo "${usage}"
34+
exit
35+
fi
36+
37+
if [ $1 != "add" ] && [ $1 != "del" ]
38+
then
39+
echo "ERROR: unrecognized coomand. please try \"$0 help\" "
40+
exit
41+
fi
42+
43+
if [ $# -lt 3 ]
44+
then
45+
echo "ERROR: too few parameters. please try \"$0 help\" "
46+
exit
47+
fi
48+
49+
COMMAND=$1
50+
VNF_NAME=$2
51+
NFV_IFACE=$3
52+
53+
if [ $COMMAND = "del" ]
54+
then
55+
if [ $# -gt 3 ]
56+
then
57+
echo "ERROR: too many parameters for del command. please try \"$0 help\" "
58+
exit
59+
fi
60+
echo "DELETING \"${VNF_NAME}\"........."
61+
sudo ip link delete dev ${NFV_IFACE}
62+
sudo ip netns del $VNF_NAME
63+
exit
64+
fi
65+
66+
67+
if [ $# -ge 4 ]
68+
then
69+
MODE=$4
70+
if [ $MODE != "inet" ] && [ $MODE != "inet6" ] && [ $MODE != "dual" ]
71+
then
72+
echo " ERROR: Mode ${MODE} is not a valid inet mode many. please try \"$0 help\" "
73+
exit
74+
fi
75+
fi
76+
77+
if [ $# -lt 6 ]
78+
then
79+
echo "ERROR: too few parameters for add command. please try \"$0 help\" "
80+
exit
81+
fi
82+
83+
VNF_IFACE="veth0-${VNF_NAME}"
84+
85+
if [ $MODE = "inet" ] || [ $MODE = "inet6" ]
86+
then
87+
88+
if [ $# -gt 8 ]
89+
then
90+
echo "ERROR: too many parameters for inet or inet6 mode. please try \"$0 help\" "
91+
exit
92+
fi
93+
94+
echo "ADDING \"${VNF_NAME}\"........."
95+
NFV_IP=$5
96+
VNF_IP=$6
97+
NH=`echo ${NFV_IP} | cut -d'/' -f1`
98+
99+
# create VNF
100+
sudo ip netns add $VNF_NAME
101+
#create link between NFV and VNF
102+
sudo ip link add ${NFV_IFACE} type veth peer name ${VNF_IFACE}
103+
#assign virtual interface to VNF
104+
sudo ip link set ${VNF_IFACE} netns ${VNF_NAME}
105+
sudo ifconfig ${NFV_IFACE} up
106+
sudo ip netns exec ${VNF_NAME} ifconfig ${VNF_IFACE} up
107+
108+
if [ $MODE = "inet" ]
109+
then
110+
#configure NFV Interface
111+
sudo ip addr add ${NFV_IP} dev ${NFV_IFACE}
112+
#configure VNF interfcae
113+
sudo ip netns exec ${VNF_NAME} ip addr add ${VNF_IP} dev ${VNF_IFACE}
114+
#enable forwarding in VNF
115+
sudo ip netns exec ${VNF_NAME} sysctl -w net.ipv4.conf.all.forwarding=1
116+
sudo ip netns exec ${VNF_NAME} ip route add default via ${NH}
117+
118+
else
119+
sudo ip netns exec ${VNF_NAME} sysctl -w net.ipv6.conf.all.forwarding=1
120+
sudo ip -6 addr add ${NFV_IP} dev ${NFV_IFACE}
121+
sudo ip netns exec ${VNF_NAME} ip -6 addr add ${VNF_IP} dev ${VNF_IFACE}
122+
sudo ip netns exec ${VNF_NAME} ip -6 route add default via ${NH}
123+
124+
fi
125+
126+
127+
if [ $# -ge 7 ]
128+
then
129+
130+
if [ $7 != "--vnf-mac" ]
131+
then
132+
echo "ERROR: invalid token \"$7 \". please try \"$0 help\" "
133+
sudo ip link delete dev ${NFV_IFACE} > /dev/null
134+
sudo ip netns del $VNF_NAME > /dev/null
135+
echo "\"${VNF_NAME}\" CLEANED "
136+
exit
137+
fi
138+
139+
if [ $# -eq 8 ]
140+
then
141+
VNF_MAC=$8
142+
sudo ip netns exec ${VNF_NAME} ifconfig ${VNF_IFACE} hw ether ${VNF_MAC}
143+
fi
144+
exit
145+
fi
146+
else
147+
if [ $# -lt 8 ]
148+
then
149+
echo "ERROR: too few parameters for dual mode. please try \"$0 help\" "
150+
exit
151+
fi
152+
153+
if [ $# -gt 10 ]
154+
then
155+
echo "ERROR: too many parameters for dual mode. please try \"$0 help\" "
156+
exit
157+
fi
158+
159+
echo "ADDING \"${VNF_NAME}\"........."
160+
NFV_IPv4=$5
161+
VNF_IPv4=$6
162+
NFV_IPv6=$7
163+
VNF_IPv6=$8
164+
165+
# create VNF
166+
sudo ip netns add $VNF_NAME
167+
#create link between NFV and VNF
168+
sudo ip link add ${NFV_IFACE} type veth peer name ${VNF_IFACE}
169+
#assign virtual interface to VNF
170+
sudo ip link set ${VNF_IFACE} netns ${VNF_NAME}
171+
sudo ifconfig ${NFV_IFACE} up
172+
sudo ip netns exec ${VNF_NAME} ifconfig ${VNF_IFACE} up
173+
174+
#configure NFV Interface
175+
sudo ip addr add ${NFV_IPv4} dev ${NFV_IFACE}
176+
sudo ip -6 addr add ${NFV_IPv6} dev ${NFV_IFACE}
177+
178+
#configure VNF interfcae
179+
sudo ip netns exec ${VNF_NAME} ip addr add ${VNF_IPv4} dev ${VNF_IFACE}
180+
sudo ip netns exec ${VNF_NAME} ip -6 addr add ${VNF_IPv6} dev ${VNF_IFACE}
181+
182+
#enable forwarding in VNF
183+
sudo ip netns exec ${VNF_NAME} sysctl -w net.ipv4.conf.all.forwarding=1
184+
sudo ip netns exec ${VNF_NAME} sysctl -w net.ipv6.conf.all.forwarding=1
185+
186+
NH4=`echo ${NFV_IPv4} | cut -d'/' -f1`
187+
NH6=`echo ${NFV_IPv6} | cut -d'/' -f1`
188+
189+
sudo ip netns exec ${VNF_NAME} ip route add default via ${NH4}
190+
sudo ip netns exec ${VNF_NAME} ip -6 route add default via ${NH6}
191+
192+
if [ $# -ge 9 ]
193+
then
194+
195+
if [ $9 != "--vnf-mac" ]
196+
then
197+
echo "ERROR: invalid token \"$9 \". please try \"$0 help\" "
198+
sudo ip link delete dev ${NFV_IFACE} > /dev/null
199+
sudo ip netns del $VNF_NAME > /dev/null
200+
echo "\"${VNF_NAME}\" CLEANED "
201+
exit
202+
fi
203+
204+
if [ $# -eq 10 ]
205+
then
206+
VNF_MAC=$10
207+
sudo ip netns exec ${VNF_NAME} ifconfig ${VNF_IFACE} hw ether ${VNF_MAC}
208+
fi
209+
fi
210+
fi
211+
exit

vagrant-box/.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
.vagrant/

vagrant-box/testbed1/Vagrantfile

Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
# -*- mode: ruby -*-
2+
# vi: set ft=ruby :
3+
4+
Vagrant.configure("2") do |config|
5+
# ssh configuration
6+
config.ssh.username = "sr6"
7+
config.ssh.password = "sr6"
8+
9+
# ingress node configuration
10+
config.vm.define "ingress" do |ingress|
11+
ingress.vm.box = "srv6-net-prog"
12+
ingress.vm.network "private_network", ip: "1:2::1", virtualbox__intnet: "ing-nfv"
13+
ingress.vm.provider "virtualbox" do |virtualbox|
14+
virtualbox.memory = "512"
15+
virtualbox.cpus = "1"
16+
virtualbox.customize ['modifyvm', :id, '--cableconnected1', 'on']
17+
virtualbox.customize ["modifyvm", :id, "--nicpromisc2", "allow-all"]
18+
end
19+
ingress.vm.provision "shell", path: "ingress.sh"
20+
end
21+
22+
# nfv node configuration
23+
config.vm.define "nfv" do |nfv|
24+
nfv.vm.box = "srv6-net-prog"
25+
nfv.vm.network "private_network", ip: "1:2::2", virtualbox__intnet: "ing-nfv"
26+
nfv.vm.network "private_network", ip: "2:3::2", virtualbox__intnet: "nfv-egr"
27+
nfv.vm.provider "virtualbox" do |virtualbox|
28+
virtualbox.memory = "512"
29+
virtualbox.cpus = "1"
30+
virtualbox.customize ['modifyvm', :id, '--cableconnected1', 'on']
31+
virtualbox.customize ["modifyvm", :id, "--nicpromisc2", "allow-all"]
32+
virtualbox.customize ["modifyvm", :id, "--nicpromisc3", "allow-all"]
33+
end
34+
nfv.vm.provision "shell", path: "nfv.sh"
35+
end
36+
37+
# gress node configuration
38+
config.vm.define "egress" do |egress|
39+
egress.vm.box = "srv6-net-prog"
40+
egress.vm.network "private_network", ip: "2:3::3", virtualbox__intnet: "nvf-egr"
41+
egress.vm.provider "virtualbox" do |virtualbox|
42+
virtualbox.memory = "512"
43+
virtualbox.cpus = "1"
44+
virtualbox.customize ['modifyvm', :id, '--cableconnected1', 'on']
45+
virtualbox.customize ["modifyvm", :id, "--nicpromisc2", "allow-all"]
46+
end
47+
egress.vm.provision "shell", path: "egress.sh"
48+
end
49+
end

vagrant-box/testbed1/egress.sh

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
#!/bin/bash
2+
3+
# The vagrant provisioning script for ingress node
4+
5+
# Install required softwares
6+
export DEBIAN_FRONTEND=noninteractive
7+
apt-get -y --force-yes install ethtool
8+
apt-get -y --force-yes install iperf
9+
apt-get -y --force-yes install iperf3
10+
apt-get -y --force-yes install libpcap-dev
11+
12+
# Install latest tcpdump that support SR
13+
git clone https://github.com/the-tcpdump-group/tcpdump
14+
cd tcpdump/
15+
sudo ./configure
16+
sudo make && sudo make install && cd ..
17+
18+
# Enable IPv6 forwarding
19+
sysctl -w net.ipv6.conf.all.forwarding=1
20+
21+
# Configure interfaces
22+
ifconfig eth1 up
23+
ip -6 addr add 2:3::3/64 dev eth1
24+
25+
# Configure routing
26+
ip -6 route add 2::/64 via 2:3::2
27+
28+
# Instal srext
29+
git clone https://github.com/netgroup/SRv6-net-prog
30+
cd SRv6-net-prog/srext/
31+
sudo make && sudo make install && depmod -a
32+
33+
exit

0 commit comments

Comments
 (0)