SSF.OS.OSPFv2
Class OSPF

java.lang.Object
  |
  +--SSF.OS.ProtocolSession
        |
        +--SSF.OS.OSPFv2.OSPF
All Implemented Interfaces:
com.renesys.raceway.DML.Configurable, FIBChangeListener

public class OSPF
extends ProtocolSession
implements FIBChangeListener

The OSPFv2 interior gateway protocol (IGP).


Nested Class Summary
 class OSPF.AgingTimer
          A cyclic timer used to age all LSAs currently installed in the databases of this session and (for the future) all external LSAs stored here.
 class OSPF.RTCControlTimer
          The Routing Table Calculation Control Timer.
 
Field Summary
 long agingInterval
          The duration of the AgingTimer
 OSPF.AgingTimer agingTimer
          A Timer aging the LSAs upon expiration
 boolean area_border_rtr
          Indicates if this is an area border router.
 java.util.HashMap areaStructs
          A HashMap which lists all area data structures of this OSPF router.
 boolean as_boundary_rtr
          Indicates if this is an AS boundary router.
 java.lang.String as_nh
          The NHI address prefix of the AS to which this router belongs.
 int as_num
          The number of the AS to which this router belongs.
static int ASPF_MCAST_ADDR
          The int value of the multicast address for ALLSPFRouters (All Shortest Path First Routers).
 boolean backbone_rtr
          Indicates if this is a backbone router.
 boolean[] debugOptions
          The show options from the DML-config-file will be recorded here
static java.lang.String DEFAULT_DEST
          The Destination ID that indicates the default route.
static int DESIG_MCAST_ADDR
           
 java.util.HashMap dynConfKeys
          A HashMap for dynamic Configuration of this OSPF session.
static int INIT_SEQUENCE_NUM
          The value used for LS Sequence Number when originating the first instance of any LSA.
static byte INTER_AREA
          Indicates a path-type of inter-area.
 boolean internal_rtr
          Indicates if this is an internal Router.
static byte INTRA_AREA
          Indicates a path-type of intra-area.
 RoutingTable ipTable
          The forwarding table, kept in the IP protocol session, which is the "live" table used for lookups when this router forwards packets.
static int LS_INFINITY
          The metric value indicating that the destination described by an LSA is unreachable
static long LS_REFRESH_TIME
          The maximum time between distinct originations of any particular self- originated LSA.
static int MAX_AGE
          The max of age an LSA can attain.
static int MAX_AGE_DIFF
          The max time dispersion that can occur, as an LSA is flooded throughout the AS.
static int MAX_SEQUENCE_NUM
          The maximum value that LS Sequence Number can attain.
static long MIN_LS_ARRIVAL
          The min time that must elapse between reception of new LSA instances during flooding.
static long MIN_LS_ITVL
          The minimum time between distinct originations of any particular LSA.
static int MTU
          The Maximum Transfer Unit supported on all Interfaces.
 java.lang.String nh
          The NHI address prefix of the local router.
 long pacingFloodTime
          long value indicating the time at which LSAs in the "Neighbor.pacingFloodList" are paced in between updates.
static byte POINT_TO_POINT
          Indicates a point-to-point connection to another router.
static int PROTOOSPF
           
 RandomStream randomStream
          RandomStream to produce random values where it's needed due to RFC 2328 and to add dynamic behaviour to the protocol.
 HashMapRoutingTable routingTable
          The OSPFv2 Routing Table of this ProtocolSession.
 OSPF.RTCControlTimer rtcControlTimer
          The Routing Table Calculation Control Timer.
 Router rtr
          The local router.
 int rtrid
          The identity of this router.
 long spfDelay
          long value specifying how long OSPF waits between receiving a topology change and starting an SPF calculation.
 long spfHoldTime
          long value specifying how long OSPF waits between two consecutive SPF calculations
static byte TO_STUB_NET
          Indicates a connection to a stub network.
static byte TO_TRANSIT_NET
          Indicates a connection to a transit network.
static Net topnet
          A reference to the top-level Net.
static byte TYPE_1_EXTERNAL
          Indicates a path-type of type-1-external.
static byte TYPE_2_EXTERNAL
          Indicates a path-type of type-2-external.
static byte VIRTUAL_LINK
          Indicates a Virtual link to another area border router.
 
Fields inherited from class SSF.OS.ProtocolSession
name, use
 
Constructor Summary
OSPF()
          Constructs an OSPF protocol session.
 
Method Summary
 long buildIARoute(LSA summaryHeader, int areaID)
          This method is called, if the best route to a particular inter-area destination must be recalculated.
 long calculateRT()
          Recalculate the entire Routing Table.
 void config(com.renesys.raceway.DML.Configuration cfg)
          Configure the ospf protocol parameters.
 java.lang.String convertRouteID(java.lang.String destID)
          Convert a destination id into the ip table format.
 void floodExternalLSA(LSA extLSA)
          Flood an external LSA out of the router's interfaces.
 int getRouterID()
          Return the smallest IP interface address belonging to this OSPF router.
 float getSimTime()
          Get the current simulation time.
 void init()
          Initialization routine called by ProtocolGraph after instantiation and when restarting the router after it has been stopped.
 boolean isSelforiginated(LSA testLSA)
          Check whether testLSA is an LSA which has been originated by the router itself and return true if so, else false.
 double nowsec()
          Returns the current simulation time in seconds.
 void opened(ProtocolSession myIP)
          Overridden.
 void originateSummary3LSA(NetworkEntry netEntry, java.lang.String destination)
          This method is called by area-border routers only, to check whether a new summary type 3 must be originated.
 void originateSummary4LSA(java.lang.Integer areaID, java.lang.Integer dest, int cost, byte pathType)
          This method is called by area-border routers only.
 void printConfigError(java.lang.String struct, int structID, java.lang.String error)
           
 void printConfigError(java.lang.String rise, java.lang.String riseID, java.lang.Exception riseEx)
          Used to print error messages concerning configuration of interfaces or areas.
 void printConfiguration()
          print the router's current ospf configuration if necessary.
 void printError(java.lang.String rise, java.lang.String riseID, java.lang.String errorStr)
          Used by an OSPF Interface or Area to print error messages.
 void printGeneralError(java.lang.String occurence, java.lang.Exception reason)
          Used to print error messages in case of general errors.
 void printGeneralWarning(java.lang.String warning)
          Used to print warning messages when the system reports a general warning.
 void printMessage(java.lang.String message)
          Method for printing debug Messages.
 boolean push(ProtocolMessage message, ProtocolSession fromSession)
          Routine to call when a message is being sent to ("pushed into") this ProtocolSession by another ProtocolSession.
 long removeIARoute(LSA summaryHeader, int areaID)
          This method is called if a Summary LSA has/has reached MAX_AGE.
 void routeAddedBy(RoutingInfo rinfo, java.lang.String protocolName)
          Notification that the named protocol has added a new entry to the IP forwarding table on this host.
 void routeDeletedBy(RoutingInfo rinfo, java.lang.String protocolName)
          Notification that the named protocol has removed an entry from the forwarding table on this host.
 void stop()
          Stop this OSPF session.
 
Methods inherited from class SSF.OS.ProtocolSession
close, closed, debugIdentifier, inGraph, open, pushAfterDelay, pushAfterDelayFailed, setGraph, version
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

PROTOOSPF

public static final int PROTOOSPF
See Also:
Constant Field Values

LS_REFRESH_TIME

public static final long LS_REFRESH_TIME
The maximum time between distinct originations of any particular self- originated LSA.


MIN_LS_ITVL

public static final long MIN_LS_ITVL
The minimum time between distinct originations of any particular LSA.


MIN_LS_ARRIVAL

public static final long MIN_LS_ARRIVAL
The min time that must elapse between reception of new LSA instances during flooding.


MAX_AGE

public static final int MAX_AGE
The max of age an LSA can attain.

See Also:
Constant Field Values

MAX_AGE_DIFF

public static final int MAX_AGE_DIFF
The max time dispersion that can occur, as an LSA is flooded throughout the AS.

See Also:
Constant Field Values

LS_INFINITY

public static final int LS_INFINITY
The metric value indicating that the destination described by an LSA is unreachable

See Also:
Constant Field Values

DEFAULT_DEST

public static final java.lang.String DEFAULT_DEST
The Destination ID that indicates the default route.

See Also:
Constant Field Values

INIT_SEQUENCE_NUM

public static final int INIT_SEQUENCE_NUM
The value used for LS Sequence Number when originating the first instance of any LSA.

See Also:
Constant Field Values

MAX_SEQUENCE_NUM

public static final int MAX_SEQUENCE_NUM
The maximum value that LS Sequence Number can attain.

See Also:
Constant Field Values

MTU

public static final int MTU
The Maximum Transfer Unit supported on all Interfaces.

See Also:
Constant Field Values

POINT_TO_POINT

public static final byte POINT_TO_POINT
Indicates a point-to-point connection to another router.

See Also:
Constant Field Values

TO_TRANSIT_NET

public static final byte TO_TRANSIT_NET
Indicates a connection to a transit network.

See Also:
Constant Field Values

TO_STUB_NET

public static final byte TO_STUB_NET
Indicates a connection to a stub network.

See Also:
Constant Field Values

VIRTUAL_LINK

public static final byte VIRTUAL_LINK
Indicates a Virtual link to another area border router.

See Also:
Constant Field Values

INTRA_AREA

public static final byte INTRA_AREA
Indicates a path-type of intra-area.

See Also:
Constant Field Values

INTER_AREA

public static final byte INTER_AREA
Indicates a path-type of inter-area.

See Also:
Constant Field Values

TYPE_1_EXTERNAL

public static final byte TYPE_1_EXTERNAL
Indicates a path-type of type-1-external.

See Also:
Constant Field Values

TYPE_2_EXTERNAL

public static final byte TYPE_2_EXTERNAL
Indicates a path-type of type-2-external.

See Also:
Constant Field Values

ASPF_MCAST_ADDR

public static final int ASPF_MCAST_ADDR
The int value of the multicast address for ALLSPFRouters (All Shortest Path First Routers). The real IP address is 224.0.0.5, but here we will use Integer.MAX_VALUE - 10.

See Also:
Constant Field Values

DESIG_MCAST_ADDR

public static final int DESIG_MCAST_ADDR
See Also:
Constant Field Values

topnet

public static Net topnet
A reference to the top-level Net.


rtr

public Router rtr
The local router.


nh

public java.lang.String nh
The NHI address prefix of the local router.


rtrid

public int rtrid
The identity of this router. It is chosen as the smallest of the IP of all its interfaces (in A.B.C.D/bits form).


internal_rtr

public boolean internal_rtr
Indicates if this is an internal Router.


area_border_rtr

public boolean area_border_rtr
Indicates if this is an area border router.


backbone_rtr

public boolean backbone_rtr
Indicates if this is a backbone router.


as_boundary_rtr

public boolean as_boundary_rtr
Indicates if this is an AS boundary router.


as_nh

public java.lang.String as_nh
The NHI address prefix of the AS to which this router belongs.


as_num

public int as_num
The number of the AS to which this router belongs.


areaStructs

public java.util.HashMap areaStructs
A HashMap which lists all area data structures of this OSPF router. Its keys are the numbers of the areas to which this router is attached to, the values contains the corresponding area data structures


routingTable

public HashMapRoutingTable routingTable
The OSPFv2 Routing Table of this ProtocolSession.


ipTable

public RoutingTable ipTable
The forwarding table, kept in the IP protocol session, which is the "live" table used for lookups when this router forwards packets.


debugOptions

public boolean[] debugOptions
The show options from the DML-config-file will be recorded here


dynConfKeys

public java.util.HashMap dynConfKeys
A HashMap for dynamic Configuration of this OSPF session.


agingTimer

public OSPF.AgingTimer agingTimer
A Timer aging the LSAs upon expiration


agingInterval

public long agingInterval
The duration of the AgingTimer


randomStream

public RandomStream randomStream
RandomStream to produce random values where it's needed due to RFC 2328 and to add dynamic behaviour to the protocol.


rtcControlTimer

public OSPF.RTCControlTimer rtcControlTimer
The Routing Table Calculation Control Timer. It manages shortest-path-tree calculation and OSPF/IP table updates.


spfDelay

public long spfDelay
long value specifying how long OSPF waits between receiving a topology change and starting an SPF calculation.


spfHoldTime

public long spfHoldTime
long value specifying how long OSPF waits between two consecutive SPF calculations


pacingFloodTime

public long pacingFloodTime
long value indicating the time at which LSAs in the "Neighbor.pacingFloodList" are paced in between updates.

Constructor Detail

OSPF

public OSPF()
Constructs an OSPF protocol session.

Method Detail

config

public void config(com.renesys.raceway.DML.Configuration cfg)
            throws com.renesys.raceway.DML.configException
Configure the ospf protocol parameters. Used at the start and in a run for reconfiguration purposes. Supported DML attributes are:
  ospf [
         # This parameter sets the time interval at which the link state database 
         # is aged when it is kept in memory.
         # optional! default value is: 4
         age_itvl        %I

         # The following attributes configure some ospf specific timers: 
         # delay time in seconds between topology change and spf calculation. The default value is 5.
         spf_delay         %I<1:(0...65535)
         # delay time in seconds between two consecutive spf calculations. The default value is 10.
         spf_hold_time     %I<1:(0...65535)
         # delay time in seconds(!) at which LSAs in the flooding queue are paced in between updates.
         # The default value is 0.033.
         pacing_flood_time %F<1:(0.005...0.1)

         # All show* parameters toggle certain debug output.
         # show* is optional! default value is: false
   	     # Link state database output
         show_lsdb               %S
         # Output the forwarding table
         show_fwd_table          %S
         # Output the shortest paths tree
         show_shortest_path_tree %S
         # Output information about hello packets
         show_hello_pkt  	     %S
         # Output information about database description packets
         show_dd_pkt     	     %S
         # Output information about the flooding procedure
         show_flooding   	     %S
         # Output information about area configuration
         show_area       	     %S
         # Output information about the neighbor states
         show_neighbors  	     %S # no output at the moment
         # Output information about the interface configuration
         show_interfaces  	     %S
         # Output information about the OSPF configuration
         show_config     	     %S
         # Enable all output at once
         show_all        	     %S

	     # Each OSPF router belongs to at least one area.
         area %T:.schemas.area  
       ]

Specified by:
config in interface com.renesys.raceway.DML.Configurable
Overrides:
config in class ProtocolSession
Parameters:
cfg - contains the values for configurable ospf protocol parameters
Throws:
com.renesys.raceway.DML.configException - thrown if any of the calls to findSingle and find throw such exception or if a misconfiguration is determined.

init

public void init()
          throws ProtocolException
Initialization routine called by ProtocolGraph after instantiation and when restarting the router after it has been stopped. It finishes the configuration of all areas belonging to the session if necessary, determines router ID and ospf router type and sets the aging Timer. Information that OSPF needs in the setup stage include: 1. a reference to the IP protocol 2. a reference to the router in which this OSPF sits 3. registration as FIBChangeListener to the IP Forwarding Table

Overrides:
init in class ProtocolSession
ProtocolException

opened

public void opened(ProtocolSession myIP)
Overridden. Only one IP session can confirm successfull configuration.

Overrides:
opened in class ProtocolSession

stop

public void stop()
Stop this OSPF session. That means stop all Timers, initialize all Data Structures to Down, 0, null or whatever is appropriate, and reject all arriving Packets.


getRouterID

public int getRouterID()
Return the smallest IP interface address belonging to this OSPF router.


nowsec

public double nowsec()
Returns the current simulation time in seconds.

Returns:
the current simulation time in seconds

getSimTime

public float getSimTime()
Get the current simulation time.


push

public boolean push(ProtocolMessage message,
                    ProtocolSession fromSession)
             throws ProtocolException
Description copied from class: ProtocolSession
Routine to call when a message is being sent to ("pushed into") this ProtocolSession by another ProtocolSession. The pusher sends a reference to itself in the second argument. This push happens immediately, without any simulation time elapsing, regardless of other activities taking place in the ProtocolGraph.

If you desire "safe" interaction with other CPU activities, even though your push() consumes no measurable/modelable CPU cycles, define the "cpudelay true" attribute for the ProtocolGraph and use pushAfterDelay(message,fromSession,0.0). This will guarantee proper ordering; that is, the framework will wait until the CPU is free before proceeding with the requested push().

Specified by:
push in class ProtocolSession
ProtocolException

isSelforiginated

public boolean isSelforiginated(LSA testLSA)
Check whether testLSA is an LSA which has been originated by the router itself and return true if so, else false.


floodExternalLSA

public void floodExternalLSA(LSA extLSA)
Flood an external LSA out of the router's interfaces.


calculateRT

public long calculateRT()
Recalculate the entire Routing Table. Therefore the current routing table will be replaced by a new one calculated from the LSAs currently stored in this router. All areas contribute to this recalculation by performing Dijkstra's stage 1 and 2 (see RFC 2328 chapter 16.1). While building the new Routing Table, the ip forwarding table is updated route by route.


originateSummary3LSA

public void originateSummary3LSA(NetworkEntry netEntry,
                                 java.lang.String destination)
This method is called by area-border routers only, to check whether a new summary type 3 must be originated. If so it creates, installs and floods a new summary LSA type 3 in the appropriate areas according to the parameters.

Parameters:
netEntry - NetworkEntry which causes the summary to be originated.
destination - String, representing the identifyer of the network to be announced.

originateSummary4LSA

public void originateSummary4LSA(java.lang.Integer areaID,
                                 java.lang.Integer dest,
                                 int cost,
                                 byte pathType)
This method is called by area-border routers only. It checks whether a new summary type 4 LSA must be originated. If so it creates, installs and floods a new summary LSA type 4 in the appropriate areas according to the parameters (Summary 4 LSAs are not installed or flooded into stub areas!

Parameters:
areaID - Integer Object representing the area's id from which the AS Boundary route was learned.
dest - Integer Object indicating the AS Boundary routers router id.
cost - int value indicating the cost of the route.
pathType - byte value indicating the type of the path leading to the ASBR.

buildIARoute

public long buildIARoute(LSA summaryHeader,
                         int areaID)
This method is called, if the best route to a particular inter-area destination must be recalculated. The destination is specified by the given Summary_LSA and the LSA's associated area id.

Parameters:
summaryHeader - LSA just installed discribing a new inter area route.
areaID - int value, indicating the area from which the summary was obtained.
Returns:
long value, indicating the time in clock ticks that it took to build the inter-area route. Always 0 at the moment.

removeIARoute

public long removeIARoute(LSA summaryHeader,
                          int areaID)
This method is called if a Summary LSA has/has reached MAX_AGE. In this case it must be determined, if "summaryHeader" has lead to an inter-area route. If so, the route must be deleted, otherwise nothing is done.

Parameters:
summaryHeader - Summary LSA which has MAX_AGE.
areaID - int value, indicating the area from which the summary was obtained.
Returns:
long value, indicating the time in clock ticks that it took to remove the inter-area route. Always 0 at the moment.

convertRouteID

public java.lang.String convertRouteID(java.lang.String destID)
Convert a destination id into the ip table format.

Parameters:
destID - String, representing a destination id in OSPFv2 format.
Returns:
String, representing a destination id in ip table format.

routeAddedBy

public void routeAddedBy(RoutingInfo rinfo,
                         java.lang.String protocolName)
Notification that the named protocol has added a new entry to the IP forwarding table on this host.

Specified by:
routeAddedBy in interface FIBChangeListener
Parameters:
rinfo - Information about the route added to the FIB.
protocolName - The name of the protocol that added the route.

routeDeletedBy

public void routeDeletedBy(RoutingInfo rinfo,
                           java.lang.String protocolName)
Notification that the named protocol has removed an entry from the forwarding table on this host.

Specified by:
routeDeletedBy in interface FIBChangeListener
Parameters:
rinfo - Information about the route deleted from the FIB.
protocolName - The name of the protocol that deleted the route.

printMessage

public void printMessage(java.lang.String message)
Method for printing debug Messages.


printConfiguration

public void printConfiguration()
print the router's current ospf configuration if necessary. That means if configuration has changed since last print and one of the following ospf options are set: "show_config", "show_all".


printError

public void printError(java.lang.String rise,
                       java.lang.String riseID,
                       java.lang.String errorStr)
Used by an OSPF Interface or Area to print error messages.


printConfigError

public void printConfigError(java.lang.String rise,
                             java.lang.String riseID,
                             java.lang.Exception riseEx)
Used to print error messages concerning configuration of interfaces or areas. The System will be halted immediately.

Parameters:
rise - String representing "Area" or "Interface", depending on the class where the error arised.
riseID - String representing the ip address/area id of the interface/area where the error arised.
riseEx - exception rised by the error.

printConfigError

public void printConfigError(java.lang.String struct,
                             int structID,
                             java.lang.String error)

printGeneralError

public void printGeneralError(java.lang.String occurence,
                              java.lang.Exception reason)
Used to print error messages in case of general errors. The system will be halted immediately.


printGeneralWarning

public void printGeneralWarning(java.lang.String warning)
Used to print warning messages when the system reports a general warning.