3.0.ipv8.messaging.interfaces.statistics_endpoint ================================================= .. py:module:: 3.0.ipv8.messaging.interfaces.statistics_endpoint Classes ------- .. autoapisummary:: 3.0.ipv8.messaging.interfaces.statistics_endpoint.StatisticsEndpoint Module Contents --------------- .. py:class:: StatisticsEndpoint(endpoint: 3.0.ipv8.types.Endpoint) Bases: :py:obj:`3.0.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. .. py:attribute:: IDS_INTRODUCTION :value: [245, 246] .. py:attribute:: IDS_PUNCTURE :value: [249, 250] .. py:attribute:: IDS_DEPRECATED :value: [235, 236, 237, 238, 239, 240, 241, 242, 243, 244, 247, 248, 251, 252, 253, 254, 255] .. py:attribute:: endpoint .. py:attribute:: statistics :type: dict[bytes, dict] .. py:method:: __getattribute__(item: str) -> Any Forward any non-intercepted call from this decorator directly to the underlying endpoint. .. py:method:: send(socket_address: 3.0.ipv8.types.Address, packet: bytes) -> None Send the packet to an address and update our stats if we are tracking the packet's prefix. .. py:method:: enable_community_statistics(community_prefix: bytes, enabled: bool) -> None Start tracking stats for packets with the given prefix. .. py:method:: on_packet(packet: tuple[3.0.ipv8.types.Address, bytes]) -> None Callback for when a packet is received through our underlying endpoint. .. py:method:: 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. .. py:method:: 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. .. py:method:: get_statistics(prefix: bytes) -> dict[int, 3.0.ipv8.messaging.interfaces.network_stats.NetworkStat] Get the message statistics per message identifier for the given prefix. .. py:method:: get_aggregate_statistics(prefix: bytes) -> dict[str, int | float] Add all the individual message statistics together for a given prefix. .. py:method:: 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. .. py:method:: 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. .. py:method:: 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. .. py:method:: 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. .. py:method:: 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.