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

Question about ManualRtNode (again)



Hi all,

    I'm currently working on ns to write my own classifier... (which
will much similar to hash classifier) ...
So I'm looking in detail on the ManualRtNode tcl code for how to use
hash classifier...

I wrote a simple simulation script to test on the ManualRtNode
capability of defining a pre-configure route...
the script seem working only when i using the :

    add-route-to-adj-node [-default] node     with the -default flag
on...

>From my understanding of the ManualRtNode Class code, the
add-route-to-adj-node will call the add-route procedure :

if (default flag is set )
    set the class variable default_ to the next available slot (calling
installNext proc)
else
    calling hash/dest classifier procedure set-hash to install the slot
in hash table...

If I use the add-route-to-adj-node without the -default flag, there is
an error or unknown-flow which I believe is invoked the newflow()
function in classifier-hash.cc .
So I'm confuse since I had set the hash entry (calling
add-route-to-adj-node without -default flag), at the classify() method
(call when a packet reach at a node, right?) in classifier-hash.cc, why
I'll get the unknown flow error?

/* from classifier-hash.cc*/
int classify(Packet * const p){
    hnode *hn = lookup(p);
    if(hn!= NULL)                                              // found
the slot , but why always fail?
        return (hn->slot);
    else if(default_ >=0)                                    // using
default is ok
        return (default_);
    return (newflow(p));                                    // cause the
error message!!!
}

 And I refer to the many_tcp.tcl script (in /ns-2.1b5/ex/), seem there
is a used of add-route-to-adj-node without the -default, and it seem ok
when i try to run it... (and how to set the option to get nam running...

?)

Besides, I'm also confuse at the codes in classifier.cc for which handle

packet arrival...
in method void Classfier::recv(p,h), it call the find method to return
an NsObject pointer of type node.
In the find method,

NsObject* Classifier::find(Packet* p) {
        NsObject* node = NULL;                        /* set to null */
        int cl = classify(p);                                    /*
return the slot found */
        if (cl < 0 || cl >= nslot_ || (node = slot_[cl]) == 0) {     //
confuse???
                if (default_target_) return default_target_;
                ...
        }
        return (node);
}

at the if statement, if (cl< 0 || cl >= nslot_ || (node = slot_[cl]) ==
0), isn't this means that it is true only if the return value of
classify() method is not in the range to the slot_ table?  now, what is
the default_target_?
 and back to the Classifier::recv method again, it will call the
NsObject::recv() method to free the packet...
so how it the packet know which next hop it will be forwarded to?

I think there must be some misunderstanding of me about the codes,
please help me clear my doubt.

Thank you.
Tan Su Wei
Malaysia