A method and apparatus are provided for routing a packet within a
plurality of n nodes arranged in a line or tree (or a combination of the
foregoing), given a maximum stack depth, s. A fixed stack process for
routing packets on a line given a stack depth, s, initially divides a
line of n nodes into segments, such as n.sup.1/s approximately equal
segments. A unique label is assigned to each segment and, within each
segment, one of up to n.sup.1/s labels is assigned to each node. A fixed
stack process for routing packets on a tree, given a target stack depth,
s, initially identifies a subset, S, of at nodes from the tree, such as
at most 3 n.sup.1/s nodes, such that after the subset, S, is removed,
each remaining subtree has at most n.sup.(s-1)/s nodes. A unique label is
assigned to each of the nodes in the subset S and, within each remaining
subtree, one of up to n.sup.(s-1)/s labels is assigned to each node. If
the bound on the stack depth cannot be violated, the fixed stack routing
process merges every two consecutive levels in the stack to one level.