INET Framework for OMNeT++/OMNEST
inet::ospfv3::Ospfv3NeighborState Class Referenceabstract

#include <Ospfv3NeighborState.h>

Inheritance diagram for inet::ospfv3::Ospfv3NeighborState:
inet::ospfv3::Ospfv3NeighborState2Way inet::ospfv3::Ospfv3NeighborStateAttempt inet::ospfv3::Ospfv3NeighborStateDown inet::ospfv3::Ospfv3NeighborStateExchange inet::ospfv3::Ospfv3NeighborStateExStart inet::ospfv3::Ospfv3NeighborStateFull inet::ospfv3::Ospfv3NeighborStateInit inet::ospfv3::Ospfv3NeighborStateLoading

Public Member Functions

virtual void processEvent (Ospfv3Neighbor *neighbor, Ospfv3Neighbor::Ospfv3NeighborEventType event)=0
 
virtual Ospfv3Neighbor::Ospfv3NeighborStateType getState () const =0
 
virtual std::string getNeighborStateString ()=0
 
virtual ~Ospfv3NeighborState ()
 

Protected Member Functions

void changeState (Ospfv3Neighbor *neighbor, Ospfv3NeighborState *newState, Ospfv3NeighborState *currentState)
 

Constructor & Destructor Documentation

◆ ~Ospfv3NeighborState()

virtual inet::ospfv3::Ospfv3NeighborState::~Ospfv3NeighborState ( )
inlinevirtual
19 {}

Member Function Documentation

◆ changeState()

void inet::ospfv3::Ospfv3NeighborState::changeState ( Ospfv3Neighbor neighbor,
Ospfv3NeighborState newState,
Ospfv3NeighborState currentState 
)
protected
15 {
16  Ospfv3Neighbor::Ospfv3NeighborStateType oldState = currentState->getState();
17  Ospfv3Neighbor::Ospfv3NeighborStateType nextState = newState->getState();
18  bool shouldRebuildRoutingTable = false;
19 
20  EV_DEBUG << "Changing neighbor state from " << currentState->getNeighborStateString() << " to " << newState->getNeighborStateString() << "\n";
21 
22  neighbor->changeState(newState, currentState);
23 
24  if ((oldState == Ospfv3Neighbor::FULL_STATE) || (nextState == Ospfv3Neighbor::FULL_STATE)) {
25  Ipv4Address routerID = neighbor->getInterface()->getArea()->getInstance()->getProcess()->getRouterID();
26  RouterLSA *routerLSA = neighbor->getInterface()->getArea()->findRouterLSA(routerID);
27 
28  if (routerLSA != nullptr) {
29  long sequenceNumber = routerLSA->getHeader().getLsaSequenceNumber();
30  if (sequenceNumber == MAX_SEQUENCE_NUMBER) {
31  routerLSA->getHeaderForUpdate().setLsaAge(MAX_AGE);
32  neighbor->getInterface()->getArea()->floodLSA(routerLSA);
33  routerLSA->incrementInstallTime();
34  }
35  else {
36  RouterLSA *newLSA = neighbor->getInterface()->getArea()->originateRouterLSA();
37 
38  newLSA->getHeaderForUpdate().setLsaSequenceNumber(sequenceNumber + 1);
39  shouldRebuildRoutingTable |= neighbor->getInterface()->getArea()->updateRouterLSA(routerLSA, newLSA);
40  if (shouldRebuildRoutingTable)
41  neighbor->getInterface()->getArea()->setSpfTreeRoot(routerLSA);
42  delete newLSA;
43 
44  neighbor->getInterface()->getArea()->floodLSA(routerLSA);
45  }
46  }
47 
48  if (neighbor->getInterface()->getState() == Ospfv3Interface::INTERFACE_STATE_DESIGNATED) {
49  NetworkLSA *networkLSA = neighbor->getInterface()->getArea()->findNetworkLSAByLSID(
50  Ipv4Address(neighbor->getInterface()->getInterfaceId()));
51 
52  if (networkLSA != nullptr) {
53  long sequenceNumber = networkLSA->getHeader().getLsaSequenceNumber();
54  if (sequenceNumber == MAX_SEQUENCE_NUMBER) {
55  networkLSA->getHeaderForUpdate().setLsaAge(MAX_AGE);
56  neighbor->getInterface()->getArea()->floodLSA(networkLSA);
57  networkLSA->incrementInstallTime();
58  }
59  else {
60  NetworkLSA *newLSA = neighbor->getInterface()->getArea()->originateNetworkLSA(neighbor->getInterface());
61 
62  if (newLSA != nullptr) {
63  newLSA->getHeaderForUpdate().setLsaSequenceNumber(sequenceNumber + 1);
64  shouldRebuildRoutingTable |= neighbor->getInterface()->getArea()->updateNetworkLSA(networkLSA, newLSA);
65  delete newLSA;
66  }
67  else { // no neighbors on the network -> old NetworkLSA must be flushed
68  networkLSA->getHeaderForUpdate().setLsaAge(MAX_AGE);
69  networkLSA->incrementInstallTime();
70  }
71  neighbor->getInterface()->getArea()->floodLSA(networkLSA);
72  }
73  }
74  }
75  }
76 
77  Ospfv3Area *thisArea = neighbor->getInterface()->getArea();
78  if (nextState == Ospfv3Neighbor::DOWN_STATE) { // this neigbor was shuted down
79  // invalidate all LSA type 3, which I know from this neighbor
80  // set MAX_AGE
81  if (thisArea->getInstance()->getAreaCount() > 1) { // this is ABR
82  for (int ar = 0; ar < thisArea->getInstance()->getAreaCount(); ar++) {
83  Ospfv3Area *area = thisArea->getInstance()->getArea(ar);
84  if (area->getAreaID() == thisArea->getAreaID()) // skip my Area
85  continue;
86 
87  // in all other Areas invalidate all Inter-Area-Prefix LSAs with same prefix IP as all
88  // known Intra-Area-Prefix LSAs from this neighbor
89  for (int i = 0; i < thisArea->getIntraAreaPrefixLSACount(); i++) {
90  IntraAreaPrefixLSA *iapLSA = thisArea->getIntraAreaPrefixLSA(i);
91  if (neighbor->getNeighborID() == iapLSA->getHeader().getAdvertisingRouter()) {
92  for (size_t k = 0; k < iapLSA->getPrefixesArraySize(); k++) {
93  // go through all Inter-Area-Prefix LSA of other Area
94  for (int j = 0; j < area->getInterAreaPrefixLSACount(); j++) {
95  InterAreaPrefixLSA *interLSA = area->getInterAreaPrefixLSA(j);
96  if ((interLSA->getHeader().getAdvertisingRouter() == thisArea->getInstance()->getProcess()->getRouterID()) &&
97  (interLSA->getPrefix().addressPrefix == iapLSA->getPrefixes(k).addressPrefix) &&
98  (interLSA->getPrefix().prefixLen == iapLSA->getPrefixes(k).prefixLen))
99  {
100  interLSA->getHeaderForUpdate().setLsaAge(MAX_AGE);
101  area->floodLSA(interLSA);
102  }
103  }
104  }
105  // invalidate INTRA LSA too
106  iapLSA->getHeaderForUpdate().setLsaAge(MAX_AGE);
107 // neighbor->getInterface()->getArea()->floodLSA(iapLSA);
108  }
109  }
110  }
111  }
112  else { // invalidate only INTRA LSA
113  for (int i = 0; i < thisArea->getIntraAreaPrefixLSACount(); i++) {
114  IntraAreaPrefixLSA *iapLSA = thisArea->getIntraAreaPrefixLSA(i);
115  if (neighbor->getNeighborID() == iapLSA->getHeader().getAdvertisingRouter()) {
116  // invalidate INTRA LSA too
117  iapLSA->getHeaderForUpdate().setLsaAge(MAX_AGE);
118  thisArea->floodLSA(iapLSA);
119  }
120  }
121  }
122  }
123 
124  if (shouldRebuildRoutingTable) {
125  neighbor->getInterface()->getArea()->getInstance()->getProcess()->rebuildRoutingTable();
126  }
127 }

Referenced by inet::ospfv3::Ospfv3NeighborStateAttempt::processEvent(), inet::ospfv3::Ospfv3NeighborStateLoading::processEvent(), inet::ospfv3::Ospfv3NeighborStateFull::processEvent(), inet::ospfv3::Ospfv3NeighborStateExchange::processEvent(), inet::ospfv3::Ospfv3NeighborState2Way::processEvent(), inet::ospfv3::Ospfv3NeighborStateDown::processEvent(), inet::ospfv3::Ospfv3NeighborStateInit::processEvent(), and inet::ospfv3::Ospfv3NeighborStateExStart::processEvent().

◆ getNeighborStateString()

◆ getState()

◆ processEvent()


The documentation for this class was generated from the following files:
inet::ospfv3::Ospfv3Neighbor::FULL_STATE
@ FULL_STATE
Definition: Ospfv3Neighbor.h:50
MAX_SEQUENCE_NUMBER
#define MAX_SEQUENCE_NUMBER
Definition: Ospfv2Common.h:34
inet::ospfv3::Ospfv3Neighbor::DOWN_STATE
@ DOWN_STATE
Definition: Ospfv3Neighbor.h:43
MAX_AGE
#define MAX_AGE
Definition: Ospfv2Common.h:27
inet::ospfv3::Ospfv3Neighbor::Ospfv3NeighborStateType
Ospfv3NeighborStateType
Definition: Ospfv3Neighbor.h:42
inet::physicallayer::k
const double k
Definition: Qam1024Modulation.cc:14
inet::ospfv3::Ospfv3Interface::INTERFACE_STATE_DESIGNATED
@ INTERFACE_STATE_DESIGNATED
Definition: Ospfv3Interface.h:33