|
1 # |
|
2 # Copyright 2005-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 dtn-ping |
|
18 net::num_nodes 3 |
|
19 |
|
20 manifest::file apps/dtnping/dtnping dtnping |
|
21 |
|
22 global num_pings |
|
23 set num_pings 10 |
|
24 set clayer tcp |
|
25 set sched ltp.sched |
|
26 foreach {var val} $opt(opts) { |
|
27 if {$var == "-n" } { |
|
28 set num_pings $val |
|
29 |
|
30 } elseif {$var == "-cl" } { |
|
31 set clayer $val |
|
32 |
|
33 } elseif {$var == "-s" } { |
|
34 set sched $val |
|
35 |
|
36 } else { |
|
37 testlog error "ERROR: unrecognized test option '$var'" |
|
38 exit 1 |
|
39 } |
|
40 } |
|
41 |
|
42 dtn::config |
|
43 |
|
44 dtn::config_interface $clayer |
|
45 dtn::config_linear_topology ALWAYSON $clayer true |
|
46 test::script { |
|
47 if {$var == "-s" } { |
|
48 dtn::config_ltp_schedule $clayer $sched |
|
49 } |
|
50 global num_pings |
|
51 testlog "Running dtnds" |
|
52 dtn::run_dtnd * |
|
53 |
|
54 testlog "Waiting for dtnds to start up" |
|
55 dtn::wait_for_dtnd * |
|
56 |
|
57 set N [net::num_nodes] |
|
58 set last_node [expr $N - 1] |
|
59 |
|
60 set dest dtn://host-0/ |
|
61 # testlog "receiving node is $first_node and sending node is $last_node" |
|
62 |
|
63 for {set i $last_node} {$i >= 0} {incr i -1} { |
|
64 testlog "Dtnping'ing from node $last_node to dtn://host-$i\ |
|
65 for $num_pings pings (one per second)" |
|
66 set pid [dtn::run_app $last_node dtnping "-c $num_pings dtn://host-$i/ping"] |
|
67 after [expr ($num_pings -1) * 1000] |
|
68 run::wait_for_pid_exit $last_node $pid 30 |
|
69 } |
|
70 |
|
71 for {set i 0} {$i < $last_node} {incr i} { |
|
72 testlog "Checking bundle stats on node $i" |
|
73 dtn::wait_for_bundle_stats $i [list $num_pings "delivered" \ |
|
74 $num_pings "generated" \ |
|
75 [expr $num_pings + ($num_pings * 2 * $i)] "received"] 5000 |
|
76 } |
|
77 |
|
78 # Last node is the ping source so it *also* has N * num_pings |
|
79 # locally delivered due to the delivery of the ping responses: |
|
80 testlog "Checking bundle stats on node $last_node" |
|
81 dtn::wait_for_bundle_stats $last_node [list \ |
|
82 [expr $num_pings * (1 + $N)] "delivered" \ |
|
83 $num_pings "generated" \ |
|
84 [expr $num_pings + ($num_pings * 2 * $last_node) ] "received"] 5000 |
|
85 |
|
86 testlog "Test success!" |
|
87 } |
|
88 |
|
89 test::exit_script { |
|
90 testlog "Stopping all dtnds" |
|
91 dtn::stop_dtnd * |
|
92 } |