I have read about Computing Bandwidth weights in Tor directory protocol, version 3. But I could not understand about how bandwidth weights are calculated. And since they appear only once in consensus, how they help in path selection by network balancing?
Maybe it's easiest to explain this by example. The following comes from the current consensus:
[...] r TorNinurtaName AA8YrCza5McQugiY3J4h5y4BF9g TsD6f/8KF1h7Npm/w2vgkzDumjY 2014-05-08 23:15:06 188.8.131.52 9001 9030 s Fast Guard HSDir Named Running Stable V2Dir Valid v Tor 0.2.3.25 w Bandwidth=238 p reject 1-65535 [...] bandwidth-weights Wbd=849 Wbe=0 Wbg=4145 Wbm=10000 Wdb=10000 Web=10000 Wed=8301 Wee=10000 Weg=8301 Wem=10000 Wgb=10000 Wgd=849 Wgg=5855 Wgm=5855 Wmb=10000 Wmd=849 Wme=0 Wmg=4145 Wmm=10000 [...]
W?? numbers are the bandwidth weights. For example,
Wgg is the "Weight for Guard-flagged nodes in the guard position".
If your client were to consider that relay as a possible guard, it would multiply its consensus weight
238*5855=1393490. The reason is that this relay has the
Guard flag, but not the
Exit flag. Your client does that for all relays and then selects one of them.