1. A computer-implemented method for forwarding packets, comprising: receiving, by a computer, a packet with a hierarchically structured variable length identifier (HSVLI) which comprises contiguous name components ordered from a most general level to a most specific level; performing a longest prefix match lookup for forwarding the packet by selecting an entry from a first data structure of entries that indicate a name component, forwarding information for the name component, and a plurality of entry identifiers that chain an entry to another entry, by: in response to determining that a size of a name component is less than or equal to a predetermined threshold, selecting an entry based on the name component; in response to determining that the size is greater than the predetermined threshold: compressing the name component to obtain a compressed key; and selecting an entry based on the compressed key; and in response to determining a lookup collision associated with the selected entry, resolving the lookup collision, thereby facilitating forwarding of packets with variable length names.