From 47c476dc0ae49ef74320b2afeb800da6a32bf367 Mon Sep 17 00:00:00 2001 From: Arvid Norberg Date: Fri, 26 Sep 2008 06:10:21 +0000 Subject: [PATCH] include TCP handshake overhead --- include/libtorrent/stat.hpp | 12 ++++++++++++ src/peer_connection.cpp | 3 +++ 2 files changed, 15 insertions(+) diff --git a/include/libtorrent/stat.hpp b/include/libtorrent/stat.hpp index fe9824164..ef4fdd04a 100644 --- a/include/libtorrent/stat.hpp +++ b/include/libtorrent/stat.hpp @@ -122,6 +122,18 @@ namespace libtorrent m_stat[i] += s.m_stat[i]; } + void sent_syn() + { + m_stat[upload_ip_protocol].add(40); + } + + void received_synack() + { + // we received SYN-ACK and also sent ACK back + m_stat[download_ip_protocol].add(40); + m_stat[upload_ip_protocol].add(40); + } + void received_dht_bytes(int bytes) { TORRENT_ASSERT(bytes >= 0); diff --git a/src/peer_connection.cpp b/src/peer_connection.cpp index 52f1f2773..6753b1831 100644 --- a/src/peer_connection.cpp +++ b/src/peer_connection.cpp @@ -3668,6 +3668,7 @@ namespace libtorrent m_socket->async_connect(m_remote , bind(&peer_connection::on_connection_complete, self(), _1)); m_connect = time_now(); + m_statistics.sent_syn(); if (t->alerts().should_post()) { @@ -3706,6 +3707,8 @@ namespace libtorrent // this means the connection just succeeded + m_statistics.received_synack(); + TORRENT_ASSERT(m_socket); #if defined TORRENT_VERBOSE_LOGGING || defined TORRENT_LOGGING (*m_ses.m_logger) << time_now_string() << " COMPLETED: " << m_remote.address().to_string()