|
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 bundle-status-reports |
|
18 net::default_num_nodes 3 |
|
19 |
|
20 dtn::config |
|
21 |
|
22 dtn::config_interface tcp |
|
23 dtn::config_linear_topology ALWAYSON tcp true |
|
24 |
|
25 test::script { |
|
26 |
|
27 proc test_sr {sr_option sr_field node_list} { |
|
28 |
|
29 global last_node |
|
30 global source |
|
31 global sr_dest |
|
32 global dest |
|
33 global dest_node |
|
34 |
|
35 testlog "Sending bundle to $dest with $sr_option set" |
|
36 |
|
37 # 3 second expiration for deleted SR's to be generated in time: |
|
38 set timestamp [dtn::tell_dtnd $last_node \ |
|
39 sendbundle $source $dest replyto=$sr_dest \ |
|
40 expiration=3 $sr_option] |
|
41 |
|
42 # If we selected deletion receipt we assume the bundle |
|
43 # won't ever arrive at the destination |
|
44 if {$sr_option != "deletion_rcpt"} { |
|
45 testlog "Waiting for bundle arrival at $dest" |
|
46 dtn::wait_for_bundle 0 "$source,$timestamp" 5 |
|
47 } |
|
48 |
|
49 set sr_guid "$source,$timestamp,$dest_node" |
|
50 |
|
51 testlog "Testing for $sr_option SR(s):" |
|
52 foreach node_name $node_list { |
|
53 set sr_guid "$source,$timestamp,$node_name" |
|
54 |
|
55 testlog " Waiting for SR arrival from $node_name to $sr_dest" |
|
56 dtn::wait_for_sr $last_node $sr_guid 5 |
|
57 |
|
58 testlog " Verifying received SR has field \"$sr_field\"" |
|
59 dtn::check_sr_fields $last_node $sr_guid $sr_field |
|
60 |
|
61 } |
|
62 } |
|
63 |
|
64 testlog "Running dtnds" |
|
65 dtn::run_dtnd * |
|
66 |
|
67 testlog "Waiting for dtnds to start up" |
|
68 dtn::wait_for_dtnd * |
|
69 |
|
70 testlog "Waiting for all links to open" |
|
71 dtn::wait_for_link_state 0 tcp-link:0-1 OPEN |
|
72 dtn::wait_for_link_state 1 tcp-link:1-0 OPEN |
|
73 dtn::wait_for_link_state 1 tcp-link:1-2 OPEN |
|
74 dtn::wait_for_link_state 2 tcp-link:2-1 OPEN |
|
75 |
|
76 # global constants |
|
77 set last_node [expr [net::num_nodes] - 1] |
|
78 set source [dtn::tell_dtnd $last_node {route local_eid}] |
|
79 set dest_node dtn://host-0 |
|
80 set dest $dest_node/test |
|
81 set sr_dest $source/sr |
|
82 set all_nodes [list] |
|
83 for {set i 0} {$i <= $last_node} {incr i} { |
|
84 lappend all_nodes "dtn://host-$i" |
|
85 } |
|
86 |
|
87 # report bundle arrivals at the bundle delivery points |
|
88 dtn::tell_dtnd $last_node tcl_registration $sr_dest |
|
89 dtn::tell_dtnd 0 tcl_registration $dest |
|
90 |
|
91 # test the SR's |
|
92 test_sr delivery_rcpt sr_delivered_time $dest_node |
|
93 test_sr forward_rcpt sr_forwarded_time [lrange $all_nodes 1 end] |
|
94 test_sr receive_rcpt sr_received_time [lrange $all_nodes 0 [expr $last_node - 1]] |
|
95 |
|
96 # need to cut the link to create a deletion SR: |
|
97 dtn::tell_dtnd 1 link close tcp-link:1-0 |
|
98 after 1000 |
|
99 test_sr deletion_rcpt sr_deleted_time dtn://host-1 |
|
100 |
|
101 # XXX/todo: add Custody and App-Acknowledgement SR tests once the |
|
102 # ability to generate those types of SRs has been implemented |
|
103 |
|
104 testlog "Success!" |
|
105 |
|
106 } |
|
107 |
|
108 test::exit_script { |
|
109 testlog "stopping all dtnds" |
|
110 dtn::stop_dtnd * |
|
111 } |