Friday, August 24, 2007

Suppress ARP Lookup in ns-2

Sometimes, it is annoying to see packets drop due to ARQ failures (showed as IFQ ARP in traces). Here is a quick fix, define a new variable trivial_mode_ in Arp.h. When it is on, the ARP lookup and query procedure is suppressed and a number as same as IP id will be used as MAC id.

Related codes in arp.cc:


ARPTable::ARPTable(const char *tclnode, const char *tclmac):
LinkDelay(),trivial_mode_(0){
LIST_INIT(&arphead_);
node_ = (MobileNode*) TclObject::lookup(tclnode);
assert(node_);

mac_ = (Mac*) TclObject::lookup(tclmac);
assert(mac_);
LIST_INSERT_HEAD(&athead_, this, link_);
//adding a mode to avoid ARP procedure
bind ("trivial_mode_", &trivial_mode_);
}

ARPEntry*
ARPTable::arplookup(nsaddr_t dst)
{
ARPEntry *a, *llinfo;

for(a = arphead_.lh_first; a; a = a->nextarp()) {
if(a->ipaddr_ == dst)
return a;
}
if (!trivial_mode_)
return 0;
else{
llinfo = new ARPEntry(&arphead_, dst);
assert(llinfo);
llinfo->macaddr_ = int(dst);
llinfo->up_ = 1;
return llinfo;
}

}

No comments: