/[resiprocate]/main/sip/resiprocate/StatisticsMessage.cxx
ViewVC logotype

Contents of /main/sip/resiprocate/StatisticsMessage.cxx

Parent Directory Parent Directory | Revision Log Revision Log


Revision 4599 - (show annotations) (download)
Wed May 11 23:10:19 2005 UTC (14 years, 7 months ago) by derek
File size: 12650 byte(s)
set svn:eol-style to LF
1 #include "resiprocate/StatisticsMessage.hxx"
2 #include "resiprocate/os/Lock.hxx"
3 #include "resiprocate/os/Logger.hxx"
4 #include "resiprocate/os/WinLeakCheck.hxx"
5
6 #include <string.h>
7
8 using namespace resip;
9
10 #define RESIPROCATE_SUBSYSTEM Subsystem::STATS
11
12 StatisticsMessage::StatisticsMessage(const StatisticsMessage::AtomicPayload& payload)
13 : ApplicationMessage(),
14 mPayload(payload)
15 {}
16
17 StatisticsMessage::StatisticsMessage(const StatisticsMessage& rhs)
18 : ApplicationMessage(rhs),
19 mPayload(rhs.mPayload)
20 {}
21
22 StatisticsMessage::~StatisticsMessage()
23 {}
24
25 Data
26 StatisticsMessage::brief() const
27 {
28 return "StatisticsMessage";
29 }
30
31 std::ostream&
32 StatisticsMessage::encode(std::ostream& strm) const
33 {
34 strm << "StatisticsMessage[";
35 /*
36 Payload payload;
37 mPayload.loadOut(payload);
38 strm << payload << "]";
39 */
40 return strm;
41 }
42
43 unsigned int
44 StatisticsMessage::Payload::sum2xxIn(MethodTypes method) const
45 {
46 unsigned int ret = 0;
47 for (int code = 200; code < 300; ++code)
48 {
49 ret += responsesReceivedByMethodByCode[method][code];
50 }
51
52 return ret;
53 }
54
55 unsigned int
56 StatisticsMessage::Payload::sum2xxOut(MethodTypes method) const
57 {
58 unsigned int ret = 0;
59 for (int code = 200; code < 300; ++code)
60 {
61 ret += responsesSentByMethodByCode[method][code];
62 }
63
64 return ret;
65 }
66
67 unsigned int
68 StatisticsMessage::Payload::sumErrIn(MethodTypes method) const
69 {
70 unsigned int ret = 0;
71 for (int code = 300; code < MaxCode; ++code)
72 {
73 ret += responsesReceivedByMethodByCode[method][code];
74 }
75
76 return ret;
77 }
78
79 unsigned int
80 StatisticsMessage::Payload::sumErrOut(MethodTypes method) const
81 {
82 unsigned int ret = 0;
83 for (int code = 300; code < MaxCode; ++code)
84 {
85 ret += responsesSentByMethodByCode[method][code];
86 }
87
88 return ret;
89 }
90
91 void
92 StatisticsMessage::logStats(const resip::Subsystem& subsystem,
93 const StatisticsMessage::Payload& stats)
94 {
95 unsigned int retriesFinal = 0;
96 for (int c = 200; c < 300; ++c)
97 {
98 retriesFinal += stats.responsesRetransmittedByMethodByCode[INVITE][c];
99 }
100
101 unsigned int retriesNonFinal = 0;
102 for (int c = 100; c < 200; ++c)
103 {
104 retriesNonFinal += stats.responsesRetransmittedByMethodByCode[INVITE][c];
105 }
106
107 WarningLog(<< subsystem
108 << std::endl
109 << "TU summary: " << stats.tuFifoSize
110 << " TRANSPORT " << stats.transportFifoSizeSum
111 << " TRANSACTION " << stats.transactionFifoSize
112 << " CLIENTTX " << stats.activeClientTransactions
113 << " SERVERTX " << stats.activeServerTransactions
114 << " TIMERS " << stats.activeTimers
115 << std::endl
116 << "Transaction summary: reqi " << stats.requestsReceived
117 << " reqo " << stats.requestsSent
118 << " rspi " << stats.responsesReceived
119 << " rspo " << stats.responsesSent
120 << std::endl
121 << "Details: INVi " << stats.requestsReceivedByMethod[INVITE] << "/S" << stats.sum2xxOut(INVITE) << "/F" << stats.sumErrOut(INVITE)
122 << " INVo " << stats.requestsSentByMethod[INVITE]-stats.requestsRetransmittedByMethod[INVITE] << "/S" << stats.sum2xxIn(INVITE) << "/F" << stats.sumErrIn(INVITE)
123 << " ACKi " << stats.requestsReceivedByMethod[ACK]
124 << " ACKo " << stats.requestsSentByMethod[ACK]-stats.requestsRetransmittedByMethod[ACK]
125 << " BYEi " << stats.requestsReceivedByMethod[BYE] << "/S" << stats.sum2xxOut(BYE) << "/F" << stats.sumErrOut(BYE)
126 << " BYEo " << stats.requestsSentByMethod[BYE]-stats.requestsRetransmittedByMethod[BYE] << "/S" << stats.sum2xxIn(BYE) << "/F" << stats.sumErrIn(BYE)
127 << " CANi " << stats.requestsReceivedByMethod[CANCEL] << "/S" << stats.sum2xxOut(BYE) << "/F" << stats.sumErrOut(BYE)
128 << " CANo " << stats.requestsSentByMethod[CANCEL]-stats.requestsRetransmittedByMethod[CANCEL] << "/S" << stats.sum2xxIn(CANCEL) << "/F" << stats.sumErrIn(CANCEL)
129 << " MSGi " << stats.requestsReceivedByMethod[MESSAGE] << "/S" << stats.sum2xxOut(MESSAGE) << "/F" << stats.sumErrOut(MESSAGE)
130 << " MSGo " << stats.requestsSentByMethod[MESSAGE]-stats.requestsRetransmittedByMethod[MESSAGE] << "/S" << stats.sum2xxIn(MESSAGE) << "/F" << stats.sumErrIn(MESSAGE)
131 << " OPTi " << stats.requestsReceivedByMethod[OPTIONS] << "/S" << stats.sum2xxOut(OPTIONS) << "/F" << stats.sumErrOut(OPTIONS)
132 << " OPTo " << stats.requestsSentByMethod[OPTIONS]-stats.requestsRetransmittedByMethod[OPTIONS] << "/S" << stats.sum2xxIn(OPTIONS) << "/F" << stats.sumErrIn(OPTIONS)
133 << " REGi " << stats.requestsReceivedByMethod[REGISTER] << "/S" << stats.sum2xxOut(REGISTER) << "/F" << stats.sumErrOut(REGISTER)
134 << " REGo " << stats.requestsSentByMethod[REGISTER]-stats.requestsRetransmittedByMethod[REGISTER] << "/S" << stats.sum2xxIn(REGISTER) << "/F" << stats.sumErrIn(REGISTER)
135 << " PUBi " << stats.requestsReceivedByMethod[PUBLISH] << "/S" << stats.sum2xxOut(PUBLISH) << "/F" << stats.sumErrOut(PUBLISH)
136 << " PUBo " << stats.requestsSentByMethod[PUBLISH] << "/S" << stats.sum2xxIn(PUBLISH) << "/F" << stats.sumErrIn(PUBLISH)
137 << " SUBi " << stats.requestsReceivedByMethod[SUBSCRIBE] << "/S" << stats.sum2xxOut(SUBSCRIBE) << "/F" << stats.sumErrOut(SUBSCRIBE)
138 << " SUBo " << stats.requestsSentByMethod[SUBSCRIBE] << "/S" << stats.sum2xxIn(SUBSCRIBE) << "/F" << stats.sumErrIn(SUBSCRIBE)
139 << " NOTi " << stats.requestsReceivedByMethod[NOTIFY] << "/S" << stats.sum2xxOut(NOTIFY) << "/F" << stats.sumErrOut(NOTIFY)
140 << " NOTo " << stats.requestsSentByMethod[NOTIFY] << "/S" << stats.sum2xxIn(NOTIFY) << "/F" << stats.sumErrIn(NOTIFY)
141 << std::endl
142 << "Retransmissions: INVx " << stats.requestsRetransmittedByMethod[INVITE]
143 << " BYEx " << stats.requestsRetransmittedByMethod[BYE]
144 << " CANx " << stats.requestsRetransmittedByMethod[CANCEL]
145 << " MSGx " << stats.requestsRetransmittedByMethod[MESSAGE]
146 << " OPTx " << stats.requestsRetransmittedByMethod[OPTIONS]
147 << " REGx " << stats.requestsRetransmittedByMethod[REGISTER]
148 << " finx " << retriesFinal
149 << " nonx " << retriesNonFinal
150 << " PUBx " << stats.requestsRetransmittedByMethod[PUBLISH]
151 << " SUBx " << stats.requestsRetransmittedByMethod[SUBSCRIBE]
152 << " NOTx " << stats.requestsRetransmittedByMethod[NOTIFY]);
153 }
154
155
156 Message*
157 StatisticsMessage::clone() const
158 {
159 return new StatisticsMessage(*this);
160 }
161
162 StatisticsMessage::Payload::Payload()
163 : tuFifoSize(0),
164 transportFifoSizeSum(0),
165 transactionFifoSize(0),
166 activeTimers(0),
167 openTcpConnections(0),
168 activeClientTransactions(0),
169 activeServerTransactions(0),
170 pendingDnsQueries(0),
171 requestsSent(0),
172 responsesSent(0),
173 requestsRetransmitted(0),
174 responsesRetransmitted(0),
175 requestsReceived(0),
176 responsesReceived(0)
177 {
178 memset(responsesByCode, 0, sizeof(responsesByCode));
179 memset(requestsSentByMethod, 0, sizeof(requestsSentByMethod));
180 memset(requestsRetransmittedByMethod, 0, sizeof(requestsRetransmittedByMethod));
181 memset(requestsReceivedByMethod, 0, sizeof(requestsReceivedByMethod));
182 memset(responsesSentByMethod, 0, sizeof(responsesSentByMethod));
183 memset(responsesRetransmittedByMethod, 0, sizeof(responsesRetransmittedByMethod));
184 memset(responsesReceivedByMethod, 0, sizeof(responsesReceivedByMethod));
185 memset(responsesSentByMethodByCode, 0, sizeof(responsesSentByMethodByCode));
186 memset(responsesRetransmittedByMethodByCode, 0, sizeof(responsesRetransmittedByMethodByCode));
187 memset(responsesReceivedByMethodByCode, 0, sizeof(responsesReceivedByMethodByCode));
188 }
189
190 StatisticsMessage::Payload&
191 StatisticsMessage::Payload::operator=(const StatisticsMessage::Payload& rhs)
192 {
193 if (&rhs != this)
194 {
195 transportFifoSizeSum = rhs.transportFifoSizeSum;
196 tuFifoSize = rhs.tuFifoSize;
197 activeTimers = rhs.activeTimers;
198 transactionFifoSize = rhs.transactionFifoSize;
199
200 openTcpConnections = rhs.openTcpConnections;
201 activeClientTransactions = rhs.activeClientTransactions;
202 activeServerTransactions = rhs.activeServerTransactions;
203 pendingDnsQueries = rhs.pendingDnsQueries;
204
205 requestsSent = rhs.requestsSent;
206 responsesSent = rhs.responsesSent;
207 requestsRetransmitted = rhs.requestsRetransmitted;
208 responsesRetransmitted = rhs.responsesRetransmitted;
209 requestsReceived = rhs.requestsReceived;
210 responsesReceived = rhs.responsesReceived;
211
212 memcpy(responsesByCode, rhs.responsesByCode, sizeof(responsesByCode));
213 memcpy(requestsSentByMethod, rhs.requestsSentByMethod, sizeof(requestsSentByMethod));
214 memcpy(requestsRetransmittedByMethod, rhs.requestsRetransmittedByMethod, sizeof(requestsRetransmittedByMethod));
215 memcpy(requestsReceivedByMethod, rhs.requestsReceivedByMethod, sizeof(requestsReceivedByMethod));
216 memcpy(responsesSentByMethod, rhs.responsesSentByMethod, sizeof(responsesSentByMethod));
217 memcpy(responsesRetransmittedByMethod, rhs.responsesRetransmittedByMethod, sizeof(responsesRetransmittedByMethod));
218 memcpy(responsesReceivedByMethod, rhs.responsesReceivedByMethod, sizeof(responsesReceivedByMethod));
219 memcpy(responsesSentByMethodByCode, rhs.responsesSentByMethodByCode, sizeof(responsesSentByMethodByCode));
220 memcpy(responsesRetransmittedByMethodByCode, rhs.responsesRetransmittedByMethodByCode, sizeof(responsesRetransmittedByMethodByCode));
221 memcpy(responsesReceivedByMethodByCode, rhs.responsesReceivedByMethodByCode, sizeof(responsesReceivedByMethodByCode));
222 }
223
224 return *this;
225 }
226
227 void
228 StatisticsMessage::loadOut(Payload& payload) const
229 {
230 mPayload.loadOut(payload);
231 }
232
233 StatisticsMessage::AtomicPayload::AtomicPayload()
234 {}
235
236 void
237 StatisticsMessage::AtomicPayload::loadIn(const Payload& payload)
238 {
239 Lock lock(mMutex);
240 Payload::operator=(payload);
241 }
242
243 void
244 StatisticsMessage::AtomicPayload::loadOut(Payload& payload) const
245 {
246 Lock lock(mMutex);
247 payload = (*this);
248 }
249
250 /* ====================================================================
251 * The Vovida Software License, Version 1.0
252 *
253 * Copyright (c) 2004 Vovida Networks, Inc. All rights reserved.
254 *
255 * Redistribution and use in source and binary forms, with or without
256 * modification, are permitted provided that the following conditions
257 * are met:
258 *
259 * 1. Redistributions of source code must retain the above copyright
260 * notice, this list of conditions and the following disclaimer.
261 *
262 * 2. Redistributions in binary form must reproduce the above copyright
263 * notice, this list of conditions and the following disclaimer in
264 * the documentation and/or other materials provided with the
265 * distribution.
266 *
267 * 3. The names "VOCAL", "Vovida Open Communication Application Library",
268 * and "Vovida Open Communication Application Library (VOCAL)" must
269 * not be used to endorse or promote products derived from this
270 * software without prior written permission. For written
271 * permission, please contact vocal@vovida.org.
272 *
273 * 4. Products derived from this software may not be called "VOCAL", nor
274 * may "VOCAL" appear in their name, without prior written
275 * permission of Vovida Networks, Inc.
276 *
277 * THIS SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESSED OR IMPLIED
278 * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
279 * OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, TITLE AND
280 * NON-INFRINGEMENT ARE DISCLAIMED. IN NO EVENT SHALL VOVIDA
281 * NETWORKS, INC. OR ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT DAMAGES
282 * IN EXCESS OF $1,000, NOR FOR ANY INDIRECT, INCIDENTAL, SPECIAL,
283 * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
284 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
285 * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
286 * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
287 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE
288 * USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH
289 * DAMAGE.
290 *
291 * ====================================================================
292 *
293 * This software consists of voluntary contributions made by Vovida
294 * Networks, Inc. and many individuals on behalf of Vovida Networks,
295 * Inc. For more information on Vovida Networks, Inc., please see
296 * <http://www.vovida.org/>.
297 *
298 */

Properties

Name Value
svn:eol-style LF

webmaster AT resiprocate DOT org
ViewVC Help
Powered by ViewVC 1.1.27