Annex C - Implementation Guidelines and Examples
(This annex is informative)
C.1.. Routeing Databases
Each database contains records as defined in the following sub-clauses. The following datatypes are defined.
FROM CommonMgmt IMPORT NSAPAddress,
AddressPrefix, BinaryAbsoluteTime;
PDU Type
lspID = ARRAY [0..7] OF Octet;
systemID = ARRAY [0..5] OF Octet;
octetTimeStamp = BinaryAbsoluteTime;
C.1.1.. Level 1 Link State Database
This database is kept by Level 1 and Level 2 Intermediate Systems, and consists of the latest Level 1 Link State PDUs from each Intermediate System (or pseudonode) in the area. The Level 1 Link State PDU lists Level 1 links to the Intermediate System that originally generated the Link State PDU.
RECORD
adr: lspID; (* 8 octet ID of LSP originator
*)
type: (Level1IntermediateSystem,
AttachedLevel2IntermediateSystem,
UnattachedLevel2IntermediateSystem);
seqnum: [0..SequenceModulus 1];
LSPage: [0..MaxAge]; (*Remaining Lifetime *)
expirationTime: TimeStamp;
(*Time at which LSP age
became zero (see 7.3.16.4). *)
SRMflags: ARRAY[1..(maximumCircuits +
maximumVirtualAdjacencies)]
OF BOOLEAN;
(*Indicates this LSP to be sent on this circuit. Note
that level 2 Intermediate systems may send level 1
LSPs to other partitions (if any exist). Only one level
2 Intermediate system per partition does this. For
level 1 Intermediate Systems the array is just
maximumCircuits long. *)
SSNflags: ARRAY[1..maximumCircuits +
maximumVirtualAdjacencies]
OF BOOLEAN;
(*Indicates that information about this LSP shall be
included in the next partial sequence number PDU
transmitted on this circuit. *)
POINTER TO LSP; (*The received LSP *)
END;
C.1.2.. Level 2 Link State Database
This database is kept by Level 2 Intermediate Systems, and consists of the latest Level 2 Link State PDUs from each Level 2 Intermediate System (or pseudonode) in the domain. The Level 2 Link State PDU lists Level 2 links to the Intermediate System that originally generated the Link State PDU.
RECORD
adr: lspID; (* 8 octet ID of LSP originator *)
type: (AttachedLevel2IntermediateSystem,
UnattachedLevel2IntermediateSystem);
seqnum: [0..SequenceModulus 1];
LSPage: [0..MaxAge]; (*Remaining Lifetime *)
expirationTime: TimeStamp;
(*Time at which LSP age
became zero (see 7.3.16.4). *)
SRMflags: ARRAY[1..(maximumCircuits)] OF
BOOLEAN;
(*Indicates this LSP to be sent on this circuit. *)
SSNflags: ARRAY[1..maximumCircuits] OF
BOOLEAN;
(*Indicates that information about this LSP must be
included in the next partial sequence number PDU
transmitted on this circuit. *)
POINTER TO LSP; (*The received LSP *)
END;
C.1.3.. Adjacency Database
This database is kept by all systems. Its purpose is to keep track of neighbours.
For Intermediate systems, the adjacency database comprises a database with an entry for each:
- Adjacency on a Point to Point circuit.
- Broadcast Intermediate System Adjacency. (Note that both a Level 1 and a Level 2 adjacency can exist between the same pair of systems.)
- Broadcast End system Adjacency.
- potential SVC on a DED circuit (maximum SVC Adjacencies for a DA circuit, or 1 for a Static circuit).
- Virtual Link Adjacency.
Each entry contains the parameters in Clause 11 for the Adjacency managed object. It also contains the variable used to store the remaining holding time for each Adjacency IDEntry and NETEntry entry, as defined below.
IDEntry = RECORD
ID: systemID;
(* The 6 octet System ID of a neighbour End system
extracted from the SOURCE ADDRESS field of its
ESH PDUs. *)
entryRemainingTime: Unsigned [1..65535]
(* The remaining holding time in seconds for this
entry. This value is not accessible to system
management. An implementation may choose to
implement the timer rules without an explicit
remainingTime being maintained. For example by
the use of asynchronous timers. It is present here in
order to permit a consistent description of the timer
rules. *)
END
NETEntry = RECORD
NET: NetworkEntityTitle;
(* The NET of a neighbour Intermediate system
as reported in its IIH PDUs. *)
entryRemainingTime: Unsigned [1..65535]
(* The remaining holding time in seconds for this
entry. This value is not accessible to system
management. An implementation may choose to
implement the timer rules without an explicit
remainingTime being maintained. For example by
the use of asynchronous timers. It is present here in
order to permit a consistent description of the timer
rules. *)
END;
C.1.4.. Circuit Database
This database is kept by all systems. Its purpose is to keep information about a circuit. It comprises an ARRAY[1..maximumCircuits].
Each entry contains the parameters in Clause 11 for a Circuit managed object (see 11.3). It also contains the remainingHelloTime (WordUnsigned [1..65535] seconds) variable for the Circuit. This variable not accessible to system management. An implementation may choose to implement the timer rules without an explicit remainingHelloTime being maintained. For example by the use of asynchronous timers. It is present here in order to permit a consistent description of the timer rules. Additionally, for Circuits of type X.25 Static Outgoing or X.25 DA, it contains the recallCount (Unsigned[0..255]) variable for the Circuit. This variable is not accessible to system management. It used to keep track of recall attempts.
C.1.5.. Level 1 Shortest Paths Database
This database is kept by Level 1 and Level 2 Intermediate Systems (unless each circuit is Level 2 Only). It is computed by the Level 1 Decision Process, using the Level 1 Link State Database. The Level 1 Forwarding Database is a subset of this database.
RECORD
adr: systemId; (*6 octet ID of destination system *)
cost: [1..MaxPathMetric];
(*Cost of best path to destination system *)
adjacencies: ARRAY[1..max
i
mum
Path
Splits]
OF POINTER TO Adjacency;
(*Pointer to adjacency for forwarding to system adr
*)
END;
C.1.6.. Level 2 Shortest Paths Database
This database is kept by Level 2 Intermediate Systems. It is computed by the Level 2 Decision Process, using the Level 2 Link State Database. The Level 2 Forwarding Database is a subset of this database.
RECORD
adr: AddressPrefix; (*destination prefix *)
cost: [1..MaxPathMetric];
(*Cost of best path to destination prefix *)
adjacencies: ARRAY[1..max
i
mum
Path
Splits]
OF POINTER TO Adjacency;
(*Pointer to adjacency for forwarding to prefix adr
*)
END;
C.1.7.. Level 1 Forwarding Database
This database is kept by Level 1 and Level 2 Intermediate Systems (unless each circuit is Level 2 Only). It is used to determine where to forward a data NPDU with destination within this system's area. It is also used to determine how to reach a Level 2 Intermediate System within the area, for data PDUs with destinations outside this system's area.
RECORD
adr:systemId;
(*6 octet ID of destination system. Destination
0 is special, meaningnearest level 2
Intermediate system *)
splits: [0..max
i
mum
Path
Splits];
(* Number of valid output adj's for reachingadr
(0 indicates it is unreachable) *)
nextHop: ARRAY[1..max
i
mum
Path
Splits] OF
POINTER TO adjacency;
(*Pointer to adjacency for forwarding to destination
system *)
END;
C.1.8.. Level 2 Forwarding Database
This database is kept by Level 2 Intermediate systems. It is used to determine where to forward a data NPDU with destination outside this system's area.
RECORD
adr: AddressPrefix; (*address of destination area.
*)
splits: [0..max
i
mum
Path
Splits];
(*Number of valid output adj's for reaching adr
(0 indicates it is unreachable) *)
nextHop: ARRAY[1..max
i
mum
Path
Splits] OF
POINTER TO adjacency;
(*Pointer to adjacency for forwarding to destination
area. *)
END;
C.2.. SPF Algorithm for Computing Equal Cost Paths
An algorithm invented by Dijkstra (see references) known as shortest path first (SPF), is used as the basis for the route calculation. It has a computational complexity of the square of the number of nodes, which can be decreased to the number of links in the domain times the log of the number of nodes for sparse networks (networks which are not highly connected).
A number of additional optimisations are possible:
- If the routeing metric is defined over a small finite field (as in this International Standard), the factor of log n may be removed by using data structures which maintain a separate list of systems for each value of the metric rather than sorting the systems by logical distance.
- Updates can be performed incrementally without requiring a complete recalculation. However, a full update must be done periodically to recover from data corruption, and studies suggest that with a very small number of link changes (perhaps 2) the expected computation complexity of the incremental update exceeds the complete recalculation. Thus, this International Standard specifies the algorithm only for the full update.
- If only End system LSP information has changed, it is not necessary to re-compute the entire Dijkstra tree for the IS. If the proper data structures exist, End Systems may be attached and detached as leaves of the tree and their forwarding information base entries altered as appropriate
The original SPF algorithm does not support load splitting over multiple paths. The algorithm in this International Standard does permit load splitting by identifying a set of equal cost paths to each destination rather than a single least cost path.
C.2.1.. Databases
PATHS This represents an acyclic directed graph of shortest paths from the system S performing the calculation. It is stored as a set of triples of the form aN,d(N),{Adj(N)}q, where:
- N is a system Identifier. In the level 1 algorithm, N is a 7 octet ID. For a non-pseudonode it is the 6 octet system ID, with a 0 appended octet. For a pseudonode it is a true 7 octet quantity, comprised of the 6 octet Designated Intermediate System ID and the extra octet assigned by the Designated Intermediate System. In the level 2 algorithm it is either a 7 octet Intermediate System or pseudonode ID (as in the level 1 algorithm), or it is a variable length address prefix (which will always be a leaf, i.e. End system, in PATHS).
- d(N) is N's distance from S (i.e. the total metric value from N to S).
- {Adj(N)} is a set of valid adjacencies that S may use for forwarding to N.
When a system is placed on PATHS, the path(s) designated by its position in the graph is guaranteed to be a shortest path.
TENT This is a list of triples of the form aN,d(N),{Adj(N)}q, where N, d(N) and {Adj(N)} are as defined above for PATHS.
- TENT can intuitively be thought of as a tentative placement of a system in PATHS. In other words, the triple aN,x,{A}q in TENT means that if N were placed in PATHS, d(N) would be x, but N cannot be placed on PATHS until it is guaranteed that no path shorter than x exists.
- The triple aN,x,{A,B}q in TENT means that if N were placed in PATHS, d(N) would be x via either adjacency A or B
NOTE - As described above, (see 7.2.6), it is suggested that the implementation keep the database TENT as a set of lists of triples of the form a*,Dist,*q, for each possible distance Dist. In addition it is necessary to be able to process those systems which are pseudonodes before any non-pseudonodes at the same distance Dist.
C.2.2.. Use of Metrics in the SPF Calculation
Internal metrics are not comparable to external metrics. Therefore, the cost of the path from N to S for external routes (routes to destinations outside of the routing domain) may include both internal and external metrics. The cost of the path from N to S (called d(N) below in database PATHS) may therefore be maintained as a two-dimensioned vector quantity (specifying internal and external metric values). In incrementing d(N) by 1, if the internal metric value is less than the maximum value MaxPathMetric, then the internal metric value is incremented by one and the external metric value left unchanged; if the internal metric value is equal to the maximum value MaxPathMetric, then the internal metric value is set to 0 and the external metric value is incremented by 1. Note that this can be implemented in a straightforward manner by maintaining the external metric as the high order bits of the distance.
NOTE - In the code of the algorithm below, the current path length is held in a variable tentlength. This variable is a two-dimensional quantity tentlength=(internal,external) and is used for comparing the current path length with d(N) as described above.
C.2.3.. Overview of the Algorithm
The basic algorithm, which builds PATHS from scratch, starts out by putting the system doing the computation on PATHS (no shorter path to SELF can possibly exist). TENT is then pre-loaded from the local adjacency database.
Note that a system is not placed in PATHS unless no shorter path to that system exists. When a system N is placed in PATHS, the path to each neighbour M of N, through N, is examined, as the path to N plus the link from N to M. If aM,*,*q is in PATHS, this new path will be longer, and thus ignored.
If aM,*,*q is in TENT, and the new path is shorter, the old entry is removed from TENT and the new path is placed in TENT. If the new path is the same length as the one in TENT, then the set of potential adjacencies {adj(M)} is set to the union of the old set (in TENT) and the new set {adj(N)}. If M is not in TENT, then the path is added to TENT.
Next the algorithm finds the triple aN,x,{Adj(N)}q in TENT, with minimal x.
NOTE - This is done efficiently because of the optimisation described above. When the list of triples for distance Dist is exhausted, the algorithm then increments Dist until it finds a list with a triple of the form a*,Dist,*q.
N is placed in PATHS. We know that no path to N can be shorter than x at this point because all paths through systems already in PATHS have already been considered, and paths through systems in TENT will have to be greater than x because x is minimal in TENT.
When TENT is empty, PATHS is complete.
C.2.4.. The Algorithm
The Decison Process Algorithm must be run once for each supported routeing metric. A Level 1 Intermediate System runs the algorithm using the Level 1 LSP database to compute Level 1 paths. In addition a Level 2 Intermediate System runs the algorithm using the Level 2 LSP database to compute Level 2 paths.
If this system is a Level 2 Intermediate System which supports the partition repair optional function the Decision Process algorithm for computing Level 1 paths must be run twice for the default metric. The first execution is done to determine which of the area's manual Area Addresses are reachable in this partition, and elect a Partition Designated Level 2 Intermediate System for the partition. The Partition Designated Level 2 Intermediate System will determine if the area is partitioned and will create virtual Level 1 links to the other Partition Designated Level 2 Intermediate Systems in the area in order to repair the Level 1 partition. This is further described in 7.2.10.
Step 0: Initialise TENT and PATHS to empty. Initialise tentlength to (0,0).
(tentlength is the pathlength of elements in TENT we are examining.)
- Add aSELF, 0, Wq to PATHS, where W is a special value indicating traffic to SELF is passed up to Transport (rather than forwarded).
- Now pre-load TENT with the local adjacency database. (Each entry made to TENT must be marked as being either an End system or an Intermediate System to enable the check at the end of Step 2 to be made correctly.) For each adjacency Adj(N), (including Manual Adjacencies, or for Level 2 enabled Reachable Addresses) on enabled circuits, to system N of SELF in state Up, compute
d(N) = cost of the parent circuit of the adjacency
(N), obtained from metrick, where k = one of de
fault metric, delay metric, monetary metric, er
ror metric.
Adj(N) = the adjacency number of the adjacency
to N
- If a triple aN,x,{Adj(M)}q is in TENT, then: If x = d(N), then Adj(M) , {Adj(M)} H Adj(N).
- If there are now more adjacencies in {Adj(M)} than maximum Path Splits, then remove excess adjacencies as described in 7.2.7.
- If x < d(N), do nothing.
- If x > d(N), remove aN,x,{Adj(M)}q from TENT and add the triple aN,d(N),Adj(N)q.
- If no triple aN, x,{Adj(M)}q is in TENT, then add aN, d(N),Adj(N)q to TENT.
- Now add any systems to which the local Intermediate system does not have adjacencies, but which are mentioned in neighbouring pseudonode LSPs. The adjacency for such systems is set to that of the Designated Intermediate System.
- For all broadcast circuits in state On, find the LSP with LSP number zero and with the first 7 octets of LSPID equal to the LnCircuitID for that circuit (i.e. pseudonode LSP for that circuit). If it is present, for all the neighbours N reported in all the LSPs of this pseudonode which do not exist in TENT add an entry aN,d(N),Adj(N)q to TENT, where
d(N) = metrick of the circuit.
Adj(N) = the adjacency number of the adjacency to the
DR.
- Go to Step 2.
Step 1: Examine the zeroth Link State PDU of P, the system just placed on PATHS (i.e. the Link State PDU with the same first 7 octets of LSPID as P, and LSP number zero).
- If this LSP is present, and the LSP Database Overload bit is clear, then for each LSP of P (i.e. all the Link State PDUs with the same first 7 octets of LSPID as P, irrespective of the value of LSP number) compute
dist(P,N) = d(P) + metrick(P,N).
for each neighbour N (both Intermediate System and End system) of the system P. If the LSP Database Overload bit is set, only consider the End system neighbours of the system P. d(P) is the second element of the triple
aP,d(P),{Adj(P)q
and metrick(P,N) is the cost of the link from P to N as reported in P's Link State PDU
- If dist(P,N) > MaxPathMetric, then do nothing.
- If aN,d(N),{Adj(N)}q is in PATHS, then do nothing.
NOTE d(N) must be less than dist(P,N), or else N would not have been put into PATHS. An additional sanity check may be done here to ensure d(N) is in fact less than dist(P,N).
- If a triple aN,x,{Adj(N)}q is in TENT, then:
- If x = dist(P,N), then Adj(N) , {Adj(N)} H Adj(P).
- If there are now more adjacencies in {Adj(N)} than maximum Path Splits, then remove excess adjacencies, as described in 7.2.7.
- If x < dist(P,N), do nothing.
- If x > dist(P,N), remove aN,x,{Adj(N)}q from TENT and add aN,dist(P,N),{Adj(P)}q.
- If no triple aN, x,{Adj(N)}q is in TENT, then add aN, dist(P,N),{P}q to TENT.
Step 2: If TENT is empty, stop, else:
- Find the element aP,x,{Adj(P)}q, with minimal x as follows:
- If an element a*,tentlength,*q remains in TENT in the list for tentlength, choose that element. If there are more than one elements in the list for tentlength, choose one of the elements (if any) for a system which is a pseudonode in preference to one for a non-pseudonode. If there are no more elements in the list for tentlength increment tentlength and repeat Step 2.
- Remove aP,tentlength,{Adj(P)}q from TENT.
- Add aP,d(P),{Adj(P)}q to PATHS.
- If this is the Level 2 Decision Process running, and the system just added to PATHS listed itself as Partition Designated Level 2 Intermediate system, then additionally add aAREA.P, d(P), {adj(P)}q to PATHS, where AREA.P is the Network Entity Title of the other end of the Virtual Link, obtained by taking the first AREA listed in P's Level 2 LSP and appending P's ID.
- If the system just added to PATHS was an End system, go to Step 2, Else go to Step 1.
NOTE - In the Level 2 context, the End systems are the set of Reachable Address Prefixes and the set of area addresses with zero cost.
C.3.. Forwarding Process
C.3.1.. Example pseudo-code for the forwarding procedure described in 7.4.3
This procedure chooses, from the Level 1 forwarding data base if level is level1, or from the Level 2 forwarding database if level is level2, an adjacency on which to forward PDUs for destination dest. A pointer to the adjacency is returned in adj, and the procedure returns the value True. If no suitable adjacency exists the procedure returns the value False, in which case a call should be made to Drop(Destination Address Unreachable, octetNumber). If queue length values are available to the forwarding process, the minimal queue length of all candidate circuits is chosen, otherwise, they are used in round robin fashion.
PROCEDURE Forward(
level: (level1, level2),
dest: NetworkLayerAddress,
VAR adj: POINTER TO adjacency) :
BOOLEAN
VAR
adjArray: ARRAY OF
ForwardingDatabaseRecords;
temp, index, minQueue: CARDINAL;
BEGIN
(*Set adjArray to appropriate database} *)
IF level = level1 THEN
adjArray := level1ForwardingDatabase
ELSE
adjArray := level2ForwardingDatabase
END;
(*Perform appropriate hashing function to obtain an
index into the database *)
IF Hash(level, dest, index) THEN
IF adjArray[index].splits > 0 THEN
(*Find minimum queue size for all equal cost
paths *)
minQueue := MaxUnsigned;
temp := adjArray[index].lastChosen + 1;
(*start off after last time *)
FOR i := 1 TO adjArray[index].splits DO
(*for all equal cost paths to dest *)
IF temp > adjArray[index].splits THEN
(*after end of valid entries, wrap to first
*)
temp := 1
ELSE
temp := temp + 1
END;
IF
QueueSize(adjArray[index].nextHop[temp])
< minQueue THEN
minQueue :=
QueueSize(adjArray[index].nextHop[tem
p]);
adj := adjArray[index].nextHop[temp];
adjArray[index].lastChosen := temp;
END;
Forward := true
END;
ELSE
Forward := false (*There must be at least one
valid output adjacency *)
END
ELSE
Forward := false (*Hash returned destination
unknown *)
END
END forward;