test/multipath-forwarding.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 multipath-forwarding
       
    18 net::num_nodes 4
       
    19 
       
    20 dtn::config
       
    21 
       
    22 set clayer   tcp
       
    23 
       
    24 foreach {var val} $opt(opts) {
       
    25     if {$var == "-cl" || $var == "cl"} {
       
    26 	set clayer $val
       
    27     } else {
       
    28 	testlog error "ERROR: unrecognized test option '$var'"
       
    29 	exit 1
       
    30     }
       
    31 }
       
    32 
       
    33 testlog "Configuring $clayer interfaces / links"
       
    34 dtn::config_interface $clayer
       
    35 dtn::config_diamond_topology ALWAYSON $clayer true
       
    36 
       
    37 test::script {
       
    38     testlog "Running dtnds"
       
    39     dtn::run_dtnd *
       
    40 
       
    41     testlog "Waiting for dtnds to start up"
       
    42     dtn::wait_for_dtnd *
       
    43 
       
    44     dtn::tell_dtnd 3 tcl_registration dtn://host-3/test
       
    45     
       
    46     testlog "Waiting for links to open"
       
    47     dtn::wait_for_link_state 0 tcp-link:0-1 OPEN
       
    48     dtn::wait_for_link_state 0 tcp-link:0-2 OPEN
       
    49 
       
    50     testlog "adding write delay to node 0 links"
       
    51     tell_dtnd 0 link reconfigure tcp-link:0-1 \
       
    52 	    test_write_delay=500 sendbuf_len=1024
       
    53     tell_dtnd 0 link reconfigure tcp-link:0-2 \
       
    54 	    test_write_delay=500 sendbuf_len=1024
       
    55 
       
    56     testlog "*"
       
    57     testlog "* Test 1: equal size bundles, equal priority routes"
       
    58     testlog "*"
       
    59 
       
    60     testlog "sending 20 bundles"
       
    61     for {set i 0} {$i < 20} {incr i} {
       
    62 	tell_dtnd 0 sendbundle dtn://host-0/test dtn://host-3/test length=2048
       
    63     }
       
    64 
       
    65     testlog "waiting for all to be transmitted"
       
    66     dtn::wait_for_bundle_stats 0 {0 pending 20 transmitted} 60
       
    67     
       
    68     testlog "checking they were load balanced"
       
    69     dtn::check_link_stats 0 tcp-link:0-1 10 bundles_transmitted
       
    70     dtn::check_link_stats 0 tcp-link:0-2 10 bundles_transmitted
       
    71 
       
    72     testlog "waiting for delivery"
       
    73     dtn::wait_for_bundle_stats 1 {0 pending 10 received 10 transmitted}
       
    74     dtn::wait_for_bundle_stats 2 {0 pending 10 received 10 transmitted}
       
    75     dtn::wait_for_bundle_stats 3 {0 pending 20 delivered 0 duplicate}
       
    76     
       
    77     dtn::tell_dtnd * bundle reset_stats
       
    78     
       
    79     testlog "*"
       
    80     testlog "* Test 2: equal size bundles, different priority routes"
       
    81     testlog "*"
       
    82 
       
    83     # XXX/demmer fixme
       
    84     if {1} {
       
    85         testlog "WARNING: priority-based forwarding no longer works"
       
    86     } else {
       
    87         
       
    88     testlog "swapping routes on node 0"
       
    89     tell_dtnd 0 route del dtn://host-3/*
       
    90     tell_dtnd 0 route add dtn://host-3/* tcp-link:0-1 route_priority=100
       
    91     tell_dtnd 0 route add dtn://host-3/* tcp-link:0-2 route_priority=0
       
    92     
       
    93     testlog "sending 20 bundles"
       
    94     for {set i 0} {$i < 20} {incr i} {
       
    95 	tell_dtnd 0 sendbundle dtn://host-0/test dtn://host-3/test length=2048
       
    96     }
       
    97 
       
    98     testlog "waiting for all to be transmitted"
       
    99     dtn::wait_for_bundle_stats 0 {0 pending 20 transmitted} 60
       
   100     
       
   101     testlog "checking they all went on one link"
       
   102     dtn::wait_for_link_stats 0 tcp-link:0-1 {20 bundles_transmitted}
       
   103     dtn::wait_for_link_stats 0 tcp-link:0-2 {0  bundles_transmitted}
       
   104 
       
   105     testlog "waiting for delivery"
       
   106     dtn::wait_for_bundle_stats 1 {0 pending 20 received 20 transmitted}
       
   107     dtn::wait_for_bundle_stats 2 {0 pending 0 received 0 transmitted}
       
   108     dtn::wait_for_bundle_stats 3 {0 pending 20 delivered 0 duplicate}
       
   109 
       
   110     testlog "swapping back routes on node 0"
       
   111     tell_dtnd 0 route del dtn://host-3/*
       
   112     tell_dtnd 0 route add dtn://host-3/* tcp-link:0-1
       
   113     tell_dtnd 0 route add dtn://host-3/* tcp-link:0-2
       
   114     
       
   115     dtn::tell_dtnd * bundle reset_stats
       
   116     }
       
   117     
       
   118     testlog "*"
       
   119     testlog "* Test 3: copy routes"
       
   120     testlog "*"
       
   121 
       
   122     testlog "swapping routes on node 0"
       
   123     tell_dtnd 0 route del dtn://host-3/*
       
   124     tell_dtnd 0 route add dtn://host-3/* tcp-link:0-1 route_priority=100 
       
   125     tell_dtnd 0 route add dtn://host-3/* tcp-link:0-2 \
       
   126 	    route_priority=0 action=copy
       
   127 
       
   128     testlog "sending 20 bundles (to different destination)"
       
   129     for {set i 0} {$i < 20} {incr i} {
       
   130 	tell_dtnd 0 sendbundle dtn://host-0/test dtn://host-3/test2 length=2048
       
   131     }
       
   132 
       
   133     testlog "waiting for all to be transmitted"
       
   134     dtn::wait_for_bundle_stats 0 {0 pending 40 transmitted} 60
       
   135     
       
   136     testlog "checking they all went on both links"
       
   137     dtn::wait_for_link_stats 0 tcp-link:0-1 {20 bundles_transmitted}
       
   138     dtn::wait_for_link_stats 0 tcp-link:0-2 {20 bundles_transmitted}
       
   139 
       
   140     testlog "waiting for arrival"
       
   141     dtn::wait_for_bundle_stats 1 {0 pending 20 received 20 transmitted 0 duplicate}
       
   142     dtn::wait_for_bundle_stats 2 {0 pending 20 received 20 transmitted 0 duplicate}
       
   143     dtn::wait_for_bundle_stats 3 {20 pending 0 delivered 20 duplicate}
       
   144 
       
   145     testlog "adding registration, waiting for delivery"
       
   146     dtn::tell_dtnd 3 tcl_registration dtn://host-3/test2
       
   147     dtn::wait_for_bundle_stats 3 {0 pending 20 delivered 20 duplicate}
       
   148     
       
   149     dtn::tell_dtnd * bundle reset_stats
       
   150     
       
   151     testlog "*"
       
   152     testlog "* Test 4: wildcard destination"
       
   153     testlog "*"
       
   154 
       
   155     testlog "adding different priority routes on node 0"
       
   156     tell_dtnd 0 route del dtn://host-3/*
       
   157     tell_dtnd 0 route add dtn://host-3/* tcp-link:0-1 route_priority=100 
       
   158     tell_dtnd 0 route add dtn://host-3/* tcp-link:0-2 route_priority=0
       
   159 
       
   160     testlog "sending 20 bundles to dummy wildcard destination"
       
   161     for {set i 0} {$i < 20} {incr i} {
       
   162 	tell_dtnd 0 sendbundle dtn://host-0/test dtn://*/nowhere length=2048
       
   163     }
       
   164 
       
   165     # XXX/demmer it would be better to have a registration that these
       
   166     # are going to, but the problem is that we don't keep track of all
       
   167     # duplicates in the core bundle daemon, so it's non-deterministic
       
   168     # how many will actually get delivered
       
   169 
       
   170     testlog "waiting for all to be transmitted on both links"
       
   171     dtn::wait_for_bundle_stats 0 {0 pending 0 delivered 40 transmitted} 60
       
   172     dtn::wait_for_link_stats 0 tcp-link:0-1 {20 bundles_transmitted}
       
   173     dtn::wait_for_link_stats 0 tcp-link:0-2 {20 bundles_transmitted}
       
   174 
       
   175     dtn::tell_dtnd * bundle reset_stats
       
   176     
       
   177     testlog "Test success!"
       
   178 }
       
   179 
       
   180 test::exit_script {
       
   181     testlog "Stopping all dtnds"
       
   182     dtn::stop_dtnd *
       
   183 }