tcp/ip overhead calculation fix

This commit is contained in:
Arvid Norberg 2008-12-10 22:54:49 +00:00
parent 5fb854d724
commit 92f121f504
1 changed files with 2 additions and 1 deletions

View File

@ -194,7 +194,8 @@ namespace libtorrent
// and IPv6 header is 40 bytes
const int header = (ipv6 ? 40 : 20) + 20;
const int mtu = 1500;
const int overhead = (std::max)(1, bytes_transferred / (mtu - header)) * header;
const int packet_size = mtu - header;
const int overhead = (std::max)(1, (bytes_transferred + packet_size - 1) / packet_size) * header;
m_stat[download_ip_protocol].add(overhead);
m_stat[upload_ip_protocol].add(overhead);
}