rtt
rtt
¶
NIP-66 RTT metadata container with relay probe capabilities.
Tests a relay's round-trip time by measuring connection open, event read, and event write latencies as defined by NIP-66. Results are stored as millisecond integers alongside detailed logs for each phase.
Note
The RTT test executes three sequential phases:
- Open -- measures WebSocket connection establishment time via connect_relay.
- Read -- measures time to receive the first event matching a
filter via
stream_events. - Write -- measures time to publish an event and verify it can be retrieved back from the relay.
If the open phase fails, read and write are automatically marked as failed with the same reason (cascading failure). The write phase includes a verification step that re-fetches the published event to confirm the relay actually stored it.
See Also
bigbrotr.nips.nip66.data.Nip66RttData: Data model for RTT measurements. bigbrotr.nips.nip66.logs.Nip66RttMultiPhaseLogs: Multi-phase log model with per-phase success/reason. bigbrotr.utils.protocol.connect_relay: Transport function used for the open phase. bigbrotr.utils.keys.KeysConfig: Key management -- RTT probes require signing keys for the write phase.
Classes¶
Nip66RttDependencies
¶
Bases: NamedTuple
Grouped dependencies for RTT probe tests.
Bundles the signing keys, event builder, and read filter required by the RTT measurement phases (open, read, write).
See Also
bigbrotr.nips.nip66.nip66.Nip66Dependencies: Top-level dependency container that includes these plus GeoIP readers. bigbrotr.utils.keys.load_keys_from_env: Function used to load the signing keys.
Nip66RttMetadata
¶
Bases: BaseNipMetadata
Container for RTT measurement data and multi-phase probe logs.
Provides the execute() class method that connects to a relay and
measures open, read, and write round-trip times.
Warning
The execute() method never raises exceptions for transport
errors or missing dependencies. All failures are captured in the
Nip66RttMultiPhaseLogs
fields. Overlay network relays tested without a proxy URL receive
an immediate failure result (all phases marked as failed).
See Also
bigbrotr.nips.nip66.nip66.Nip66:
Top-level model that orchestrates this alongside other tests.
bigbrotr.models.metadata.MetadataType:
The NIP66_RTT variant used when storing these results.
Functions¶
execute
async
classmethod
¶
execute(
relay: Relay,
deps: Nip66RttDependencies,
timeout: float | None = None,
proxy_url: str | None = None,
*,
allow_insecure: bool = False,
) -> Self
Test a relay's round-trip times across three phases.
Phases are executed sequentially: open -> read -> write. If the open phase fails, read and write are marked as failed with the same reason (cascading failure).
Parameters:
-
relay(Relay) –Relay to test.
-
deps(Nip66RttDependencies) –Grouped dependencies (keys, event_builder, read_filter).
-
timeout(float | None, default:None) –Connection timeout in seconds (default: 10.0).
-
proxy_url(str | None, default:None) –Optional SOCKS5 proxy URL for overlay networks.
-
allow_insecure(bool, default:False) –Fall back to unverified SSL (default: False).
Returns:
-
Self–An
Nip66RttMetadatainstance with measurement data and logs.
Source code in src/bigbrotr/nips/nip66/rtt.py
104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 | |