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

Re: [ns] Adding a simple extra feature in FullTcp agent



Hello again,

I am still having problems with the Extra Agent. I want to add an extra agent to FullTcp and the tcl command should look like this:
set tcp1 [new Agent/TCP/FullTcp/Extra]

This "/Extra" is just a function that changes a byte of the packets before they are sent. Once the byte is changed the function calls the original send function (Connector::send(p, h);). I have add and extra byte in the hdr_tcp in the tcp.h, this is the byte that is going to be changed by the function. I have also add the new Extra Class in the tcp-full.h and it looks like that:

class ExtraFullTcpAgent : public FullTcpAgent { 
public:
        void    send(Packet* p, Handler* h);
};
 

I have also add the Extra functions in tcp-full.cc:

static class ExtraFullTcpClass : public TclClass { 
public:
        ExtraFullTcpClass() : TclClass("Agent/TCP/FullTcp/Extra") {}
        TclObject* create(int, const char*const*) { 
                return (new ExtraFullTcpAgent());
        }
} class_extra_full;

void
ExtraFullTcpAgent::send(Packet* p, Handler* h)
{
        hdr_tcp* tcph = (hdr_tcp*)p->access(off_tcp_);
        tcph->tos() = 40;    //It only changes the new byte in the packet for 40
        Connector::send(p, h);
}
 
 

I haven't modified the Makefile because all the changes made are in tcp-full.h and tcp-full.c. (already included in the Makefile). I ran "make depend" and then "make" and everything is OK. After that I create a very simple NS script with two nodes and setting the nodes with the new Agent (set tcp1 [new Agent/TCP/FullTcp/Extra]).

When I execute the script (ns tcp_extra.tcl) it comes up the next error:

invalid command name "Agent/TCP/FullTcp/Extra"
    while executing
"Agent/TCP/FullTcp/Extra create _o34 "
    invoked from within
"catch "$className create $o $args" msg"
    (procedure "new" line 3)
    invoked from within
"new Agent/TCP/FullTcp/Extra"
    (file "tcp_qos.tcl" line 47)

I think that NS doesn't recognize the new agent Extra, but I don't understand why. I think I've modified all the necessary files to create a new agent. Can anybody tell me what I am doing wrong???

Many, many thanks....          abel

-- 
Abel Mayal de la Torre

BT Advanced Communications Technology Centre
B29/Room 138
Adastral Park
Martlesham Heath
Ipswich
Suffolk IP5 3RE

Tph: 01473 647615
E-Mail: [email protected]