blob: 10e3747fbd74ad7689290fd2f7200e40f0cfb21a [file] [log] [blame]
Eric Newberry608211e2017-11-27 21:59:37 -07001#!/bin/bash
2source ../multi-host.conf
3
4echo "host A IP addresses $IP4_A1 and $IP4_A2"
5echo "host C IP address $IP4_C1"
6echo "host D IP address $IP4_D1"
7
8clean_up() {
9 r=$(ssh $CTRL_C "sudo killall nfd" 2>&1)
10 r=$(ssh $CTRL_D "sudo killall test-congestionmark-producer" 2>&1)
11 r=$(ssh $CTRL_D "sudo killall nfd" 2>&1)
12 r=$(sudo killall nfd 2>&1)
13}
14
15### Setup
16
17# Start NFD on hosts A, C, and D
18workdir=$(pwd)
19echo "starting nfd on host A..."
20mkdir -p $workdir/logs; sudo nfd > $workdir/logs/nfd.log 2>&1 &
21sleep 1
22
23echo "starting nfd on host C..."
24ssh $CTRL_C "mkdir -p $workdir/logs; sudo nfd &> $workdir/logs/nfd.log &"
25sleep 1
26
27echo "starting nfd on host D..."
28ssh $CTRL_D "mkdir -p $workdir/logs; sudo nfd &> $workdir/logs/nfd.log &"
29sleep 1
30
31# Create faces
32ssh $CTRL_C "nfdc face create udp4://$IP4_A1"
33nfdc face create udp4://$IP4_D1
34
35# Set up routes
36ssh $CTRL_C "nfdc route add /arizona/cs udp4://$IP4_A1"
37if [[ $? -ne 0 ]]; then
38 echo "C: Failed to create route for /arizona/cs toward A"
39 clean_up
40 exit 1
41fi
42
43ssh $CTRL_C "nfdc route add /ucla/cs udp4://$IP4_A1"
44if [[ $? -ne 0 ]]; then
45 echo "C: Failed to create route for /ucla/cs toward A"
46 clean_up
47 exit 1
48fi
49
50ssh $CTRL_C "nfdc route add /ucsd/caida udp4://$IP4_A1"
51if [[ $? -ne 0 ]]; then
52 echo "C: Failed to create route for /ucsd/caida toward A"
53 clean_up
54 exit 1
55fi
56
57nfdc route add /arizona/cs udp4://$IP4_D1
58if [[ $? -ne 0 ]]; then
59 echo "A: Failed to create route for /arizona/cs toward D"
60 clean_up
61 exit 1
62fi
63
64nfdc route add /ucla/cs udp4://$IP4_D1
65if [[ $? -ne 0 ]]; then
66 echo "A: Failed to create route for /ucla/cs toward D"
67 clean_up
68 exit 1
69fi
70
71nfdc route add /ucsd/caida udp4://$IP4_D1
72if [[ $? -ne 0 ]]; then
73 echo "A: Failed to create route for /ucsd/caida toward D"
74 clean_up
75 exit 1
76fi
77
78### TestCase 1
79
80# A: Use CongestionMarkStrategy (value=7) strategy for /arizona/cs namespace
81nfdc strategy set /arizona/cs /localhost/nfd/strategy/congestion-mark/%FD%01/7/true
82if [[ $? -ne 0 ]]; then
83 echo "A: Failed to set CongestionMarkStrategy for /arizona/cs prefix"
84 clean_up
85 exit 2
86fi
87
88# D: Start producer for /arizona/cs
89ssh $CTRL_D "test-congestionmark-producer /arizona/cs &>/dev/null &"
90
91# C: Send Interest for /arizona/cs
92output=$(ssh $CTRL_C "test-congestionmark-consumer /arizona/cs")
93status=$?
94if [[ $? -ne 0 ]]; then
95 echo "Consumer for Interest /arizona/cs did not exit with status 0"
96 echo "Actual: $status"
97 clean_up
98 exit 6
99fi
100if [[ $output != "CongestionMark=7" ]]; then
101 echo "Interest /arizona/cs not answered with a Data containing a congestion mark with a value of 7"
102 echo "Actual: $output"
103 clean_up
104 exit 3
105fi
106
107### TestCase 2
108
109# D: Start producer for /ucla/cs
110ssh $CTRL_D "test-congestionmark-producer /ucla/cs &>/dev/null &"
111
112# C: Send Interest for /ucla/cs
113output=$(ssh $CTRL_C "test-congestionmark-consumer /ucla/cs")
114status=$?
115if [[ $? -ne 0 ]]; then
116 echo "Consumer for Interest /ucla/cs did not exit with status 0"
117 echo "Actual: $status"
118 clean_up
119 exit 6
120fi
121if [[ $output != "CongestionMark=0" ]]; then
122 echo "Interest /ucla/cs not answered with a Data without a congestion mark"
123 echo "Actual: $output"
124 clean_up
125 exit 4
126fi
127
128### TestCase 3
129
130# D: Start producer for /ucsd/caida
131ssh $CTRL_D "test-congestionmark-producer /ucsd/caida &>/dev/null &"
132sleep 1
133
134# C: Use CongestionMarkStrategy (value=2) strategy for /ucsd/caida namespace
135ssh $CTRL_C "nfdc strategy set /ucsd/caida /localhost/nfd/strategy/congestion-mark/%FD%01/2/true"
136if [[ $? -ne 0 ]]; then
137 echo "C: Failed to set CongestionMarkStrategy for /ucsd/caida prefix"
138 clean_up
139 exit 2
140fi
141
142# A: Use CongestionMarkStrategy (value=3, override) strategy for /ucsd/caida namespace
143nfdc strategy set /ucsd/caida /localhost/nfd/strategy/congestion-mark/%FD%01/3/false
144if [[ $? -ne 0 ]]; then
145 echo "A: Failed to set CongestionMarkStrategy for /ucsd/caida prefix"
146 clean_up
147 exit 2
148fi
149
150# C: Send Interest for /ucsd/caida
151output=$(ssh $CTRL_C "test-congestionmark-consumer /ucsd/caida")
152status=$?
153if [[ $? -ne 0 ]]; then
154 echo "Consumer for Interest /ucsd/caida did not exit with status 0"
155 echo "Actual: $status"
156 clean_up
157 exit 6
158fi
159if [[ $output != "CongestionMark=3" ]]; then
160 echo "Interest /ucsd/caida not answered with a Data containing a congestion mark with a value of 3"
161 echo "Actual: $output"
162 clean_up
163 exit 5
164fi