test/no-duplicate-send.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 no-duplicate-send
       
    18 net::num_nodes 3
       
    19 
       
    20 dtn::config
       
    21 
       
    22 set clayer tcp
       
    23 set length 5000
       
    24 
       
    25 foreach {var val} $opt(opts) {
       
    26     if {$var == "-cl" || $var == "cl"} {
       
    27 	set clayer $val
       
    28     } elseif {$var == "-length" || $var == "length"} {
       
    29         set length $val	
       
    30     } else {
       
    31 	puts "ERROR: unrecognized test option '$var'"
       
    32 	exit 1
       
    33     }
       
    34 }
       
    35 
       
    36 testlog "Configuring $clayer interfaces / links"
       
    37 dtn::config_interface $clayer
       
    38 dtn::config_linear_topology ALWAYSON $clayer true
       
    39 conf::add dtnd * "param set early_deletion false"
       
    40 
       
    41 test::script {
       
    42     testlog "Running dtnds"
       
    43     dtn::run_dtnd *
       
    44 
       
    45     testlog "Waiting for dtnds to start up"
       
    46     dtn::wait_for_dtnd *
       
    47     
       
    48     set last_node [expr [net::num_nodes] - 1]
       
    49     set source    [dtn::tell_dtnd $last_node {route local_eid}]
       
    50     set dest      dtn://host-0/test
       
    51     
       
    52     dtn::tell_dtnd 0 tcl_registration $dest
       
    53     
       
    54     testlog "Sending bundle"
       
    55     set timestamp [dtn::tell_dtnd $last_node sendbundle $source $dest length=$length]
       
    56     
       
    57     testlog "Waiting for bundle arrival"
       
    58     dtn::wait_for_bundle 0 "$source,$timestamp" 30
       
    59 
       
    60     testlog "Checking bundle data"
       
    61     dtn::check_bundle_data 0 "$source,$timestamp" \
       
    62 	    is_admin 0 source $source dest $dest
       
    63     
       
    64     testlog "Checking that bundle was received"
       
    65     dtn::wait_for_bundle_stat 0 1 received
       
    66     dtn::wait_for_bundle_stat 1 1 transmitted
       
    67     dtn::wait_for_bundle_stat 2 1 transmitted
       
    68 
       
    69     testlog "Checking that bundle still pending"
       
    70     dtn::wait_for_bundle_stat 0 1 pending
       
    71     dtn::wait_for_bundle_stat 1 1 pending
       
    72     dtn::wait_for_bundle_stat 2 1 pending
       
    73 
       
    74     testlog "Stopping and restarting link"
       
    75     dtn::tell_dtnd 2 link close tcp-link:2-1
       
    76     dtn::wait_for_link_state 2 tcp-link:2-1 UNAVAILABLE
       
    77     dtn::tell_dtnd 2 link open tcp-link:2-1
       
    78     dtn::wait_for_link_state 2 tcp-link:2-1 OPEN
       
    79 
       
    80     testlog "Checking that bundle was not retransmitted"
       
    81     dtn::wait_for_bundle_stat 0 1 received
       
    82     dtn::wait_for_bundle_stat 1 1 transmitted
       
    83     dtn::wait_for_bundle_stat 2 1 transmitted
       
    84     
       
    85     dtn::wait_for_bundle_stat 0 1 pending
       
    86     dtn::wait_for_bundle_stat 1 1 pending
       
    87     dtn::wait_for_bundle_stat 2 1 pending
       
    88     
       
    89     testlog "Test success!"
       
    90 }
       
    91 
       
    92 test::exit_script {
       
    93     testlog "Stopping all dtnds"
       
    94     dtn::stop_dtnd *
       
    95 }