Show / Hide Table of Contents

Class NetStatistics

Thread-safe counter for network statistics including sent/received packets, bytes, and packet loss.

Inheritance
object
NetStatistics
Namespace: LiteNetLib
Assembly: LiteNetLib.dll
Syntax
public sealed class NetStatistics

Properties

BytesReceived

Total number of bytes received.

Declaration
public long BytesReceived { get; }
Property Value
Type Description
long

BytesSent

Total number of bytes sent.

Declaration
public long BytesSent { get; }
Property Value
Type Description
long

PacketLoss

Total number of packets lost during transmission.

Declaration
public long PacketLoss { get; }
Property Value
Type Description
long

PacketLossPercent

Percentage of sent packets that were lost. Calculated as (PacketLoss * 100) / PacketsSent.

Declaration
public long PacketLossPercent { get; }
Property Value
Type Description
long

PacketsReceived

Total number of packets received.

Declaration
public long PacketsReceived { get; }
Property Value
Type Description
long

PacketsSent

Total number of packets sent.

Declaration
public long PacketsSent { get; }
Property Value
Type Description
long

Methods

AddBytesReceived(long)

Adds a specific amount to the total bytes received.

Declaration
public void AddBytesReceived(long bytesReceived)
Parameters
Type Name Description
long bytesReceived

Number of bytes to add.

AddBytesSent(long)

Adds a specific amount to the total bytes sent.

Declaration
public void AddBytesSent(long bytesSent)
Parameters
Type Name Description
long bytesSent

Number of bytes to add.

AddPacketLoss(long)

Adds a specific amount to the total packet loss count.

Declaration
public void AddPacketLoss(long packetLoss)
Parameters
Type Name Description
long packetLoss

Number of lost packets to add.

IncrementPacketLoss()

Increments the count of lost packets by one.

Declaration
public void IncrementPacketLoss()

IncrementPacketsReceived()

Increments the count of received packets by one.

Declaration
public void IncrementPacketsReceived()

IncrementPacketsSent()

Increments the count of sent packets by one.

Declaration
public void IncrementPacketsSent()

Reset()

Resets all statistical counters to zero.

Declaration
public void Reset()

ToString()

Returns a string representation of the current network statistics.

Declaration
public override string ToString()
Returns
Type Description
string

A formatted string containing bytes received/sent, packets received/sent, and loss information.

Overrides
object.ToString()
In this article
Back to top Generated by DocFX