Opened 2 years ago

Closed 8 months ago

# When randomly choosing IPv4 or IPv6, set IPv6 probability based on IPv6 weight

Reported by: Owned by: teor neel Medium Tor: unspecified Core Tor/Tor Normal tor-client ipv6 neel@… #17835

### Description

We can't make 50% of clients use IPv6 until most relays have IPv6. Otherwise, we would overload the IPv6 Guards. Right now, about 25% of Guard consensus weight has IPv6:
https://metrics.torproject.org/advbw-ipv6.html

When we are randomly choosing IPv4 or IPv6, we need to set the initial IPv6 probability based on the IPv6 Guard consensus weight. (Or the number of IPv6 bridges, if we're using bridges.)

With IPv4-only, IPv6-only, and DualStack Entry nodes, the formulas are:

```IPv4-capable-weight = IPv4-only + DualStack
IPv6-capable-weight = IPv6-only + DualStack
Total-weight = IPv4-only + IPv6-only + DualStack

IPv4-capable-fraction = IPv4-capable-weight / Total-weight
IPv6-capable-fraction = IPv6-capable-weight / Total-weight

IPv4-probability = IPv4-capable-fraction / (IPv4-capable-fraction + IPv6-capable-fraction)
IPv6-probability = IPv6-capable-fraction / (IPv4-capable-fraction + IPv6-capable-fraction)
```

We should update these probabilities whenever we get a new consensus, new bridge lines, or new bridge descriptors.

## Child Tickets

TicketTypeStatusOwnerSummary
#28653enhancementclosedSpecify IPv4 and IPv6 weight calculations in dir-spec.txt

### comment:1 Changed 2 years ago by teor

(Currently, relays can't be IPv6-only, but bridges can be configured as IPv6-only.)

### comment:2 Changed 2 years ago by neel

Owner: set to neel new → assigned

### comment:3 Changed 2 years ago by neel

Where should I look for this patch?

### comment:4 Changed 23 months ago by teor

When the consensus is received, tor parses it, and assigns bandwidth weights to each relay. Each relay has an IPv4 address, and an optional IPv6 address. Some relays can be entry nodes, depending on their flags.

When bridges are configured, tor parses the config, and weights each bridge equally. Each bridge has one or two IP addresses. Each bridge is an entry node.

Once the entry nodes have up-to-date weights and addresses, you can calculate the entry node weight for IPv4 and IPv6.

We'll also need some documentation for this weight calculation, probably in dir-spec.txt.

### comment:5 Changed 23 months ago by teor

Type: defect → enhancement

### comment:6 Changed 8 months ago by teor

Resolution: → wontfix assigned → closed
Note: See TracTickets for help on using tickets.