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

Re: question about agent type



It seems I sparked something here... I agree: what I suggested was an inelegant 
quick hack, a fix more than anything. Sure one could use the "info class" method 
or write his own target instproc (I tend ot prefer this). But you don't need to 
put the node instproc is-nbd? in ns-node.tcl, since it only concerns nbd stuff 
it can be with the nbd tcl code. Hence restricting the pollution.

> Why, you could just do [$agent info class "Agent/NBD"] which will
> return 1 if $agent derives from Agent/NBD and 0 otherwise.
> 
> But the whole idea of tailoring ns-node.tcl (add-target-New) to suit
> this particular nbd agent is a hack.  Maybe a better solution would be
> having a special target function for your object. Something like this
> may work:
> Agent/NBD instproc target {{t ""}} {
>         if { $t == "" } {
>                 $self cmd target
>         } else {      
>                 $self instvar node_
>                 $self cmd target [$node_ set ll_(0)]
>         }
> }
> 
> It's a hack too, but at least it doesn't pollute ns-node.tcl with classnames.
> 
>   -Yuri
> 
> Lloyd Wood <[email protected]> writes:
> 
> > On 19 Feb 2000, Yuri Pryadkin wrote:
> > 
> > > Or use the info command:
> > >   if {[$agent info class] == "Agent/NBD"} {...}
> > 
> > Surely that's not very class-friendly, because it promptly breaks
> > for any subsequent classes derived from NBD?
> > 
> > Something like:
> > 
> > if {[string first "Agent/NBD" [$agent info class]] == 0} { }
> > 
> > strikes me as slightly better, but even that could fall over if you
> > say derive an entirely separate class from Agent called NBDother,
> > requiring extra tests to separate the two out.
> > 
> > This is just one good reason why all classes should have / tagged on
> > the end as default; then testing for Agent/NBD/ would catch
> > _everything_ safely. Oh, and tagging / on the start would mean that
> > substring matches can't confuse /Agent/NBD/ with an entirely separate
> > /Agent/TapAgent/NBD/.
> > 
> > Less messy in the long run.
> > 
> > L.
> > 
> > Apache redirects teach you a lot about the ns class hierarchy.
> > 
> > <[email protected]>PGP<http://www.ee.surrey.ac.uk/Personal/L.Wood/>
> > 
> > 
> > > Tarik Alj <[email protected]> writes:
> > > 
> > > > >From the base class agent write an instproc is-nbd? that always return 
0; from 
> > > > your nbd agent class write an intsproc is-nbd? that always return 1. It 
should 
> > > > do the trick...
> > > > 
> > > > > 
> > > > > Hello,
> > > > > 
> > > > > I would like to develop an agent for ad-hoc network which runs a 
> > > > > neighbor discovery protocol, and just that.
> > > > > As the aodv routing protocol does neighbor discovery, my code-writing 
> > > > > strategy has been to steal as much as I could into the aodv code.
> > > > > But, I want my new agent, call it nbd, to be a normal agent, not a 
> > > > > routing one like aodv. However, I would like nbd to send its packets  
> > > > > (hello messages in fact) direclty to the ll layer.
> > > > > To do so, I think I should add to the add-target-New procedure in 
ns/tcl
> > > > > /lib/ns-node.tcl the following:
> > > > > 
> > > > > 	#
> > > > > 	# Send Target
> > > > > 	#
> > > > > 
> > > > > If the agent is a nbd
> > > > > 	$agent target [$self set ll_(0)]
> > > > > else
> > > > > 	$agent target [$self entry]
> > > > > 	
> > > > > 	#
> > > > > 	# Recv Target
> > > > > 	#
> > > > > 	...
> > > > > 
> > > > > How could I code the "agent is a nbd" part?
> > > > > How could I get the type of an agent when the only thing I know about 
it
> > > > >  is "$agent"?
> > > > > 
> > > > > any suggestions about how I could do what I want to do?
> > > > > 
> > > > > Cheers,
> > > > > --
> > > > > Robin POSS
> > > > 
> > > > Tarik

Tarik Alj

INRS-Telecommunications
Place Bonaventure
900 De La Gauchetierre Ouest
Niveau C, Case Postale 644
Montreal, Qc, H5A 1C6
Canada