blob: 2a650255eeffa5659ddd467e82739033c4871345 [file] [log] [blame]
schneiderklausd8197df2019-03-16 11:31:40 -07001/*
2 * Copyright (c) 2016-2019, Regents of the University of California,
3 * Colorado State University,
4 * University Pierre & Marie Curie, Sorbonne University.
Weiwei Liu245d7912016-07-28 00:04:25 -07005 *
6 * This file is part of ndn-tools (Named Data Networking Essential Tools).
7 * See AUTHORS.md for complete list of ndn-tools authors and contributors.
8 *
9 * ndn-tools is free software: you can redistribute it and/or modify it under the terms
10 * of the GNU General Public License as published by the Free Software Foundation,
11 * either version 3 of the License, or (at your option) any later version.
12 *
13 * ndn-tools is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY;
14 * without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
15 * PURPOSE. See the GNU General Public License for more details.
16 *
17 * You should have received a copy of the GNU General Public License along with
18 * ndn-tools, e.g., in COPYING.md file. If not, see <http://www.gnu.org/licenses/>.
19 *
20 * See AUTHORS.md for complete list of ndn-cxx authors and contributors.
21 *
22 * @author Weiwei Liu
23 */
24
schneiderklausd8197df2019-03-16 11:31:40 -070025#include "statistics-collector.hpp"
Weiwei Liu245d7912016-07-28 00:04:25 -070026
27namespace ndn {
28namespace chunks {
Weiwei Liu245d7912016-07-28 00:04:25 -070029
Davide Pesavento70576402019-06-07 16:42:21 -040030StatisticsCollector::StatisticsCollector(PipelineInterestsAdaptive& pipeline,
31 RttEstimator& rttEstimator,
Weiwei Liu245d7912016-07-28 00:04:25 -070032 std::ostream& osCwnd, std::ostream& osRtt)
33 : m_osCwnd(osCwnd)
34 , m_osRtt(osRtt)
35{
36 m_osCwnd << "time\tcwndsize\n";
37 m_osRtt << "segment\trtt\trttvar\tsrtt\trto\n";
38 pipeline.afterCwndChange.connect(
Davide Pesavento70576402019-06-07 16:42:21 -040039 [this] (time::nanoseconds timeElapsed, double cwnd) {
40 m_osCwnd << timeElapsed.count() / 1e9 << '\t' << cwnd << '\n';
Weiwei Liu245d7912016-07-28 00:04:25 -070041 });
Davide Pesavento70576402019-06-07 16:42:21 -040042 rttEstimator.afterMeasurement.connect(
43 [this] (const RttEstimator::Sample& sample) {
44 m_osRtt << *sample.segNum << '\t'
Davide Pesaventoba560662019-06-26 22:45:44 -040045 << sample.rtt.count() / 1e6 << '\t'
46 << sample.rttVar.count() / 1e6 << '\t'
47 << sample.sRtt.count() / 1e6 << '\t'
48 << sample.rto.count() / 1e6 << '\n';
Weiwei Liu245d7912016-07-28 00:04:25 -070049 });
50}
51
Weiwei Liu245d7912016-07-28 00:04:25 -070052} // namespace chunks
Davide Pesavento70576402019-06-07 16:42:21 -040053} // namespace ndn