SSF.OS.OSPFv2
Class HashMapRoutingTable

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

public class HashMapRoutingTable
extends java.lang.Object

An implementation of OSPF routing table usingn HashMaps to distinguish between router and network entries.


Field Summary
 OSPF myOSPF
          A link to the OSPF session this routing table belongs to.
 java.util.HashMap networks
          A HashMap storing routing table entries with destination "network".
 java.util.HashMap routers
          A HashMap storing routing table entries with destination "router".
 
Constructor Summary
HashMapRoutingTable(OSPF o)
          Create a new OSPF Routing Table formed by two HashMaps.
 
Method Summary
 void add(NetworkEntry newNEntry, java.lang.String key)
          add a new entry (NetworkEntry) to the routing table whose destination is a network.
 void add(RouterEntry newREntry, java.lang.Integer key, java.lang.Integer areaID)
          add a new entry (RouterEntry) to the routing table whose destination is a router.
 void delNet(java.lang.String key)
          remove an entry from HashMap "networks".
 void delRout(java.lang.Integer key, java.lang.Integer aID)
          remove a particular route from HashMap "routers".
 void delRouter(java.lang.Integer key)
          remove ALL routes to a particular router.
 RouterEntry getDest(java.lang.Integer destID, java.lang.Integer destArea)
          Lookup the routing table for a particular RouterEntry and return it if it exists.
 NetworkEntry getDest(java.lang.String destID)
          Lookup the routing table for a NetworkEntry and return it if it exists.
 int getNetCost(java.lang.String netKey, int areaID)
          Return the cost of a NetworkEntry Object specified by its key String.
 java.lang.Object[] getNetKeys()
          return the keys of all network entries.
 java.lang.String getPathType(byte type)
          Convert the given path type in a String.
 java.lang.Integer getPrefASBREntryArea(java.lang.Integer key)
          return the id of the area which stores the Summary LSA that lead to the preferred RouterEntry leading to a particular AS Boundary router.
 int getRoutCost(java.lang.Integer routKey, int areaID)
          Return the cost of the RouterEntry Object describing the preferred paths to an AS Boundary Router.
 java.util.Iterator getRoutKeys()
          return the key values of all router entries.
 void print()
          print this Table in a form following the examples of RFC 2328 chapter 11.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

routers

public java.util.HashMap routers
A HashMap storing routing table entries with destination "router". If destination is an area border router or an AS boundary router and there is a valid entry, it will be found in this structure. Keys are Integers representing the routers router ID. The associated value is also a HashMap, matching area IDs (key) to RouterEntry objects (value). This is because their may be several equal-cost paths to the same router through several areas, if two ABRs or ASBRs share multiple areas in common.


networks

public java.util.HashMap networks
A HashMap storing routing table entries with destination "network". All valid network entries can be found here. Keys are Strings consisting of destination ID and address mask, separated by a slash. The associated value is a NetworkEntry.


myOSPF

public OSPF myOSPF
A link to the OSPF session this routing table belongs to.

Constructor Detail

HashMapRoutingTable

public HashMapRoutingTable(OSPF o)
Create a new OSPF Routing Table formed by two HashMaps. One for router entries and one for network entries.

Method Detail

add

public void add(RouterEntry newREntry,
                java.lang.Integer key,
                java.lang.Integer areaID)
add a new entry (RouterEntry) to the routing table whose destination is a router.

Parameters:
newREntry - RouterEntry to be added.
key - Integer representing the destinations router's ID.
areaID - Integer representing area's ID whose link state information has led to the RouterEntry.

add

public void add(NetworkEntry newNEntry,
                java.lang.String key)
add a new entry (NetworkEntry) to the routing table whose destination is a network.

Parameters:
newNEntry - NetworkEntry to be added.
key - String consisting of an ip address followed by a slash followed by a network mask. It uniquely identifys the NetworkEntry.

getDest

public NetworkEntry getDest(java.lang.String destID)
Lookup the routing table for a NetworkEntry and return it if it exists.

Parameters:
destID - String, representing the identifier of the network entry.
Returns:
NetworkEntry or null if there is no entry.

getDest

public RouterEntry getDest(java.lang.Integer destID,
                           java.lang.Integer destArea)
Lookup the routing table for a particular RouterEntry and return it if it exists.

Parameters:
destID - Integer, representing the identifier of the router entry.
destArea - Integer, representing the id of the area who is responsible for the entry.
Returns:
RouterEntry or null if there is no entry.

getNetCost

public int getNetCost(java.lang.String netKey,
                      int areaID)
Return the cost of a NetworkEntry Object specified by its key String. If there is no such entry, return -1.

Parameters:
netKey - String which uniquely identifies the NetworkEntry if it exists.
areaID - id of the area in which a new Summary LSA should be installed.
Returns:
int value representing the cost of the shortest paths to the destination network if there is such a destination, else -1.

getRoutCost

public int getRoutCost(java.lang.Integer routKey,
                       int areaID)
Return the cost of the RouterEntry Object describing the preferred paths to an AS Boundary Router. If there is no such entry, return -1.

Parameters:
routKey - Integer representing the ASBR's router id.
areaID - id of the area in which a new Summary LSA should be installed.
Returns:
int value representing the cost of the preferred shortest paths (according to RFC 2328 chapter 16.4 step 3) to the ASBR if exist, else -1.

getPrefASBREntryArea

public java.lang.Integer getPrefASBREntryArea(java.lang.Integer key)
return the id of the area which stores the Summary LSA that lead to the preferred RouterEntry leading to a particular AS Boundary router. The preferred path is determined as described in RFC 2328 chapter 16.4 step 3. If there is no such entry, return -1.

Parameters:
key - Integer Object indicating the AS Boundary router's router id.
Returns:
Integer representing the area's id or -1 if there is no entry.

delNet

public void delNet(java.lang.String key)
remove an entry from HashMap "networks". This Method is used, when the table became invalid to delete networks which were modified. The remaining network entries then must be invalid and should be deleted from the IP forwarding table.

Parameters:
key - String Object, representing the key value of the network destination.

delRout

public void delRout(java.lang.Integer key,
                    java.lang.Integer aID)
remove a particular route from HashMap "routers". This Method is used to delete an unreachable router route from the routing table.

Parameters:
key - Integer Object, representing the key value of the router destination.
aID - Integer Object, representing the id of the area who has lead to this entry.

delRouter

public void delRouter(java.lang.Integer key)
remove ALL routes to a particular router. This method is used to delete AS Boundary Routers from an invalidated routing table.

Parameters:
key - Integer Object, representing the id of the router to be removed.

getNetKeys

public java.lang.Object[] getNetKeys()
return the keys of all network entries. The method is used when this table is invalidated. While calculating the new routes, all routes which remains the same or have changed in the new routing table are deleted from this table by method "delNet()". The remaining routes serve as a mnemonic for routes which became unreachable and so can be removed from ip forwarding table accurately.

Returns:
Object[] containing the destination keys of the remaining network entries.

getRoutKeys

public java.util.Iterator getRoutKeys()
return the key values of all router entries. The method is used to determine routes to AS boundary routers and to update and send summary LSAs of type 4.

Returns:
Iterator containing the destination keys of all RouterEntry Objects.

print

public void print()
print this Table in a form following the examples of RFC 2328 chapter 11.


getPathType

public java.lang.String getPathType(byte type)
Convert the given path type in a String.