Order peers with the published algorithm
03First group by priority. Within one priority, RFC 2782 recommends an ordering algorithm with an inclusive random draw and removal after each selection.
B leaves the candidate set. Remaining total is 1; draw 1 chooses A next. Z remains to be ordered before moving to priority 20.
Source for this drawing: RFC 2782 · Read RFC source: Weight selection algorithm ↗
New to this? Start hereA quick picture + helpful background
A message needs an address.
Think of a packet as a small addressed envelope. Devices pass it onward; transport protocols decide what delivery promises an application gets.
Helpful first, if these ideas are unfamiliar
These pictures are analogies to help you learn. The linked RFC explains the actual rules.
Terms in this drawing
Related RFCs and changes
“Updates” changes part of an earlier RFC. “Obsoletes” replaces it. This list shows selected related documents.
Keep zero weights first, use cumulative weights, select the first sum at least the draw, then remove that record.
- Priority comes first. Example Z/A/B are priority 10 with weights 0/1/3; C is priority 20 with weight 65535. C’s larger weight does not let it jump ahead of reachable priority-10 targets.
- The described ordering algorithm SHOULD be used in the absence of a protocol specifying other weighting information (Weight, page 4). Arrange the remaining records at one priority in any order, except put all zero-weight records first. The chosen stable example order is Z,A,B.
- Compute running sums: Z=0, A=1, B=4. Choose a uniform random integer from 0 through total 4 inclusive. Select the first running sum greater than or equal to the draw. A chosen draw of 3 selects B. Remove B, recompute over the remaining records, and repeat for every priority.
- Inclusive zero matters: with this chosen order, draw 0 selects Z, draw 1 selects A, and draws 2,3,4 select B. This is five equally likely draw values; zero weight is not an absolute prohibition. With only zero weights, total and draw are zero, so the first remaining record is chosen and then removed.
- Do not promise exact Weight/total traffic percentages. Official technical erratum 2984, proposing to change the algorithm, is Rejected. Erratum 8120 about the fictional example’s exact three-quarter claim is Held for Document Update, not a verified replacement rule. This guide preserves the published inclusive algorithm and avoids the misleading percentage claim. Verified editorial erratum 6600 fixes a spelling typo only.
- Removing each chosen record creates a retry order without replacement; it is not a command to connect to every server after success. Weight represents relatively static selection information, not a live server-load measurement (The Weight field, pages 5–6).
Example order is Z,A,B, with chosen draw 3 and then 1. Supplied draws in the offline model are explicit teaching inputs, not live randomness or measured traffic distribution.
Read the RFC section ↗