|
1 # |
|
2 # Copyright 2006 Intel Corporation |
|
3 # |
|
4 # Licensed under the Apache License, Version 2.0 (the "License"); |
|
5 # you may not use this file except in compliance with the License. |
|
6 # You may obtain a copy of the License at |
|
7 # |
|
8 # http://www.apache.org/licenses/LICENSE-2.0 |
|
9 # |
|
10 # Unless required by applicable law or agreed to in writing, software |
|
11 # distributed under the License is distributed on an "AS IS" BASIS, |
|
12 # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
|
13 # See the License for the specific language governing permissions and |
|
14 # limitations under the License. |
|
15 # |
|
16 |
|
17 test::name custody-transfer |
|
18 net::num_nodes 4 |
|
19 set clayer tcp |
|
20 foreach {var val} $opt(opts) { |
|
21 if {$var == "-cl" } { |
|
22 set clayer $val |
|
23 } |
|
24 } |
|
25 |
|
26 |
|
27 dtn::config |
|
28 |
|
29 dtn::config_interface $clayer |
|
30 dtn::config_linear_topology OPPORTUNISTIC $clayer true |
|
31 |
|
32 test::script { |
|
33 testlog "running dtnds" |
|
34 dtn::run_dtnd * |
|
35 |
|
36 testlog "waiting for dtnds to start up" |
|
37 dtn::wait_for_dtnd * |
|
38 |
|
39 set N [net::num_nodes] |
|
40 set src dtn://host-0/test |
|
41 set dst dtn://host-[expr $N - 1]/test |
|
42 set src_route dtn://host-0/* |
|
43 set dst_route dtn://host-[expr $N - 1]/* |
|
44 |
|
45 for {set i 0} {$i < $N} {incr i} { |
|
46 dtn::tell_dtnd $i tcl_registration dtn://host-$i/test |
|
47 } |
|
48 |
|
49 testlog "*" |
|
50 testlog "* Test 1: basic custody transfer" |
|
51 testlog "*" |
|
52 |
|
53 testlog "sending bundle with custody transfer" |
|
54 set timestamp [dtn::tell_dtnd 0 sendbundle $src $dst custody] |
|
55 |
|
56 testlog "checking that node 0 got the bundle" |
|
57 dtn::wait_for_bundle_stats 0 {1 received 0 transmitted} |
|
58 dtn::wait_for_bundle_stats 1 {0 received 0 transmitted} |
|
59 dtn::wait_for_bundle_stats 2 {0 received 0 transmitted} |
|
60 dtn::wait_for_bundle_stats 3 {0 received 0 transmitted} |
|
61 |
|
62 testlog "checking that node 0 took custody" |
|
63 dtn::wait_for_bundle_stats 0 {1 pending 1 custody} |
|
64 dtn::wait_for_bundle_stats 1 {0 pending 0 custody} |
|
65 dtn::wait_for_bundle_stats 2 {0 pending 0 custody} |
|
66 dtn::wait_for_bundle_stats 3 {0 pending 0 custody} |
|
67 |
|
68 testlog "opening link from 0-1" |
|
69 dtn::tell_dtnd 0 link open $clayer-link:0-1 |
|
70 dtn::wait_for_link_state 0 $clayer-link:0-1 OPEN |
|
71 |
|
72 testlog "checking that custody was transferred" |
|
73 dtn::wait_for_bundle_stats 0 {2 received 1 transmitted} |
|
74 dtn::wait_for_bundle_stats 1 {1 received 1 generated 1 transmitted} |
|
75 dtn::wait_for_bundle_stats 2 {0 received 0 transmitted} |
|
76 dtn::wait_for_bundle_stats 3 {0 received 0 transmitted} |
|
77 |
|
78 dtn::wait_for_bundle_stats 0 {0 pending 0 custody} |
|
79 dtn::wait_for_bundle_stats 1 {1 pending 1 custody} |
|
80 dtn::wait_for_bundle_stats 2 {0 pending 0 custody} |
|
81 dtn::wait_for_bundle_stats 3 {0 pending 0 custody} |
|
82 |
|
83 testlog "open the rest of the links, check delivery" |
|
84 dtn::tell_dtnd 1 link open $clayer-link:1-2 |
|
85 dtn::tell_dtnd 2 link open $clayer-link:2-3 |
|
86 |
|
87 dtn::wait_for_bundle_stats 3 {1 delivered} |
|
88 dtn::wait_for_bundle 3 "$src,$timestamp" 30 |
|
89 |
|
90 dtn::wait_for_bundle_stats 0 {0 pending 0 custody} |
|
91 dtn::wait_for_bundle_stats 1 {0 pending 0 custody} |
|
92 dtn::wait_for_bundle_stats 2 {0 pending 0 custody} |
|
93 dtn::wait_for_bundle_stats 3 {0 pending 0 custody} |
|
94 |
|
95 testlog "*" |
|
96 testlog "* Test 2: custody timer retransmission" |
|
97 testlog "*" |
|
98 |
|
99 dtn::tell_dtnd * bundle reset_stats |
|
100 |
|
101 set custody_timer_opts "custody_timer_min=5 custody_timer_lifetime_pct=0" |
|
102 |
|
103 testlog "removing route from node 1" |
|
104 dtn::tell_dtnd 1 route del $dst_route |
|
105 |
|
106 testlog "sending another bundle, checking that node 1 has custody" |
|
107 set timestamp [dtn::tell_dtnd 0 sendbundle $src $dst custody] |
|
108 |
|
109 dtn::wait_for_bundle_stats 0 {2 received 1 transmitted} |
|
110 dtn::wait_for_bundle_stats 1 {1 received 1 generated 1 transmitted} |
|
111 dtn::wait_for_bundle_stats 2 {0 received 0 transmitted} |
|
112 dtn::wait_for_bundle_stats 3 {0 received 0 transmitted} |
|
113 |
|
114 dtn::wait_for_bundle_stats 0 {0 pending 0 custody} |
|
115 dtn::wait_for_bundle_stats 1 {1 pending 1 custody} |
|
116 dtn::wait_for_bundle_stats 2 {0 pending 0 custody} |
|
117 dtn::wait_for_bundle_stats 3 {0 pending 0 custody} |
|
118 |
|
119 testlog "adding route to null on node 1, checking transmitted" |
|
120 eval dtn::tell_dtnd 1 route add $dst_route null $custody_timer_opts |
|
121 |
|
122 dtn::wait_for_bundle_stats 0 {2 received 1 transmitted} |
|
123 dtn::wait_for_bundle_stats 1 {1 received 1 generated 2 transmitted} |
|
124 dtn::wait_for_bundle_stats 2 {0 received 0 transmitted} |
|
125 dtn::wait_for_bundle_stats 3 {0 received 0 transmitted} |
|
126 |
|
127 dtn::wait_for_bundle_stats 0 {0 pending 0 custody} |
|
128 dtn::wait_for_bundle_stats 1 {1 pending 1 custody} |
|
129 dtn::wait_for_bundle_stats 2 {0 pending 0 custody} |
|
130 dtn::wait_for_bundle_stats 3 {0 pending 0 custody} |
|
131 |
|
132 testlog "waiting for a couple retransmissions" |
|
133 |
|
134 dtn::wait_for_bundle_stats 0 {2 received 1 transmitted} |
|
135 dtn::wait_for_bundle_stats 1 {1 received 4 transmitted} |
|
136 dtn::wait_for_bundle_stats 2 {0 received 0 transmitted} |
|
137 dtn::wait_for_bundle_stats 3 {0 received 0 transmitted} |
|
138 |
|
139 dtn::wait_for_bundle_stats 0 {0 pending 0 custody} |
|
140 dtn::wait_for_bundle_stats 1 {1 pending 1 custody} |
|
141 dtn::wait_for_bundle_stats 2 {0 pending 0 custody} |
|
142 dtn::wait_for_bundle_stats 3 {0 pending 0 custody} |
|
143 |
|
144 testlog "switching route back, waiting for retransmission and delivery" |
|
145 dtn::tell_dtnd 1 route del $dst_route |
|
146 eval dtn::tell_dtnd 1 route add $dst_route $clayer-link:1-2 $custody_timer_opts |
|
147 |
|
148 dtn::wait_for_bundle_stats 0 {2 received 1 transmitted} |
|
149 dtn::wait_for_bundle_stats 1 {2 received 5 transmitted} |
|
150 dtn::wait_for_bundle_stats 2 {2 received 2 transmitted} |
|
151 dtn::wait_for_bundle_stats 3 {1 received 1 transmitted} |
|
152 |
|
153 dtn::wait_for_bundle_stats 3 {1 delivered} |
|
154 dtn::wait_for_bundle 3 "$src,$timestamp" 30 |
|
155 |
|
156 dtn::wait_for_bundle_stats 0 {0 pending 0 custody} |
|
157 dtn::wait_for_bundle_stats 1 {0 pending 0 custody} |
|
158 dtn::wait_for_bundle_stats 2 {0 pending 0 custody} |
|
159 dtn::wait_for_bundle_stats 3 {0 pending 0 custody} |
|
160 |
|
161 testlog "*" |
|
162 testlog "* Test 3: duplicate detection" |
|
163 testlog "*" |
|
164 |
|
165 dtn::tell_dtnd * bundle reset_stats |
|
166 |
|
167 set custody_timer_opts "custody_timer_min=5 custody_timer_lifetime_pct=0" |
|
168 |
|
169 testlog "speeding up custody timer for route on node 0" |
|
170 dtn::tell_dtnd 0 route del $dst_route |
|
171 eval dtn::tell_dtnd 0 route add $dst_route $clayer-link:0-1 $custody_timer_opts |
|
172 |
|
173 testlog "removing destination route for node 1" |
|
174 dtn::tell_dtnd 1 route del $dst_route |
|
175 |
|
176 testlog "switching reverse route for node 1 to null" |
|
177 dtn::tell_dtnd 1 route del $src_route |
|
178 dtn::tell_dtnd 1 route add $src_route null |
|
179 |
|
180 testlog "sending another bundle" |
|
181 set timestamp [dtn::tell_dtnd 0 sendbundle $src $dst custody] |
|
182 |
|
183 testlog "checking that node 1 and node 0 both have custody" |
|
184 dtn::wait_for_bundle_stats 0 {1 received 1 transmitted} |
|
185 dtn::wait_for_bundle_stats 1 {1 received 1 generated 1 transmitted} |
|
186 dtn::wait_for_bundle_stats 2 {0 received 0 transmitted} |
|
187 dtn::wait_for_bundle_stats 3 {0 received 0 transmitted} |
|
188 |
|
189 dtn::wait_for_bundle_stats 0 {1 pending 1 custody} |
|
190 dtn::wait_for_bundle_stats 1 {1 pending 1 custody} |
|
191 dtn::wait_for_bundle_stats 2 {0 pending 0 custody} |
|
192 dtn::wait_for_bundle_stats 3 {0 pending 0 custody} |
|
193 |
|
194 testlog "waiting for a retransmission, making sure duplicate is deleted" |
|
195 dtn::wait_for_bundle_stats 0 {1 received 2 transmitted} |
|
196 dtn::wait_for_bundle_stats 1 {2 received 2 generated 2 transmitted} |
|
197 |
|
198 dtn::wait_for_bundle_stats 0 {1 pending 1 custody} |
|
199 dtn::wait_for_bundle_stats 1 {1 pending 1 custody} |
|
200 |
|
201 testlog "flipping back the route from 1 to 0" |
|
202 dtn::tell_dtnd 1 route del $src_route |
|
203 dtn::tell_dtnd 1 route add $src_route $clayer-link:1-0 |
|
204 |
|
205 testlog "waiting for another retransmission, checking custody transferred" |
|
206 dtn::wait_for_bundle_stats 0 {2 received 3 transmitted} |
|
207 dtn::wait_for_bundle_stats 1 {3 received 3 generated 3 transmitted} |
|
208 |
|
209 dtn::wait_for_bundle_stats 0 {0 pending 0 custody} |
|
210 dtn::wait_for_bundle_stats 1 {1 pending 1 custody} |
|
211 |
|
212 testlog "adding route back to 1 and waiting for delivery" |
|
213 dtn::tell_dtnd 1 route del $dst_route |
|
214 dtn::tell_dtnd 1 route add $dst_route $clayer-link:1-2 |
|
215 |
|
216 dtn::wait_for_bundle_stats 3 {1 delivered} |
|
217 dtn::wait_for_bundle 3 "$src,$timestamp" 30 |
|
218 |
|
219 dtn::wait_for_bundle_stats 0 {0 pending 0 custody} |
|
220 dtn::wait_for_bundle_stats 1 {0 pending 0 custody} |
|
221 dtn::wait_for_bundle_stats 2 {0 pending 0 custody} |
|
222 dtn::wait_for_bundle_stats 3 {0 pending 0 custody} |
|
223 |
|
224 testlog "*" |
|
225 testlog "* Test 4: bundle expiration with custody" |
|
226 testlog "*" |
|
227 dtn::tell_dtnd * bundle reset_stats |
|
228 |
|
229 testlog "removing route for node 1" |
|
230 dtn::tell_dtnd 1 route del $dst_route |
|
231 |
|
232 testlog "sending bundle, checking custody transfer" |
|
233 set timestamp [dtn::tell_dtnd 0 sendbundle $src $dst custody expiration=10] |
|
234 |
|
235 dtn::wait_for_bundle_stats 0 {2 received 1 transmitted} |
|
236 dtn::wait_for_bundle_stats 1 {1 received 1 generated 1 transmitted} |
|
237 |
|
238 dtn::wait_for_bundle_stats 0 {0 pending 0 custody 1 delivered} |
|
239 dtn::wait_for_bundle_stats 1 {1 pending 1 custody 0 delivered} |
|
240 |
|
241 testlog "waiting for bundle to expire" |
|
242 dtn::wait_for_bundle_stats 1 {1 expired} |
|
243 |
|
244 testlog "checking that custody was cleaned up" |
|
245 dtn::wait_for_bundle_stats 1 {0 pending 0 custody} |
|
246 dtn::wait_for_bundle_stats 0 {0 pending 0 custody} |
|
247 |
|
248 testlog "checking that expiration status report was delivered" |
|
249 dtn::wait_for_bundle_stats 0 {2 delivered} |
|
250 |
|
251 testlog "re-adding route" |
|
252 dtn::tell_dtnd 1 route add $dst_route $clayer-link:1-2 |
|
253 |
|
254 testlog "*" |
|
255 testlog "* Test 5: delivery before taking custody" |
|
256 testlog "*" |
|
257 |
|
258 dtn::tell_dtnd * bundle reset_stats |
|
259 |
|
260 testlog "disabling custody acceptance on node 0" |
|
261 dtn::tell_dtnd 0 param set accept_custody 0 |
|
262 |
|
263 testlog "sending a bundle to a nonexistant registration" |
|
264 set dst2 "dtn://host-0/test2" |
|
265 set timestamp [dtn::tell_dtnd 0 sendbundle $src $dst2 custody expiration=10] |
|
266 |
|
267 testlog "checking that it is pending with no custodian" |
|
268 dtn::wait_for_bundle_stats 0 {1 received 1 pending 0 custody} |
|
269 |
|
270 testlog "adding a registration, checking delivery" |
|
271 dtn::tell_dtnd 0 tcl_registration $dst2 |
|
272 dtn::wait_for_bundle_stats 0 {0 pending 0 custody 1 delivered} |
|
273 |
|
274 # XXX/TODO: add support / test cases for: |
|
275 # |
|
276 # restart posts a new custody timer |
|
277 # noroute timer |
|
278 # no contact timer |
|
279 # retransmission over an ONDEMAND link that's gone idle |
|
280 # multiple routes, ensure retransmission only on one |
|
281 # race between bundle delete and custody timer cancelling |
|
282 |
|
283 testlog "test success!" |
|
284 } |
|
285 |
|
286 test::exit_script { |
|
287 testlog "stopping all dtnds" |
|
288 dtn::stop_dtnd * |
|
289 } |