The ONL NPR Tutorial

NPR Tutorial >> Filters, Queues and Bandwidth TOC

New Window?

Basic Packet Filtering

Advanced routers use packet classification to identify incoming packets that should be blocked or should be given special treatement. For example, a choke router might drop all Telnet (TCP protocol, destination port 23) packets going to certain subnets for security reasons. Packet classification generalizes the packet matching found in routing tables by inspecting fields other than a packet's destination IP address. An NPR filter table is a set of rules where each rule indicates the action for matching packets. [[ simple-filter-resize.png Figure ]]

The PLC (Parse, Lookup and Classify) block of an NPR searches both a filter table and a route table in parallel. The filter table contains packet forwarding rules that extend the rules in a route table. In the simplest case, the NPR selects the highest-priority, matching entry found in the route table and filter table.

In the approach described here, we assume that the filter table contains only simple primary filters. Packet filter rules allow you to not only direct a packet to one of 64 datagram output queues managed by a Queue Manager but also to drop the packet or forward the packet to other NPR components (e.g., plugin microengine) and reserved flow queues. (In a more sophisticated approach described elsewhere, you can use a filter table to duplicate a packet by installing either a filter with the multicast feature or an auxilliary filters).

This page describes how to use simple features of primary filters, and how to modify filters. An example based on some of the concepts discussed on this page is given in NPR Tutorial => Examples => Filters, Queues and Bandwidth. The sections in this page are:


The NPR Filter Table

Conceptually, each port of an NPR has a filter table in which each entry has 14 fields. These fields fall into one of three groups:

This page covers only the most basic fields that make up a primary filter. Fields having to do with TCP fields, exceptions and plugins are described elsewhere. [[ filter-matching.png Figure ]]

Unlike a route table entry that allows you to match only on a portion of the the destination IP address in the IP header, a filter extends the match over multiple fields. These comparison fields are located in the IP and transport layer (TCP, UDP) headers. The five most basic key fields are:

Every filter has a non-negative, integer priority between 0 and 63 that is used to select between the best matching route entry and the best matching primary filter. 0 is considered to be the highest priority and 63 the lowest. Recall that when multiple route entries match a route table, the one with the longest prefix is selected. But when multiple filters match a filter table with only primary filters, the one with the highest priority (lowest priority number) is chosen. PLC chooses the highest priority entry from a search of both the route table and the primary filters in the filter table. Another difference between a route table and a filter table is that all entries in a route table have the same priority (60 by default); but each entry in a filter table has its own priority (50 by default).
[[ queues-resize.png Figure ]]

The action fields indicate what to do with a matching packet. A simple filter allows you to drop a matching packet or forward it to a scheduling queue at an output port. Complex filters (discussed elsewhere) allow you to send a packet to a plugin microengine, or to generate duplicate packets (e.g., multicast) for forwarding to multiple outputs.

There are 8,192 packet scheduling queues at each of the NPR's five output ports. Each output port has a packet scheduler (PS) that orders packets based on a weighted deficit round-robin (WDRR) algorithm. Each queue has a Queue ID (QID) numbered from 0 to 8191. QIDs 0-63 are for datagram queues, and QIDs 64-8191 are for reserved queues. If only route tables are used, the NPR forwards packets to a datagram queue which is determined by the hash algorithm described in Filters,_Queues_and_Bandwidth => Mapping Flows to Queues . But a primary filter allows you to forward the packet to any one of 40,960 queues (5 ports x 8,192 queues/port).


Installing a Simple Primary Filter

[[ add-filter-resize.png Figure ]]

Here is how you install a simple primary filter:

The figure (right) shows a default Add Filter window.

The figure below shows that we have changed some fields from their default values so that the filter will match UDP packets coming from any IP address (0.0.0.0/0) and port number (*) and going to any port at any host in the 192.168.2.0/24 subnet. In this case, all packets destined for NPR 2 will match this key. A matching packet will be sent to queue 64 at output port 4. And the priority of the filter is 50 making it higher priority than the default priority of 60 for route tables.

Key Fields

[[ add-filter-dialogue-basic-resize.png Figure ]]

The basic key fields in a simple primary filter are matched against the classic 5-tuple found in a packet's IP header and transport layer (TCP, UDP) header: destination IP address, destination port, source IP address, source port, and protocol. As noted earlier, you use the same a.b.c.d/x dotted decimal CIDR notation as was used for route tables to specify a filter's destination address/mask. By default, the filter starts with the value 0.0.0.0/0 which will match any IP address. Similarly, a filter's source address/mask is matched against a packet's source IP address.

You can enter a source port number, or you can select the asterisk (*) if you want to match any source port. You can also specify a destination port number in a similar manner. Both TCP and UDP use 16-bit port numbers to identify applications or services (e.g., 80 for Web server, 22 for SSH login). Clients connecting to applications/services typically use ephemeral (short-lived) port numbers that are assigned by the client's operating system.

The protocol field menu allows you to select one of three protocols (tcp, udp, icpmp) or asterisk (*) if you don't care about the packet's protocol field or you can enter a protocol number (e.g., 2 for IGMP, 46 for RSVP).

Action Fields

The simplest packet action is to drop a matching packet by selecting the drop box. But more typically, you will want to forward a packet to one of the packet scheduling queues:

Note (port 0): A value of 0 in the qid field has special meaning: it means that you want the RLI to compute the datagram QID based on the NPR's stochastic fair queueing hash algorithm to be described later.

Recall that packets are directed to queues 0-63 (datagram queues) by matches using the route table. Although you can use a filter to direct packets to datagram queues 1-63, you usually use a filter to direct packets to a queue numbered between 64 and 8191.

Control Fields

The priority box was described earlier.

The Filter Table Window

[[ filter-table-resize.png Figure ]]

After adding the filter to the filter table, the Filter Table window (above) shows a compact form of the filter we just added. The fields that we modified are shown enclosed in red boxes. There are three fields that were not shown in the Add Filter window:



The Filter Table Edit Menu

A Filter Table Window has four menu items:

We have already discussed the Add Filter item. The Edit Filter and Delete Filter items allow you to change a filter and delete a filter respectively. We will not discuss these two items since they are straightforward.

The Stop/Start Stats menu item is a feature of our NSP (Network Service Platform) routers and has no meaning in the NPR.


Testing a Filter

You can verify that a filter is being selected by monitoring the stats counter associated with the filter. In our example above, the filter was assigned stats counter 31 which can be monitored in the same way that we monitored the matching of a route table entry in The Remote Laboratory Interface => Basic Monitoring.

Here is a simple experiment to test the above filter:

You should see the filter packet count increasing only while the filter is enabled and the route table entry packet count increasing when the filter is disabled. Alternatively, repeat the above experiment but change the filter priority between 50 and 70 to demonstrate that effect of priority on filter selection.
 

Recap


 Revised:  Tue, Aug 26, 2008 

  
  

NPR Tutorial >> Filters, Queues and Bandwidth TOC