Skip to content
This repository has been archived by the owner on Jan 2, 2025. It is now read-only.

Commit

Permalink
Merge branch 'master' into feature/improve-output-format
Browse files Browse the repository at this point in the history
  • Loading branch information
bassosimone authored Oct 7, 2019
2 parents 65ae8dc + 5324893 commit d7e9916
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 8 deletions.
1 change: 0 additions & 1 deletion .appveyor.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ image: Visual Studio 2017
environment:
matrix:
- CMAKE_GENERATOR: "Visual Studio 15 2017 Win64"
- CMAKE_GENERATOR: "Visual Studio 15 2017"
build_script:
- cmd: cmake -G "%CMAKE_GENERATOR%" .
- cmd: cmake --build . -- /nologo /property:Configuration=Release
Expand Down
12 changes: 5 additions & 7 deletions libndt.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -1951,7 +1951,7 @@ bool Client::ndt7_download() noexcept {
}
// The following value is the maximum amount of bytes that an implementation
// SHOULD be prepared to handle when receiving ndt7 messages.
constexpr Size ndt7_bufsiz = (1 << 17);
constexpr Size ndt7_bufsiz = (1 << 24);
std::unique_ptr<uint8_t[]> buff{new uint8_t[ndt7_bufsiz]};
auto begin = std::chrono::steady_clock::now();
auto latest = begin;
Expand Down Expand Up @@ -2016,7 +2016,7 @@ bool Client::ndt7_upload() noexcept {
for (;;) {
auto now = std::chrono::steady_clock::now();
std::chrono::duration<double> elapsed = now - begin;
std::chrono::duration<double, std::micro> elapsed_ms =
std::chrono::duration<double, std::micro> elapsed_usec =
std::chrono::duration_cast<std::chrono::microseconds>(elapsed);
if (elapsed.count() > max_upload_time) {
LIBNDT_EMIT_DEBUG("ndt7: upload has run for enough time");
Expand All @@ -2027,7 +2027,7 @@ bool Client::ndt7_upload() noexcept {
if (interval.count() > measurement_interval) {
nlohmann::json measurement;
measurement["AppInfo"] = nlohmann::json();
measurement["AppInfo"]["ElapsedTime"] = (std::uint64_t) elapsed_ms.count();
measurement["AppInfo"]["ElapsedTime"] = (std::uint64_t) elapsed_usec.count();
measurement["AppInfo"]["NumBytes"] = total;
#ifdef __linux__
// Read tcp_info data for the socket and print it as JSON.
Expand All @@ -2036,7 +2036,7 @@ bool Client::ndt7_upload() noexcept {
if (sys_getsockopt(sock_, IPPROTO_TCP, TCP_INFO, (void *)&tcpinfo,
&tcpinfolen) == 0) {
measurement["TCPInfo"] = nlohmann::json();
measurement["TCPInfo"]["ElapsedTime"] = (std::uint64_t) elapsed_ms.count();
measurement["TCPInfo"]["ElapsedTime"] = (std::uint64_t) elapsed_usec.count();
#define XX(lower_, upper_) measurement["TCPInfo"][#upper_] = (uint64_t)tcpinfo.lower_;
NDT7_ENUM_TCP_INFO
#undef XX
Expand All @@ -2045,18 +2045,16 @@ bool Client::ndt7_upload() noexcept {
on_performance(nettest_flag_upload, 1, static_cast<double>(total),
elapsed.count(), max_upload_time);
// This could fail if there are non-utf8 characters. This structure just
// contains integers and ASCII strings.
// contains integers and ASCII strings, so we should be good.
std::string json = measurement.dump();
on_result("ndt7", "upload", json);

// Send measurement to the server.
Err err = ws_send_frame(sock_, ws_opcode_text | ws_fin_flag,
(uint8_t *)json.data(), json.size());
if (err != Err::none) {
LIBNDT_EMIT_WARNING("ndt7: cannot send measurement");
return false;
}

latest = now;
}
Err err = netx_sendn(sock_, frame.data(), frame.size());
Expand Down

0 comments on commit d7e9916

Please sign in to comment.