test/flood-router.tcl
changeset 0 2b3e5ec03512
equal deleted inserted replaced
-1:000000000000 0:2b3e5ec03512
       
     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 flood-router
       
    18 net::num_nodes 5
       
    19 
       
    20 dtn::config --no_null_link
       
    21 
       
    22 set cl   tcp
       
    23 set linktype ALWAYSON
       
    24 
       
    25 foreach {var val} $opt(opts) {
       
    26     if {$var == "-cl" || $var == "cl"} {
       
    27 	set cl $val
       
    28     } elseif {$var == "-linktype" || $var == "linktype"} {
       
    29         set linktype $val	
       
    30     } else {
       
    31 	testlog error "ERROR: unrecognized test option '$var'"
       
    32 	exit 1
       
    33     }
       
    34 }
       
    35 
       
    36 testlog "Configuring $cl interfaces / links"
       
    37 
       
    38 set dtn::router_type "flood"
       
    39 
       
    40 dtn::config_interface $cl
       
    41 dtn::config_diamond_topology $linktype $cl false
       
    42 
       
    43 test::script {
       
    44     testlog "Running dtnds"
       
    45     dtn::run_dtnd *
       
    46 
       
    47     testlog "Waiting for dtnds to start up"
       
    48     dtn::wait_for_dtnd *
       
    49 
       
    50     if {$linktype == "ALWAYSON"} {
       
    51 	testlog "Waiting for links to open"
       
    52 	dtn::wait_for_link_state 0 $cl-link:0-1 OPEN
       
    53 	dtn::wait_for_link_state 0 $cl-link:0-2 OPEN
       
    54     }
       
    55     
       
    56     testlog "injecting a bundle"
       
    57     tell_dtnd 0 sendbundle dtn://host-0/test dtn://host-3/test \
       
    58 	    length=4096 expiration=10
       
    59 
       
    60     testlog "waiting for it to be flooded around"
       
    61     dtn::wait_for_bundle_stats 0 {1 pending 2 transmitted}
       
    62     dtn::wait_for_bundle_stats 1 {1 pending 1 transmitted}
       
    63     dtn::wait_for_bundle_stats 2 {1 pending 1 transmitted}
       
    64     dtn::wait_for_bundle_stats 3 {1 pending 1 transmitted}
       
    65     
       
    66     testlog "checking that duplicates were detected properly"
       
    67     dtn::check_bundle_stats 0 {0 duplicate}
       
    68     if {[dtn::test_bundle_stats 1 {0 duplicate}]} {
       
    69         dtn::check_bundle_stats 2 {1 duplicate}
       
    70     } else {
       
    71         dtn::check_bundle_stats 1 {1 duplicate}
       
    72         dtn::check_bundle_stats 2 {0 duplicate}
       
    73     }
       
    74     dtn::check_bundle_stats 3 {1 duplicate}
       
    75 
       
    76     testlog "adding links from node 4 to/from nodes 2 and 3"
       
    77     tell_dtnd 4 link add $cl-link:4-2 \
       
    78 	    "$net::host(2):[dtn::get_port $cl 2]" $linktype $cl
       
    79     if {! [dtn::is_bidirectional $cl]} {
       
    80 	tell_dtnd 2 link add $cl-link:2-4 \
       
    81 		"$net::host(4):[dtn::get_port $cl 4]" $linktype $cl
       
    82     }
       
    83     tell_dtnd 4 link add $cl-link:4-3 \
       
    84 	    "$net::host(3):[dtn::get_port $cl 3]" $linktype $cl
       
    85     if {! [dtn::is_bidirectional $cl]} {
       
    86 	tell_dtnd 3 link add $cl-link:3-4 \
       
    87 		"$net::host(4):[dtn::get_port $cl 4]" $linktype $cl
       
    88     }
       
    89     
       
    90     testlog "checking the bundle is flooded to node 4 and back out"
       
    91     dtn::wait_for_bundle_stats 4 {1 pending 1 transmitted 1 duplicate}
       
    92     
       
    93     testlog "waiting for bundle to expire everywhere "
       
    94     dtn::wait_for_bundle_stats 0 {0 pending 1 expired}
       
    95     dtn::wait_for_bundle_stats 1 {0 pending 1 expired}
       
    96     dtn::wait_for_bundle_stats 2 {0 pending 1 expired}
       
    97     dtn::wait_for_bundle_stats 3 {0 pending 1 expired}
       
    98     dtn::wait_for_bundle_stats 4 {0 pending 1 expired}
       
    99 
       
   100     testlog "Test success!"
       
   101 }
       
   102 
       
   103 test::exit_script {
       
   104     testlog "Stopping all dtnds"
       
   105     dtn::stop_dtnd *
       
   106 }