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

Re: [ns] How to reset TCP Agent after receiving all ACKS? + Finding Sink of Given TCP Source



Thank you very much,

You are right, it worked, but only after changing the script and first creating
the source, then the sink and then linking them together, in order to have all
names of the various agents.

There is one more question remaining, namely is there any command to get the
sink of a given tcp source?

eg. This worked

$tcp0 proc done {} {
global ns, tcpsink0
puts "[$ns now]: Last ACK received"
$self reset
$tcpsink0 reset
}

but I tried to do

$tcp0 proc done {} {
global ns
puts "[$ns now]: Last ACK received"
set tcpsink0 [$tcp0 target]
$tcpsink0 reset
$self reset
}

in order to get the TCPSink, but it doesn't work (I can not do $tcpsink0 reset)


If I run your script without modification, I get the error

ns: _o59 done: can't read "sink": no such variable
    while executing
"$sink reset"
I also wonder what the command
$self instvar sink

was supposed to do. Maybe to get the target of the agent, but it didn't.


Enrique Campos-Nanez wrote:

> 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