latest.ipv8.messaging.interfaces.statistics_endpoint

Module Contents

Classes

StatisticsEndpoint

This class is responsible for keeping stats regarding community.

class latest.ipv8.messaging.interfaces.statistics_endpoint.StatisticsEndpoint(endpoint: latest.ipv8.types.Endpoint)

Bases: latest.ipv8.messaging.interfaces.endpoint.EndpointListener

This class is responsible for keeping stats regarding community. The stats are basically of the messages that the community can handle.

This endpoint acts both as wrapper for IPv8 Endpoint, and EndpointListener. It inherits from EndpointListener directly and implements on_packet(self, packet) to measure statistics about received data. But, all the functionality of Endpoint itself is delegated to the existing IPv8 UDPEndpoint.

IDS_INTRODUCTION = [245, 246]
IDS_PUNCTURE = [249, 250]
IDS_DEPRECATED = [235, 236, 237, 238, 239, 240, 241, 242, 243, 244, 247, 248, 251, 252, 253, 254, 255]
__getattribute__(item: str) Any

Forward any non-intercepted call from this decorator directly to the underlying endpoint.

send(socket_address: latest.ipv8.types.Address, packet: bytes) None

Send the packet to an address and update our stats if we are tracking the packet’s prefix.

enable_community_statistics(community_prefix: bytes, enabled: bool) None

Start tracking stats for packets with the given prefix.

on_packet(packet: tuple[latest.ipv8.types.Address, bytes]) None

Callback for when a packet is received through our underlying endpoint.

add_sent_stat(prefix: bytes, identifier: int, num_bytes: int, timestamp: float | None = None) None

Update the sending stats of a given prefix and message identifier.

add_received_stat(prefix: bytes, identifier: int, num_bytes: int, timestamp: float | None = None) None

Update the receiving stats of a given prefix and message identifier.

get_statistics(prefix: bytes) dict[int, latest.ipv8.messaging.interfaces.network_stats.NetworkStat]

Get the message statistics per message identifier for the given prefix.

get_aggregate_statistics(prefix: bytes) dict[str, int | float]

Add all the individual message statistics together for a given prefix.

get_message_sent(prefix: bytes, include_introduction: bool = False, include_puncture: bool = False, include_deprecated: bool = False) int

Calculate the number of sent messages for a given community prefix.

get_message_received(prefix: bytes, include_introduction: bool = False, include_puncture: bool = False, include_deprecated: bool = False) int

Calculate the number of received messages for a given community prefix.

get_bytes_sent(prefix: bytes, include_introduction: bool = False, include_puncture: bool = False, include_deprecated: bool = False) int

Calculate the number of sent bytes for a given community prefix.

get_bytes_received(prefix: bytes, include_introduction: bool = False, include_puncture: bool = False, include_deprecated: bool = False) int

Calculate the number of received bytes for a given community prefix.

is_excluded(identifier: int, include_introduction: bool, include_puncture: bool, include_deprecated: bool) bool

Whether a given message identifier should be counted with the given filters.