Reputation: 43
when i want to implemented file .tcl in ns2 appear this phrase (segmentation fault (core dumped)) i dont know how to solve this . i use ns2 version 2.35 in centos 7
set ns [new Simulator]
#open nam file
set nf [open out.nam w]
$ns namtrace-all $nf
#set variables of topology
set lanNodes 5
set link("bandwidth") 5mb
set link("delay") 2ms
set link("queue") DropTail
#define two routers
set router0 [$ns node]
set router1 [$ns node]
#link two routers
$ns duplex-link $router0 $router1 2mb 2ms DropTail
#create and connect nodes with routers
for {set i 0}{$i < $lanNodes}{incr i} {
set n($i) [$ns node]
set n([expr $i+5]) [$ns node]
$ns duplex-link $n($i) $router0 $link("bandwidth") $link("delay") $link("queue")
$ns duplex-link $n([expr $i+5]) $router1 $link("bandwidth") $link("delay") $link("queue")
}
proc finish { } {
global ns nf
close $nf
$ns flush-trace
exec nam out.nam
exit
}
$ns at 5 "finish"
$ns run
Upvotes: 0
Views: 2863
Reputation: 5909
Your file runs OK in a 32bits OS, when the typo´s in line 16 are edited:
Wrong is : for {set i 0}{$i < $lanNodes}{incr i} {
Right is : for {set i 0} {$i < $lanNodes} {incr i} {
** Ns2 is for a 32bits OS. However a lot of simulations will also work with a 64bits OS.
-
Upvotes: 0