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

Re: [ns] Checking packet type




>i am writing this procedure :
>Agent instproc packet-type {} {
>       $self instvar type_
>       return $type_
>    }
>
>its giving me error as "cant read type_ no scuh varaible"
>i am calling it as:
>
>$tcp1 packet-type   in my tcl script...
>
>any coments???

I answer your specific question at the end.

BUT... there are two reasons you might want to reconsider your
approach.

1. You might notice that very few ns agents actually check their
packet type.  Since the ns APIs directly bind the source and the sink
there's not really a need to check each packet's type.

(I.e., if you're checking the type to detect a misconfiguration, why
not do it at "connect" time.)

2. In cases where you really need distinguish packet type (say, to queue
UDP and TCP differently), it will be very expensive to go to Tcl for
every packet.  As a general rule it's a very bad idea
(performance-wise) to put Tcl code in the per-packet processing loop.
Usual ns style is to create a classifer that will sort the packets out
in C++.

(More times than I'd like we've had to re-implement something
prototyped in Tcl in C++ because it really shouldn't have been in Tcl
to start with.

That said... if you really want to check the packet type in Tcl, your
procedure is getting an error no field called "type_" (as the error
message said).  Looking at the packet declaration (in packet.cc, oddly
enough) should show the proper way to spell "packet type".

   -John Heidemann



>
>
>sameer
>>===== Original Message From Debojyoti Dutta <[email protected]> =====
>>one simple way is to write a small command for the class Agent that will
>>return the packet type.
>>
>>cheers
>>debo
>>
>>On Wed, 7 Feb 2001, sameer wrote:
>>
>>> If i want to check the packet type(whether udp or tcp) whithin my tcl
>>> script(to perform certain operation) can i do that...
>>> if yes then what variable i have to check ???
>>>
>>> thanks
>>>
>>> sameer
>>>
>>>
>
>