You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Externally, TVU UDP receiver appears to bind to one port, typically 8002 UDP.
22
+
Internally, TVU is actually bound with multiple sockets to improve kernel's handling of the packet queues.
23
+
24
+
> **NOTE:** TPU sockets use similar logic
25
+
26
+
A node advertises one external ip/port for TVU while binding multiple sockets to that same port using SO_REUSEPORT:
27
+
28
+
```rust
29
+
let (tvu_port, tvu_sockets) =multi_bind_in_range_with_config(
30
+
bind_ip_addr,
31
+
port_range,
32
+
socket_config_reuseport,
33
+
num_tvu_sockets.get(),
34
+
)
35
+
.expect("tvu multi_bind");
36
+
```
37
+
38
+
`multi_bind_in_range_with_config` sets `SO_REUSEPORT`. This means that other nodes only need to know about the one ip/port pair for TVU (similar principle applies in the case of TPU UDP sockets). The kernel distributes the incoming packets to all sockets bound to that port, and each socket can be serviced by a different thread.
39
+
40
+
> **NOTE:** TVU QUIC socket does not use `SO_REUSEPORT`, but otherwise works similarly to UDP
41
+
42
+
The TVU socket information is published via Gossip and is available in the `ContactInfo` struct.
43
+
To set a TVU socket, the node calls `set_tvu(...)`. The `set_tvu()` method is created by the macro `set_socket!`. For example:
In the `ContactInfo` struct, all sockets are identified by a tag/key, e.g.:
53
+
54
+
```rust
55
+
constSOCKET_TAG_TVU:u8=10; // For UDP
56
+
constSOCKET_TAG_TVU_QUIC:u8=11; // For QUIC
57
+
```
58
+
59
+
*`set_socket()` creates a `SocketEntry` and stores that into `ContactInfo::sockets`
60
+
*`set_socket()` updates `ContactInfo::cache`
61
+
62
+
```rust
63
+
cache: [SocketAddr; SOCKET_CACHE_SIZE]
64
+
```
65
+
66
+
`cache` is purely for quick lookups and optimization; it is not serialized and sent to peer nodes.
67
+
`SocketEntry` is serialized and sent to peer nodes within the gossip message type `CrdsData::ContactInfo`. Upon receiving the `ContactInfo`, the peer node calls the `get_socket!` macro to retrieve the TVU port associated with the node.
68
+
For example, to retrieve the TVU ports of the remote node, the peer node calls:
0 commit comments