35 #ifdef LOG_PACKET_TIMES
42 CALogPacketStats* pLog=(CALogPacketStats*)param;
44 while(pLog->m_bRunLog)
48 pLog->logTimeingStats();
49 pLog->resetTimeingStats();
50 countLog=pLog->m_iLogIntervallInHalfMinutes;
58 SINT32 CALogPacketStats::start()
61 m_pthreadLog=
new CAThread((
UINT8*)
"Packet Stats Logging Thread");
62 m_pthreadLog->setMainLoop(loopLogPacketStats);
64 return m_pthreadLog->start(
this);
67 SINT32 CALogPacketStats::stop()
70 if(m_pthreadLog!=NULL)
82 m_csTimeingStats.lock();
83 UINT32 proccessingTime=
diff64(oQueueEntry.timestamp_proccessing_end,oQueueEntry.timestamp_proccessing_start);
84 UINT32 proccessingTimeOP=
diff64(oQueueEntry.timestamp_proccessing_end_OP,oQueueEntry.timestamp_proccessing_start_OP);
89 m_timingCountDataPacketsUpstream++;
90 add64(m_timingSumDataPacketUpstream,proccessingTime);
91 if(proccessingTime>m_timingMaxDataPacketUpstream)
92 m_timingMaxDataPacketUpstream=proccessingTime;
93 else if(m_timingMinDataPacketUpstream>proccessingTime)
94 m_timingMinDataPacketUpstream=proccessingTime;
95 add64(m_timingSumDataPacketUpstreamOP,proccessingTimeOP);
96 if(proccessingTimeOP>m_timingMaxDataPacketUpstreamOP)
97 m_timingMaxDataPacketUpstreamOP=proccessingTimeOP;
98 else if(m_timingMinDataPacketUpstreamOP>proccessingTimeOP)
99 m_timingMinDataPacketUpstreamOP=proccessingTimeOP;
103 m_timingCountClosePacketsUpstream++;
104 add64(m_timingSumClosePacketUpstream,proccessingTime);
105 if(proccessingTime>m_timingMaxClosePacketUpstream)
106 m_timingMaxClosePacketUpstream=proccessingTime;
107 else if(m_timingMinClosePacketUpstream>proccessingTime)
108 m_timingMinClosePacketUpstream=proccessingTime;
109 add64(m_timingSumClosePacketUpstreamOP,proccessingTimeOP);
110 if(proccessingTimeOP>m_timingMaxClosePacketUpstreamOP)
111 m_timingMaxClosePacketUpstreamOP=proccessingTimeOP;
112 else if(m_timingMinClosePacketUpstreamOP>proccessingTimeOP)
113 m_timingMinClosePacketUpstreamOP=proccessingTimeOP;
117 m_timingCountOpenPacketsUpstream++;
118 add64(m_timingSumOpenPacketUpstream,proccessingTime);
119 if(proccessingTime>m_timingMaxOpenPacketUpstream)
120 m_timingMaxOpenPacketUpstream=proccessingTime;
121 else if(m_timingMinOpenPacketUpstream>proccessingTime)
122 m_timingMinOpenPacketUpstream=proccessingTime;
123 add64(m_timingSumOpenPacketUpstreamOP,proccessingTimeOP);
124 if(proccessingTimeOP>m_timingMaxOpenPacketUpstreamOP)
125 m_timingMaxOpenPacketUpstreamOP=proccessingTimeOP;
126 else if(m_timingMinOpenPacketUpstreamOP>proccessingTimeOP)
127 m_timingMinOpenPacketUpstreamOP=proccessingTimeOP;
130 UINT32 poolTime=
diff64(oQueueEntry.pool_timestamp_out,oQueueEntry.pool_timestamp_in);
131 m_timingCountPoolPacketsUpstream++;
132 add64(m_timingSumPoolPacketUpstream,poolTime);
133 if(poolTime>m_timingMaxPoolPacketUpstream)
134 m_timingMaxPoolPacketUpstream=poolTime;
135 else if(m_timingMinPoolPacketUpstream>poolTime)
136 m_timingMinPoolPacketUpstream=poolTime;
140 CAMsg::printMsg(LOG_CRIT,
"Upload Packet processing time (arrival --> send): %u µs -- Queue out --> Queue in %u µs\n",
141 proccessingTime,proccessingTimeOP);
143 CAMsg::printMsg(LOG_CRIT,
"Upload Packet processing time (arrival --> send): %u µs -- Queue out --> Queue in %u µs -- Pool Time: %u µs\n",
144 proccessingTime,proccessingTimeOP,poolTime);
151 m_timingCountDataPacketsDownStream++;
152 add64(m_timingSumDataPacketDownStream,proccessingTime);
153 if(proccessingTime>m_timingMaxDataPacketDownStream)
154 m_timingMaxDataPacketDownStream=proccessingTime;
155 else if(m_timingMinDataPacketDownStream>proccessingTime)
156 m_timingMinDataPacketDownStream=proccessingTime;
157 add64(m_timingSumDataPacketDownStreamOP,proccessingTimeOP);
158 if(proccessingTimeOP>m_timingMaxDataPacketDownStreamOP)
159 m_timingMaxDataPacketDownStreamOP=proccessingTimeOP;
160 else if(m_timingMinDataPacketDownStreamOP>proccessingTimeOP)
161 m_timingMinDataPacketDownStreamOP=proccessingTimeOP;
163 UINT32 poolTime=
diff64(oQueueEntry.pool_timestamp_out,oQueueEntry.pool_timestamp_in);
164 m_timingCountPoolPacketsDownStream++;
165 add64(m_timingSumPoolPacketDownStream,poolTime);
166 if(poolTime>m_timingMaxPoolPacketDownStream)
167 m_timingMaxPoolPacketDownStream=poolTime;
168 else if(m_timingMinPoolPacketDownStream>poolTime)
169 m_timingMinPoolPacketDownStream=poolTime;
173 CAMsg::printMsg(LOG_CRIT,
"Download Packet processing time (arrival --> send): %u µs -- Queue out --> Queue in %u µs\n",
174 proccessingTime,proccessingTimeOP);
176 CAMsg::printMsg(LOG_CRIT,
"Download Packet processing time (arrival --> send): %u µs -- Queue out --> Queue in %u µs -- Pool Time: %u µs\n",
177 proccessingTime,proccessingTimeOP,poolTime);
182 m_csTimeingStats.unlock();
186 SINT32 CALogPacketStats::logTimeingStats()
188 m_csTimeingStats.lock();
190 UINT32 aveCloseUpstream=0;
192 UINT32 aveDataDownStream=0;
193 UINT32 aveDataUpstreamOP=0;
194 UINT32 aveCloseUpstreamOP=0;
195 UINT32 aveOpenUpstreamOP=0;
196 UINT32 aveDataDownStreamOP=0;
197 if(m_timingCountOpenPacketsUpstream>0)
199 aveOpenUpstream=
div64(m_timingSumOpenPacketUpstream,m_timingCountOpenPacketsUpstream);
200 aveOpenUpstreamOP=
div64(m_timingSumOpenPacketUpstreamOP,m_timingCountOpenPacketsUpstream);
202 if(m_timingCountDataPacketsUpstream>0)
204 aveDataUpstream=
div64(m_timingSumDataPacketUpstream,m_timingCountDataPacketsUpstream);
205 aveDataUpstreamOP=
div64(m_timingSumDataPacketUpstreamOP,m_timingCountDataPacketsUpstream);
207 if(m_timingCountClosePacketsUpstream>0)
209 aveCloseUpstream=
div64(m_timingSumClosePacketUpstream,m_timingCountClosePacketsUpstream);
210 aveCloseUpstreamOP=
div64(m_timingSumClosePacketUpstreamOP,m_timingCountClosePacketsUpstream);
212 if(m_timingCountDataPacketsDownStream>0)
214 aveDataDownStream=
div64(m_timingSumDataPacketDownStream,m_timingCountDataPacketsDownStream);
215 aveDataDownStreamOP=
div64(m_timingSumDataPacketDownStreamOP,m_timingCountDataPacketsDownStream);
220 UINT32 avePoolDownStream=0;
221 if(m_timingCountPoolPacketsUpstream>0)
222 avePoolUpstream=
div64(m_timingSumPoolPacketUpstream,m_timingCountPoolPacketsUpstream);
223 if(m_timingCountPoolPacketsDownStream>0)
224 aveDataDownStream=
div64(m_timingSumPoolPacketDownStream,m_timingCountPoolPacketsDownStream);
226 CAMsg::printMsg(LOG_DEBUG,
"Packet timeing stats [µs] -- Data Packets Upstream [%u] (Min/Max/Ave): %u/%u/%u -- Open Packets Upstream [%u]: %u/%u/%u Close Packets Upstream [%u] %u/%u/%u -- Data Packets Downstream [%u]: %u/%u/%u \n",
227 m_timingCountDataPacketsUpstream,m_timingMinDataPacketUpstream,m_timingMaxDataPacketUpstream,aveDataUpstream,
228 m_timingCountOpenPacketsUpstream,m_timingMinOpenPacketUpstream,m_timingMaxOpenPacketUpstream,aveOpenUpstream,
229 m_timingCountClosePacketsUpstream,m_timingMinClosePacketUpstream,m_timingMaxClosePacketUpstream,aveCloseUpstream,
230 m_timingCountDataPacketsDownStream,m_timingMinDataPacketDownStream,m_timingMaxDataPacketDownStream,aveDataDownStream);
232 CAMsg::printMsg(LOG_DEBUG,
"Packet timeing stats (only Queue out --> Queue in)[µs] -- Data Packets Upstream [%u] (Min/Max/Ave): %u/%u/%u -- Open Packets Upstream [%u]: %u/%u/%u Close Packets Upstream [%u] %u/%u/%u -- Data Packets Downstream [%u]: %u/%u/%u \n",
233 m_timingCountDataPacketsUpstream,m_timingMinDataPacketUpstreamOP,m_timingMaxDataPacketUpstreamOP,aveDataUpstreamOP,
234 m_timingCountOpenPacketsUpstream,m_timingMinOpenPacketUpstreamOP,m_timingMaxOpenPacketUpstreamOP,aveOpenUpstreamOP,
235 m_timingCountClosePacketsUpstream,m_timingMinClosePacketUpstreamOP,m_timingMaxClosePacketUpstreamOP,aveCloseUpstreamOP,
236 m_timingCountDataPacketsDownStream,m_timingMinDataPacketDownStreamOP,m_timingMaxDataPacketDownStreamOP,aveDataDownStreamOP);
238 CAMsg::printMsg(LOG_DEBUG,
"Pool timeing stats [µs] -- Upstream [%u] (Min/Max/Ave): %u/%u/%u -- Downstream [%u]: %u/%u/%u\n",
239 m_timingCountPoolPacketsUpstream,m_timingMinPoolPacketUpstream,m_timingMaxPoolPacketUpstream,avePoolUpstream,
240 m_timingCountPoolPacketsDownStream,m_timingMinPoolPacketDownStream,m_timingMaxPoolPacketDownStream,avePoolDownStream);
242 m_csTimeingStats.unlock();
246 SINT32 CALogPacketStats::resetTimeingStats()
248 m_csTimeingStats.lock();
249 m_timingMaxDataPacketUpstream=0;
250 m_timingMaxDataPacketDownStream=0;
251 m_timingMaxClosePacketUpstream=0;
252 m_timingMinDataPacketUpstream=0xFFFFFFFF;
253 m_timingMinDataPacketDownStream=0xFFFFFFFF;
254 m_timingMinClosePacketUpstream=0xFFFFFFFF;
255 m_timingCountDataPacketsUpstream=m_timingCountDataPacketsDownStream=0;
256 m_timingCountClosePacketsUpstream=0;
257 setZero64(m_timingSumDataPacketUpstream);
258 setZero64(m_timingSumDataPacketDownStream);
259 setZero64(m_timingSumClosePacketUpstream);
260 m_timingMaxOpenPacketUpstream=0;
261 m_timingMinOpenPacketUpstream=0xFFFFFFFF;
262 m_timingCountOpenPacketsUpstream=0;
263 setZero64(m_timingSumOpenPacketUpstream);
265 m_timingMaxDataPacketUpstreamOP=0;
266 m_timingMaxDataPacketDownStreamOP=0;
267 m_timingMaxClosePacketUpstreamOP=0;
268 m_timingMinDataPacketUpstreamOP=0xFFFFFFFF;
269 m_timingMinDataPacketDownStreamOP=0xFFFFFFFF;
270 m_timingMinClosePacketUpstreamOP=0xFFFFFFFF;
271 setZero64(m_timingSumDataPacketUpstreamOP);
272 setZero64(m_timingSumDataPacketDownStreamOP);
273 setZero64(m_timingSumClosePacketUpstreamOP);
274 m_timingMaxOpenPacketUpstreamOP=0;
275 m_timingMinOpenPacketUpstreamOP=0xFFFFFFFF;
276 setZero64(m_timingSumOpenPacketUpstreamOP);
279 m_timingMaxPoolPacketUpstream=0;
280 m_timingMaxPoolPacketDownStream=0;
281 m_timingMinPoolPacketUpstream=m_timingMinPoolPacketDownStream=0xFFFFFFFF;
282 m_timingCountPoolPacketsUpstream=0;
283 setZero64(m_timingSumPoolPacketUpstream);
284 m_timingCountPoolPacketsDownStream=0;
285 setZero64(m_timingSumPoolPacketDownStream);
287 m_csTimeingStats.unlock();
SINT32 sSleep(UINT32 sec)
Sleeps sec Seconds.
UINT32 diff64(const UINT64 &bigop, const UINT64 &smallop)
void setZero64(UINT64 &op1)
UINT32 div64(UINT64 &op1, UINT32 op2)
void add64(UINT64 &op1, UINT32 op2)
#define THREAD_RETURN_SUCCESS
static SINT32 printMsg(UINT32 typ, const char *format,...)
Writes a given message to the log.