Stat

class Stat

Aggregates the six byte-stream channels of a peer connection (or the whole session). The pure-Kotlin port of libtorrent's stat (stat.hpp).

The six StatChannels, indexed by the Channel enum, split traffic by direction (upload / download) and class (BitTorrent payload, BitTorrent protocol overhead, and IP/TCP overhead). Helpers roll these up into the familiar upload_rate / total_download / ... figures the rest of libtorrent reports.

second_tick must be driven once per second (passing the real elapsed milliseconds) so each channel's smoothed rate stays in bytes/second.

Constructors

Link copied to clipboard
constructor()

Types

Link copied to clipboard

The six channels of a Stat, in their fixed C++ ordinal order.

Link copied to clipboard
object Companion

Functions

Link copied to clipboard
fun addStat(downloaded: Long, uploaded: Long)

Seeds the payload totals with downloaded / uploaded bytes carried over from an earlier connection. (add_stat)

Link copied to clipboard
fun clear()

Resets all six channels. (clear)

Link copied to clipboard
Link copied to clipboard
Link copied to clipboard
Link copied to clipboard
operator fun get(c: Stat.Channel): StatChannel

Direct access to a channel, mirroring stat::operator[].

Link copied to clipboard
Link copied to clipboard
Link copied to clipboard
Link copied to clipboard
Link copied to clipboard
Link copied to clipboard
Link copied to clipboard
operator fun plusAssign(s: Stat)

Folds every channel of s into this one. (operator+=)

Link copied to clipboard
fun receivedBytes(bytesPayload: Int, bytesProtocol: Int)

Record received bytes, split into payload and protocol. (received_bytes)

Link copied to clipboard

Account for a received SYN-ACK plus the ACK we send back. (received_synack)

Link copied to clipboard
fun secondTick(tickIntervalMs: Int)

Advances every channel's smoothed rate; call once per second. (second_tick)

Link copied to clipboard
fun sentBytes(bytesPayload: Int, bytesProtocol: Int)

Record sent bytes, split into payload and protocol. (sent_bytes)

Link copied to clipboard
fun sentSyn(ipv6: Boolean)

Account for sending a TCP SYN (40 bytes IPv4, 60 IPv6). (sent_syn)

Link copied to clipboard
Link copied to clipboard
Link copied to clipboard
Link copied to clipboard
Link copied to clipboard
Link copied to clipboard
Link copied to clipboard
Link copied to clipboard
fun trancieveIpPacket(bytesTransferred: Int, ipv6: Boolean)

Charges the IP/TCP overhead of moving bytesTransferred bytes to both the upload and download IP-protocol channels, matching trancieve_ip_packet.

Link copied to clipboard
Link copied to clipboard
Link copied to clipboard
Link copied to clipboard