aodv_logs.cc

Go to the documentation of this file.
00001 /*
00002 Copyright (c) 1997, 1998 Carnegie Mellon University.  All Rights
00003 Reserved. 
00004 
00005 Redistribution and use in source and binary forms, with or without
00006 modification, are permitted provided that the following conditions are met:
00007 
00008 1. Redistributions of source code must retain the above copyright notice,
00009 this list of conditions and the following disclaimer.
00010 2. Redistributions in binary form must reproduce the above copyright notice,
00011 this list of conditions and the following disclaimer in the documentation
00012 and/or other materials provided with the distribution.
00013 3. The name of the author may not be used to endorse or promote products
00014 derived from this software without specific prior written permission.
00015 
00016 THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
00017 IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
00018 OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
00019 IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
00020 SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
00021 PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
00022 OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
00023 WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
00024 OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
00025 ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
00026 
00027 The AODV code developed by the CMU/MONARCH group was optimized and tuned by Samir Das and Mahesh Marina, University of Cincinnati. The work was partially done in Sun Microsystems.
00028  
00029 */
00030 
00031 #include <aodv/aodv.h>
00032 #include <aodv/aodv_packet.h>
00033 #include <ip.h>
00034 
00035 #define CURRENT_TIME    Scheduler::instance().clock()
00036 
00037 static const int verbose = 0;
00038 
00039 /* =====================================================================
00040    Logging Functions
00041    ===================================================================== */
00042 void
00043 AODV::log_link_del(nsaddr_t dst)
00044 {
00045         static int link_del = 0;
00046 
00047         if(! logtarget || ! verbose) return;
00048 
00049         /*
00050          *  If "god" thinks that these two nodes are still
00051          *  reachable then this is an erroneous deletion.
00052          */
00053         sprintf(logtarget->pt_->buffer(),
00054                 "A %.9f _%d_ deleting LL hop to %d (delete %d is %s)",
00055                 CURRENT_TIME,
00056                 index,
00057                 dst,
00058                 ++link_del,
00059                 God::instance()->hops(index, dst) != 1 ? "VALID" : "INVALID");
00060         logtarget->pt_->dump();
00061 }
00062 
00063 
00064 void
00065 AODV::log_link_broke(Packet *p)
00066 {
00067         static int link_broke = 0;
00068         struct hdr_cmn *ch = HDR_CMN(p);
00069 
00070         if(! logtarget || ! verbose) return;
00071 
00072         sprintf(logtarget->pt_->buffer(),
00073                 "A %.9f _%d_ LL unable to deliver packet %d to %d (%d) (reason = %d, ifqlen = %d)",
00074                 CURRENT_TIME,
00075                 index,
00076                 ch->uid_,
00077                 ch->next_hop_,
00078                 ++link_broke,
00079                 ch->xmit_reason_,
00080                 ifqueue->length());
00081     logtarget->pt_->dump();
00082 }
00083 
00084 void
00085 AODV::log_link_kept(nsaddr_t dst)
00086 {
00087         static int link_kept = 0;
00088 
00089         if(! logtarget || ! verbose) return;
00090 
00091 
00092         /*
00093          *  If "god" thinks that these two nodes are now
00094          *  unreachable, then we are erroneously keeping
00095          *  a bad route.
00096          */
00097         sprintf(logtarget->pt_->buffer(),
00098                 "A %.9f _%d_ keeping LL hop to %d (keep %d is %s)",
00099                 CURRENT_TIME,
00100                 index,
00101                 dst,
00102                 ++link_kept,
00103                 God::instance()->hops(index, dst) == 1 ? "VALID" : "INVALID");
00104         logtarget->pt_->dump();
00105 }
00106 

Generated on Tue Mar 6 16:47:43 2007 for ns2 Network Simulator 2.29 by  doxygen 1.4.6