[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [ns] Getting the sink of TCP connection
I solved the problem by modifying the create-connection procedure and assigning the sink_ variable to the sink handle
eg.
Simulator instproc create-connection {s_type source d_type dest pktClass} {
set s_agent [new Agent/$s_type]
set d_agent [new Agent/$d_type]
$s_agent set fid_ $pktClass
$d_agent set fid_ $pktClass
$self attach-agent $source $s_agent
$self attach-agent $dest $d_agent
$self connect $s_agent $d_agent
$s_agent set sink_ $d_agent # added line to set sink_ variable
return $s_agent
}
Then in the done() procedure I just access the sink_ variable and reset the sink
Agent/TCP instproc done {} {
global ns
$self instvar sink_
puts "[$ns now]: Last ACK received"
set sink [$self set sink_]
$sink reset
$self reset
}
Thanks for your help, if anybody knows a better solution, I would gladly hear it.
Nikos
Xuan Chen wrote:
> I think some web traffic related scripts have done such thing before. You
> probably want to have a look at the scripts under ~/ns/tcl/webcache, say
> webtraf.tcl. Hope it helps.
>
> -chen xuan
>
> On Wed, 6 Jun 2001, Nikolaos Katsarakis Austauschstud. (M. Schweigel) wrote:
>
> > Thank you for your answer,
> >
> > actually I had done this and it worked, but what I needed is to write a done() procedure for the TCP Agent, which will reset
> > the Agent and its sink.
> >
> > So I would like to be able to get the particular sink of each TCP agent, so that I don't have to write a done() procedure for
> > every TCP Agent I create in my simulation. If that is not possible, then I guess I have to do it this way.
> >
> > Bye
> >
> > Nick
> >
> > Xuan Chen wrote:
> >
> > > Try this:
> > >
> > > set tcp [new Agent/TCP]
> > > $tcp set class_ 2
> > > set sink [new Agent/TCPSink]
> > > $ns attach-agent $n0 $tcp
> > > $ns attach-agent $n2 $sink
> > > $ns connect $tcp $sink
> > >
> > > Thanks.
> > > -chen xuan
> > >
> > > On Wed, 6 Jun 2001, Nikolaos Katsarakis Austauschstud. (M. Schweigel) wrote:
> > >
> > > > If I use the command:
> > > >
> > > > set tcp0 [$ns create-connection TCP $n0 TCPSink $n2 1]
> > > >
> > > > I only get the handle to the source agent.
> > > >
> > > > How can I afterwards get the handle to the sink agent?
> > > >
> > > > I tried set sink0 [$tpc0 target] but it didn't work.
> > > >
> > > > I tried to do $sink0 reset and got the following error message:
> > > >
> > > > --- Classfier::no-slot{} default handler (tcl/lib/ns-lib.tcl) ---
> > > > _o12: no target for slot -1
> > > > _o12 type: Classifier/Hash/Dest
> > > > content dump:
> > > > classifier _o12
> > > > 0 offset
> > > > 0 shift
> > > > 2147483647 mask
> > > > 3 slots
> > > > slot 0: _o61
> > > > slot 1: _o22
> > > > slot 2: _o22
> > > > -1 default
> > > > ---------- Finished standard no-slot{} default handler ----------
> > > >
> > > > If anybody knows the right way to use the target command (or any other command to get the handle to the target of a given
> > > > agent), please let me know.
> > > >
> > > > Thank you
> > > >
> > > > Nikos
> > > >
> > > >
> > >
> > > --
> > > Xuan Chen
> > > USC/ISI
> >
>
> --
> Xuan Chen
> USC/ISI