• Main Page
  • Classes
  • Files
  • File List

/Users/yzchen/ns/ns-allinone-2.33/ns-2.33/trace/cmu-trace.h

00001 /* -*-  Mode:C++; c-basic-offset:8; tab-width:8; indent-tabs-mode:t -*-
00002  *
00003  * Copyright (c) 1997 Regents of the University of California.
00004  * All rights reserved.
00005  *
00006  * Redistribution and use in source and binary forms, with or without
00007  * modification, are permitted provided that the following conditions
00008  * are met:
00009  * 1. Redistributions of source code must retain the above copyright
00010  *    notice, this list of conditions and the following disclaimer.
00011  * 2. Redistributions in binary form must reproduce the above copyright
00012  *    notice, this list of conditions and the following disclaimer in the
00013  *    documentation and/or other materials provided with the distribution.
00014  * 3. All advertising materials mentioning features or use of this software
00015  *    must display the following acknowledgement:
00016  *      This product includes software developed by the Computer Systems
00017  *      Engineering Group at Lawrence Berkeley Laboratory.
00018  * 4. Neither the name of the University nor of the Laboratory may be used
00019  *    to endorse or promote products derived from this software without
00020  *    specific prior written permission.
00021  *
00022  * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
00023  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
00024  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
00025  * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
00026  * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
00027  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
00028  * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
00029  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
00030  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
00031  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
00032  * SUCH DAMAGE.
00033  *
00034  * $Header: /cvsroot/nsnam/ns-2/trace/cmu-trace.h,v 1.27 2008/02/18 03:39:03 tom_henderson Exp $
00035  */
00036 
00037 /* Ported from CMU/Monarch's code, nov'98 -Padma.*/
00038 
00039 #ifndef __cmu_trace__
00040 #define __cmu_trace__
00041 
00042 #include "trace.h"
00043 #include "god.h"
00044 
00045 #ifndef __PRETTY_FUNCTION__
00046 #define __PRETTY_FUNCTION__ ("")
00047 #endif /* !__PRETTY_FUNCTION__ */
00048 
00049 /* ======================================================================
00050    Global Defines
00051    ====================================================================== */
00052 #define DROP            'D'
00053 #define RECV            'r'
00054 #define SEND            's'
00055 #define FWRD            'f'
00056 
00057 // change wrt Mike's code
00058 #define EOT             'x'
00059 
00060 
00061 
00062 #define TR_ROUTER       0x01
00063 #define TR_MAC          0x02
00064 #define TR_IFQ          0x04
00065 #define TR_AGENT        0x08
00066 
00067 #define TR_PHY          0x10
00068 
00069 #define DROP_END_OF_SIMULATION          "END"
00070 #define DROP_MAC_COLLISION              "COL"
00071 #define DROP_MAC_DUPLICATE              "DUP"
00072 #define DROP_MAC_PACKET_ERROR           "ERR"
00073 #define DROP_MAC_RETRY_COUNT_EXCEEDED   "RET"
00074 #define DROP_MAC_INVALID_STATE          "STA"
00075 #define DROP_MAC_BUSY                   "BSY"
00076 #define DROP_MAC_INVALID_DST            "DST"
00077 #define DROP_MAC_SLEEP                  "SLP"   // smac sleep state
00078 
00079 #define DROP_RTR_NO_ROUTE               "NRTE"  // no route
00080 #define DROP_RTR_ROUTE_LOOP             "LOOP"  // routing loop
00081 #define DROP_RTR_TTL                    "TTL"   // ttl reached zero
00082 #define DROP_RTR_QFULL                  "IFQ"   // queue full
00083 #define DROP_RTR_QTIMEOUT               "TOUT"  // packet expired
00084 #define DROP_RTR_MAC_CALLBACK           "CBK"   // MAC callback
00085 #define DROP_RTR_SALVAGE                "SAL"
00086 
00087 #define DROP_IFQ_QFULL                  "IFQ"   // no buffer space in IFQ
00088 #define DROP_IFQ_ARP_FULL               "ARP"   // dropped by ARP
00089 #define DROP_IFQ_FILTER                 "FIL"
00090 
00091 #define DROP_OUTSIDE_SUBNET             "OUT"   // dropped by base stations if received rtg updates from nodes outside its domain.
00092 
00093 #define MAX_ID_LEN      3
00094 #define MAX_NODE        4096
00095 
00101 class PacketTracer
00102 {
00103         public:
00104                 PacketTracer();
00105                 virtual ~PacketTracer();
00106                 void setNext(PacketTracer *next);
00107                 PacketTracer *getNext();
00108                 int format_unknow(Packet *p, int offset, BaseTrace *pt_, int newtrace);
00109         protected:
00110                 virtual int format(Packet *p, int offset, BaseTrace *pt_, int newtrace) = 0;    //return 0 if the packet is unknown
00111                 PacketTracer *next_;
00112 };
00113 
00114 
00115 class CMUTrace : public Trace {
00116 public:
00117         CMUTrace(const char *s, char t);
00118         void    recv(Packet *p, Handler *h);
00119         void    recv(Packet *p, const char* why);
00120 
00121         static void addPacketTracer(PacketTracer *pt);
00122 
00123 
00124 private:
00125         char    tracename[MAX_ID_LEN + 1];
00126         int     nodeColor[MAX_NODE];
00127         int     tracetype;
00128         MobileNode *node_;
00129         int     newtrace_;
00130 
00131         //<zheng: ns 2.27 removed the following part, but we need it to control the broadcast radius>
00132         static double  bradius;
00133         static double  radius_scaling_factor_;
00134         static double  duration_scaling_factor_;
00135         static void calculate_broadcast_parameters();
00136         //</zheng>
00137 
00138         int     initialized() { return node_ && 1; }
00139         int     node_energy();
00140         int             command(int argc, const char*const* argv);
00141         void    format(Packet *p, const char *why);
00142 
00143         void    nam_format(Packet *p, int offset);
00144 
00145         void    format_phy(Packet *p, int offset);
00146 
00147         void    format_mac_common(Packet *p, const char *why, int offset);
00148         void    format_mac(Packet *p, int offset);
00149         void    format_smac(Packet *p, int offset);
00150         void    format_ip(Packet *p, int offset);
00151 
00152         void    format_arp(Packet *p, int offset);
00153         void    format_hdlc(Packet *p, int offset);
00154         void    format_dsr(Packet *p, int offset);
00155         void    format_msg(Packet *p, int offset);
00156         void    format_tcp(Packet *p, int offset);
00157         void    format_sctp(Packet *p, int offset);
00158         void    format_rtp(Packet *p, int offset);
00159         void    format_tora(Packet *p, int offset);
00160         void    format_imep(Packet *p, int offset);
00161         void    format_aodv(Packet *p, int offset);
00162         void    format_olsr(Packet* p, int offset);
00163         void    format_cdswl(Packet* p, int offset);
00164 
00165         // This holds all the tracers added at run-time
00166         static PacketTracer *pktTrc_;
00167 
00168 };
00169 
00170 #endif /* __cmu_trace__ */

Generated on Tue Aug 10 2010 16:16:08 for ns-2.33 by  doxygen 1.7.1