[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [ns] How to reset TCP Agent after receiving all ACKS?
I think resetting the sink as well will do the trick, but I am not sure if this is the best way to do it. For example, try
Agent/TCP instproc done {} {
$self instvar sink
global ns
puts "[$ns now]: Last ACK received"
$self reset
$sink reset
}
And set the ink to the TCPSink agent, for example
$tcp set sink $tcpSink0
Enrique Campos-Nanez
On Wednesday, May 30, 2001, at 01:32 PM, Nikolaos Katsarakis Austauschstud. (M. Schweigel) wrote:
Hello,
I want to execute the done() procedure for a TCP Agent every time it finishes
sending the data provided by its source.
For example in the following script, I start the source at 0 and stop it at 5
sec, so at 6,057 sec it prints:
6.0574999999999868: Last ACK received
but then I start it again at 10 sec and stop it at 15 sec, but the done()
procedure won't get called again. If I do a $self reset, then the done
procedure will be called for all packets received from that time on. What
should I do, in order to make the done() procedure get called again only at the
end of the simulation?
I would like to get an output like that:
6.0574999999999868: Last ACK received
16.0575000000001: Last ACK received
Thank you very much
Nikos
----------------------------tcp_reset.tcl-------------------------------------
#! /usr/sww/bin/tclsh
Agent/TCP instproc done {} {
global ns
puts "[$ns now]: Last ACK received"
#$self reset
}
# program defaults
set link_bw 384kb
set link_del 50ms
#Create a simulator object
set ns [new Simulator]
#Open a trace file
set nf [open out.nam w]
$ns namtrace-all $nf
#Define a 'finish' procedure
proc finish {} {
global ns nf f0 trackfile0
$ns flush-trace
#Close the output files
close $nf
exec nam -r 0.04 out.nam &
exit 0
}
#define a color
$ns color 1 DarkGreen
#Create three nodes
set n0 [$ns node]
set n1 [$ns node]
set n2 [$ns node]
#Connect the nodes with two links
$ns duplex-link $n0 $n1 $link_bw $link_del DropTail
$ns duplex-link $n1 $n2 $link_bw $link_del DropTail
$ns queue-limit $n0 $n1 500
#orient the links
$ns duplex-link-op $n0 $n1 orient 20deg
$ns duplex-link-op $n1 $n2 orient 340deg
set tcp0 [$ns create-connection TCP $n0 TCPSink $n2 1]
$tcp0 set packetSize_ 1460
#Create a CBR traffic source and attach it to tcp0
set cbr0 [new Application/Traffic/CBR]
$cbr0 set packetSize_ 1460
$cbr0 set rate_ 400kb
$cbr0 attach-agent $tcp0
#Schedule events
$ns at 0 "$cbr0 start"
$ns at 5.0 "$cbr0 stop"
$ns at 10.0 "$cbr0 start"
$ns at 15.0 "$cbr0 stop"
$ns at 50.0 "finish"
#Run the simulation
$ns run