|
1 # |
|
2 # Copyright 2007 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 inflight-interrupt |
|
18 net::num_nodes 2 |
|
19 |
|
20 set cl tcp |
|
21 |
|
22 foreach {var val} $opt(opts) { |
|
23 if {$var == "-cl" || $var == "cl"} { |
|
24 set cl $val |
|
25 } else { |
|
26 testlog error "ERROR: unrecognized test option '$var'" |
|
27 exit 1 |
|
28 } |
|
29 } |
|
30 |
|
31 dtn::config |
|
32 dtn::config_interface $cl |
|
33 |
|
34 # disable fragmentation |
|
35 # XXX/demmer this only works for stream cl's |
|
36 conf::add dtnd * "param set reactive_frag_enabled false" |
|
37 conf::add dtnd * "link set_cl_defaults $cl reactive_frag_enabled=false" |
|
38 |
|
39 dtn::config_linear_topology ALWAYSON $cl true \ |
|
40 "test_write_delay=1000 sendbuf_len=1024" |
|
41 |
|
42 test::script { |
|
43 testlog "Running dtnds" |
|
44 dtn::run_dtnd * |
|
45 |
|
46 testlog "Waiting for dtnds to start up" |
|
47 dtn::wait_for_dtnd * |
|
48 |
|
49 testlog "Waiting for link to open" |
|
50 dtn::wait_for_link_state 0 $cl-link:0-1 OPEN |
|
51 |
|
52 set source dtn://host-0/test |
|
53 set dest dtn://host-1/test |
|
54 |
|
55 dtn::tell_dtnd 1 tcl_registration $dest |
|
56 |
|
57 testlog "Sending bundle" |
|
58 dtn::tell_dtnd 0 sendbundle $source $dest length=5000 |
|
59 |
|
60 testlog "Waiting for bundle to be in flight" |
|
61 dtn::wait_for_link_stats 0 $cl-link:0-1 {1 bundles_inflight} |
|
62 |
|
63 testlog "Closing the link" |
|
64 tell_dtnd 0 link close $cl-link:0-1 |
|
65 dtn::wait_for_link_state 0 $cl-link:0-1 UNAVAILABLE |
|
66 |
|
67 testlog "Checking that bundle is still queued on the link" |
|
68 dtn::check_bundle_stats 0 {1 pending} |
|
69 dtn::check_bundle_stats 1 {0 received} |
|
70 dtn::check_link_stats 0 $cl-link:0-1 {1 bundles_queued 0 bundles_inflight} |
|
71 |
|
72 testlog "Reopening the link" |
|
73 tell_dtnd 0 link open $cl-link:0-1 |
|
74 |
|
75 testlog "Waiting for it to be transmitted" |
|
76 dtn::wait_for_bundle_stats 0 {0 pending} |
|
77 dtn::wait_for_bundle_stats 1 {0 pending 1 received 1 delivered} |
|
78 |
|
79 testlog "Checking the link stats" |
|
80 dtn::check_link_stats 0 $cl-link:0-1 {0 bundles_queued 0 bundles_inflight 1 bundles_transmitted} |
|
81 dtn::check_link_stats 0 $cl-link:0-1 {0 bytes_queued 0 bytes_inflight} |
|
82 |
|
83 testlog "Repeating the test with two bundles in flight" |
|
84 tell_dtnd 0 bundle reset_stats |
|
85 tell_dtnd 1 bundle reset_stats |
|
86 |
|
87 dtn::tell_dtnd 0 sendbundle $source $dest length=5000 |
|
88 dtn::tell_dtnd 0 sendbundle $source $dest length=5000 |
|
89 |
|
90 testlog "Waiting for first bundle to be in flight" |
|
91 dtn::wait_for_link_stats 0 $cl-link:0-1 {1 bundles_queued 1 bundles_inflight} |
|
92 |
|
93 testlog "Closing the link" |
|
94 tell_dtnd 0 link close $cl-link:0-1 |
|
95 dtn::wait_for_link_state 0 $cl-link:0-1 UNAVAILABLE |
|
96 |
|
97 testlog "Checking that bundles are still queued on the link" |
|
98 dtn::check_bundle_stats 0 {2 pending} |
|
99 dtn::check_bundle_stats 1 {0 received} |
|
100 dtn::check_link_stats 0 $cl-link:0-1 {2 bundles_queued} |
|
101 |
|
102 testlog "Reopening the link" |
|
103 tell_dtnd 0 link open $cl-link:0-1 |
|
104 |
|
105 testlog "Waiting for them to be transmitted" |
|
106 dtn::wait_for_bundle_stats 0 {0 pending} |
|
107 dtn::wait_for_bundle_stats 1 {0 pending 2 received 2 delivered} |
|
108 |
|
109 testlog "Checking the link stats" |
|
110 dtn::check_link_stats 0 $cl-link:0-1 {0 bundles_queued 0 bundles_inflight 2 bundles_transmitted} |
|
111 dtn::check_link_stats 0 $cl-link:0-1 {0 bytes_queued 0 bytes_inflight} |
|
112 |
|
113 testlog "Test success!" |
|
114 } |
|
115 |
|
116 test::exit_script { |
|
117 testlog "Stopping all dtnds" |
|
118 dtn::stop_dtnd * |
|
119 } |