[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Bug about gen-map in the daily snapshot



Hi Alton,

Thank you very much for the code you sent me. I have figured out what is
wrong with the daily snapshot gen-map function. It is very useful for
getting the objects in the network. Hope it is useful for the other ns
users, too.

First, as Haobo mentioned before, in the following code, 'Node' should be
changed to 'Node_':
	if ![info exists Node_($i)] {
			incr i
			continue
		}

Second, the following code is missing right after the above code:
		set n $Node_($i)

Last, since the Agent class seems already changed somehow, it doesn't have
instvar portID_ and addr_ anymore. Change them to dst_port_ and dst_addr_ in
the following code:
		# Would be nice to dump agents attached to the dmux here?
		if {[llength [$n set agents_]] > 0} {
			puts "\n\tAgents at node (possibly in order of
creation):"
			foreach a [$n set agents_] {
		#		puts "\t\t$a\t[gc $a]\t\tportID: [$a set
portID_]([$a set addr_])"
			puts "\t\t$a\t[gc $a]\t\tportID: [$a set
dst_port_]([$a set dst_addr_])"		
			}
		}	

Now it can give us a clear report of what the network is composed of. We
only need to use 
$ns gen-map
to get the result.

Regards,
Huiwen
 

> -----Original Message-----
> From:	Yu, Alton [CAR:6T14:EXCH] 
> Sent:	Thursday, October 21, 1999 3:58 PM
> To:	Li, Huiwen [SC1:106:EXCH]
> Subject:	RE: Tcl problem & gen-map
> 
> Huiwen,
> 
> I am using the version ns-2.1b4a, and I had no problem 
> running it. Perhaps, try running the command at a later time 
> (e.g. at 0.1). Attach is the copy of gen-map function I have:
> 
> Simulator instproc gen-map {} {
> 	# Did you ever see such uglier code? duh?
> 	#
> 
> 	$self instvar Node_ link_
> 
> 	set nn [Node set nn_]
> 	for {set i 0} {$i < $nn} {incr i} {
> 		set n $Node_($i)
> 		puts "Node [$n tn]"
> 		foreach nc [$n info vars] {
> 			switch $nc {
> 				ns_		continue
> 				id_		continue
> 				neighbor_	continue
> 				agents_		continue
> 				routes_		continue
> 				np_		continue
> 				default {
> 					if [$n array exists $nc] {
> 						puts 
> "\t\t$nc\t[$n array get $nc]"
> 					} else {
> 						set v [$n set $nc]
> 						puts 
> "\t\t$nc${v}([gc $v])"
> 					}
> 				}
> 			}
> 		}
> 		# Would be nice to dump agents attached to the 
> dmux here?
> 		if {[llength [$n set agents_]] > 0} {
> 			puts "\n\tAgents at node (possibly in 
> order of creation):"
> 			foreach a [$n set agents_] {
> 				puts "\t\t$a\t[gc 
> $a]\t\tportID: [$a set portID_]([$a set addr_])"
> 			}
> 		}
> 		puts ""
> 		foreach li [array names link_ [$n id]:*] {
> 			set L [split $li :]
> 			set nbr [[$self get-node-by-id [lindex 
> $L 1]] entry]
> 			set ln $link_($li)
> 			puts "\tLink $ln, fromNode_ [[$ln set 
> fromNode_] tn] -> toNode_ [[$ln set toNode_] tn]"
> 			puts "\tComponents (in order) head first"
> 			for {set c [$ln head]} {$c != $nbr} 
> {set c [$c target]} {
> 				puts "\t\t$c\t[gc $c]"
> 			}
> 		}
> 		puts "---"
> 	}
> }