Measure the number of UDP datagrams sent and received
This commit is contained in:
parent
4d140ea6bd
commit
e584d9cd2e
|
@ -160,7 +160,9 @@ Stats::Stats(size_t req_todo, size_t nclients)
|
||||||
bytes_head(0),
|
bytes_head(0),
|
||||||
bytes_head_decomp(0),
|
bytes_head_decomp(0),
|
||||||
bytes_body(0),
|
bytes_body(0),
|
||||||
status() {}
|
status(),
|
||||||
|
udp_dgram_recv(0),
|
||||||
|
udp_dgram_sent(0) {}
|
||||||
|
|
||||||
Stream::Stream() : req_stat{}, status_success(-1) {}
|
Stream::Stream() : req_stat{}, status_success(-1) {}
|
||||||
|
|
||||||
|
@ -1377,6 +1379,8 @@ int Client::write_udp(const sockaddr *addr, socklen_t addrlen,
|
||||||
auto nwrite = sendto(fd, data, datalen, MSG_DONTWAIT, addr, addrlen);
|
auto nwrite = sendto(fd, data, datalen, MSG_DONTWAIT, addr, addrlen);
|
||||||
if (nwrite < 0) {
|
if (nwrite < 0) {
|
||||||
std::cerr << "sendto: errno=" << errno << std::endl;
|
std::cerr << "sendto: errno=" << errno << std::endl;
|
||||||
|
} else {
|
||||||
|
++worker->stats.udp_dgram_sent;
|
||||||
}
|
}
|
||||||
|
|
||||||
ev_io_stop(worker->loop, &wev);
|
ev_io_stop(worker->loop, &wev);
|
||||||
|
@ -2971,6 +2975,8 @@ int main(int argc, char **argv) {
|
||||||
stats.bytes_head += s.bytes_head;
|
stats.bytes_head += s.bytes_head;
|
||||||
stats.bytes_head_decomp += s.bytes_head_decomp;
|
stats.bytes_head_decomp += s.bytes_head_decomp;
|
||||||
stats.bytes_body += s.bytes_body;
|
stats.bytes_body += s.bytes_body;
|
||||||
|
stats.udp_dgram_recv += s.udp_dgram_recv;
|
||||||
|
stats.udp_dgram_sent += s.udp_dgram_sent;
|
||||||
|
|
||||||
for (size_t i = 0; i < stats.status.size(); ++i) {
|
for (size_t i = 0; i < stats.status.size(); ++i) {
|
||||||
stats.status[i] += s.status[i];
|
stats.status[i] += s.status[i];
|
||||||
|
@ -3029,14 +3035,19 @@ traffic: )" << util::utos_funit(stats.bytes_total)
|
||||||
<< util::utos_funit(stats.bytes_head) << "B (" << stats.bytes_head
|
<< util::utos_funit(stats.bytes_head) << "B (" << stats.bytes_head
|
||||||
<< ") headers (space savings " << header_space_savings * 100
|
<< ") headers (space savings " << header_space_savings * 100
|
||||||
<< "%), " << util::utos_funit(stats.bytes_body) << "B ("
|
<< "%), " << util::utos_funit(stats.bytes_body) << "B ("
|
||||||
<< stats.bytes_body << R"() data
|
<< stats.bytes_body << R"() data)" << std::endl;
|
||||||
min max mean sd +/- sd
|
if (config.is_quic()) {
|
||||||
|
std::cout << "UDP datagram: " << stats.udp_dgram_sent << " sent, "
|
||||||
|
<< stats.udp_dgram_recv << " received" << std::endl;
|
||||||
|
}
|
||||||
|
std::cout
|
||||||
|
<< R"( min max mean sd +/- sd
|
||||||
time for request: )"
|
time for request: )"
|
||||||
<< std::setw(10) << util::format_duration(ts.request.min) << " "
|
<< std::setw(10) << util::format_duration(ts.request.min) << " "
|
||||||
<< std::setw(10) << util::format_duration(ts.request.max) << " "
|
<< std::setw(10) << util::format_duration(ts.request.max) << " "
|
||||||
<< std::setw(10) << util::format_duration(ts.request.mean) << " "
|
<< std::setw(10) << util::format_duration(ts.request.mean) << " "
|
||||||
<< std::setw(10) << util::format_duration(ts.request.sd)
|
<< std::setw(10) << util::format_duration(ts.request.sd) << std::setw(9)
|
||||||
<< std::setw(9) << util::dtos(ts.request.within_sd) << "%"
|
<< util::dtos(ts.request.within_sd) << "%"
|
||||||
<< "\ntime for connect: " << std::setw(10)
|
<< "\ntime for connect: " << std::setw(10)
|
||||||
<< util::format_duration(ts.connect.min) << " " << std::setw(10)
|
<< util::format_duration(ts.connect.min) << " " << std::setw(10)
|
||||||
<< util::format_duration(ts.connect.max) << " " << std::setw(10)
|
<< util::format_duration(ts.connect.max) << " " << std::setw(10)
|
||||||
|
@ -3050,8 +3061,8 @@ time for request: )"
|
||||||
<< util::format_duration(ts.ttfb.sd) << std::setw(9)
|
<< util::format_duration(ts.ttfb.sd) << std::setw(9)
|
||||||
<< util::dtos(ts.ttfb.within_sd) << "%"
|
<< util::dtos(ts.ttfb.within_sd) << "%"
|
||||||
<< "\nreq/s : " << std::setw(10) << ts.rps.min << " "
|
<< "\nreq/s : " << std::setw(10) << ts.rps.min << " "
|
||||||
<< std::setw(10) << ts.rps.max << " " << std::setw(10)
|
<< std::setw(10) << ts.rps.max << " " << std::setw(10) << ts.rps.mean
|
||||||
<< ts.rps.mean << " " << std::setw(10) << ts.rps.sd << std::setw(9)
|
<< " " << std::setw(10) << ts.rps.sd << std::setw(9)
|
||||||
<< util::dtos(ts.rps.within_sd) << "%" << std::endl;
|
<< util::dtos(ts.rps.within_sd) << "%" << std::endl;
|
||||||
|
|
||||||
SSL_CTX_free(ssl_ctx);
|
SSL_CTX_free(ssl_ctx);
|
||||||
|
|
|
@ -230,6 +230,10 @@ struct Stats {
|
||||||
std::vector<RequestStat> req_stats;
|
std::vector<RequestStat> req_stats;
|
||||||
// The statistics per client
|
// The statistics per client
|
||||||
std::vector<ClientStat> client_stats;
|
std::vector<ClientStat> client_stats;
|
||||||
|
// The number of UDP datagrams received.
|
||||||
|
size_t udp_dgram_recv;
|
||||||
|
// The number of UDP datagrams sent.
|
||||||
|
size_t udp_dgram_sent;
|
||||||
};
|
};
|
||||||
|
|
||||||
enum ClientState { CLIENT_IDLE, CLIENT_CONNECTED };
|
enum ClientState { CLIENT_IDLE, CLIENT_CONNECTED };
|
||||||
|
|
|
@ -524,6 +524,8 @@ int Client::read_quic() {
|
||||||
|
|
||||||
assert(quic.conn);
|
assert(quic.conn);
|
||||||
|
|
||||||
|
++worker->stats.udp_dgram_recv;
|
||||||
|
|
||||||
auto path = ngtcp2_path{
|
auto path = ngtcp2_path{
|
||||||
{local_addr.len, &local_addr.su.sa},
|
{local_addr.len, &local_addr.su.sa},
|
||||||
{addrlen, &su.sa},
|
{addrlen, &su.sa},
|
||||||
|
|
Loading…
Reference in New Issue