SSF.OS.OSPFv2
Class Neighbor

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

public class Neighbor
extends java.lang.Object

The class Neighbor represents a conversation between its interface owner and the neighboring interface. All Information to build and maintain this conversation is represented in it. It is identified either by the neighboring router's OSPF Router ID or by its Neighbor ip address.


Nested Class Summary
 class Neighbor.FloodingTimer
          /* A multiple shot Timer for flooding LSAs in LS Update Packets.
 class Neighbor.InactivityTimer
          /* The Inactivity Timer for this Neighbor class.
 class Neighbor.LastRecDDPacket
          A class in which the important information of the last received DD packet are recorded.
 class Neighbor.RetransmissionTimer
          /* The Retransmission Timer for this Neighbor class.
 
Field Summary
static int ATTEMPT
          Indicates that the current state of neighbor conversation is ATTEMPT
 DD_Packet dataDescContent
          A Database Description Packet.
 java.util.Vector dbSummList
          The complete list of LSAs that make up the area link-state database, at the moment the neighbor goes into Database Exchange state (EXCHANGE).
 int DDSeqNum
          The DD Sequence Number of the DD packet that is currently being sent to the neighbor
 Neighbor.InactivityTimer deadTimer
          Single shot timer whose firing indicates that no Hello Packet has been seen from this Neighbor recently.
static int DOWN
          Indicates that the current state of neighbor conversation is DOWN
static int EXCHANGE
          Indicates that the current state of neighbor conversation is EXCHANGE
static int EXSTART
          Indicates that the current state of neighbor conversation is EXSTART
 Neighbor.FloodingTimer floodTimer
          Multiple shot timer whose firing indicates that LSAs should be reflooded.
static int FULL
          Indicates that the current state of neighbor conversation is FULL
static int INIT
          Indicates that the current state of neighbor conversation is INIT
 boolean isMaster
          To know who is master in the master/slave relationship during Database Exchage.
 Neighbor.LastRecDDPacket lastDDPacket
          Another data structure for keeping information of the last received DD packet.
static int LOADING
          Indicates that the current state of neighbor conversation is LOADING
 LS_RequestPacket lsReqContent
          A Link State Request Packet.
 java.util.Hashtable lsReqList
          The list of LSAs that need to be received from this neighbor in order to synchronize the two neighbor's link-state database.
 java.util.HashMap lsRetransList
          The list of LSAs that have been flooded but not yet acknowledged on this adjacency.
 int neighborBDR
          The neighbor's IDEA of the backup designated router.
 int neighborDR
          The neighbor's IDEA of the designated router.
 int neighborID
          The router ID of the Neighbor Router.
 int neighborIPAddr
          The IP address of the neighboring router's interface to the attached network.
 java.lang.String neighborNHI
          The NHI address prefix of the neighboring router.
 int neighborPrio
          The Router priority of the neighboring router.
 boolean[] options
          The optional OSPF capabilities supported by the neighbor.
 java.util.HashMap pacingFloodList
          The list of LSAs that must be flooded out to this neighbor when the pacingTimer fires.
 Neighbor.RetransmissionTimer retransTimer
          Multiple shot timer whose firing indicates that a Database Description or Request Packet should be retransmitted.
 int state
          The functional level of the neighbor conversation
static int TWOWAY
          Indicates that the current state of neighbor conversation is 2-WAY
 
Constructor Summary
Neighbor(OSPF myOSPF, AreaData myArea, Interface myInterface, int ipaddr)
          Constructs an Neighbor.
 
Method Summary
 void adjOk()
          A decision must be made as to whether an adjacency should be established/maintained with the neighbor.
 void badLSReq()
          Called if a LS Request has been received for an LSA not contained in the database.
 void directAcknowledge(LSA ackLSA)
          Send a direct Acknowledgment for a particular LSA to the Neighbor.
 void exchange(Packet dataDescPkt)
          called if state is EXCHANGE.
 void exchangeDone()
          At this point, the router has sent and received an entire sequence of Database Description Packets.
 java.util.Vector fillAndSendUpdate(java.util.Vector requests)
          Fill an LS Update Packet with requested LSAs and send it to the Neighbor.
 void fillDDPacketWithHeaders()
          fill the global DD Packet dataDescContent with as many headers from the database summary list as possible.
 void fillRequestPacket()
          fill the global LS Request Packet lsReqContent with the keys of as many LSAs from the link state request list as possible.
 java.lang.String getStrFromState(int status)
          Converts the integer value of state in a more readable format.
 boolean hasKnownLSType(LSA testLSA)
          Check whether testLSA has a known LS Type and return true if so, otherwise false.
 void initDBExchange()
          initializes the Database Exchange between two Neighbors
 void loadingDone()
          Link State Updates have been received for all out-of-date portions of the database.
 void negotiation(Packet dataDescPkt)
          called when a DD Packet is received while state was EXSTART, or state turned to EXSTART.
 void negotiationDone(boolean neighborIsMaster, java.util.Vector payload)
          At this point Master/Slave relationship is definitly established.
 void oneWayHelloRec(Packet helloPkt, int sourceIP)
          Have seen a Neighbor, but the Neighbor doesn't know about me
 void processFloodedUpdate(Packet lsUpdPkt)
          LS Update Packet has been received while state was FULL.
 void processLSAck(Packet lsAckPkt)
          When an LS Ack Packet was received, this method is called by the Interface which is adjacent to this Neighbor.
 void processLSAs(java.util.Vector ddPayload)
          Process the LSA Headers received in the last received Database Description Packet.
 void processLSRequest(Packet lsReqPkt)
          examine the requested LSAs, locate them in the database and send them in LS Update Packets to the Neighbor.
 void processLSUpdate(Packet lsUpdPkt)
          LS Update Packet has been received while state was EXCHANGE or LOADING.
 boolean processReceivedLSA(LSA recLSA)
          This method is called by either "processLSUpdate" or "processFloodedUpdate".
protected  void removeRequest(java.lang.String removeKey)
          Remove a key from the LS Request List.
 void reset()
          reset the Neighbor Data Structure to the initial values.
 void sendPacket(ProtocolMessage content)
          Sends an OSPF Packet (database description or ls request) to the Neighbor this Structure was built for.
 void seqNumMismatch(java.lang.String reason)
          Actions to be performed, if the received DD Packet has a) an unexpected DD sequence number or b) unexpectedly the Initialize bit set or c) an Options field differing from the last Options field received.
 boolean startFlooding()
          The Interface's pacingTimer schedules the first flooding of an LSA.
 void subseqTreatment(Packet dataDescPkt)
          called by the Interface Data Structure if a DD Packet was received and the relationship with the neighbor is in state LOADING or FULL.
 void twoWayHelloRec(Packet helloPkt, int sourceIP)
          Determine whether an adjacency should be established with the neighbor
 void twoWayReceived(Packet dataDescPkt)
          called when a DD Packet is received while state was INIT.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

DOWN

public static final int DOWN
Indicates that the current state of neighbor conversation is DOWN

See Also:
Constant Field Values

ATTEMPT

public static final int ATTEMPT
Indicates that the current state of neighbor conversation is ATTEMPT

See Also:
Constant Field Values

INIT

public static final int INIT
Indicates that the current state of neighbor conversation is INIT

See Also:
Constant Field Values

TWOWAY

public static final int TWOWAY
Indicates that the current state of neighbor conversation is 2-WAY

See Also:
Constant Field Values

EXSTART

public static final int EXSTART
Indicates that the current state of neighbor conversation is EXSTART

See Also:
Constant Field Values

EXCHANGE

public static final int EXCHANGE
Indicates that the current state of neighbor conversation is EXCHANGE

See Also:
Constant Field Values

LOADING

public static final int LOADING
Indicates that the current state of neighbor conversation is LOADING

See Also:
Constant Field Values

FULL

public static final int FULL
Indicates that the current state of neighbor conversation is FULL

See Also:
Constant Field Values

state

public int state
The functional level of the neighbor conversation


isMaster

public boolean isMaster
To know who is master in the master/slave relationship during Database Exchage. false means neighbor is slave, true means neighbor is master.


DDSeqNum

public int DDSeqNum
The DD Sequence Number of the DD packet that is currently being sent to the neighbor


lastDDPacket

public Neighbor.LastRecDDPacket lastDDPacket
Another data structure for keeping information of the last received DD packet.


neighborPrio

public int neighborPrio
The Router priority of the neighboring router.


neighborID

public int neighborID
The router ID of the Neighbor Router.


neighborNHI

public java.lang.String neighborNHI
The NHI address prefix of the neighboring router.


neighborIPAddr

public int neighborIPAddr
The IP address of the neighboring router's interface to the attached network.


options

public boolean[] options
The optional OSPF capabilities supported by the neighbor.


neighborDR

public int neighborDR
The neighbor's IDEA of the designated router.


neighborBDR

public int neighborBDR
The neighbor's IDEA of the backup designated router.


lsRetransList

public java.util.HashMap lsRetransList
The list of LSAs that have been flooded but not yet acknowledged on this adjacency. It is implemented as HashMap because it should be easy to replace old instances of LSAs by new ones.


dbSummList

public java.util.Vector dbSummList
The complete list of LSAs that make up the area link-state database, at the moment the neighbor goes into Database Exchange state (EXCHANGE). It is implemented as Vector because all LSAs stored in it are unique at every time.


lsReqList

public java.util.Hashtable lsReqList
The list of LSAs that need to be received from this neighbor in order to synchronize the two neighbor's link-state database.


pacingFloodList

public java.util.HashMap pacingFloodList
The list of LSAs that must be flooded out to this neighbor when the pacingTimer fires. When this happened they are transferred to the lsRetransList.


dataDescContent

public DD_Packet dataDescContent
A Database Description Packet. Used, to exchange LS Database informations with the Neighbor when both became adjacent. It saves the last sent DD Packet.


lsReqContent

public LS_RequestPacket lsReqContent
A Link State Request Packet. Used to request more recent LSAs from the Neighbor when state is EXCHANGE, LOADING or FULL. It saves the last sent LS Request Packet.


deadTimer

public Neighbor.InactivityTimer deadTimer
Single shot timer whose firing indicates that no Hello Packet has been seen from this Neighbor recently.


retransTimer

public Neighbor.RetransmissionTimer retransTimer
Multiple shot timer whose firing indicates that a Database Description or Request Packet should be retransmitted.


floodTimer

public Neighbor.FloodingTimer floodTimer
Multiple shot timer whose firing indicates that LSAs should be reflooded.

Constructor Detail

Neighbor

public Neighbor(OSPF myOSPF,
                AreaData myArea,
                Interface myInterface,
                int ipaddr)
Constructs an Neighbor.

Method Detail

reset

public void reset()
reset the Neighbor Data Structure to the initial values. This is part of the stop process of the OSPF Session.


oneWayHelloRec

public void oneWayHelloRec(Packet helloPkt,
                           int sourceIP)
Have seen a Neighbor, but the Neighbor doesn't know about me


twoWayHelloRec

public void twoWayHelloRec(Packet helloPkt,
                           int sourceIP)
Determine whether an adjacency should be established with the neighbor


twoWayReceived

public void twoWayReceived(Packet dataDescPkt)
called when a DD Packet is received while state was INIT.


negotiation

public void negotiation(Packet dataDescPkt)
called when a DD Packet is received while state was EXSTART, or state turned to EXSTART.


negotiationDone

public void negotiationDone(boolean neighborIsMaster,
                            java.util.Vector payload)
At this point Master/Slave relationship is definitly established. DD sequence numbers have been exchanged. This is the begin of sending/receiving of DD Packets.


processLSAs

public void processLSAs(java.util.Vector ddPayload)
Process the LSA Headers received in the last received Database Description Packet.

Parameters:
ddPayload - A Vector holding the LSA Headers to process.

fillDDPacketWithHeaders

public void fillDDPacketWithHeaders()
fill the global DD Packet dataDescContent with as many headers from the database summary list as possible. Remove every header filled in the Packet from the list. The amount of headers in the DD Packet is restricted by the OSPF MTU value.


seqNumMismatch

public void seqNumMismatch(java.lang.String reason)
Actions to be performed, if the received DD Packet has a) an unexpected DD sequence number or b) unexpectedly the Initialize bit set or c) an Options field differing from the last Options field received.


badLSReq

public void badLSReq()
Called if a LS Request has been received for an LSA not contained in the database. This indicates an error in the Database Exchange process. Actions to be performed are the same as in seqNumMismatch. In addition, stop the possibly activated retrans- mission timer.


exchange

public void exchange(Packet dataDescPkt)
called if state is EXCHANGE. This method is executed every time a DD Packets arrives sent by the Neighbor. When the last Packet arrives, it transfers the state into LOADING or FULL


exchangeDone

public void exchangeDone()
At this point, the router has sent and received an entire sequence of Database Description Packets. Now it must be determined whether the new state is FULL, or Link State Request Packets have to be send.


subseqTreatment

public void subseqTreatment(Packet dataDescPkt)
called by the Interface Data Structure if a DD Packet was received and the relationship with the neighbor is in state LOADING or FULL. The only DD Packets received should be duplicates.


adjOk

public void adjOk()
A decision must be made as to whether an adjacency should be established/maintained with the neighbor.


fillRequestPacket

public void fillRequestPacket()
fill the global LS Request Packet lsReqContent with the keys of as many LSAs from the link state request list as possible. The amount of keys in the LS Request Packet is restricted by the OSPF MTU value.


fillAndSendUpdate

public java.util.Vector fillAndSendUpdate(java.util.Vector requests)
                                   throws ProtocolException
Fill an LS Update Packet with requested LSAs and send it to the Neighbor. If there are more LSAs requested than could sent by a single LS Update Packet, return the rest of the requests to handle in a Vector. Else return an empty Vector.

ProtocolException

processLSRequest

public void processLSRequest(Packet lsReqPkt)
examine the requested LSAs, locate them in the database and send them in LS Update Packets to the Neighbor.


processLSUpdate

public void processLSUpdate(Packet lsUpdPkt)
LS Update Packet has been received while state was EXCHANGE or LOADING. Examine the received LSAs, check whether they were requested or not and process them accordingly. Therefore use method "processReceivedLSA" for further treatment.

Parameters:
lsUpdPkt - an LS Update Packet received while Neighbor state was EXCHANGE or LOADING.

removeRequest

protected void removeRequest(java.lang.String removeKey)
Remove a key from the LS Request List. If there is an LS Request Packet ready to send or the Packet is waiting for updates it requested and it holds this key, then remove it from the packets content too.

Parameters:
removeKey - A String representing the key which shall be removed.

processReceivedLSA

public boolean processReceivedLSA(LSA recLSA)
                           throws ProtocolException
This method is called by either "processLSUpdate" or "processFloodedUpdate". It gets recLSA from a received LS Update Packet and processes it as decribed in chapter 13 on page 143-146 in RFC 2328. The method returns "true" if recLSA should be removed from the LS Retransmission List in the case it has been placed there before, otherwise "false".

Parameters:
recLSA - LSA which was received in an LS Update Packet.
Returns:
boolean indicating whether recLSA should be removed from LS Retransmission List or not.
Throws:
ProtocolException - thrown if a Bad LS Request is triggered.

startFlooding

public boolean startFlooding()
The Interface's pacingTimer schedules the first flooding of an LSA. This method groups together these LSAs and sends out one LS Update Packet. If there are more LSAs that must be flooded out than fitting in a single packet, it returns true otherwise false.

Returns:
boolean value indicating wether the pacingTimer must be started again due to LSAs left for flooding out, or not.

hasKnownLSType

public boolean hasKnownLSType(LSA testLSA)
Check whether testLSA has a known LS Type and return true if so, otherwise false. Known LS Types are: Router-LSA, Network-LSA, Summary-Network-LSA, Summary-ASBR-LSA and AS-External-LSA.


processFloodedUpdate

public void processFloodedUpdate(Packet lsUpdPkt)
LS Update Packet has been received while state was FULL.


loadingDone

public void loadingDone()
Link State Updates have been received for all out-of-date portions of the database.


sendPacket

public void sendPacket(ProtocolMessage content)
Sends an OSPF Packet (database description or ls request) to the Neighbor this Structure was built for. This method only send the Packet! The parameter content must be set appropriately before.


initDBExchange

public void initDBExchange()
initializes the Database Exchange between two Neighbors


getStrFromState

public java.lang.String getStrFromState(int status)
Converts the integer value of state in a more readable format. This is only used for debuging purposes.


directAcknowledge

public void directAcknowledge(LSA ackLSA)
Send a direct Acknowledgment for a particular LSA to the Neighbor.


processLSAck

public void processLSAck(Packet lsAckPkt)
When an LS Ack Packet was received, this method is called by the Interface which is adjacent to this Neighbor. It then processes the received Packet.