Commit 69ecf90c authored by Christopher Alfeld's avatar Christopher Alfeld

This program will take a ns file as command line and generate a full IR

file ready for tbrun.
parent b33aaa35
tbsetup
Syntax:
tbsetup <ns-file>
tbsetup does all tasks necessary to setup up for an experiment on the
testbed. It generates an IR file that can be used with 'tbrun' to
actually configure the testbed.
#!/usr/local/bin/tclsh
if {[file dirname [info script]] == "."} {
set updir ".."
} else {
set updir [file dirname [file dirname [info script]]]
}
set ns2ir "$updir/ir/ns2ir/parse.tcl"
set assign "$updir/ir/assign.tcl"
if {$argc != 1} {
puts stderr "Syntax: $argv0 <ns-file>"
exit 1
}
set nsFile [lindex $argv 0]
set t [split $nsFile .]
set prefix [join [lrange $t 0 [expr [llength $t] - 2]] .]
set irFile "$prefix.ir"
set logFile "$prefix.log"
if {[catch "open $logFile w" logFp]} {
puts stderr "Could not open $logFile for writing."
exit 1
}
puts "Input: $nsFile"
puts "Output: $irFile"
puts "Log: $logFile"
if {! [file exists $nsFile]} {
puts stderr "$nsFile does not exist"
exit 1
}
puts "Parsing ns input."
if {[catch "exec $ns2ir $nsFile $irFile >@ $logFp 2>@ $logFp" err]} {
puts stderr "Error parsing ns input. ($err)"
exit 1
}
if {! [file exists $irFile]} {
puts stderr "$irFile not generated. Make sure you have a 'run' command in your ns file."
exit 1
}
puts "PLACEHOLDER - Determining available resources."
puts "Allocating resources - This may take a while."
if {[catch "exec $assign $irFile >@ $logFp 2>@ $logFp" err]} {
puts stderr "Error allocating resources. ($err)"
exit 1
}
puts "PLACEHODLER - Reserving resources."
puts "Setup finished - $irFile generated."
set ns [new Simulator]
set n0 [$ns node]
set n1 [$ns node]
set n2 [$ns node]
$ns duplex-link $n0 $n1 100Mb 10ms DropTail
$ns duplex-link $n1 $n2 100Mb 10ms DropTail
$ns run
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment