@@ -287,40 +287,59 @@ int pqihandler::ExtractTrafficInfo(std::list<RSTrafficClue>& out_lst,std::li
287287}
288288
289289// NEW extern fn to extract rates.
290- int pqihandler::ExtractRates (std::map<RsPeerId, RsBwRates> &ratemap, RsBwRates &total)
290+
291+ int pqihandler::ExtractRates (std::map<RsPeerId, RsBwRates> &ratemap, RsBwRates &total)
291292{
293+ /* Initialize standard totals */
292294 total.mMaxRateIn = getMaxRate (true );
293295 total.mMaxRateOut = getMaxRate (false );
294296 total.mRateIn = 0 ;
295297 total.mRateOut = 0 ;
296298 total.mQueueIn = 0 ;
297299 total.mQueueOut = 0 ;
300+ total.mQueueOutBytes = 0 ;
301+ total.mTotalIn = 0 ;
302+ total.mTotalOut = 0 ;
298303
299304 /* Lock once rates have been retrieved */
300305 RS_STACK_MUTEX (coreMtx); /* *************** LOCKED MUTEX ****************/
301306
302307 std::map<RsPeerId, SearchModule *>::iterator it;
308+
303309 for (it = mods.begin (); it != mods.end (); ++it)
304310 {
305311 SearchModule *mod = (it -> second);
306312
307313 RsBwRates peerRates;
314+
315+ /* Call the relay in pqiperson (which calls pqistreamer) */
308316 mod -> pqi -> getRates (peerRates);
309317
318+ /* Accumulate standard statistics */
310319 total.mRateIn += peerRates.mRateIn ;
311320 total.mRateOut += peerRates.mRateOut ;
312321 total.mQueueIn += peerRates.mQueueIn ;
313322 total.mQueueOut += peerRates.mQueueOut ;
323+ total.mQueueOutBytes += peerRates.mQueueOutBytes ;
314324
325+ /* Accumulate cumulative statistics into global totals */
326+ total.mTotalIn += peerRates.mTotalIn ;
327+ total.mTotalOut += peerRates.mTotalOut ;
328+
329+ /* Store individual peer rates in the result map */
315330 ratemap[it->first ] = peerRates;
316331
332+ /* Clean debug message for this layer */
333+ // RsDbg() << "OUTQUEUEBYTES [pqihandler] Collected Peer: " << it->first << " | Bytes: " << peerRates.mQueueOutBytes;
334+
335+ /* Debug message for extraction layer */
336+ // RsDbg() << "BWSUM Handler [ExtractRates] Peer: " << it->first << " | In: " << peerRates.mTotalIn << " | Out: " << peerRates.mTotalOut;
337+
317338 }
318339
319340 return 1 ;
320341}
321342
322-
323-
324343// internal fn to send updates
325344int pqihandler::UpdateRates ()
326345{
@@ -464,12 +483,16 @@ int pqihandler::UpdateRates()
464483 {
465484 SearchModule *mod = (it -> second);
466485
467- // for our down bandwidth we use the calculated value without taking into account the max up provided by peers via BwCtrl
468- // this is harmless as they will control their up bw on their side
486+ // attn: the bwctrl service only passes to the peers a max in value, therefore we are not aware of our peers max out
487+ // see p3bwctrl and rsconfig.h
488+
489+ // for our down bandwidth we use the calculated value as is, because BwCtrl does not provide a max out from our peers
490+ // this down limit will be passed to our peers via BwCtrl
469491 mod -> pqi -> setMaxRate (true , in_max_bw);
470492
471- // for our up bandwidth we take into account the max down provided by peers via BwCtrl
472- // because we don't want to clog our outqueues, the TCP buffers, and the peers inbound queues
493+ // for our up bandwidth we take into account the max in provided by peers via BwCtrl
494+ // we don't want to clog our outqueues, the TCP buffers, and the peers inbound queues
495+ // attn: this up limit will not passed to our peers via BwCtrl
473496 mod -> pqi -> setMaxRate (false , out_max_bw);
474497 if ((rateMap_it = rateMap.find (mod->pqi ->PeerId ())) != rateMap.end ())
475498 if (rateMap_it->second .mAllowedOut > 0 )
0 commit comments