[ns] pls help me to solve this error

priyadharshini Manoharan priyadharshini.manoharan at gmail.com
Sun Jan 20 20:11:43 PST 2008


#create a simulator object
set ns [new Simulator]

#Define differentcolors
$ns color 1 Blue
$ns color 2 Red

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

#Define a finish procedure
proc finish {} {
    global ns nf
    $ns flush-trace
    #close the NAM trace file
    close $nf
    #execute NAM on the trace file
    exec nam out nam &
    exit 0
}

#create nodes
set n0 [$ns node]
set n1 [$ns node]
set n2 [$ns node]
set n3 [$ns node]
set n4 [$ns node]
set n5 [$ns node]
set n6 [$ns node]
set n7 [$ns node]
set n8 [$ns node]
set n9 [$ns node]
set n10 [$ns node]
set n11 [$ns node]

#create link between nodes
$ns duplex-link $n0 $n1 2Mb 10ms DropTail
$ns duplex-link $n1 $n2 2Mb 10ms DropTail
$ns duplex-link $n2 $n3 2Mb 10ms DropTail
$ns duplex-link $n3 $n4 2Mb 10ms DropTail
$ns duplex-link $n1 $n5 2Mb 10ms DropTail
$ns duplex-link $n5 $n6 2Mb 10ms DropTail
$ns duplex-link $n2 $n6 2Mb 10ms DropTail
$ns duplex-link $n6 $n7 2Mb 10ms DropTail
$ns duplex-link $n3 $n7 2Mb 10ms DropTail
$ns duplex-link $n7 $n4 2Mb 10ms DropTail
#Ficitious link so delay taken as 1s
$ns duplex-link $n0 $n0 2Mb 1s DropTail
$ns duplex-link $n1 $n1 2Mb 1s DropTail
$ns duplex-link $n2 $n2 2Mb 1s DropTail
$ns duplex-link $n3 $n3 2Mb 1s DropTail
$ns duplex-link $n4 $n4 2Mb 1s DropTail
#since initially only one link per path is congested
#$ns duplex-link $n5 $n5 2Mb 10ms Droptail
#$ns duplex-link $n6 $n6 2Mb 10ms Droptail
#$ns duplex-link $n7 $n7 2Mb 10ms Droptail
#$ns duplex-link $n8 $n8 2Mb 10ms Droptail
#$ns duplex-link $n9 $n9 2Mb 10ms Droptail

#Node n10 and n11 are considered as initial points TCP agent n UDP agent
$ns duplex-link $n10 $n0 2Mb 10ms DropTail
$ns duplex-link $n11 $n0 2Mb 10ms DropTail

#set queue size of link n10-n0 n n11-n0 to 10
$ns queue-limit $n10 $n0 10
$ns queue-limit $n11 $n0 10

#Give node position
$ns duplex-link-op $n0 $n1 orient right
$ns duplex-link-op $n1 $n2 orient right
$ns duplex-link-op $n2 $n3 orient right
$ns duplex-link-op $n3 $n4 orient right
$ns duplex-link-op $n1 $n5 orient right-down
$ns duplex-link-op $n2 $n6 orient right-down
$ns duplex-link-op $n3 $n7 orient right-down
$ns duplex-link-op $n5 $n6 orient right
$ns duplex-link-op $n6 $n7 orient right
$ns duplex-link-op $n7 $n4 orient right-up
#$ns duplex-link-op $n1 $n8 orient right-up
#$ns duplex-link-op $n8 $n9 orient right
#$ns duplex-link-op $n9 $n4 orient right-down
#$ns duplex-link-op $n11 $n0 orient right-up
#$ns duplex-link-op $n10 $n0 orient right-down

#Monitor the queue for link n0-n1,n1-n2,n2-n3,n3-n4 for NAM
$ns duplex-link-op $n0 $n1 queuePos 0.5
$ns duplex-link-op $n1 $n2 queuePos 0.5
$ns duplex-link-op $n2 $n3 queuePos 0.5
$ns duplex-link-op $n3 $n4 queuePos 0.5

#set up a TCP connection
set tcp [new Agent/TCP]
$tcp set class_ 2
$ns attach-agent $n10 $tcp
set sink [new Agent/TCPSink]
$ns attach-agent $n4 $sink
$tcp set fid_ 1

#set up a FTP over TCP connection
set ftp [new Application/FTP]
$ftp attach-agent $tcp
$ftp set type_ FTP

#set a UDP connection
set udp [new Agent/UDP]
$ns attach-agent $n11 $udp
set null [new Agent/Null]
$ns attach-agent $n4 $null
$ns connect $udp $null
$udp set fid_ 2

#set up a CBR over UDP connection
set cbr [new Application/Traffic/CBR]
$cbr attach-agent $udp
$cbr set type_ CBR
$cbr set packet_size_ 1000
$cbr set rate_ 1mb
$cbr set random_ false

#schedule events for the CBR & FTP agents
$ns at 0.1 "$cbr start"
$ns at 1.0 "$ftp start"
$ns at 4.0 "$ftp stop"
$ns at 4.5 "$cbr stop"

#Detach tcp & sink agent (not really necessary)
$ns at 4.5 "$ns detach-agent $n0 $tcp;$ns detach-agent $n4 sink"

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

#Print CBR packet Size & interval
puts "CBR packet size = [$cbr set packet_size_]"
puts "CBR interval = [$cbr set interval_]"

#Print FTP packet size & interval
#puts "FTP packet size = [$ftp set packet_size_]"
#puts "FTP interval = [$ftp set interval_]"

#Run the simulation
$ns run

If I run the program I am not getting the nam file...What is the error in my
script????

CBR packet size = 1000
CBR interval = 0.0080000000000000002
--- Classfier::no-slot{} default handler (tcl/lib/ns-lib.tcl) ---
        _o42: no target for slot -1
        _o42 type: Classifier/Hash/Dest
content dump:
classifier _o42
        0 offset
        0 shift
        2147483647 mask
        1 slots
                slot 10: _o387 (Classifier/Port)
        -1 default
---------- Finished standard no-slot{} default handler ----------


-- 
Do Whatever Your Heart Desires Xclusively For Yourself.

Priyadharshini Manoharan


More information about the Ns-users mailing list