SSF.OS.OSPFv2
Class LSDatabase

java.lang.Object
  |
  +--SSF.OS.OSPFv2.LSDatabase

public class LSDatabase
extends java.lang.Object

An OSPF Link State database.


Field Summary
 java.util.HashMap routerLSAs
          HashMaps for keeping all LSA's belonging to one area.
 java.util.HashMap summaryLSAs
           
 
Constructor Summary
LSDatabase(OSPF ospf, AreaData area)
           
 
Method Summary
 void ageAndCheckLSAs()
          Age all LSAs in this Area and check self-originated LSAs for reorigination.
 void ageAndCheckLSAsOfType(byte lsType)
          Called by "ageAndCheckLSAs()" to age a particular kind of LSAs and check self-originated LSAs whether they must be reoriginated or not.
 void clear()
          clear the LSDatabase.
 java.util.Vector getAllLSAHeaders()
          return all LSA Headers (Router and Summary) in a Vector.
 LSA getLSA(java.lang.String key)
          Determine whether a particular LSA is stored in this database, and if so return a complete copy of this LSA, otherwise return null.
 java.util.HashMap getLSAHashMap(byte type)
          Return the HashMap in which LSAs of the type given in the parameter type are stored.
 int getNextSeqNum(java.lang.String lsaKey, byte lsaType)
          Return the sequence number of the next instance of the LSA specified by its key and its type.
 java.util.Vector getRouterAndNetworkLSAs()
          Return all router and network LSAs in a Vector.
 boolean hasInstanceOf(LSA testLSA)
          Check whether an instance of the given LSA exists and if so return true else false.
 boolean hasRightInstanceOf(LSA testLSA)
          Check whether an instance of the given LSA exists and if so return true if this instance is newer than the given one else false.
 boolean installOwnLSA(LSA newLSA)
          installs a new self-originated LSA if possible.
 boolean installRecLSA(LSA newLSA)
          installs an LSA received during the flooding process or in database exchange process if possible.
 java.lang.String isNewerThan(LSA lsa1, LSA lsa2)
          Take two instances of an LSA and determine which of them is newer.
 void prematureAgeLSA(byte type, int lsID)
          Set a particular LSA's age to MAX_AGE and flood it out to flush it from the routing domain.
 void printDatabase()
          Print lists of all Router- and Summary-LSAs stored in this database.
 void setNextSeqNum(java.lang.String lsaKey, byte lsaType, int newSeqNum)
          Set value of nextSeqNum of the LSA specified by lsaKey and lsaType to newSeqNum.
 boolean shouldRecalcRoutTable(LSA newLSA, LSA oldLSA)
          Return true if the new LSA to install differs from the old LSA already stored here, otherwise false.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

routerLSAs

public java.util.HashMap routerLSAs
HashMaps for keeping all LSA's belonging to one area. For each internal LSA type an associated HashMap should be implemented. Actually we just deal with two types router- and summery-LSA. The key is a String containing LS type LS id and advertising router seperated by a space. The value is an LSASlot holding the LSA and its install timestamp.


summaryLSAs

public java.util.HashMap summaryLSAs
Constructor Detail

LSDatabase

public LSDatabase(OSPF ospf,
                  AreaData area)
Method Detail

installOwnLSA

public boolean installOwnLSA(LSA newLSA)
installs a new self-originated LSA if possible. Return true if installing was successful else false.


installRecLSA

public boolean installRecLSA(LSA newLSA)
installs an LSA received during the flooding process or in database exchange process if possible. Return true if installing was successful else false.


shouldRecalcRoutTable

public boolean shouldRecalcRoutTable(LSA newLSA,
                                     LSA oldLSA)
Return true if the new LSA to install differs from the old LSA already stored here, otherwise false. So this method returns whether the Routing Table should be recalculated, or not.


getAllLSAHeaders

public java.util.Vector getAllLSAHeaders()
return all LSA Headers (Router and Summary) in a Vector.


getLSAHashMap

public java.util.HashMap getLSAHashMap(byte type)
Return the HashMap in which LSAs of the type given in the parameter type are stored. This Method is used by "hasRightInstanceOf", "hasInstanceOf" and "isSelforiginated".


hasRightInstanceOf

public boolean hasRightInstanceOf(LSA testLSA)
Check whether an instance of the given LSA exists and if so return true if this instance is newer than the given one else false.


hasInstanceOf

public boolean hasInstanceOf(LSA testLSA)
Check whether an instance of the given LSA exists and if so return true else false.


getLSA

public LSA getLSA(java.lang.String key)
Determine whether a particular LSA is stored in this database, and if so return a complete copy of this LSA, otherwise return null.

Parameters:
key - String representing the unique identifier of an LSA. (see LSA.getKey).
Returns:
LSA containing the desired LSA or null if the LSA could not be found.

getNextSeqNum

public int getNextSeqNum(java.lang.String lsaKey,
                         byte lsaType)
Return the sequence number of the next instance of the LSA specified by its key and its type. This method is used in case of selforiginated LSAs only!

Parameters:
lsaKey - String representing the key value of the LSA.
lsaType - byte value indicating the type of the LSA.
Returns:
int value representing the next sequence number of the LSA.

setNextSeqNum

public void setNextSeqNum(java.lang.String lsaKey,
                          byte lsaType,
                          int newSeqNum)
Set value of nextSeqNum of the LSA specified by lsaKey and lsaType to newSeqNum. Only used in case of selforiginated LSAs!

Parameters:
lsaKey - String representing the key value of the LSA.
lsaType - byte value indicating the type of the LSA.
newSeqNum - The new sequence number of the next LSA instance to be installed.

isNewerThan

public java.lang.String isNewerThan(LSA lsa1,
                                    LSA lsa2)
Take two instances of an LSA and determine which of them is newer. Return true if lsa1 is newer than lsa2, false if lsa2 is newer than lsa1, identical if this method couldn't find any difference.

Parameters:
lsa1 - first LSA to compare.
lsa2 - second LSA to compare.
Returns:
String holding "true", "false" or "identical".

prematureAgeLSA

public void prematureAgeLSA(byte type,
                            int lsID)
Set a particular LSA's age to MAX_AGE and flood it out to flush it from the routing domain. As soon as it is no longer contained on any neighbor link state retransmission list and non of the router's neighbors are in states EXCHANGE or LOADING, it will be removed. This method supports Summary-LSAs only. For Router-LSAs premature aging is integrated in the creation process.

Parameters:
type - byte value indicating the type of the LSA to be premature aged.
lsID - int value representing an ip address of a network (LSA type 3) or the ip address which serves as id of the destination router (LSA type 4).

ageAndCheckLSAs

public void ageAndCheckLSAs()
Age all LSAs in this Area and check self-originated LSAs for reorigination.


ageAndCheckLSAsOfType

public void ageAndCheckLSAsOfType(byte lsType)
Called by "ageAndCheckLSAs()" to age a particular kind of LSAs and check self-originated LSAs whether they must be reoriginated or not.

Parameters:
lsType - byte value, indicating the type of the LSAs to be aged and checked.

printDatabase

public void printDatabase()
Print lists of all Router- and Summary-LSAs stored in this database.


getRouterAndNetworkLSAs

public java.util.Vector getRouterAndNetworkLSAs()
Return all router and network LSAs in a Vector. This method is called when calculating a new routing table. SSF-Net does not support broadcast so there are NO network LSAs stored here at this time.


clear

public void clear()
clear the LSDatabase. Remove all LSAs from the HashMaps.