In Layer Four switching, the route and resources allocated to a packet are determined by the destination address as well as other header elds of the packet such as source address, TCP and UDP port numbers. Layer Four switching uni es rewall processing, RSVP style resource reservation lters, QoS Routing, and normal unicast and multicast forwarding into a single framework. In this framework, the forwarding database of a router consists of a potentially large number of lters on key header elds. A given packet header can match multiple lters, so each lter is given a cost, and the packet is forwarded using the least cost matching lter. In this paper, we describe two new algorithms for solving the least cost matching lter problem at high speeds. Our rst algorithm is based on a grid-of-tries construction and works optimally for processing lters consisting of two pre x elds such as destination-source lters using linear space. Our second algorithm, cross-producting, provides fast lookup time...