test/reroute-topology.tcl
changeset 0 2b3e5ec03512
equal deleted inserted replaced
-1:000000000000 0:2b3e5ec03512
       
     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 reroute-topology
       
    18 net::num_nodes 4
       
    19 
       
    20 set testopt(cl)       tcp
       
    21 run::parse_test_opts
       
    22 
       
    23 set cl $testopt(cl)
       
    24 
       
    25 dtn::config
       
    26 dtn::config_interface $cl
       
    27 
       
    28 dtn::config_linear_topology ALWAYSON $cl true
       
    29 
       
    30 test::script {
       
    31     testlog "running dtnds"
       
    32     dtn::run_dtnd *
       
    33 
       
    34     testlog "waiting for dtnds to start up"
       
    35     dtn::wait_for_dtnd *
       
    36 
       
    37     set source    dtn://host-0/test
       
    38     set dest      dtn://host-3/test
       
    39     dtn::tell_dtnd 3 tcl_registration $dest
       
    40 
       
    41     set addr0 $net::internal_host(3):[dtn::get_port $cl 0]
       
    42     set addr1 $net::internal_host(3):[dtn::get_port $cl 1]
       
    43     set addr2 $net::internal_host(3):[dtn::get_port $cl 2]
       
    44     set addr3 $net::internal_host(3):[dtn::get_port $cl 3]
       
    45     
       
    46     testlog "waiting for links to establish"
       
    47     dtn::wait_for_link_state 0 null OPEN
       
    48     dtn::wait_for_link_state 0 $cl-link:0-1 OPEN
       
    49     dtn::wait_for_link_state 1 $cl-link:1-0 OPEN
       
    50     dtn::wait_for_link_state 1 $cl-link:1-2 OPEN
       
    51     dtn::wait_for_link_state 2 $cl-link:2-1 OPEN
       
    52     dtn::wait_for_link_state 2 $cl-link:2-3 OPEN
       
    53     dtn::wait_for_link_state 3 $cl-link:3-2 OPEN
       
    54 
       
    55     testlog "closing link from 2-3"
       
    56     tell_dtnd 2 link close $cl-link:2-3
       
    57     dtn::wait_for_link_state 2 $cl-link:2-3 UNAVAILABLE
       
    58     
       
    59     testlog "adding a second link from 2-3 and a route to it"
       
    60     tell_dtnd 2 link add alt-$cl-link:2-3 $addr3 OPPORTUNISTIC $cl remote_eid=dtn://host-3
       
    61     tell_dtnd 2 route add dtn://host-3/* alt-$cl-link:2-3
       
    62 
       
    63     testlog "sending a bundle"
       
    64     set timestamp1 [dtn::tell_dtnd 0 sendbundle $source $dest]
       
    65 
       
    66     testlog "checking that it's deferred on both links"
       
    67     dtn::wait_for_bundle_stats 2 {1 pending}
       
    68     dtn::wait_for_link_stats 2 $cl-link:2-3 {1 bundles_deferred}
       
    69     dtn::wait_for_link_stats 2 alt-$cl-link:2-3 {1 bundles_deferred}
       
    70 
       
    71     testlog "opening one link, checking that it gets sent"
       
    72     tell_dtnd 2 link open alt-$cl-link:2-3
       
    73     dtn::wait_for_bundle_stats 2 {0 pending}
       
    74     dtn::wait_for_link_stats 2 $cl-link:2-3 {0 bundles_deferred}
       
    75     dtn::wait_for_link_stats 2 alt-$cl-link:2-3 {0 bundles_deferred 1 bundles_transmitted}
       
    76 
       
    77     testlog "waiting for delivery"
       
    78     dtn::wait_for_bundle_stats 3 {1 delivered}
       
    79 
       
    80     testlog "checking it was deleted everywhere"
       
    81     dtn::check_bundle_stats 0 {0 pending}
       
    82     dtn::check_bundle_stats 1 {0 pending}
       
    83     dtn::check_bundle_stats 2 {0 pending}
       
    84     dtn::check_bundle_stats 3 {0 pending}
       
    85 
       
    86     tell_dtnd * bundle reset_stats
       
    87 
       
    88     testlog "closing the link again"
       
    89     tell_dtnd 2 link close alt-$cl-link:2-3
       
    90     dtn::wait_for_link_state 2 $cl-link:2-3 UNAVAILABLE
       
    91 
       
    92     testlog "sending another bundle"
       
    93     set timestamp2 [dtn::tell_dtnd 0 sendbundle $source $dest expiration=5]
       
    94 
       
    95     testlog "checking that it's deferred on both links"
       
    96     dtn::wait_for_bundle_stats 2 {1 pending}
       
    97     dtn::wait_for_link_stats 2 $cl-link:2-3 {1 bundles_deferred}
       
    98     dtn::wait_for_link_stats 2 alt-$cl-link:2-3 {1 bundles_deferred}
       
    99 
       
   100     testlog "checking that only one copy exists"
       
   101     dtn::wait_for_bundle_stats 0 {0 pending}
       
   102     dtn::wait_for_bundle_stats 1 {0 pending}
       
   103     dtn::wait_for_bundle_stats 3 {0 pending}
       
   104 
       
   105     testlog "waiting for it to expire"
       
   106     dtn::wait_for_bundle_stats 2 {1 expired}
       
   107     dtn::wait_for_bundle_stats 2 {0 pending}
       
   108     dtn::wait_for_link_stats 2 $cl-link:2-3 {0 bundles_deferred}
       
   109     dtn::wait_for_link_stats 2 alt-$cl-link:2-3 {0 bundles_deferred}
       
   110 
       
   111     tell_dtnd * bundle reset_stats
       
   112     
       
   113     testlog "sending another set of bundles, waiting for them to be deferred on both links"
       
   114     dtn::tell_dtnd 0 sendbundle $source $dest expiration=120
       
   115     dtn::tell_dtnd 0 sendbundle $source $dest expiration=120
       
   116     dtn::tell_dtnd 0 sendbundle $source $dest expiration=120
       
   117     dtn::tell_dtnd 0 sendbundle $source $dest expiration=120
       
   118     dtn::tell_dtnd 0 sendbundle $source $dest expiration=120
       
   119     
       
   120     dtn::wait_for_bundle_stats 2 {5 pending}
       
   121     dtn::wait_for_link_stats 2 $cl-link:2-3 {5 bundles_deferred}
       
   122     dtn::wait_for_link_stats 2 alt-$cl-link:2-3 {5 bundles_deferred}
       
   123 
       
   124     testlog "adding links between node 1 and node 3"
       
   125     tell_dtnd 1 link add $cl-link:1-3 $addr3 opportunistic tcp remote_eid=dtn://host-3
       
   126     tell_dtnd 3 link add $cl-link:3-1 $addr1 opportunistic tcp remote_eid=dtn://host-1
       
   127     tell_dtnd 1 link open $cl-link:1-3
       
   128     dtn::wait_for_link_state 1 $cl-link:1-3 OPEN
       
   129     dtn::wait_for_link_state 3 $cl-link:3-1 OPEN
       
   130 
       
   131     testlog "switching routes on node 1 to node 3 and vice versa"
       
   132     tell_dtnd 1 route del dtn://host-3/*
       
   133     tell_dtnd 1 route add dtn://host-3/* $cl-link:1-3
       
   134 
       
   135     tell_dtnd 3 route del dtn://host-1/*
       
   136     tell_dtnd 3 route add dtn://host-1/* $cl-link:3-1
       
   137 
       
   138     testlog "switching routes on node 2"
       
   139     tell_dtnd 2 route del dtn://host-3/*
       
   140     tell_dtnd 2 route add dtn://host-3/* $cl-link:2-1
       
   141 
       
   142     testlog "checking that bundles were properly sent from node 2"
       
   143     dtn::wait_for_link_stats 2 $cl-link:2-3 {0 bundles_deferred}
       
   144     dtn::wait_for_link_stats 2 alt-$cl-link:2-3 {0 bundles_deferred}
       
   145 
       
   146     testlog "checking that bundles were delivered"
       
   147     dtn::wait_for_bundle_stats 3 {5 delivered}
       
   148 
       
   149     testlog "making sure no bundles are pending"
       
   150     dtn::wait_for_bundle_stats 0 {0 pending}
       
   151     dtn::wait_for_bundle_stats 1 {0 pending}
       
   152     dtn::wait_for_bundle_stats 2 {0 pending}
       
   153     dtn::wait_for_bundle_stats 3 {0 pending}
       
   154 }
       
   155 
       
   156 test::exit_script {
       
   157     testlog "stopping all dtnds"
       
   158     dtn::stop_dtnd *
       
   159 }