All new accounts created on Gitlab now require administrator approval. If you invite any collaborators, please let Flux staff know so they can approve the accounts.

Commit fc5a568f authored by Christopher Alfeld's avatar Christopher Alfeld

Added parsing support for make-lan. You can now have lans in your ns

files.  Note: none of the backend has been written yet.

Also did a number of minor bug fixes.  The most serious bug showed up when
you have a topology with no links.
parent 59abe444
Class lan
# print
# output format: <id> "<nodes>" <delay> <bw>
lan instproc print {file} {
global nodeid_map prefix
if {[info exists nodeid_map(lan[$self set id])]} {
set lanname $nodeid_map(lan[$self set id])
} else {
set lanname lan[$self set id]
}
puts -nonewline $file "$lanname \""
set lastnode [lindex [$self set nodes] end]
foreach node [$self set nodes] {
if {[info exists nodeid_map(n[$node set id])]} {
set nodename $nodeid_map(n[$node set id])
} else {
set nodename n[$self set id]
}
puts -nonewline $file "$nodename"
if {$node != $lastnode} {
puts -nonewline $file " "
}
}
puts -nonewline $file "\" [$self set bw] [$self set delay] "
$self instvar lanlinks
if {! [info exists lanlinks]} {
set lanlinks {}
}
foreach link [$self set lanlinks] {
puts -nonewline $file "$prefix-$link "
}
puts $file ""
}
#add link
lan instproc addlink {link} {
$self instvar lanlinks
lappend lanlinks $link
}
\ No newline at end of file
...@@ -5,6 +5,7 @@ Class node ...@@ -5,6 +5,7 @@ Class node
# output format is: nodeID type link(s) # output format is: nodeID type link(s)
node instproc print {file} { node instproc print {file} {
global nodeid_map global nodeid_map
global prefix
if {[info exists nodeid_map(n[$self set id])]} { if {[info exists nodeid_map(n[$self set id])]} {
set nodename $nodeid_map(n[$self set id]) set nodename $nodeid_map(n[$self set id])
...@@ -12,9 +13,12 @@ node instproc print {file} { ...@@ -12,9 +13,12 @@ node instproc print {file} {
set nodename n[$self set id] set nodename n[$self set id]
} }
$self instvar nodelinks $self instvar nodelinks
if {! [info exists nodelinks]} {
set nodelinks {}
}
puts -nonewline $file "$nodename [$self set type]" puts -nonewline $file "$nodename [$self set type]"
foreach link $nodelinks { foreach link $nodelinks {
puts -nonewline $file " $link" puts -nonewline $file " $prefix-$link"
} }
#we have to add ". bandwidth delay" to delay nodes. #we have to add ". bandwidth delay" to delay nodes.
if [string match [$self set type] delay] { if [string match [$self set type] delay] {
...@@ -31,3 +35,17 @@ node instproc addlink {link} { ...@@ -31,3 +35,17 @@ node instproc addlink {link} {
$self instvar nodelinks $self instvar nodelinks
lappend nodelinks $link lappend nodelinks $link
} }
#getLan/setLan
node instproc setLan {lan} {
$self set lan $lan
}
node instproc getLan {} {
$self instvar lan
if {![info exists lan]} {
$self set lan ""
}
return [$self set lan]
}
\ No newline at end of file
...@@ -13,6 +13,7 @@ source $libdir/tcl-object.tcl ...@@ -13,6 +13,7 @@ source $libdir/tcl-object.tcl
source $libdir/node.tcl source $libdir/node.tcl
source $libdir/link.tcl source $libdir/link.tcl
source $libdir/event.tcl source $libdir/event.tcl
source $libdir/lan.tcl
### ###
# calfeld@cs.utah.edu # calfeld@cs.utah.edu
...@@ -27,10 +28,11 @@ proc set {args} { ...@@ -27,10 +28,11 @@ proc set {args} {
if {! $skipset} { if {! $skipset} {
real_set skipset 1 real_set skipset 1
real_set var [lindex $args 0] real_set var [lindex $args 0]
if {$var != "currnode"} { if {$var != "currnode" && $var != "currlan"} {
if {[llength $args] > 1} { if {[llength $args] > 1} {
real_set val [lindex $args 1] real_set val [lindex $args 1]
if {[regexp {^n[0-9]+$} $val] != -1} { if {([regexp {^n[0-9]+$} $val] != -1) ||
([regexp {^lan[0-9]+$} $val] != -1)} {
if {![info exists nodeid_map($val)]} { if {![info exists nodeid_map($val)]} {
real_set nodeid_map($val) $var real_set nodeid_map($val) $var
} }
...@@ -55,6 +57,7 @@ proc nop {args} {} ...@@ -55,6 +57,7 @@ proc nop {args} {}
#begin at 0. 1,2,3... i cheerfully ignore the possibility of wrapping... #begin at 0. 1,2,3... i cheerfully ignore the possibility of wrapping...
set nodeID 0 set nodeID 0
set linkID 0 set linkID 0
set lanID 0
set eventID 0 set eventID 0
set nodelist {} set nodelist {}
...@@ -63,6 +66,8 @@ set linkslist {} ...@@ -63,6 +66,8 @@ set linkslist {}
set eventlist {} set eventlist {}
set lanlist {}
# sim.tcl handles the ns Simulator methods # sim.tcl handles the ns Simulator methods
source $libdir/sim.tcl source $libdir/sim.tcl
......
...@@ -35,7 +35,7 @@ ...@@ -35,7 +35,7 @@
# SUCH DAMAGE. # SUCH DAMAGE.
# #
# @(#) $Header: /home/cvs_mirrors/cvs-public.flux.utah.edu/CVS/testbed/tbsetup/ns2ir/Attic/sim.tcl,v 1.2 2000-10-18 22:21:48 calfeld Exp $ # @(#) $Header: /home/cvs_mirrors/cvs-public.flux.utah.edu/CVS/testbed/tbsetup/ns2ir/Attic/sim.tcl,v 1.3 2000-12-26 20:10:09 calfeld Exp $
# #
...@@ -178,6 +178,7 @@ Simulator instproc run {} { ...@@ -178,6 +178,7 @@ Simulator instproc run {} {
global nodelist global nodelist
global linkslist global linkslist
global eventlist global eventlist
global lanlist
global irfile global irfile
set IRfile [open $irfile w] set IRfile [open $irfile w]
...@@ -195,6 +196,13 @@ Simulator instproc run {} { ...@@ -195,6 +196,13 @@ Simulator instproc run {} {
$event print $IRfile $event print $IRfile
} }
puts $IRfile "END events" puts $IRfile "END events"
puts $IRfile "START lans"
foreach lan $lanlist {
$lan print $IRfile
}
puts $IRfile "END lans"
close $IRfile
} }
Simulator instproc halt {} { Simulator instproc halt {} {
...@@ -239,13 +247,13 @@ Simulator instproc duplex-link { n1 n2 bw delay type args } { ...@@ -239,13 +247,13 @@ Simulator instproc duplex-link { n1 n2 bw delay type args } {
# if there are delay or bandwidth restrictions, add a delay node # if there are delay or bandwidth restrictions, add a delay node
# and link to it # and link to it
# if {$delay!="" && $delay!=0 || $bw!="" && $bw!=0} { # if {$delay!="" && $delay!=0 || $bw!="" && $bw!=0} {
# #delaynode is not a 'real' Sim method. created for testbed. # #delaynode is not a 'real' Sim method. created for testbed.
# set dnode [$self delaynode [$self bw_parse $bw] [$self delay_parse $delay]] # set dnode [$self delaynode [$self bw_parse $bw] [$self delay_parse $delay]]
# #
# $self duplex-link $n1 $dnode 0 0 $type $args # $self duplex-link $n1 $dnode 0 0 $type $args
# $self duplex-link $n2 $dnode 0 0 $type $args # $self duplex-link $n2 $dnode 0 0 $type $args
# } # }
set currLink l$linkID set currLink l$linkID
link $currLink link $currLink
...@@ -474,3 +482,44 @@ Simulator instproc bw_parse { bspec } { ...@@ -474,3 +482,44 @@ Simulator instproc bw_parse { bspec } {
} }
} }
} }
######################################################################
# calfeld
# Lan code
######################################################################
Simulator instproc make-lan {nodelist bw delay
{llType LL}
{ifqType Queue/DropTail}
{macType Mac}
{chanType Channel}
{phyType Phy/WiredPhy}} {
global lanlist
global lanID
foreach node $nodelist {
if {[$node getLan] != {}} {
throw "$node already in a LAN!"
}
}
set currlan lan$lanID
lan $currlan
$currlan set nodes $nodelist
$currlan set bw $bw
$currlan set delay $delay
$currlan set id $lanID
foreach node $nodelist {
$node setLan $currlan
}
lappend lanlist $currlan
incr lanID
return $currlan
}
\ No newline at end of file
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