Re: [ns] Disable ARP

2007-03-21 Thread Pedro Vale Estrela



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
> >

Re: [ns] Disable ARP

2007-03-20 Thread Pedro Vale Estrela


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

Never mind.
The two lines work perfectly. They just happened to trigger another
problem, which is taken care of now :)

On Tue, 27 Feb 2007 18:27:37 -0500
Ahmad Khayyat <[EMAIL PROTECTED]> wrote:

> What is the easiest way to disable the use of the ARP protocol?
> I guess the IP address corresponds to the MAC address in ns-2, doesn't
> it? So how do I make the LL/ARP modules use it immediately without
> using ARP?
> 
> I tried adding the following two lines at the top of
> ARPTable::arpresolve(nsaddr_t dst, Packet *p, LL *ll)
> 
> mac_->hdr_dst((char*) HDR_MAC(p), dst);
> return 0;
> 
> but that caused strange behaviour on rare occasions, where a packet
> suddenly would appear in another far node. Playing with ARP doesn't
> explain the problem for me, but somehow removing those two lines
> gets rid of the strange behaviour. So, what is a proper way of
> disabling ARP?
> 
> Thanks..
> Ahmad




Re: [ns] Disable ARP

2007-02-28 Thread Ahmad Khayyat

Never mind.
The two lines work perfectly. They just happened to trigger another
problem, which is taken care of now :)

On Tue, 27 Feb 2007 18:27:37 -0500
Ahmad Khayyat <[EMAIL PROTECTED]> wrote:

> What is the easiest way to disable the use of the ARP protocol?
> I guess the IP address corresponds to the MAC address in ns-2, doesn't
> it? So how do I make the LL/ARP modules use it immediately without
> using ARP?
> 
> I tried adding the following two lines at the top of
> ARPTable::arpresolve(nsaddr_t dst, Packet *p, LL *ll)
> 
> mac_->hdr_dst((char*) HDR_MAC(p), dst);
> return 0;
> 
> but that caused strange behaviour on rare occasions, where a packet
> suddenly would appear in another far node. Playing with ARP doesn't
> explain the problem for me, but somehow removing those two lines
> gets rid of the strange behaviour. So, what is a proper way of
> disabling ARP?
> 
> Thanks..
> Ahmad