test/prophet.tcl
changeset 0 2b3e5ec03512
equal deleted inserted replaced
-1:000000000000 0:2b3e5ec03512
       
     1 #
       
     2 #    Copyright 2007 Baylor University
       
     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 # name of test
       
    18 test::name prophet
       
    19 
       
    20 # XXX/wilson automate these and other args
       
    21 # number of participating nodes
       
    22 net::num_nodes 3
       
    23 set length 5000
       
    24 set cl tcp
       
    25 
       
    26 dtn::config --router_type prophet --no_null_link
       
    27 
       
    28 testlog "Configuring tcp interfaces / links"
       
    29 dtn::config_interface $cl
       
    30 dtn::config_linear_topology OPPORTUNISTIC $cl false
       
    31 
       
    32 set link1 $cl-link:1-0
       
    33 set link2 $cl-link:2-1
       
    34 
       
    35 # Test plan:
       
    36 #   Send bundle from 2 to 0 before any routes are discovered
       
    37 #   Bring up link from 1 to 0 to introduce the route
       
    38 #   Bring down link from 1 to 0
       
    39 #   Bring up link from 2 to 1 to introduce the route
       
    40 #   Bring down link from 2 to 1
       
    41 #   Bring up link from 1 to 0
       
    42 #   Check that bundle is delivered to 0
       
    43 
       
    44 test::script {
       
    45     testlog "Running dtnds"
       
    46     dtn::run_dtnd *
       
    47 
       
    48     testlog "Waiting for dtnds to start up"
       
    49     dtn::wait_for_dtnd *
       
    50 
       
    51 #   Send bundle from 2 to 0 before any routes are discovered
       
    52     set source dtn://host-2
       
    53     set dest   dtn://host-0/test
       
    54     dtn::tell_dtnd 0 tcl_registration $dest
       
    55 
       
    56     testlog "Sending bundle from 2 to 0"
       
    57     set timestamp [dtn::tell_dtnd 2 sendbundle $source $dest length=$length]
       
    58 
       
    59 #   Bring up link from 1 to 0 to introduce the route
       
    60     testlog "Tickle $link1 on 1 to emulate discovery"
       
    61     dtn::tell_dtnd 1 link set_available $link1 true
       
    62 
       
    63     # wait for stuff to happen
       
    64     after 2000
       
    65 
       
    66 #   Bring down link from 1 to 0
       
    67     testlog "Disable $link1 on 1 to emulate \"out of range\""
       
    68     dtn::tell_dtnd 1 link set_available $link1 false
       
    69 
       
    70     # now 1 and 0 know each other
       
    71 
       
    72 #   Bring up link from 2 to 1 to introduce the route
       
    73     testlog "Tickle $link2 on 2 to emulate discovery"
       
    74     dtn::tell_dtnd 2 link set_available $link2 true
       
    75 
       
    76     # wait for stuff to happen
       
    77     after 2000
       
    78 
       
    79 #   Bring down link from 2 to 1
       
    80     testlog "Disable $link2 on 2 to emulate \"out of range\""
       
    81     dtn::tell_dtnd 2 link set_available $link2 false
       
    82 
       
    83 #   Bring up link from 1 to 0
       
    84     testlog "Tickle $link1 on 1 to emulate discovery"
       
    85     dtn::tell_dtnd 1 link set_available $link1 true
       
    86 
       
    87     # wait for stuff to happen
       
    88     after 2000
       
    89 
       
    90 #   Check that bundle is delivered to 0
       
    91     testlog "Waiting for bundle arrival on 0"
       
    92     dtn::wait_for_bundle 0 "$source,$timestamp" 30
       
    93     testlog "Checking bundle data"
       
    94     dtn::check_bundle_data 0 "$source,$timestamp" \
       
    95          is_admin 0 source $source dest $dest
       
    96 
       
    97     dtn::wait_for_bundle_stats 0 {1 delivered}
       
    98 
       
    99     testlog "Test success!"
       
   100 }
       
   101 
       
   102 test::exit_script {
       
   103     testlog "Stopping all dtnds"
       
   104     dtn::stop_dtnd *
       
   105 }