test/comparison/base-dtn.conf
changeset 0 2b3e5ec03512
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/comparison/base-dtn.conf	Thu Apr 21 14:57:45 2011 +0100
@@ -0,0 +1,231 @@
+
+# Start of base-dtn conf file
+# Use in conjuction with dtn-cmd-half.sh
+# Needs value of :  $id, $maxnodes, $tmp_logdir, $perhop, dtn2testroot, localdir
+# set id 1
+# set maxnodes 4
+# set perhop 0
+# set tmp_logdir /tmp/$exp/$nodeid
+# set dtn2testroot /proj/DTN/nsdi/DTN2/test
+# set localdir  ...
+# set ftplogfile  ...
+
+
+set fd_ftplog [open $ftplogfile w]
+
+log /daemon INFO "bundle daemon config running for node id $id..."
+
+log /daemon INFO "incoming bundles are in $localdir "
+
+
+
+
+set tmpdir $tmp_logdir
+set localhost node-$id
+
+set dest node-$maxnodes
+
+
+set tidy    [storage set tidy]
+set port 5000
+set region emulab
+
+
+set dbdir "$tmpdir/bundledb"
+set payloaddir  "$tmpdir/bundles"
+
+
+
+
+#
+# pull in the test utilities
+#
+
+source "$dtn2testroot/file-injector.tcl"
+source "$dtn2testroot/tcl-registration.tcl"
+
+foreach dir [list $dbdir $payloaddir ] {
+	if {! [file exists $dir]} {
+	    file mkdir $dir
+	}
+}
+
+# clean up
+if {$tidy} {
+    puts "tidy option set, cleaning payload and local file dirs"
+    foreach dir [list  $dbdir $payloaddir] {
+	file delete -force $dir
+	file mkdir $dir
+    }
+}
+
+# validate the directories (XXX/demmer move this into C eventually)
+foreach dirtype [list  dbdir payloaddir] {
+    set dir [set $dirtype]
+    if {! [file exists $dir]} {
+	error "$dirtype directory $dir doesn't exist"
+    }
+    
+    if {[file type $dir] != "directory"} {
+	error "$dirtype directory $dir is not a directory"
+    }
+
+    if {[glob -nocomplain $dir/*] != {}} {
+	error "$dirtype directory $dir not empty and re-reading state not implemented \
+		(use the -t option)"
+    }
+}
+
+
+
+# initialize storage
+storage set dbdir $dbdir
+# XXX/demmer make this "storage type"
+storage init berkeleydb
+
+# set the payload directory and other params
+param set payload_dir $payloaddir
+param set tcpcl_ack_blocksz 4096
+
+param set proactive_frag_threshold 40960
+
+# param set payload_test_no_remove true
+param set tcpcl_test_fragment_size 40000
+
+
+# set a local tcp interface
+#if {$id != 1} {
+#    set localhost node-$id-link-[expr $id - 1]
+#}
+
+set tcp_local_eid bundles://$region/tcp://$localhost:$port/
+interface $tcp_local_eid
+
+# and a file one
+# set file_local_eid file://unix/file://$localdir/
+# interface $file_local_eid
+
+
+#
+# set up routing...
+# Line topology assumed
+
+
+set peer node-[expr $id + 1]
+
+# Set up e2e routing for source 
+if {$perhop == 0} {
+    if {$id == 1} {
+	set peer node-$maxnodes
+    }
+}
+
+
+# No routing next hop for end of the line topology
+if {$id != $maxnodes} {
+    set tcp_peer_eid bundles://$region/tcp://$peer:$port/
+    # with a tcp route 
+#    route add bundles://$region/bundles://$peer/* $tcp_peer_eid ONDEMAND
+#      route add bundles://$region/bundles://*/* $tcp_peer_eid ONDEMAND
+    route add bundles://$region/bundles://$dest/* $tcp_peer_eid ONDEMAND
+
+    log /daemon INFO "route added FOR $dest through  $tcp_peer_eid"
+
+}
+
+
+
+#
+# Use the initscript hook to store some code we want run only _after_
+# everything else is initialized
+#
+
+
+
+
+proc time {} {
+    return [clock seconds]
+}
+
+proc test_bundle_arrived {regid bundle_info} {
+
+    array set b $bundle_info
+    global fd_ftplog
+    if ($b(is_admin)) {
+	error "Unexpected admin bundle arrival $b(source) -> b($dest)"
+    }
+    log /daemon INFO "bundle arrival"
+    foreach {key val} [array get b] {
+	if {$key == "payload"} {
+	    log /daemon INFO "payload:\t [string range $b(payload) 0 64]"
+	} else {
+	    log /daemon INFO "$key:\t $b($key)"
+	}
+    }
+    ## Hack for file tail XXX sushant, check ??
+    set tmp ":: bundle arrived [file tail $source] --> [file tail $b(dest)] length $b(length)"
+
+    log /file_injector INFO $tmp
+    puts $fd_ftplog "[time] $tmp"
+    flush $fd_ftplog
+}
+
+
+   
+
+# test proc for sending a bundle
+proc sendbundle {node} {
+
+    global localhost peer port region
+    set length  1048576
+    set length  5000
+
+    set payload "test bundle payload data\n"
+
+    while {$length - [string length $payload] > 32} {
+	append payload [format "%4d: 0123456789abcdef\n" [string length $payload]]
+    }
+    while {$length > [string length $payload]} {
+	append payload "."
+    }
+    
+    bundle inject bundles://$region/bundles://$localhost/	\
+	    	  bundles://$region/bundles://$node/demux	\
+                  $payload                                      \
+                  option [list length $length]
+}
+
+
+######################################
+#For source
+
+if {$id == 1} {
+    log /daemon INFO "At source starting file injector start "
+    log /daemon INFO "Local dir is: $localdir , Dest is  $dest "
+    
+    test set initscript {
+	file_injector_start $localdir bundles://$region/bundles://$localhost/ \
+	    bundles://$region/bundles://$dest/demux
+    }
+}
+
+if {$id < $maxnodes} {
+    if {$id != 1} {
+	#For intermediate nodes
+	log /daemon INFO "At forwarding nodes registring logging "
+	test set initscript {
+	    registration add logger bundles://*/*
+	}
+    }
+}
+
+#For dest  nodes
+
+if {$id == $maxnodes} {
+    log /daemon INFO "At destination registring initscript "
+    test set initscript {
+	tcl_registration bundles://*/* test_bundle_arrived
+    }
+}   
+
+######################################