Previous Table of Contents Next


Identifying Routes Based on the AS_Path

Identifying routes based on the AS_path information is a bit more involved. As you know by now, the AS_path list is a list of ASs that a route has traversed before reaching a BGP peer. The list itself is a character string that contains characters from the following set: 0,1,2,3,4,5,6,7,8,9, "space," left brace "{", right brace "}", left parenthesis "(", right parenthesis ")", the beginning of the input string, the end of the input string, and a comma ",".


Troubleshooting:  
Example: Ch. 10, pp. 310-312. Identifying and Filtering Routes Based on the AS_Path

The AS_path list 10 2, for example, is actually: a beginning of string character followed by character 1 followed by a 0 followed by a space followed by a 2 followed by an end of string character.

Trying to identify the AS_path list consists of comparing the list to what is called a regular expression. A regular expression is just a pattern of characters represented by a formula such as: ^200 100$, which is a regular expression representing a list that starts with 200, followed by a space, and then ends with 100. The "^" and the "$" are representations of the beginning and end of string characters, respectively.

A regular expression can be formed by using single-character patterns or multiple-character patterns.

Single-Character Patterns

A single-character pattern tries to match a single character. The single-character regular expression 3 tries to match the character 3 in an input string. You can specify a range of single characters to match against a string. Ranges are included within brackets ([]). The order in which the characters forming the range get listed is not important. The regular expression consisting of the range [efghEFGH], for example, is trying to match any of the above characters in an input string. Given the two input strings, "hello" and "there," the regular expression matches both of these lists because they both contain the character e.

Ranges can be listed by typing the end points of a range; for example, ranges [a-z] and [0-9] indicate any lowercase character between a and z and any numeric character between 0 and 9, respectively.

You can also reverse or negate the pattern matching by including a caret (^) at the beginning of the range. The range [^a-dA-D], for example, matches any character except a,b,c,d,A,B,C,D. Some characters have a special meaning, such as the dollar sign $ and the underscore _, as described in table 5-4.

Table 5-4 Regular expression special characters

Character Symbol Special Meaning

Period . Matches any single character, including white space.
Asterisk * Matches 0 or more sequences of the pattern.
Plus sign + Matches 1 or more sequences of the pattern.
Question mark ? Matches 0 or 1 occurrences of the pattern.
Caret ^ Matches the beginning of the input string.
Dollar sign $ Matches the end of the input string.
Underscore _ Matches a comma (,), left brace ({), right brace (}), left
parenthesis, right parenthesis, the
beginning of the input string, the end of the input string, or a space.
Brackets [range] Designates a range of single-character patterns.
Hyphen - Separates the end points of a range.

To list the special characters as part of an input list, they need to be preceded with a backslash (\). The range [abc\$], for example, will match an input string that contains the characters a,b,c, and $. Table 5-4 lists the special characters used in regular expressions.

Multiple-Character Patterns

Multiple-character regular expressions are just an ordered sequence of single-character patterns. The pattern is a combination of letters, numbers, any keyboard character, and special meaning characters. An example of a multiple-character regular expression follows: 100 1[0-9] . This regular expression matches any string that contains the exact sequence 100, followed by a space, followed by 1, followed by any number between 0 and 9. Any of the following input strings will match the regular expression: 123 100 10 11, or, 100 19, or 19 100 11 200, and so on.


Previous Table of Contents Next