INET Framework for OMNeT++/OMNEST
inet::ospfv3::Ospfv3Instance Class Reference

#include <Ospfv3Instance.h>

Inheritance diagram for inet::ospfv3::Ospfv3Instance:

Public Member Functions

 Ospfv3Instance (int instanceId, Ospfv3Process *parentProcess, int addressFamily)
 
virtual ~Ospfv3Instance ()
 
int getInstanceID ()
 
int getAddressFamily ()
 
Ospfv3ProcessgetProcess () const
 
void init ()
 
bool hasArea (Ipv4Address)
 
void addArea (Ospfv3Area *)
 
Ospfv3AreagetAreaById (Ipv4Address areaId)
 
Ospfv3AreagetArea (int i)
 
void debugDump ()
 
Ipv4Address getNewInterAreaPrefixLinkStateID ()
 
void subtractInterAreaPrefixLinkStateID ()
 
void processPacket (Packet *pk)
 
int getUniqueId ()
 
int getAreaCount ()
 
void removeFromAllRetransmissionLists (LSAKeyType lsaKey)
 
std::string detailedInfo () const
 

Public Attributes

IInterfaceTableift = nullptr
 

Private Attributes

int addressFamily
 
int instanceID
 
Ospfv3ProcesscontainingProcess
 
std::vector< Ospfv3Area * > areas
 
cModule * containingModule = nullptr
 
std::map< Ipv4Address, Ospfv3Area * > areasById
 
int ospfv3IfIndex = 0
 
Ipv4Address interAreaPrefixLsID = Ipv4Address::UNSPECIFIED_ADDRESS
 

Constructor & Destructor Documentation

◆ Ospfv3Instance()

inet::ospfv3::Ospfv3Instance::Ospfv3Instance ( int  instanceId,
Ospfv3Process parentProcess,
int  addressFamily 
)
10 {
11  this->instanceID = instanceId;
12  this->containingProcess = parentProcess;
15  this->ift = check_and_cast<IInterfaceTable *>(containingModule->getSubmodule("interfaceTable"));
16 }

◆ ~Ospfv3Instance()

inet::ospfv3::Ospfv3Instance::~Ospfv3Instance ( )
virtual
19 {
20  long areaCount = areas.size();
21  for (long i = 0; i < areaCount; i++) {
22  delete areas[i];
23  }
24 }

Member Function Documentation

◆ addArea()

void inet::ospfv3::Ospfv3Instance::addArea ( Ospfv3Area newArea)
32 {
33  this->areas.push_back(newArea);
34  this->areasById[newArea->getAreaID()] = newArea;
35 } // addArea

Referenced by inet::ospfv3::Ospfv3Process::parseConfig().

◆ debugDump()

void inet::ospfv3::Ospfv3Instance::debugDump ( )
160 {
161  EV_DEBUG << "Instance " << this->getInstanceID() << "\n";
162  for (auto it = this->areas.begin(); it != this->areas.end(); it++) {
163  EV_DEBUG << "\tArea id " << (*it)->getAreaID() << " has these interfaces:\n";
164  (*it)->debugDump();
165  }
166 } // debugDump

◆ detailedInfo()

std::string inet::ospfv3::Ospfv3Instance::detailedInfo ( ) const
184 {
185  std::stringstream out;
186  int processID = this->getProcess()->getProcessID();
187  Ipv4Address routerID = this->getProcess()->getRouterID();
188  out << "Ospfv3 " << processID << " address-family ";
189 
190  if (this->addressFamily == IPV4INSTANCE)
191  out << "IPv4 (router-id " << routerID << ")\n\n";
192  else
193  out << "IPv6 (router-id " << routerID << ")\n\n";
194 
195  out << "Neighbor ID\tPri\tState\t\tDead Time\tInterface ID\tInterface\n";
196  for (auto it = this->areas.begin(); it != this->areas.end(); it++) {
197  int intfCount = (*it)->getInterfaceCount();
198  for (int i = 0; i < intfCount; i++) {
199  Ospfv3Interface *intf = (*it)->getInterface(i);
200  int neiCount = intf->getNeighborCount();
201  for (int n = 0; n < neiCount; n++) {
202  Ospfv3Neighbor *neighbor = intf->getNeighbor(n);
203  out << neighbor->getNeighborID() << "\t";
204  out << neighbor->getNeighborPriority() << "\t";
205  switch (neighbor->getState()) {
207  out << "DOWN\t\t";
208  break;
209 
211  out << "ATTEMPT\t\t";
212  break;
213 
215  out << "INIT\t\t";
216  break;
217 
219  if (intf->getDesignatedID() == Ipv4Address::UNSPECIFIED_ADDRESS)
220  out << "2WAY\t\t";
221  else
222  out << "2WAY/DROTHER\t";
223  break;
224 
226  out << "EXSTART\t\t";
227  break;
228 
230  out << "EXCHANGE\t\t";
231  break;
232 
234  out << "LOADING\t\t";
235  break;
236 
238  if (neighbor->getNeighborID() == intf->getDesignatedID())
239  out << "FULL/DR\t\t";
240  else if (neighbor->getNeighborID() == intf->getBackupID())
241  out << "FULL/BDR\t\t";
242  else
243  out << "FULL/DROTHER\t";
244  break;
245  }
246 
247  int dead = intf->getDeadInterval() - ((int)simTime().dbl() - neighbor->getLastHelloTime());
248  if (dead < 0)
249  dead = 0;
250  out << dead << "\t\t"; // "00:00:40\t\t";
251  out << neighbor->getNeighborInterfaceID() << "\t\t";
252  out << intf->getIntName() << "\n";
253  }
254  }
255  }
256 
257  return out.str();
258 }

Referenced by inet::ospfv3::operator<<().

◆ getAddressFamily()

int inet::ospfv3::Ospfv3Instance::getAddressFamily ( )
inline

◆ getArea()

Ospfv3Area* inet::ospfv3::Ospfv3Instance::getArea ( int  i)
inline

◆ getAreaById()

Ospfv3Area * inet::ospfv3::Ospfv3Instance::getAreaById ( Ipv4Address  areaId)

◆ getAreaCount()

◆ getInstanceID()

int inet::ospfv3::Ospfv3Instance::getInstanceID ( )
inline

◆ getNewInterAreaPrefixLinkStateID()

Ipv4Address inet::ospfv3::Ospfv3Instance::getNewInterAreaPrefixLinkStateID ( )
169 {
170  Ipv4Address currIP = this->interAreaPrefixLsID;
171  int newIP = currIP.getInt() + 1;
172  this->interAreaPrefixLsID = Ipv4Address(newIP);
173  return currIP;
174 }

Referenced by inet::ospfv3::Ospfv3Area::originateDefaultInterAreaPrefixLSA(), and inet::ospfv3::Ospfv3Area::originateInterAreaPrefixLSA().

◆ getProcess()

Ospfv3Process* inet::ospfv3::Ospfv3Instance::getProcess ( ) const
inline
32 { return this->containingProcess; }

Referenced by inet::ospfv3::Ospfv3Interface::acknowledgeLSA(), inet::ospfv3::Ospfv3Interface::addDelayedAcknowledgement(), inet::ospfv3::Ospfv3Interface::ageDatabase(), inet::ospfv3::Ospfv3InterfaceState::calculateDesignatedRouter(), inet::ospfv3::Ospfv3NeighborState::changeState(), inet::ospfv3::Ospfv3InterfaceState::changeState(), inet::ospfv3::Ospfv3Neighbor::clearRequestRetransmissionTimer(), inet::ospfv3::Ospfv3Neighbor::clearUpdateRetransmissionTimer(), detailedInfo(), inet::ospfv3::Ospfv3Interface::detailedInfo(), inet::ospfv3::Ospfv3Interface::floodLSA(), inet::ospfv3::Ospfv3Neighbor::needAdjacency(), inet::ospfv3::Ospfv3Interface::originateLinkLSA(), inet::ospfv3::Ospfv3Interface::processDDPacket(), inet::ospfv3::Ospfv3InterfaceStateDown::processEvent(), inet::ospfv3::Ospfv3NeighborStateAttempt::processEvent(), inet::ospfv3::Ospfv3NeighborStateFull::processEvent(), inet::ospfv3::Ospfv3NeighborStateLoading::processEvent(), inet::ospfv3::Ospfv3NeighborState2Way::processEvent(), inet::ospfv3::Ospfv3NeighborStateDown::processEvent(), inet::ospfv3::Ospfv3NeighborStateExchange::processEvent(), inet::ospfv3::Ospfv3NeighborStateInit::processEvent(), inet::ospfv3::Ospfv3InterfaceStateDrOther::processEvent(), inet::ospfv3::Ospfv3NeighborStateExStart::processEvent(), inet::ospfv3::Ospfv3InterfaceStateDr::processEvent(), inet::ospfv3::Ospfv3InterfaceStateWaiting::processEvent(), inet::ospfv3::Ospfv3InterfaceStatePointToPoint::processEvent(), inet::ospfv3::Ospfv3InterfaceStateBackup::processEvent(), inet::ospfv3::Ospfv3Interface::processHelloPacket(), inet::ospfv3::Ospfv3Interface::processLSR(), inet::ospfv3::Ospfv3Interface::processLSU(), inet::ospfv3::Ospfv3Neighbor::reset(), inet::ospfv3::Ospfv3Neighbor::retransmitDatabaseDescriptionPacket(), inet::ospfv3::Ospfv3Neighbor::retransmitUpdatePacket(), inet::ospfv3::Ospfv3Neighbor::sendDDPacket(), inet::ospfv3::Ospfv3Interface::sendDelayedAcknowledgements(), inet::ospfv3::Ospfv3Neighbor::sendLinkStateRequestPacket(), inet::ospfv3::Ospfv3Interface::sendLSAcknowledgement(), inet::ospfv3::Ospfv3Neighbor::startRequestRetransmissionTimer(), inet::ospfv3::Ospfv3Neighbor::startUpdateRetransmissionTimer(), inet::ospfv3::Ospfv3Interface::~Ospfv3Interface(), and inet::ospfv3::Ospfv3Neighbor::~Ospfv3Neighbor().

◆ getUniqueId()

int inet::ospfv3::Ospfv3Instance::getUniqueId ( )
inline
42 { return ospfv3IfIndex++; }

◆ hasArea()

bool inet::ospfv3::Ospfv3Instance::hasArea ( Ipv4Address  areaId)
27 {
28  return containsKey(this->areasById, areaId);
29 } // hasArea

Referenced by inet::ospfv3::Ospfv3Process::parseConfig().

◆ init()

void inet::ospfv3::Ospfv3Instance::init ( )
152 {
153  for (auto it = this->areas.begin(); it != this->areas.end(); it++)
154  (*it)->init();
155 
156  WATCH_PTRVECTOR(this->areas);
157 } // init

◆ processPacket()

void inet::ospfv3::Ospfv3Instance::processPacket ( Packet pk)
44 {
45  const auto& packet = pk->peekAtFront<Ospfv3Packet>();
46  EV_INFO << "Process " << this->containingProcess->getProcessID() << " received packet: (" << packet->getClassName() << ")" << packet->getName() << "\n";
47  if (packet->getVersion() != 3) {
48  delete pk;
49  return;
50  }
51 
52  int intfId = pk->getTag<InterfaceInd>()->getInterfaceId();
53  Ipv4Address areaId = packet->getAreaID();
54  Ospfv3Area *area = this->getAreaById(packet->getAreaID());
55  if (area != nullptr) {
56  Ospfv3Interface *intf = area->getInterfaceById(intfId);
57 
58  if (intf == nullptr) {
59  EV_DEBUG << "Interface is null in instance::processPacket\n";
60  // it must be the backbone area and...
61  if (areaId == Ipv4Address::UNSPECIFIED_ADDRESS) {
62  if (this->getAreaCount() > 1) {
63  // it must be a virtual link and the source router's router ID must be the endpoint of this virtual link and...
64  intf = area->findVirtualLink(packet->getRouterID());
65 
66  if (intf != nullptr) {
67  Ospfv3Area *virtualLinkTransitArea = this->getAreaById(intf->getTransitAreaID());
68  if (virtualLinkTransitArea != nullptr) {
69  // the receiving interface must attach to the virtual link's configured transit area
70  Ospfv3Interface *virtualLinkInterface = virtualLinkTransitArea->getInterfaceById(intfId);
71  //
72  if (virtualLinkInterface == nullptr) {
73  intf = nullptr;
74  }
75  }
76  else {
77  intf = nullptr;
78  }
79  }
80  }
81  }
82  }
83  if (intf != nullptr) {
84  Ipv6Address destinationAddress = pk->getTag<L3AddressInd>()->getDestAddress().toIpv6();
85  Ipv6Address allDRouters = Ipv6Address::ALL_OSPF_DESIGNATED_ROUTERS_MCAST;
86  Ospfv3Interface::Ospfv3InterfaceFaState interfaceState = intf->getState();
87 
88  // if destination address is ALL_D_ROUTERS the receiving interface must be in DesignatedRouter or Backup state
89  if (((destinationAddress == allDRouters) &&
90  ((interfaceState == Ospfv3Interface::INTERFACE_STATE_DESIGNATED) ||
91  (interfaceState == Ospfv3Interface::INTERFACE_STATE_BACKUP))) ||
92  (destinationAddress != allDRouters))
93  {
94  // packet authentication
95  ospf::OspfPacketType packetType = static_cast<ospf::OspfPacketType>(packet->getType());
96  Ospfv3Neighbor *neighbor = nullptr;
97 
98  // all packets except HelloPackets are sent only along adjacencies, so a Neighbor must exist
99  if (packetType != ospf::OspfPacketType::HELLO_PACKET)
100  neighbor = intf->getNeighborById(packet->getRouterID());
101 
102  switch (packetType) {
104  intf->processHelloPacket(pk);
105  break;
106 
108  if (neighbor != nullptr) {
109  EV_DEBUG << "Instance is sending packet to interface\n";
110  intf->processDDPacket(pk);
111  }
112  break;
113 
115  if (neighbor != nullptr) {
116  intf->processLSR(pk, neighbor);
117  }
118  break;
119 
121  if (neighbor != nullptr) {
122  intf->processLSU(pk, neighbor);
123  }
124  break;
125 
127  if (neighbor != nullptr) {
128  intf->processLSAck(pk, neighbor);
129  }
130  break;
131 
132  default:
133  break;
134  }
135  }
136  else {
137  delete pk;
138  }
139  }
140  }
141 } // processPacket

Referenced by inet::ospfv3::Ospfv3Process::handleMessage().

◆ removeFromAllRetransmissionLists()

void inet::ospfv3::Ospfv3Instance::removeFromAllRetransmissionLists ( LSAKeyType  lsaKey)
144 {
145  long areaCount = areas.size();
146  for (long i = 0; i < areaCount; i++) {
147  areas.at(i)->removeFromAllRetransmissionLists(lsaKey);
148  }
149 }

Referenced by inet::ospfv3::Ospfv3Interface::processLSU().

◆ subtractInterAreaPrefixLinkStateID()

void inet::ospfv3::Ospfv3Instance::subtractInterAreaPrefixLinkStateID ( )
177 {
178  Ipv4Address currIP = this->interAreaPrefixLsID;
179  int newIP = currIP.getInt() - 1;
180  this->interAreaPrefixLsID = Ipv4Address(newIP);
181 }

Member Data Documentation

◆ addressFamily

int inet::ospfv3::Ospfv3Instance::addressFamily
private

Referenced by detailedInfo(), and Ospfv3Instance().

◆ areas

std::vector<Ospfv3Area *> inet::ospfv3::Ospfv3Instance::areas
private

◆ areasById

std::map<Ipv4Address, Ospfv3Area *> inet::ospfv3::Ospfv3Instance::areasById
private

Referenced by addArea(), getAreaById(), and hasArea().

◆ containingModule

cModule* inet::ospfv3::Ospfv3Instance::containingModule = nullptr
private

Referenced by Ospfv3Instance().

◆ containingProcess

Ospfv3Process* inet::ospfv3::Ospfv3Instance::containingProcess
private

Referenced by Ospfv3Instance(), and processPacket().

◆ ift

IInterfaceTable* inet::ospfv3::Ospfv3Instance::ift = nullptr

Referenced by Ospfv3Instance().

◆ instanceID

int inet::ospfv3::Ospfv3Instance::instanceID
private

Referenced by Ospfv3Instance().

◆ interAreaPrefixLsID

Ipv4Address inet::ospfv3::Ospfv3Instance::interAreaPrefixLsID = Ipv4Address::UNSPECIFIED_ADDRESS
private

◆ ospfv3IfIndex

int inet::ospfv3::Ospfv3Instance::ospfv3IfIndex = 0
private

The documentation for this class was generated from the following files:
inet::findContainingNode
cModule * findContainingNode(const cModule *from)
Find the node containing the given module.
Definition: ModuleAccess.cc:31
inet::ospfv3::Ospfv3Neighbor::TWOWAY_STATE
@ TWOWAY_STATE
Definition: Ospfv3Neighbor.h:46
inet::ospf::LINKSTATE_ACKNOWLEDGEMENT_PACKET
@ LINKSTATE_ACKNOWLEDGEMENT_PACKET
Definition: OspfPacketBase_m.h:69
inet::Ipv4Address::getInt
uint32_t getInt() const
Returns the address as an uint32_t in host byte order (e.g.
Definition: Ipv4Address.h:186
inet::ospfv3::Ospfv3Neighbor::FULL_STATE
@ FULL_STATE
Definition: Ospfv3Neighbor.h:50
inet::ospfv3::Ospfv3Instance::areasById
std::map< Ipv4Address, Ospfv3Area * > areasById
Definition: Ospfv3Instance.h:56
inet::ospfv3::Ospfv3Instance::ospfv3IfIndex
int ospfv3IfIndex
Definition: Ospfv3Instance.h:57
inet::ospfv3::Ospfv3Neighbor::DOWN_STATE
@ DOWN_STATE
Definition: Ospfv3Neighbor.h:43
inet::ospfv3::Ospfv3Instance::getProcess
Ospfv3Process * getProcess() const
Definition: Ospfv3Instance.h:32
inet::ospf::LINKSTATE_REQUEST_PACKET
@ LINKSTATE_REQUEST_PACKET
Definition: OspfPacketBase_m.h:67
inet::ospfv3::Ospfv3Instance::getAreaCount
int getAreaCount()
Definition: Ospfv3Instance.h:43
inet::ospfv3::Ospfv3Instance::getAreaById
Ospfv3Area * getAreaById(Ipv4Address areaId)
Definition: Ospfv3Instance.cc:37
inet::ospfv3::Ospfv3Neighbor::EXCHANGE_START_STATE
@ EXCHANGE_START_STATE
Definition: Ospfv3Neighbor.h:47
inet::ospfv3::Ospfv3Neighbor::ATTEMPT_STATE
@ ATTEMPT_STATE
Definition: Ospfv3Neighbor.h:44
L3AddressInd
removed DscpReq Ipv4ControlInfo Ipv6ControlInfo up L3AddressInd L3AddressInd
Definition: IUdp-gates.txt:20
inet::ospfv3::Ospfv3Interface::Ospfv3InterfaceFaState
Ospfv3InterfaceFaState
Definition: Ospfv3Interface.h:26
inet::ospf::HELLO_PACKET
@ HELLO_PACKET
Definition: OspfPacketBase_m.h:65
inet::ospfv3::Ospfv3Process::getProcessID
int getProcessID() const
Definition: Ospfv3Process.h:39
inet::ospf::LINKSTATE_UPDATE_PACKET
@ LINKSTATE_UPDATE_PACKET
Definition: OspfPacketBase_m.h:68
IPV4INSTANCE
#define IPV4INSTANCE
Definition: Ospfv3Common.h:20
inet::ospfv3::Ospfv3Instance::containingModule
cModule * containingModule
Definition: Ospfv3Instance.h:55
inet::ospfv3::Ospfv3Process::getRouterID
Ipv4Address getRouterID()
Definition: Ospfv3Process.h:40
inet::ospfv3::Ospfv3Instance::instanceID
int instanceID
Definition: Ospfv3Instance.h:52
inet::ospf::DATABASE_DESCRIPTION_PACKET
@ DATABASE_DESCRIPTION_PACKET
Definition: OspfPacketBase_m.h:66
inet::ospf::OspfPacketType
OspfPacketType
Enum generated from inet/routing/ospf_common/OspfPacketBase.msg:15 by opp_msgtool.
Definition: OspfPacketBase_m.h:64
inet::ospfv3::Ospfv3Instance::ift
IInterfaceTable * ift
Definition: Ospfv3Instance.h:48
inet::ospfv3::Ospfv3Instance::interAreaPrefixLsID
Ipv4Address interAreaPrefixLsID
Definition: Ospfv3Instance.h:58
inet::ospfv3::Ospfv3Instance::containingProcess
Ospfv3Process * containingProcess
Definition: Ospfv3Instance.h:53
inet::Ipv4Address::UNSPECIFIED_ADDRESS
static const Ipv4Address UNSPECIFIED_ADDRESS
0.0.0.0
Definition: Ipv4Address.h:91
inet::ospfv3::Ospfv3Instance::getInstanceID
int getInstanceID()
Definition: Ospfv3Instance.h:30
inet::ospfv3::Ospfv3Neighbor::EXCHANGE_STATE
@ EXCHANGE_STATE
Definition: Ospfv3Neighbor.h:48
inet::ospfv3::Ospfv3Neighbor::INIT_STATE
@ INIT_STATE
Definition: Ospfv3Neighbor.h:45
inet::ospfv3::Ospfv3Instance::areas
std::vector< Ospfv3Area * > areas
Definition: Ospfv3Instance.h:54
inet::ospfv3::Ospfv3Instance::addressFamily
int addressFamily
Definition: Ospfv3Instance.h:51
inet::Ipv6Address::ALL_OSPF_DESIGNATED_ROUTERS_MCAST
static const Ipv6Address ALL_OSPF_DESIGNATED_ROUTERS_MCAST
OSPF designated routers.
Definition: Ipv6Address.h:87
inet::containsKey
bool containsKey(const std::map< K, V, _C > &m, const Tk &a)
Definition: stlutils.h:80
inet::ospfv3::Ospfv3Neighbor::LOADING_STATE
@ LOADING_STATE
Definition: Ospfv3Neighbor.h:49
inet::ospfv3::Ospfv3Interface::INTERFACE_STATE_BACKUP
@ INTERFACE_STATE_BACKUP
Definition: Ospfv3Interface.h:32
inet::ospfv3::Ospfv3Interface::INTERFACE_STATE_DESIGNATED
@ INTERFACE_STATE_DESIGNATED
Definition: Ospfv3Interface.h:33