M trying to add some changes to NS and it doesn't work
could some one helps me ? :( ..
i wrote the msg.tcl file :
Class Sender -superclass Agent/Message
#Message format : Addr Op SeqNo
Sender instproc send-next {} {
$self instvar seq_ agent_addr_
$self send $agent_addr_ send $seq_
incr seq_
global ns
$ns at [expr [$ns now]+0.1] "$self send-next"
}
Sender instproc recv {msg} {
$self instvar agent_addr_
set sdr [lindex $msg 0]
set seq [lindex $msg 2]
puts "Sender gets ack $seq from $sdr"
}
Class Receiver --superclass Agent/Message
Receiver instproc recv {msg} {
$self instvar agent_addr_
set sdr [lindex $msg 0]
set seq [lindex $msg 2]
puts ?"Receiver gets seq $seq from $sdr"?
$self send ?$addr_ ack $seq
}
# Create scheduler
set ns [new Simulator]
# Turn on Tracing
set fd [open message.nam? w]
$ns namtrace-all $fd
for {set i 0} {$i < 6} {incr i} {
set n($i) [$ns node]
}
$ns duplex-link $n(0) $n(1) 128kb 50ms DropTail
$ns duplex-link $n(1) $n(4) 10Mb 1ms DropTail
$ns duplex-link $n(1) $n(5) 10Mb 1ms DropTail
$ns duplex-link $n(0) $n(2) 10Mb 1ms DropTail
$ns duplex-link $n(0) $n(3) 10Mb 1ms DropTail
$ns queue-limit $n(0) $n(1) 5
$ns queue-limit $n(1) $n(0) 5
# Packet loss produced by queueing
# Routing protocol: let?s run distance vector
$ns rtproto DV
set udp0 [new Agent/UDP]
$ns attach-agent $n(2) $udp0
set null0 [new Agent/Null]
$ns attach-agent $n(4) $null0
$ns connect $udp0 $null0
set exp0 [new Application/Traffic/Exponential]
$exp0 set rate_ 128k
$exp0 attach-agent $udp0
$ns at 1.0 ?$exp0 start?
set sdr [new Sender]
$sdr set packetSize_ 1000
set rcvr [new Receiver]
$rcvr set packetSize_ 40
$ns attach $n(3) $sdr
$ns attach $n(5) $rcvr
$ns connect $sdr $rcvr
$ns connect $rcvr $sdr
$ns at 1.1 ?$sdr send-next
$ns at 2.0 finish
proc finish {} {
global ns fd
$ns flush-trace
close $fd
exit 0
}
?
AND when i try :
~/ns/ns-allinone-2.1b6 $ ./ns-2.1b6/ns ../msg.tcl
I have the following message:
uneven number of args
(Object init line 1)
invoked from within
"-superclass init Agent/Message"
(Class create line 1)
invoked from within
"Receiver create -superclass Agent/Message"
("eval" body line 1)
invoked from within
"eval [list $self] create [list $m] $args
"
(procedure "Receiver" line 5)
(Class unknown line 5)
(Object init line 5)
invoked from within
"Receiver init -superclass Agent/Message"
(Class create line 1)
invoked from within
"Class create Receiver -superclass Agent/Message"
("eval" body line 1)
invoked from within
"eval [list $self] create [list $m] $args
"
(procedure "Class" line 5)
(Class unknown line 5)
invoked from within
"Class Receiver -superclass Agent/Message"
(file "../test.tcl" line 19)
WHAT'S wrong with this ?
Thnx
HALIM Jalil
[email protected]