This is interesting. In my particular simulation, neither version works:
mac_->hdr_dst((char*) HDR_MAC(p), ch->next_hop());
or
mac_->hdr_dst((char*) HDR_MAC(p), dst);
However, the code that I've sent you always works, and does this:
When arp wants to resolve an IP address, it:
a) finds the host that has that IP address,
b) goes to the first MAC interface,
c) and returns its mac address.
To ease the coding of this stuff, I'm doing this via otcl, where is MUCH
easier (1) to do this kind of stuff, that depends on global variables, etc;
If speed is a problem (this happens for every forwarded packet), it could be
done in C++ only, of course.
Pedro Vale Estrela
Note 1: this only happens after one has major experience hacking otcl code!
> -Original Message-
> From: Ahmad Khayyat [mailto:[EMAIL PROTECTED]
> Sent: quarta-feira, 21 de Março de 2007 0:51
> To: [EMAIL PROTECTED]
> Subject: Re: [ns] Disable ARP
>
> Hi Pedro,
>
> Thank you for the valuable help.
> Actually, I am using the following three lines at the top of
> ARPTable::arpresolve
> with no problems so far. They just happened to trigger another nasty
> bug in my code that I like to believe I have taken care of ;)
>
> hdr_cmn *ch = HDR_CMN(p);
> mac_->hdr_dst((char*) HDR_MAC(p), ch->next_hop());
> return 0;
>
> I am using this with both NOAH and AODV over significantly modified
> WPAN MAC.
>
> I appreciate you sharing your fix with me, and will keep it in mind in
> case problems arise later.
>
> Regards,
> Ahmad
>
> On Tue, 20 Mar 2007 23:29:38 -
> "Pedro Vale Estrela" <[EMAIL PROTECTED]> wrote:
>
> >
> > I've got the same problem, and using this code does not solve the
> > problem for all cases (in my particular simulation)
> >
> > Instead, I'm using this with great success:
> >
> > In C++, at the top of ARPTable::arpresolve , insert this code that
> > requires #include "utils_ns.h" (see
> > http://tagus.inesc-
> id.pt/~pestrela/ns2/contributed_code.html#_Toc147652229)
> >
> > --- cut here ---
> >
> > TCL_EVALFr("ARP_find_mobile_iaddr2mac %d", dst);
> > LL *ll = (LL *)TclObject::lookup(Tcl::instance().result());
> >
> > if(!ll){
> > dprintf("Error: LL empty\n");
> > exit(-1);
> > }
> >
> > int mac = ll->mac_->addr();
> > mac_->hdr_dst((char*) HDR_MAC(p), mac);
> > return 0;
> >
> > --- cut here ---
> >
> >
> > then, add this tcl code to your script or /tcl/lib/ns-lib.tcl. I'm
> > not sure, but this code MIGHT require the NOAH extension because that
> > for {set i 0} { $i < [Node set nn_] loop.
> >
> >
> > --- cut here ---
> >
> >
> > # Given the node handle, return the haddr, iaddr or ID
> > proc NOAH_handle2iaddr { handle } {
> >
> > if { $handle == "-1" } {
> > return "-1"
> > }
> >
> > set iaddr [$handle address?]
> > return $iaddr
> > }
> >
> >
> >
> > #
> > # Given the node's address in haddr, iaddr or ID, search and return
> > the handle
> > # (TODO:) create an array at creation to store these pairs for faster
> > lookup #
> > proc NOAH_iaddr2handle { node_iaddr } {
> > if { $node_iaddr == "-1" } {
> > return "-1"
> > }
> >
> > set ns_ [Simulator instance]
> >
> > for {set i 0} { $i < [Node set nn_]} {incr i} {
> > set node_handle [$ns_ set Node_($i)]
> >
> > if {[string compare [NOAH_handle2iaddr $node_handle]
> > $node_iaddr] == 0} {
> > return $node_handle
> > }
> > }
> >
> > return "-1"
> > }
> >
> >
> > ##
> > ## PROC: returns the handle of a given NODE, by its iaddress
> > ##
> >
> > ## FIXME: assume itf(0), codigo C++ devolve mac dessa interface
> > ##
> > ## this code is used by the disabled ARP (option 2)
> > proc ARP_find_mobile_iaddr2mac { iaddr } {
> > set ns_ [Simulator instance]
> > set MH_node_handle [NOAH_iaddr2handle $iaddr]
> >
> > set ll [$MH_node_handle set ll_(0)]
> >
> > #puts "found: $MH_node_handle $ll"
> > return $ll
> > }
> >
> > --- cut here ---
> >
> >
> >
> >
> >
> >
> > -
> >
> > Re: [ns] Disable ARP
> > Ahmad Khayyat
> > Wed, 28 Feb 2007 02:27:15 -0800
> >