-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtest_agent.sh
More file actions
executable file
·127 lines (105 loc) · 4.25 KB
/
Copy pathtest_agent.sh
File metadata and controls
executable file
·127 lines (105 loc) · 4.25 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
#!/bin/sh
# Script to test the IOAM agent with network namespaces
if [ "$EUID" -ne 0 ]; then
echo "Please run as root."
exit
fi
make
# Remove previous namespaces
cleanup()
{
ip netns delete encap || true
ip netns delete transit || true
ip netns delete decap || true
}
echo "Cleaning up..."
cleanup
echo -e "Done cleaning.\n"
echo "Adding network namespaces..."
ip netns add encap
ip netns add transit
ip netns add decap
echo -e "Done adding namespaces.\n"
echo "Listing network namespaces..."
ip netns list
echo -e "Done listing.\n"
echo "Creating links..."
# encap <-> transit link
ip link add ioam-veth-encap netns encap type veth peer ioam-veth-t-e netns transit
# transit <-> decap link
ip link add ioam-veth-decap netns decap type veth peer ioam-veth-t-d netns transit
echo -e "Done creating links.\n"
echo "Renaming interfaces..."
# rename links: encap (veth0) <-> (veth0) transit (veth1) <-> (veth0) decap
ip -netns encap link set ioam-veth-encap name veth0
ip -netns decap link set ioam-veth-decap name veth0
ip -netns transit link set ioam-veth-t-e name veth0
ip -netns transit link set ioam-veth-t-d name veth1
echo -e "Done renaming interfaces.\n"
echo "Setting IPv6 addresses..."
# db01::1/64 <-> db01::2/64 | db02::2/64 <-> db02::1/64
ip -netns encap addr add db01::1/64 dev veth0
ip -netns transit addr add db01::2/64 dev veth0
ip -netns transit addr add db02::2/64 dev veth1
ip -netns decap addr add db02::1/64 dev veth0
echo -e "Done setting addresses.\n"
echo "Turning interfaces up..."
ip -netns encap link set veth0 up
ip -netns transit link set veth0 up
ip -netns transit link set veth1 up
ip -netns decap link set veth0 up
echo -e "Done turning interfaces up\n"
echo "Turning loopback interfaces up..."
ip -netns encap link set lo up
ip -netns transit link set lo up
ip -netns transit link set lo up
ip -netns decap link set lo up
echo -e "Done turning loopback interfaces up\n"
echo "Setting routes..."
#ip -netns encap route add db02::/64 via db01::2 dev veth0
ip -netns encap route add db02::/64 encap ioam6 mode inline trace prealloc type 0xf6e002 ns 123 size 96 via db01::2 dev veth0
ip -netns decap route add db01::/64 via db02::2 dev veth0
echo -e "Done set routes\n"
echo "Setting forwarding on transit node..."
ip netns exec transit sysctl -w net.ipv6.conf.all.forwarding=1
echo -e "Done setting forwarding on transit.\n"
echo "Sysctl on encap..."
ip netns exec encap sysctl -w net.ipv6.ioam6_id=1
ip netns exec encap sysctl -w net.ipv6.ioam6_id_wide=1
ip netns exec encap sysctl -w net.ipv6.conf.veth0.ioam6_enabled=1
ip netns exec encap sysctl -w net.ipv6.conf.veth0.ioam6_id=1
ip netns exec encap sysctl -w net.ipv6.conf.veth0.ioam6_id_wide=1
ip -netns encap ioam namespace add 123 data 12345678 wide deadcafedeadcafe
ip -netns encap ioam schema add 7 deadbeef
ip -netns encap ioam namespace set 123 schema 7
echo "Sysctl on transit..."
ip netns exec transit sysctl -w net.ipv6.ioam6_id=2
ip netns exec transit sysctl -w net.ipv6.ioam6_id_wide=2
ip netns exec transit sysctl -w net.ipv6.conf.veth0.ioam6_enabled=1
ip netns exec transit sysctl -w net.ipv6.conf.veth0.ioam6_id=2
ip netns exec transit sysctl -w net.ipv6.conf.veth0.ioam6_id_wide=2
ip netns exec transit sysctl -w net.ipv6.conf.veth1.ioam6_enabled=1
ip netns exec transit sysctl -w net.ipv6.conf.veth1.ioam6_id=2
ip netns exec transit sysctl -w net.ipv6.conf.veth1.ioam6_id_wide=2
ip -netns transit ioam namespace add 123 data 12345678 wide deadcafedeadcafe
ip -netns encap ioam namespace set 123 schema 7
echo "Sysctl on decap..."
ip netns exec decap sysctl -w net.ipv6.ioam6_id=3
ip netns exec decap sysctl -w net.ipv6.ioam6_id_wide=3
ip netns exec decap sysctl -w net.ipv6.conf.veth0.ioam6_enabled=1
ip netns exec decap sysctl -w net.ipv6.conf.veth0.ioam6_id=3
ip netns exec decap sysctl -w net.ipv6.conf.veth0.ioam6_id_wide=3
ip -netns decap ioam namespace add 123 data 12345678 wide deadcafedeadcafe
ip -netns encap ioam schema add 7 deadbeef
ip -netns encap ioam namespace set 123 schema 7
echo -e "\nSleeping for 2 seconds..."
sleep 2
echo -e "\n\n** TESTING (Ctrl-C to stop IOAM agent) **"
sudo ip netns exec encap ping -i 0.5 db02::1 -q &
PING_PID=$!
sudo ip netns exec decap ./ioam-agent -i veth0 -d traces.csv
sudo kill $PING_PID
echo -e "\n\n** DONE **\n\n"
echo "Cleaning up..."
cleanup
echo -e "Done cleaning.\n"