In a network router, a tree structure or a sorting network is used to compare
scheduling values and select a packet to be forwarded from an appropriate queue.
In the tree structure, each leaf represents the scheduling value of a queue and
internal nodes of the structure represent winners in comparisons of scheduling
values of sibling nodes of the tree structure. CBR scheduling values may first
be compared to select a queue and, if transmission from a CBR queue is not timely,
a packet may be selected using WFQ scheduling values. The scheduling values are
updated to reflect variable packet lengths and byte stuffing in the prior packet.
Scheduling may be performed in multiple stages.