00001 // 00002 // iostats.hh : Collect various statistics for Diffusion 00003 // authors : Chalermek Intanagonwiwat and Fabio Silva 00004 // 00005 // Copyright (C) 2000-2003 by the University of Southern California 00006 // $Id: iostats.hh,v 1.2 2005/09/13 04:53:47 tomh Exp $ 00007 // 00008 // This program is free software; you can redistribute it and/or 00009 // modify it under the terms of the GNU General Public License, 00010 // version 2, as published by the Free Software Foundation. 00011 // 00012 // This program is distributed in the hope that it will be useful, 00013 // but WITHOUT ANY WARRANTY; without even the implied warranty of 00014 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 00015 // GNU General Public License for more details. 00016 // 00017 // You should have received a copy of the GNU General Public License along 00018 // with this program; if not, write to the Free Software Foundation, Inc., 00019 // 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA. 00020 // 00021 // Linking this file statically or dynamically with other modules is making 00022 // a combined work based on this file. Thus, the terms and conditions of 00023 // the GNU General Public License cover the whole combination. 00024 // 00025 // In addition, as a special exception, the copyright holders of this file 00026 // give you permission to combine this file with free software programs or 00027 // libraries that are released under the GNU LGPL and with code included in 00028 // the standard release of ns-2 under the Apache 2.0 license or under 00029 // otherwise-compatible licenses with advertising requirements (or modified 00030 // versions of such code, with unchanged license). You may copy and 00031 // distribute such a system following the terms of the GNU GPL for this 00032 // file and the licenses of the other code concerned, provided that you 00033 // include the source code of that other code when and as the GNU GPL 00034 // requires distribution of source code. 00035 // 00036 // Note that people who make modified versions of this file are not 00037 // obligated to grant this special exception for their modified versions; 00038 // it is their choice whether to do so. The GNU General Public License 00039 // gives permission to release a modified version without this exception; 00040 // this exception also makes it possible to release a modified version 00041 // which carries forward this exception. 00042 00043 #ifndef _STATS_HH_ 00044 #define _STATS_HH_ 00045 00046 #ifdef HAVE_CONFIG_H 00047 #include "config.h" 00048 #endif // HAVE_CONFIG_H 00049 00050 #include <list> 00051 00052 #include "main/message.hh" 00053 #include "main/tools.hh" 00054 00055 using namespace std; 00056 00057 class NeighborStatsEntry { 00058 public: 00059 int id_; 00060 int recv_messages_; 00061 int recv_bcast_messages_; 00062 int sent_messages_; 00063 00064 NeighborStatsEntry(int id) : id_(id) 00065 { 00066 recv_messages_ = 0; 00067 recv_bcast_messages_ = 0; 00068 sent_messages_ = 0; 00069 } 00070 }; 00071 00072 typedef list<NeighborStatsEntry *> NeighborStatsList; 00073 00074 class DiffusionStats { 00075 public: 00076 DiffusionStats(int id, int warm_up_time = 0); 00077 void logIncomingMessage(Message *msg); 00078 void logOutgoingMessage(Message *msg); 00079 void printStats(FILE *output); 00080 bool ignoreEvent(); 00081 00082 private: 00083 int node_id_; 00084 int warm_up_time_; 00085 struct timeval start_; 00086 struct timeval finish_; 00087 NeighborStatsList nodes_; 00088 00089 // Counters 00090 int num_bytes_recv_; 00091 int num_bytes_sent_; 00092 int num_packets_recv_; 00093 int num_packets_sent_; 00094 int num_bcast_bytes_recv_; 00095 int num_bcast_bytes_sent_; 00096 int num_bcast_packets_recv_; 00097 int num_bcast_packets_sent_; 00098 00099 // Message counter 00100 int num_interest_messages_sent_; 00101 int num_interest_messages_recv_; 00102 int num_data_messages_sent_; 00103 int num_data_messages_recv_; 00104 int num_exploratory_data_messages_sent_; 00105 int num_exploratory_data_messages_recv_; 00106 int num_pos_reinforcement_messages_sent_; 00107 int num_pos_reinforcement_messages_recv_; 00108 int num_neg_reinforcement_messages_sent_; 00109 int num_neg_reinforcement_messages_recv_; 00110 00111 int num_new_messages_sent_; 00112 int num_new_messages_recv_; 00113 int num_old_messages_sent_; 00114 int num_old_messages_recv_; 00115 00116 NeighborStatsEntry * getNeighbor(int id); 00117 }; 00118 00119 #endif // !_STATS_HH_
1.4.6