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

[ns] possible bug in MAC ARP



 Hi, there:
   I post a message yesterday about ARP timeout. Now I found the reason.
 But I think the working principle of ARP is not reasonable in ns-2.

   In arp.cc, the maximum number of packets which are waiting  for ARP
 reply is defined to be 3. These packets must have different destination
 addresses. If when one packet is waiting for ARP reply, another packet
 which has the same destination address as the first packet arrives, the
 second packet will overwrite the first packet and send another ARP
 request at once, regardless of whether the first ARP is timeout.
   In my opinion, dropping a packet without buffering or retry is brute.
 if the first packet is very important (such as routing reply), dropping
 the first packet will cause the loss of a path. I would to know if LL
 layer provide retry function if ARP failed?

  Thanks a lot!

 Frank



 int
 ARPTable::arpresolve(nsaddr_t dst, Packet *p, LL *ll)
 {
         ARPEntry *llinfo ;

 	assert(initialized());

 	llinfo = arplookup(dst);
  #ifdef DEBUG
         fprintf(stderr, "%d - %s\n", node_->address(), __FUNCTION__);
 #endif

 	if(llinfo && llinfo->up_) {
 		mac_->hdr_dst((char*) HDR_MAC(p), llinfo->macaddr_);
 		return 0;
 	}

 	if(llinfo == 0) {
 		/*
 		 *  Create a new ARP entry
 		 */
 		llinfo = new ARPEntry(&arphead_, dst);
 	}

         if(llinfo->count_ >= ARP_MAX_REQUEST_COUNT) {
                 /*
                  * Because there is not necessarily a scheduled event between
                  * this callback and the point where the callback can return
                  * to this point in the code, the order of operations is very
                  * important here so that we don't get into an infinite loop.
                  *                                      - josh
                  */
                 Packet *t = llinfo->hold_;

                 llinfo->count_ = 0;
                 llinfo->hold_ = 0;
 		hdr_cmn* ch;

                 if(t) {
                         ch = HDR_CMN(t);

                         if (ch->xmit_failure_) {
                                 ch->xmit_reason_ = 0;
                                 ch->xmit_failure_(t, ch->xmit_failure_data_);
                         }
                         else {
                                 drop(t, DROP_IFQ_ARP_FULL);
                         }
                 }

                 ch = HDR_CMN(p);

 		if (ch->xmit_failure_) {
                         ch->xmit_reason_ = 0;
                         ch->xmit_failure_(p, ch->xmit_failure_data_);
                 }
                 else {
                         drop(p, DROP_IFQ_ARP_FULL);
                 }

                 return EADDRNOTAVAIL;
         }

 	llinfo->count_++;


 	if(llinfo->hold_)
 	        drop(llinfo->hold_, DROP_IFQ_ARP_FULL);
 	llinfo->hold_ = p;

	/*
 	 *  We don't have a MAC address for this node.  Send an ARP Request.
 	 *
 	 *  XXX: Do I need to worry about the case where I keep ARPing
 	 *	 for the SAME destination.
 	 */
 	int src = node_->address(); // this host's IP addr
 	arprequest(src, dst, ll);
 	return EADDRNOTAVAIL;
 }