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

RE: [ns] HELP!! packet source address ??



> If anybody knows how to find out the source address of
> a packet (where it first was sent from), please let me
> know how to write the small piece of code in tcl, what
> kind of objects and functions to use. Thanks!!

Well, this is how you do it in C++:

(assiming that p is a Packet*)

int off_ip_ = hdr_ip::offset();
hdr_ip* hdrip = (hdr_ip*)p->access(off_ip_);

hdrip->dst_ is the destination address,
hdrip->src_ is the source address. I just tried redirecting
a packet like this: hdrip->dst_ = hdrip->src_;
and it works just fine.

I don�t know how to do it in TCL, but you could do it in
C++ and pass the results to the TCL interpreter (see the
beginning of ns notes and documentation).

Regards,
Michael