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

[ns] dynamically connecting to agents




Hi all,

I am trying to implement an application level protocol that dynamically
connects to agents on different nodes.
The agent class in ns-2.1b7a contains virtual declarations of sendto(). Has
anyone implemented it yet ?


This corresponds to the problem in the Marc Greis Tutorial about
implementing "$pa send $node" in the chapter on ping agent. I tried to
implement "$pa1 send $pa2" where pa1 and pa2 are two ping agents attached to
nodes n0 and n3. the C++ code added to the function command in ping.cc looks
like :
if (argc == 3) {
    if (strcmp(argv[1], "send") == 0) {
          Tcl& tcl = Tcl::instance();
Agent*  destn_ = (Agent*)TclObject::lookup(argv[2]);
if (destn_ == 0) {
tcl.resultf("no such object %s", argv[2]);
return (TCL_ERROR);
}
Packet* pkt = allocpkt();
      hdr_ping* hdr =! hdr_ping::access(pkt);
      hdr_ip* iph=hdr_ip::access(pkt);
       iph->daddr()=destn_->addr();
       iph->dport()=destn_->port();
      hdr->ret = 0;
      hdr->send_time = Scheduler::instance().clock();

      send(pkt, 0);
      return (TCL_OK);
}


This compiles well but, the classifier at the recieving node fails to
classify the packet and calls the no-slot default handler instead. The
message is:

--- Classifier::no-slot{} default handler (tcl/lib/ns-lib.tcl)---
  -o21: no target for slot -1
  -o21 type: Classifier/Hash/Dest
content dump:
classifier _o21
0 offset
0 shift
2147483647 mask
4 slots
slot 0: _o75
slot 1: _o75
slot 2: _o75
slot 3: _o86
-1 default
Note that the ping agent is the only agent attached to the recieving node.
So there should be only one slot instead of the four reported in the error
above. Also, the value of iph->dport() is 0, but the classifier sees it as
-1 !

I tried to force the iph->dport() to 1, and the new error message changed to
the expected :

  -o87: no target for slot 1
  -o87 type: Classifier/Port
content dump:
classifier _o87
0 offset
0 shift
2147483647 mask
1 slots
slot 0: _o86
-1 default

What is the problem ?

thanks for your time
abhishek



Get Your Private, Free E-mail from MSN Hotmail at http://www.hotmail.com.