test/reactive-fragmentation.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 reactive-fragmentation
       
    18 net::num_nodes 2
       
    19 
       
    20 dtn::config
       
    21 dtn::config_interface tcp
       
    22 dtn::config_linear_topology ALWAYSON tcp true \
       
    23 	"test_write_delay=1000 segment_length=512"
       
    24 
       
    25 test::script {
       
    26     testlog "Running dtnds"
       
    27     dtn::run_dtnd *
       
    28 
       
    29     testlog "Waiting for dtnds to start up"
       
    30     dtn::wait_for_dtnd *
       
    31 
       
    32     dtn::tell_dtnd 1 tcl_registration dtn://host-1/test
       
    33 
       
    34     testlog "Waiting for links to open"
       
    35     dtn::wait_for_link_state 0 tcp-link:0-1 OPEN
       
    36     dtn::wait_for_link_state 1 tcp-link:1-0 OPEN
       
    37 
       
    38     testlog "Sending bundle"
       
    39     set timestamp [dtn::tell_dtnd 0 sendbundle \
       
    40 	    dtn://host-0/test dtn://host-1/test length=8096 expiration=3600]
       
    41 
       
    42     for {set i 0} {$i < 5} {incr i} {
       
    43 	set wait [expr 2000 + int(2500 * rand())]
       
    44 	testlog "Waiting [expr $wait / 1000] seconds"
       
    45 	after $wait
       
    46 	
       
    47 	testlog "Interrupting the link"
       
    48 	dtn::tell_dtnd 0 link close tcp-link:0-1 
       
    49 	dtn::wait_for_link_state 0 tcp-link:0-1 UNAVAILABLE
       
    50 	dtn::tell_dtnd 0 link open tcp-link:0-1
       
    51 	dtn::wait_for_link_state 0 tcp-link:0-1 OPEN
       
    52     }
       
    53 
       
    54     testlog "Waiting for the bundle to arrive and to be reassembled"
       
    55     dtn::wait_for_bundle 1 "dtn://host-0/test,$timestamp" 30
       
    56 
       
    57     testlog "Checking that no bundles are pending"
       
    58     dtn::wait_for_bundle_stats 0 {0 pending}
       
    59     dtn::wait_for_bundle_stats 1 {0 pending 1 delivered}
       
    60 
       
    61     testlog "Checking that it really did fragment"
       
    62     set stats [dtn::tell_dtnd 1 bundle stats]
       
    63     regexp {(\d+) received} $stats match received
       
    64     if {$received == 1} {
       
    65 	error "only one bundle received"
       
    66     }
       
    67     testlog "$received fragments received"
       
    68 
       
    69     testlog "Resetting stats"
       
    70     tell_dtnd 0 bundle reset_stats
       
    71     tell_dtnd 1 bundle reset_stats
       
    72 
       
    73     testlog "Disabling reactive fragmentation on node 1"
       
    74     tell_dtnd 0 link reconfigure tcp-link:0-1 reactive_frag_enabled=0
       
    75 
       
    76     testlog "Sending another bundle"
       
    77     set timestamp [dtn::tell_dtnd 0 sendbundle \
       
    78 	    dtn://host-0/test dtn://host-1/test length=8096 expiration=3600]
       
    79 
       
    80     for {set i 0} {$i < 5} {incr i} {
       
    81 	set wait [expr 2000 + int(2500 * rand())]
       
    82 	testlog "Waiting [expr $wait / 1000] seconds"
       
    83 	after $wait
       
    84 	
       
    85 	testlog "Interrupting the link"
       
    86 	dtn::tell_dtnd 0 link close tcp-link:0-1 
       
    87 	dtn::wait_for_link_state 0 tcp-link:0-1 UNAVAILABLE
       
    88 	dtn::tell_dtnd 0 link open tcp-link:0-1
       
    89 	dtn::wait_for_link_state 0 tcp-link:0-1 OPEN
       
    90     }
       
    91 
       
    92     testlog "Waiting for the bundle to arrive and to be reassembled"
       
    93     dtn::wait_for_bundle 1 "dtn://host-0/test,$timestamp" 30
       
    94 
       
    95     testlog "Checking that no bundles are pending"
       
    96     dtn::wait_for_bundle_stats 0 {0 pending}
       
    97     dtn::wait_for_bundle_stats 1 {0 pending 1 delivered}
       
    98 
       
    99     testlog "Checking that it really did fragment"
       
   100     set stats [dtn::tell_dtnd 1 bundle stats]
       
   101     regexp {(\d+) received} $stats match received
       
   102     if {$received == 1} {
       
   103 	error "only one bundle received"
       
   104     }
       
   105     testlog "$received fragments received"
       
   106 
       
   107     testlog "Test success!"
       
   108 }
       
   109 
       
   110 test::exit_script {
       
   111     testlog "Stopping all dtnds"
       
   112     dtn::stop_dtnd *
       
   113 }