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

RE: [ns] Need help on new Node Classifier!!!



The recv procedure of address classifier is like the follwoing:

int AddressClassifier::classify(Packet *p) {
	hdr_ip* iph = hdr_ip::access(p);
	return mshift(iph->daddr());
};

It seems it can get the slot number, which is , like you said, 3; however,
I still believe you need to check the clot table of each nodes, the
following procedure in tcl may be helpful: (4 nodes)

proc dumping {} {
    global ns n
    puts "link head from n(0) to n(2): [[$ns set link_(0:2)] head]"
    puts "link head from n(2) to n(0): [[$ns set link_(2:0)] head]"
    puts "link head from n(1) to n(2): [[$ns set link_(1:2)] head]"
    puts "link head from n(2) to n(1): [[$ns set link_(2:1)] head]"
    puts "link head from n(1) to n(3): [[$ns set link_(1:3)] head]"
    puts "link head from n(3) to n(1): [[$ns set link_(3:1)] head]"
    puts "link head from n(3) to n(2): [[$ns set link_(3:2)] head]"
    puts "link head from n(2) to n(3): [[$ns set link_(2:3)] head]"

    puts "$n(3) is node [$n(3) id]"
    puts "n(2)'s neighbours are [$n(2) neighbors]"
    puts "the dmux_ in n(0) is [$n(0) set dmux_]"
    puts "the dmux_ in n(2) is [$n(2) set dmux_]"
    puts "the dmux_ in n(1) is [$n(1) set dmux_]"
    puts "the dmux_ in n(3) is [$n(3) set dmux_]"

    set r [$ns get-routelogic]
    puts "the routelogic is $r"
    # $r dump 4

    for {set i 0} {$i<4} {incr i} {
	set cl [$n($i) set classifier_]
	puts "the one in slot 1 [$cl slot 1]"
	puts "the slot is [$cl findslot [[$ns set link_(1:3)] head]]"
	puts "the classifier is $cl"
	$cl dump
    }
}

Use the idea the the upper procedure try to dump the slot table of the node.
Also check the [class info] to confirm if each node got the right classifier
and how they populate the slot tables. Good luck!

Regards,
Peng He

-----Original Message-----
From: Xiaojun Cao [mailto:[email protected]]
Sent: July 25, 2001 2:04 PM
To: penghe
Cc: [email protected]
Subject: Re: [ns] Need help on new Node Classifier!!!


I just use default "duplex-link"
If I just use my new classifier, which didn't override any of the
function, everything is OK. However if I want override function like
recv, it will have problem like I mentioned. It seems that find() call
classify() ,then problem came.

Thanks a lot

yours
Xiaojun Cao



penghe wrote:

> It seems you didn't install the object(link head) into the slot table of
the
> classifiers. BTW, where are your links?
>
> Regards,
> Peng He
>
> -----Original Message-----
> From: [email protected] [mailto:[email protected]]On Behalf Of
> Xiaojun Cao
> Sent: July 24, 2001 3:02 PM
> Cc: [email protected]
> Subject: [ns] Need help on new Node Classifier!!!
>
>
> hi,
> I am trying to simulate a node which has packet filter. So I create a
> new classifer inherted from AddressClassifier and override its Function
> ::recv, it's just like following:
>
> void myClassifier::recv(Packet *p, Handler *h)
> {
>     hdr_ip * iph=hdr_ip::access(p);
>     nsaddr_t src=mshift(iph->saddr());
>     nsaddr_t dst=mshift(iph->daddr());
>     int fid=iph->flowid();
>
> NsObject * target =find(p);
> if(dst==Currentid){
>
>     if(!target) target->recv(p,h);
> ....
> }
> ....
>
> }
>
> Basically, I will check the destionation address and decide whether this
> packet will be passed to an upper agent or next node.
> The problem came from: find(p)----> I can trace and found that  nslot_
> is always 0, however, cl=classify(p) would be 3.  I dont know why?
> Could you give me a hand?
> Thanks a lot!
>
> yours,
> Xiaojun Cao
>
> ********Here is the dump info:
>
> --- Classfier::no-slot{} default handler (tcl/lib/ns-lib.tcl) ---
>     _o17: no target for slot 3
>     _o17 type: Classifier/Addr/MYFiL
> content dump:
> classifier _o17
>     0 offset
>     0 shift
>     2147483647 mask
>     0 slots
> ---------- Finished standard no-slot{} default handler ----------
>
> ********The toplogy is as following:
>
> set n0 [$ns node]
> set n1 [$ns MyNode]
> set n2 [$ns MyNode]
>
> #n0--->n1-->n2
> #n0 send udp packet to n2
> ....
>
> ******The node tcl code is as following:
> MyNode instproc mk-default-classifier {} {
>
>     $self instvar address_ classifier_ id_
>     set classifier_ [new Classifier/Addr/MYFiL]
>      $classifier_ set mask_ [AddrParams NodeMask 1]
>      $classifier_ set shift_ [AddrParams NodeShift 1]
>      set address_ $id_
> }