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

[ns] silly problem



I am having ns dump core with this simple script. am i missing something ?

Debo

-----

#Create a simulator object
set ns [new Simulator]
set N 5

#Open the nam trace file
set f [open out.tr w]
set nf [open out.nam w]
$ns trace-all $f
$ns namtrace-all $nf

#Define a 'finish' procedure
proc finish {} {
    global ns nf f
    $ns flush-trace
    #Close the trace file
    close $nf
    close $f
    #Execute nam on the trace file
    # exec nam out.nam &
    exit 0
}

#Create  nodes
for {set i 1} {$i < $N} {incr i} {    
    set n($i) [$ns node]
}


#Create links between the nodes
$ns duplex-link $n(1) $n(2) 1Mb 25ms DropTail
$ns duplex-link $n(2) $n(3) 1Mb 25ms DropTail
$ns duplex-link $n(3) $n(4) 1Mb 25ms DropTail
$ns duplex-link $n(4) $n(1) 1Mb 25ms DropTail

# echo  "Well links have been created"

# Create tcp agents
# Create sink agents
# Create traffic agents

for {set i 1} {$i < $N} {incr i} {   
    for {set j 1} {$i < $N} {incr i} {
	set tcp($i:$j) [new Agent/TCP]
	set exp($i:$j) [new Application/Traffic/Exponential]
	set sink($i:$j) [new Agent/TCPSink]
    }
}

# Attach the agents and connect the stuff

for {set i 1} {$i < $N} {incr i} {  
    for {set j 1} {$i < $N} {incr i} {
	$ns attach-agent $n($i) $tcp($i:$j)
	$ns attach-agent $n($j) $sink($i:$j)
	$ns connect $tcp($i:$j) $sink($i:$j)
	$exp($i:$j) attach-agent $tcp($i:$j)
    }
}


#Schedule events for the traffic agents
for {set i 1} {$i < $N} {incr i} {  
    for {set j 1} {$i < $N} {incr i} {
	$ns at 0.0 "$exp($i:$j)  start"
    }
}



#Call the finish procedure after 5 seconds of simulation time
$ns at 5.0 "finish"

#Run the simulation
$ns run