DRCL JavaSim API

drcl.inet.protocol.ospf
Class OSPF

java.lang.Object
  |
  +--drcl.DrclObj
        |
        +--drcl.comp.Component
              |
              +--drcl.net.Module
                    |
                    +--drcl.inet.Protocol
                          |
                          +--drcl.inet.protocol.Routing
                                |
                                +--drcl.inet.protocol.ospf.OSPF
All Implemented Interfaces:
java.lang.Cloneable, InetConstants, ObjectDuplicable, java.io.Serializable, UnicastRouting

public class OSPF
extends Routing
implements UnicastRouting

The package, drcl.inet.protocol.OSPF, implements the link-state routing protocol, OSPF v2, Open Shortest Path First routing protocol and follow the RFC2328. In this implementation, we refered much from OSPF code in GNU Zebra project, especially zebra 0.85. The general data structure can refer to figure 9 and section 5 RFC2328 (If not specially mentioned, the following sections, figures, and etc. can be found in RFC 2328)

Author:
Wei-peng Chen, Hung-ying Tyan
See Also:
OSPF_Area, OSPF_DBdesc, OSPF_Packet, OSPF_Interface, OSPF_LS_Database, OSPF_LSA, OSPF_LSA_Header, OSPF_LSack, OSPF_LSrequest, OSPF_LSupdate, OSPF_Neighbor, OSPF_TimeOut_EVT, Serialized Form

Inner classes inherited from class drcl.comp.Component
Component.LockPack
 
Field Summary
protected  java.util.Vector area_list
          The list of OSPF areas to which this router is attached
protected static int DATABASE
          A constant indicating a database description packet.
static boolean debug
           
static int DEBUG_ACK
          Debug level of handling LSA acknowledgement packets.
static int DEBUG_LSA
          Debug level of handling LSA update packets.
static int DEBUG_NEIGHBOR
          Debug level of neighbor state changes.
static int DEBUG_REFRESH
          Debug level of LSA refresh events.
static int DEBUG_SAMPLE
          Debug level to enable sampled debug messages.
static int DEBUG_SEND
          Debug level of sending ospf packets.
static int DEBUG_SPF
          Debug level of calculating SPF tree and installing route entries.
static int DEBUG_TIMEOUT
          Debug level of handling timeout events.
static boolean debug2
           
protected static int HELLO
          A constant indicating a hello packet.
protected static int LS_ACK
          A constant indicating a link state acknowledge packet.
protected static int LS_REQUEST
          A constant indicating a link state request packet.
protected static int LS_UPDATE
          A constant indicating a link state update packet.
protected  java.util.Vector ospf_if_list
          The list of OSPF Interfaces to which this router is attached
protected  int router_id
          OSPF router ID of this node
 
Fields inherited from class drcl.inet.protocol.Routing
queryPort, rtconfigPort
 
Fields inherited from class drcl.net.Module
address, downPort, PortGroup_DOWN, PortGroup_UP, timerPort, upPort
 
Fields inherited from class drcl.comp.Component
FLAG_COMPONENT_NOTIFICATION, FLAG_DEBUG_ENABLED, FLAG_DIRECT_OUTPUT_ENABLED, FLAG_ENABLED, FLAG_ERROR_ENABLED, FLAG_EVENT_ENABLED, FLAG_GARBAGE_DISPLAY_ENABLED, FLAG_GARBAGE_ENABLED, FLAG_PORT_NOTIFICATION, FLAG_STARTED, FLAG_STOPPED, FLAG_TRACE_ENABLED, FLAG_UNDEFINED_START, id, infoPort, lockHead, name, parent, PortGroup_DEFAULT_GROUP, PortGroup_EVENT, PortGroup_SERVICE, Root, Trace_DATA, Trace_SEND
 
Fields inherited from interface drcl.inet.InetConstants
BYTE_MODE, DEFAULT_BANDWIDTH, DEFAULT_BUFFER_SIZE, DEFAULT_MTU, EVENT_ID_CHANGED_PORT_ID, EVENT_IDENTITY_ADDED, EVENT_IDENTITY_REMOVED, EVENT_IF_NEIGHBOR_DOWN, EVENT_IF_NEIGHBOR_UP, EVENT_IF_PORT_ID, EVENT_MCAST_HOST_PORT_ID, EVENT_PKT_ARRIVAL, EVENT_PKT_ARRIVAL_PORT_ID, EVENT_RT_ENTRY_ADDED, EVENT_RT_ENTRY_MODIFIED, EVENT_RT_ENTRY_REMOVED, EVENT_RT_MCAST_CHANGED_PORT_ID, EVENT_RT_UCAST_CHANGED_PORT_ID, EVENT_VIF_NEIGHBOR_DOWN, EVENT_VIF_NEIGHBOR_UP, EVENT_VIF_PORT_ID, HOST_ENTRY_EXT, ID_CSL, MCAST_QUERY_PORT_ID, PACKET_MODE, PID_DV, PID_DVMRP, PID_HELLO, PID_IGMP, PID_OSPF, PID_RSVP, PID_TCP, PID_UDP, SERVICE_CONFIGSW_PORT_ID, SERVICE_ID_PORT_ID, SERVICE_IF_PORT_ID, SERVICE_MCAST_PORT_ID, SERVICE_RT_PORT_ID, UCAST_QUERY_PORT_ID
 
Constructor Summary
OSPF()
          Constructor.
 
Method Summary
 void dataArriveAtDownPort(java.lang.Object data_, Port downPort_)
          Handle data arriving at the down port.
protected  void delayed_acknowledge(OSPF_LSA lsa)
          Delayed acknowledgement Include multiple acks in one packet.
protected  void direct_acknowledge(OSPF_LSA lsa, OSPF_Interface oif, int now_, boolean clone_)
          Direct acknowledgement
 void duplicate(java.lang.Object source_)
          Duplicates the content of source_, including ID, name, child components and connections among them, to this component.
 java.lang.String[] getDebugLevelNames()
          Returns the names of defined debug levels; subclasses should override this method if debug levels are defined.
 java.lang.String getName()
          Returns the (informational) name of the component.
protected  int inactivity_timer(OSPF_Neighbor nbr)
           
 java.lang.String info()
          Returns information regarding this component.
protected  void lsa_receive(OSPF_LSA lsa, OSPF_Neighbor from)
          Process every LSA received in LS update packet.
protected  void neighborDownEventHandler(int ifindex_, NetAddress neighbor_, Port inPort_)
          Called back when a neighbor down event is received.
protected  void neighborUpEventHandler(int ifindex_, NetAddress neighbor_, Port inPort_)
          Called back when a neighbor up event is received.
protected  void ospf_area_rt_install(OSPF_Area area)
          Install area's vertex_list to routing table
protected  void ospf_dbdesc_seqnum_init(OSPF_Neighbor nbr)
           
protected  OSPF_Interface ospf_if_lookup_by_addr(long addr)
           
protected  void ospf_lsa_flood(OSPF_LSA lsa)
          flood ospf_lsa within appropriate scope
protected  void ospf_lsa_flood(OSPF_LSA lsa, int scope_type)
          flood ospf_lsa within appropriate scope
protected  void ospf_lsdb_install(OSPF_LSA new_lsa, OSPF_Area area)
          When installing more recent LSA, must detach less recent database copy from LS-lists of neighbors, and attach new one.
protected  void ospf_lsdb_install(OSPF_LSA new_lsa, OSPF_LSA old_lsa)
           
protected  void ospf_lsdb_install(OSPF_LSA new_lsa, OSPF_LSA old_lsa, int scope_type)
          Install a new LSA into the database
protected  void ospf_lsdb_install(OSPF_LSA new_lsa, OSPF_LSA old_lsa, OSPF_Area area)
          Replaces old_lsa with new_lsa and removes old_lsa from the retranslists in area.
protected  OSPF_LSA ospf_lsdb_lookup(int type, int id, int advrtr, java.lang.Object scope)
          ordinary lookup function
protected  void ospf_message_broadcast(int type, java.lang.Object body, int body_size, OSPF_Interface oif)
          Send the packet to every neighbor connected to this interfac.
protected  void ospf_message_send(int type, java.lang.Object body, int body_size, long dst, OSPF_Interface oif)
          send the pkt to specific neighbor on specific if
protected  void ospf_possible_ack(OSPF_LSA received, int ismore_recent, OSPF_Interface oif, int impliedack_flag, int duplicate_flag, int now_)
          Possible ack action mentioned in sec 13 (5)(e) and (7)(b)
protected  void ospf_route_add(long dst, OSPF_SPF_vertex new_en, OSPF_Area area, int now_)
          Add a routing entry into RoutingTable and synchronize with drcl.inet.core.RT
protected  void ospf_router_lsa_flood(OSPF_Area area, boolean check_)
           
protected  int ospf_send_dbdesc(OSPF_Neighbor nbr)
          Send the database description to the peer ref: 10.8
protected  int ospf_send_hello(OSPF_Interface oif)
          ospf_send_hello hello pkts are sent out each functing interface *** not used, we use drcl.inet.core.Hello as underlying Hello service provider ref: sec.
protected  int ospf_send_lsreq(OSPF_Neighbor nbr)
          Send the LS request pkt to its peer ref: sec.
protected  int ospf_send_single_hello(OSPF_Interface oif, long dst)
          used when receiving EVENT_IF_NEIGHBOR_UP, send only one hello packet to ensure two-way connection
 void ospf_set_area_id(int id_)
          xxx: Specify the area id for this router (Needed to be modified)
protected  void process(java.lang.Object data_, Port inPort_)
          This method classifies inPort_ and delegates process of data to the appropriate handler.
 void reset()
          Resets the component for being used anew.
protected  void timeout(java.lang.Object evt_)
          Handling timeout event.
protected  void transit_vertex_rtable_install(OSPF_SPF_vertex v, OSPF_Area area, int now_)
          Hold the intermediate results on area routing table Install a new entry into routing table
 
Methods inherited from class drcl.inet.protocol.Routing
addRTEntry, addRTEntry, addRTEntry, addRTEntry, addRTEntry, addRTEntry, addRTEntry, graftRTEntry, graftRTEntry, graftRTEntry, pruneRTEntry, pruneRTEntry, pruneRTEntry, removeAllRTEntries, removeRTEntry, removeRTEntry, replaceRTEntry, replaceRTEntry, retrieveAllRTEntries, retrieveRTEntry, retrieveRTEntryDest, retrieveRTEntrySrc
 
Methods inherited from class drcl.inet.Protocol
broadcast, broadcast, broadcast, broadcast, broadcast, broadcast, createConfigSwitchPort, createIDChangedEventPort, createIDServicePort, createIFEventPort, createIFQueryPort, createMcastHostEventPort, createMcastQueryPort, createMulticastRTChangedEventPort, createPktArrivalEventPort, createRTServicePort, createUcastQueryPort, createUnicastRTChangedEventPort, createVIFEventPort, forward, forward, forward, forward, forward, forward, idAddedEventHandler, idRemovedEventHandler, mcastHostJoinEventHandler, mcastHostLeaveEventHandler, mcastQueryHandler, pktArrivalHandler, processOther, rtAddedEventHandler, rtModifiedEventHandler, rtRemovedEventHandler, ucastQueryHandler, vNeighborDownEventHandler, vNeighborUpEventHandler
 
Methods inherited from class drcl.net.Module
cancelTimeout, dataArriveAtUpPort, deliver, getAddress, removeDefaultDownPort, removeDefaultUpPort, removeTimerPort, setAddress, setTimeout, setTimeoutAt
 
Methods inherited from class drcl.comp.Component
_resume, _start, _stop, addComponent, addComponent, addEventPort, addEventPort, addForkPort, addPort, addPort, addPort, addPort, addPort, addPort, addPort, addPort, addServerPort, addServerPort, cancelFork, componentAdded, componentRemoved, connect, containsComponent, containsComponent, containsPort, debug, disconnectAll, disconnectAllPeers, disconnectAllPorts, drop, drop, error, error, expose, exposeEventPorts, exposePort, exposePort, exposePort, exposePort, exposePort, findAvailable, findAvailable, findAvailable, finishing, fork, forkAt, getAllComponents, getAllPorts, getAllPorts, getAllWiresInside, getAllWiresInsideOut, getAllWiresOut, getComponent, getComponentFlag, getComponentFlag, getContract, getContractHT, getContractHT, getDebugFlagsInBinary, getForkManager, getID, getParent, getPort, getPort, getRoot, getRuntime, getTime, iduplicate, isAncestorOf, isComponentNotificationEnabled, isContainer, isDebugEnabled, isDebugEnabledAt, isDirectOutputEnabled, isEnabled, isErrorNoticeEnabled, isEventExportEnabled, isGarbageDisplayEnabled, isGarbageEnabled, isPortNotificationEnabled, isPortRemovable, isStarted, isStopped, isTraceEnabled, lock, notify, notifyAll, operate, portAdded, portRemoved, reboot, removeAll, removeAllComponents, removeAllPorts, removeAllPorts, removeComponent, removeComponent, removePort, removePort, removePort, resume, run, sduplicate, send, sendAt, setComponentFlag, setComponentFlag, setComponentNotificationEnabled, setContract, setDebugEnabled, setDebugEnabled, setDebugEnabledAt, setDebugEnabledAt, setDebugEnabledAt, setDirectOutputEnabled, setDirectOutputEnabled, setEnabled, setErrorNoticeEnabled, setErrorNoticeEnabled, setEventExportEnabled, setEventExportEnabled, setExecutionBoundary, setGarbageDisplayEnabled, setGarbageDisplayEnabled, setGarbageEnabled, setGarbageEnabled, setID, setID, setName, setPort, setPort, setPortNotificationEnabled, setPortRemovable, setRuntime, setTraceEnabled, setTraceEnabled, sleepFor, sleepUntil, stop, toString, unexpose, unlock, useLocalForkManager, useLocalForkManager, wait
 
Methods inherited from class drcl.DrclObj
clone
 
Methods inherited from class java.lang.Object
equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

debug

public static boolean debug

debug2

public static boolean debug2

HELLO

protected static final int HELLO
A constant indicating a hello packet.

DATABASE

protected static final int DATABASE
A constant indicating a database description packet.

LS_REQUEST

protected static final int LS_REQUEST
A constant indicating a link state request packet.

LS_UPDATE

protected static final int LS_UPDATE
A constant indicating a link state update packet.

LS_ACK

protected static final int LS_ACK
A constant indicating a link state acknowledge packet.

router_id

protected int router_id
OSPF router ID of this node

area_list

protected java.util.Vector area_list
The list of OSPF areas to which this router is attached

ospf_if_list

protected java.util.Vector ospf_if_list
The list of OSPF Interfaces to which this router is attached

DEBUG_SAMPLE

public static final int DEBUG_SAMPLE
Debug level to enable sampled debug messages.

DEBUG_NEIGHBOR

public static final int DEBUG_NEIGHBOR
Debug level of neighbor state changes.

DEBUG_SEND

public static final int DEBUG_SEND
Debug level of sending ospf packets.

DEBUG_SPF

public static final int DEBUG_SPF
Debug level of calculating SPF tree and installing route entries.

DEBUG_REFRESH

public static final int DEBUG_REFRESH
Debug level of LSA refresh events.

DEBUG_LSA

public static final int DEBUG_LSA
Debug level of handling LSA update packets.

DEBUG_ACK

public static final int DEBUG_ACK
Debug level of handling LSA acknowledgement packets.

DEBUG_TIMEOUT

public static final int DEBUG_TIMEOUT
Debug level of handling timeout events.
Constructor Detail

OSPF

public OSPF()
Constructor.
Method Detail

getName

public java.lang.String getName()
Description copied from class: Component
Returns the (informational) name of the component.
Overrides:
getName in class Component

getDebugLevelNames

public java.lang.String[] getDebugLevelNames()
Description copied from class: Component
Returns the names of defined debug levels; subclasses should override this method if debug levels are defined.
Overrides:
getDebugLevelNames in class Component

info

public java.lang.String info()
Description copied from class: Component
Returns information regarding this component. Subclasses should override this method to provide useful information at run-time.
Overrides:
info in class Component

reset

public void reset()
Description copied from class: Component
Resets the component for being used anew. All the internal variables must be set to the initial state. All the ports and child components are reset as well.
Overrides:
reset in class Component

duplicate

public void duplicate(java.lang.Object source_)
Description copied from class: Component
Duplicates the content of source_, including ID, name, child components and connections among them, to this component. Subclasses need to override this method to copy its own variables.
Overrides:
duplicate in class Protocol

timeout

protected void timeout(java.lang.Object evt_)
Handling timeout event. According to the timeout event which can be obtained from evt_, there are different handling functions.
Overrides:
timeout in class Module
Parameters:
evt_ - event object got from the timer port

process

protected void process(java.lang.Object data_,
                       Port inPort_)
Description copied from class: Module
This method classifies inPort_ and delegates process of data to the appropriate handler. If a subclass decides to override this method, then it should call super.process(data_, inPort_) to make those handlers effective.
Overrides:
process in class Module
Following copied from class: drcl.net.Module
See Also:
Module.dataArriveAtUpPort(Object, drcl.comp.Port), Module.dataArriveAtDownPort(Object, drcl.comp.Port), Module.processOther(Object, drcl.comp.Port)

dataArriveAtDownPort

public void dataArriveAtDownPort(java.lang.Object data_,
                                 Port downPort_)
Handle data arriving at the down port. According to the different packet types ( OSPF Hello pkt, Database descricption pkt,Link State update pkt, LS request pkt, or LS ack pkt), different corresponding methods can handle the packet. Note for OSPF_Hello pkt will be received only once. The other hello maintaince is done by drcl.inet.core.Hello
Overrides:
dataArriveAtDownPort in class Module
Parameters:
date_ - message body arriving at the down port.
downPort_ - down port at which messages arrive.

neighborUpEventHandler

protected void neighborUpEventHandler(int ifindex_,
                                      NetAddress neighbor_,
                                      Port inPort_)
Called back when a neighbor up event is received. Create a OSPF_Neighbor data associated with OSPF_Interface data in this router.
Overrides:
neighborUpEventHandler in class Protocol
Parameters:
ifindex_ - index of the interface.
See Also:
Hello

neighborDownEventHandler

protected void neighborDownEventHandler(int ifindex_,
                                        NetAddress neighbor_,
                                        Port inPort_)
Description copied from class: Protocol
Called back when a neighbor down event is received.
Overrides:
neighborDownEventHandler in class Protocol
Following copied from class: drcl.inet.Protocol
Parameters:
ifindex_ - index of the interface.
See Also:
Protocol.createIFEventPort()

inactivity_timer

protected int inactivity_timer(OSPF_Neighbor nbr)

lsa_receive

protected void lsa_receive(OSPF_LSA lsa,
                           OSPF_Neighbor from)
Process every LSA received in LS update packet. Maintain the Link State database stored in the router. Compare the existing LS in the database to the received one. Update the database if the received is more updated. Broadcast to its neighbor if necessary. Finally ack the LS to its originator. ref: section 13

direct_acknowledge

protected void direct_acknowledge(OSPF_LSA lsa,
                                  OSPF_Interface oif,
                                  int now_,
                                  boolean clone_)
Direct acknowledgement

delayed_acknowledge

protected void delayed_acknowledge(OSPF_LSA lsa)
Delayed acknowledgement Include multiple acks in one packet. Hold these acks until the timer timeout. ref: sec. 13.5

ospf_possible_ack

protected void ospf_possible_ack(OSPF_LSA received,
                                 int ismore_recent,
                                 OSPF_Interface oif,
                                 int impliedack_flag,
                                 int duplicate_flag,
                                 int now_)
Possible ack action mentioned in sec 13 (5)(e) and (7)(b)

ospf_message_send

protected void ospf_message_send(int type,
                                 java.lang.Object body,
                                 int body_size,
                                 long dst,
                                 OSPF_Interface oif)
send the pkt to specific neighbor on specific if

ospf_message_broadcast

protected void ospf_message_broadcast(int type,
                                      java.lang.Object body,
                                      int body_size,
                                      OSPF_Interface oif)
Send the packet to every neighbor connected to this interfac. For sending packets downward, we call the forward(), defined in Protocol.java void forward(PacketBody p_, long src_, long dest_, int dest_ulp_, boolean routerAlert_, int TTL, int ToS, int link_id) route-lookup forwarding routerAlert is set to be true, in which the packet is sent in only one hop. In this case, whatever dst is irrevelent

ospf_send_hello

protected int ospf_send_hello(OSPF_Interface oif)
ospf_send_hello hello pkts are sent out each functing interface *** not used, we use drcl.inet.core.Hello as underlying Hello service provider ref: sec. 9.5

ospf_send_single_hello

protected int ospf_send_single_hello(OSPF_Interface oif,
                                     long dst)
used when receiving EVENT_IF_NEIGHBOR_UP, send only one hello packet to ensure two-way connection

ospf_send_dbdesc

protected int ospf_send_dbdesc(OSPF_Neighbor nbr)
Send the database description to the peer ref: 10.8

ospf_send_lsreq

protected int ospf_send_lsreq(OSPF_Neighbor nbr)
Send the LS request pkt to its peer ref: sec. 10.9

ospf_router_lsa_flood

protected void ospf_router_lsa_flood(OSPF_Area area,
                                     boolean check_)

ospf_lsa_flood

protected void ospf_lsa_flood(OSPF_LSA lsa)
flood ospf_lsa within appropriate scope

ospf_lsa_flood

protected void ospf_lsa_flood(OSPF_LSA lsa,
                              int scope_type)
flood ospf_lsa within appropriate scope

ospf_lsdb_lookup

protected OSPF_LSA ospf_lsdb_lookup(int type,
                                    int id,
                                    int advrtr,
                                    java.lang.Object scope)
ordinary lookup function

ospf_lsdb_install

protected void ospf_lsdb_install(OSPF_LSA new_lsa,
                                 OSPF_Area area)
When installing more recent LSA, must detach less recent database copy from LS-lists of neighbors, and attach new one. ref. sec 13.2

ospf_lsdb_install

protected void ospf_lsdb_install(OSPF_LSA new_lsa,
                                 OSPF_LSA old_lsa,
                                 OSPF_Area area)
Replaces old_lsa with new_lsa and removes old_lsa from the retranslists in area. Recalculates SPF if necessary (see 13.2).

ospf_lsdb_install

protected void ospf_lsdb_install(OSPF_LSA new_lsa,
                                 OSPF_LSA old_lsa)

ospf_lsdb_install

protected void ospf_lsdb_install(OSPF_LSA new_lsa,
                                 OSPF_LSA old_lsa,
                                 int scope_type)
Install a new LSA into the database

ospf_if_lookup_by_addr

protected OSPF_Interface ospf_if_lookup_by_addr(long addr)

ospf_set_area_id

public void ospf_set_area_id(int id_)
xxx: Specify the area id for this router (Needed to be modified)

ospf_dbdesc_seqnum_init

protected void ospf_dbdesc_seqnum_init(OSPF_Neighbor nbr)

ospf_area_rt_install

protected void ospf_area_rt_install(OSPF_Area area)
Install area's vertex_list to routing table

transit_vertex_rtable_install

protected void transit_vertex_rtable_install(OSPF_SPF_vertex v,
                                             OSPF_Area area,
                                             int now_)
Hold the intermediate results on area routing table Install a new entry into routing table

ospf_route_add

protected void ospf_route_add(long dst,
                              OSPF_SPF_vertex new_en,
                              OSPF_Area area,
                              int now_)
Add a routing entry into RoutingTable and synchronize with drcl.inet.core.RT

DRCL JavaSim API

Copyright © 2001 - DRCL, OSU     ~ Back to JavaSim Home ~