umts-tracer.cc

00001 /*
00002  * Copyright (c) 2007 Regents of the SIGNET lab, University of Padova.
00003  * All rights reserved.
00004  *
00005  * Redistribution and use in source and binary forms, with or without
00006  * modification, are permitted provided that the following conditions
00007  * are met:
00008  * 1. Redistributions of source code must retain the above copyright
00009  *    notice, this list of conditions and the following disclaimer.
00010  * 2. Redistributions in binary form must reproduce the above copyright
00011  *    notice, this list of conditions and the following disclaimer in the
00012  *    documentation and/or other materials provided with the distribution.
00013  * 3. Neither the name of the University of Padova (SIGNET lab) nor the 
00014  *    names of its contributors may be used to endorse or promote products 
00015  *    derived from this software without specific prior written permission.
00016  *
00017  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 
00018  * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED 
00019  * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR 
00020  * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR 
00021  * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, 
00022  * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, 
00023  * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; 
00024  * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, 
00025  * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR 
00026  * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF 
00027  * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
00028  */
00029 
00030 //#include "mphy.h"
00031 //#include<math.h>
00032 //#include<node-core.h>
00033 #include<packettracer.h>
00034 #include<sap.h>
00035 #include<packet.h>
00036 #include"umts-phy.h"
00037 #include"umts-headers.h"
00038 #include"umts-packet.h"
00039 #include<string>
00040 
00041 
00042 class UmtsTracer : public Tracer
00043 {
00044  public:
00045   UmtsTracer();
00046  protected:
00047   void format(Packet *p, SAP* sap);
00048 };
00049 
00050 
00051 
00052 UmtsTracer::UmtsTracer() : Tracer(1) {}
00053 
00054 
00055 void UmtsTracer::format(Packet *p, SAP *sap)
00056 {
00057 
00058 
00059   hdr_cmn* ch = HDR_CMN(p);
00060   hdr_umtsphy* uh = HDR_UMTSPHY(p);
00061   hdr_MPhy*    ph = HDR_MPHY(p); 
00062   hdr_rlc*   rlch = hdr_rlc::access(p);
00063 
00064   packet_t  t = ch->ptype();
00065 
00066   //  if ((t != PT_UM) && (t != PT_AM)) 
00067   if (t == PT_AM) 
00068     {
00069       //fprintf(stderr,"UMTSTRACER:  type RLC/A;\n");   
00070     }
00071   else if (t == PT_UMTSCTRL) 
00072     {
00073       //fprintf(stderr,"UMTSTRACER:  type UMTS/CTRL\n");
00074     }
00075   else 
00076     {
00077       // fprintf(stderr,"UMTSTRACER: unknown type\n");
00078       return;
00079     }
00080 
00081 
00082 
00083   char tstr[10];
00084   //  if ((uh->bs_code_id > 0)||(uh->me_code_id > 0))
00085   if (uh->me_code_id > 0)
00086     {
00087 //       if (uh->direction == DIRECTION_DOWNLINK)       
00088 //      snprintf(tstr,3,"%03d",uh->bs_code_id);
00089 //       else
00090         snprintf(tstr,9,"%02d",uh->me_code_id);
00091     }
00092   else
00093     strncpy(tstr, "   ", 9);    
00094   tstr[9] = '\0';  
00095 
00096 
00097 
00098   string descr;
00099 
00100   if (ch->ptype() == PT_AM) 
00101     {
00102       descr.append("AM");
00103       descr.append((rlch->lltype() & RLC_DATA) ? "DATA" : "STATUS");
00104       if (rlch->lltype() & RLC_BITMAP) descr.append(" BITMAP");
00105       if (rlch->lltype() & RLC_MRW) 
00106         {
00107           descr.append(" MRW");
00108           char fsn[10];
00109           snprintf(fsn,10," %d",rlch->SN_MRW);
00110           descr.append(fsn);
00111         }
00112       if (rlch->lltype() & RLC_MRWACK) 
00113         {
00114           descr.append(" MRWACK");
00115           char fsn[10];
00116           snprintf(fsn,10," %d",rlch->SN_MRW_ACK);
00117           descr.append(fsn);
00118         }
00119 
00120       if (rlch->lltype() & RLC_ACK) descr.append(" ACK");
00121       if (rlch->poll()) descr.append(" POLL");
00122     }
00123   else if (ch->ptype() == PT_UMTSCTRL)
00124     {
00125       descr.append("CTRL");
00126     }
00127   else if (ch->ptype() == PT_UM)
00128     {
00129       descr.append("UM");
00130     }
00131   else 
00132     {
00133       descr.append("UNKOWN");
00134     }
00135   
00136 
00137 
00138 
00139   writeTrace(sap, " UMTS %s %s %s %s %02d %02d %03d %s %s",
00140              (uh->direction == DIRECTION_DOWNLINK) ? "DL" : "UL",
00141              (uh->data == true) ? "D" : "C",
00142              (uh->powerUp == true) ? "PU" : "PD",
00143              tstr,
00144              rlch->src_rlc_id_, 
00145              rlch->dst_rlc_id_,
00146              rlch->seqno(),
00147              (rlch->eopno() == rlch->seqno()) ? "eop" : "---",
00148              descr.c_str());
00149              
00150 }
00151 
00152 extern "C" int Umtstracer_Init()
00153 {  
00154   SAP::addTracer(new UmtsTracer);
00155   return 0;
00156 }
00157 extern "C" int  Cygumtstracer_Init()
00158 {
00159   Umtstracer_Init();
00160 }
00161 
00162 

Generated on Wed Nov 26 15:47:29 2008 for NS-MIRACLE library by  doxygen 1.5.2