INET Framework for OMNeT++/OMNEST
inet::ospf::Neighbor Class Reference

#include <OSPFNeighbor.h>

Classes

struct  DDPacketID
 
struct  TransmittedLSA
 

Public Types

enum  NeighborEventType {
  HELLO_RECEIVED = 0, START = 1, TWOWAY_RECEIVED = 2, NEGOTIATION_DONE = 3,
  EXCHANGE_DONE = 4, BAD_LINK_STATE_REQUEST = 5, LOADING_DONE = 6, IS_ADJACENCY_OK = 7,
  SEQUENCE_NUMBER_MISMATCH = 8, ONEWAY_RECEIVED = 9, KILL_NEIGHBOR = 10, INACTIVITY_TIMER = 11,
  POLL_TIMER = 12, LINK_DOWN = 13, DD_RETRANSMISSION_TIMER = 14, UPDATE_RETRANSMISSION_TIMER = 15,
  REQUEST_RETRANSMISSION_TIMER = 16
}
 
enum  NeighborStateType {
  DOWN_STATE = 0, ATTEMPT_STATE = 1, INIT_STATE = 2, TWOWAY_STATE = 4,
  EXCHANGE_START_STATE = 8, EXCHANGE_STATE = 16, LOADING_STATE = 32, FULL_STATE = 64
}
 
enum  DatabaseExchangeRelationshipType { MASTER = 0, SLAVE = 1 }
 

Public Member Functions

 Neighbor (RouterID neighbor=NULL_ROUTERID)
 
virtual ~Neighbor ()
 
void processEvent (NeighborEventType event)
 
void reset ()
 
void initFirstAdjacency ()
 
NeighborStateType getState () const
 
void sendDatabaseDescriptionPacket (bool init=false)
 
bool retransmitDatabaseDescriptionPacket ()
 
void createDatabaseSummary ()
 
void sendLinkStateRequestPacket ()
 
void retransmitUpdatePacket ()
 
bool needAdjacency ()
 
void addToRetransmissionList (OSPFLSA *lsa)
 If the LSA is already on the retransmission list then it is replaced, else a copy of the LSA is added to the end of the retransmission list. More...
 
void removeFromRetransmissionList (LSAKeyType lsaKey)
 
bool isLinkStateRequestListEmpty (LSAKeyType lsaKey) const
 
OSPFLSAfindOnRetransmissionList (LSAKeyType lsaKey)
 
void startUpdateRetransmissionTimer ()
 
void clearUpdateRetransmissionTimer ()
 
void addToRequestList (OSPFLSAHeader *lsaHeader)
 
void removeFromRequestList (LSAKeyType lsaKey)
 
bool isLSAOnRequestList (LSAKeyType lsaKey) const
 
OSPFLSAHeaderfindOnRequestList (LSAKeyType lsaKey)
 
void startRequestRetransmissionTimer ()
 
void clearRequestRetransmissionTimer ()
 
void addToTransmittedLSAList (LSAKeyType lsaKey)
 
bool isOnTransmittedLSAList (LSAKeyType lsaKey) const
 
void ageTransmittedLSAList ()
 
unsigned long getUniqueULong ()
 
void deleteLastSentDDPacket ()
 
void setNeighborID (RouterID id)
 
RouterID getNeighborID () const
 
void setPriority (unsigned char priority)
 
unsigned char getPriority () const
 
void setAddress (IPv4Address address)
 
IPv4Address getAddress () const
 
void setDesignatedRouter (DesignatedRouterID routerID)
 
DesignatedRouterID getDesignatedRouter () const
 
void setBackupDesignatedRouter (DesignatedRouterID routerID)
 
DesignatedRouterID getBackupDesignatedRouter () const
 
void setRouterDeadInterval (short interval)
 
short getRouterDeadInterval () const
 
void setDDSequenceNumber (unsigned long sequenceNumber)
 
unsigned long getDDSequenceNumber () const
 
void setOptions (OSPFOptions options)
 
OSPFOptions getOptions () const
 
void setLastReceivedDDPacket (DDPacketID packetID)
 
DDPacketID getLastReceivedDDPacket () const
 
void setDatabaseExchangeRelationship (DatabaseExchangeRelationshipType relation)
 
DatabaseExchangeRelationshipType getDatabaseExchangeRelationship () const
 
void setInterface (Interface *intf)
 
InterfacegetInterface ()
 
const InterfacegetInterface () const
 
cMessage * getInactivityTimer ()
 
cMessage * getPollTimer ()
 
cMessage * getDDRetransmissionTimer ()
 
cMessage * getUpdateRetransmissionTimer ()
 
bool isUpdateRetransmissionTimerActive () const
 
bool isRequestRetransmissionTimerActive () const
 
bool isFirstAdjacencyInited () const
 
bool designatedRoutersAreSetUp () const
 
void setupDesignatedRouters (bool setUp)
 
unsigned long getDatabaseSummaryListCount () const
 
void incrementDDSequenceNumber ()
 
bool isLinkStateRequestListEmpty () const
 
bool isLinkStateRetransmissionListEmpty () const
 
void popFirstLinkStateRequest ()
 

Static Public Member Functions

static const char * getStateString (NeighborStateType stateType)
 

Private Member Functions

void changeState (NeighborState *newState, NeighborState *currentState)
 

Private Attributes

NeighborStatestate = nullptr
 
NeighborStatepreviousState = nullptr
 
cMessage * inactivityTimer = nullptr
 
cMessage * pollTimer = nullptr
 
cMessage * ddRetransmissionTimer = nullptr
 
cMessage * updateRetransmissionTimer = nullptr
 
bool updateRetransmissionTimerActive = false
 
cMessage * requestRetransmissionTimer = nullptr
 
bool requestRetransmissionTimerActive = false
 
DatabaseExchangeRelationshipType databaseExchangeRelationship = (DatabaseExchangeRelationshipType)-1
 
bool firstAdjacencyInited = false
 
unsigned long ddSequenceNumber = 0
 
DDPacketID lastReceivedDDPacket
 
RouterID neighborID
 
unsigned char neighborPriority = 0
 
IPv4Address neighborIPAddress
 
OSPFOptions neighborOptions
 
DesignatedRouterID neighborsDesignatedRouter
 
DesignatedRouterID neighborsBackupDesignatedRouter
 
bool designatedRoutersSetUp = false
 
short neighborsRouterDeadInterval = 0
 
std::list< OSPFLSA * > linkStateRetransmissionList
 
std::list< OSPFLSAHeader * > databaseSummaryList
 
std::list< OSPFLSAHeader * > linkStateRequestList
 
std::list< TransmittedLSAtransmittedLSAs
 
OSPFDatabaseDescriptionPacketlastTransmittedDDPacket = nullptr
 
InterfaceparentInterface = nullptr
 

Static Private Attributes

static unsigned long ddSequenceNumberInitSeed = 0
 

Friends

class NeighborState
 

Member Enumeration Documentation

Enumerator
MASTER 
SLAVE 
72  {
73  MASTER = 0,
74  SLAVE = 1
75  };
Definition: OSPFNeighbor.h:74
Definition: OSPFNeighbor.h:73
Enumerator
HELLO_RECEIVED 
START 
TWOWAY_RECEIVED 
NEGOTIATION_DONE 
EXCHANGE_DONE 
BAD_LINK_STATE_REQUEST 
LOADING_DONE 
IS_ADJACENCY_OK 
SEQUENCE_NUMBER_MISMATCH 
ONEWAY_RECEIVED 
KILL_NEIGHBOR 
INACTIVITY_TIMER 
POLL_TIMER 
LINK_DOWN 
DD_RETRANSMISSION_TIMER 
UPDATE_RETRANSMISSION_TIMER 
REQUEST_RETRANSMISSION_TIMER 
41  {
42  HELLO_RECEIVED = 0,
43  START = 1,
44  TWOWAY_RECEIVED = 2,
45  NEGOTIATION_DONE = 3,
46  EXCHANGE_DONE = 4,
48  LOADING_DONE = 6,
49  IS_ADJACENCY_OK = 7,
51  ONEWAY_RECEIVED = 9,
52  KILL_NEIGHBOR = 10,
53  INACTIVITY_TIMER = 11,
54  POLL_TIMER = 12,
55  LINK_DOWN = 13,
59  };
Definition: OSPFNeighbor.h:52
Definition: OSPFNeighbor.h:51
Definition: OSPFNeighbor.h:42
Definition: OSPFNeighbor.h:53
Definition: OSPFNeighbor.h:44
Definition: OSPFNeighbor.h:45
Definition: OSPFNeighbor.h:54
Definition: OSPFNeighbor.h:55
Definition: OSPFNeighbor.h:48
Definition: OSPFNeighbor.h:43
Definition: OSPFNeighbor.h:46
Definition: OSPFNeighbor.h:49
Enumerator
DOWN_STATE 
ATTEMPT_STATE 
INIT_STATE 
TWOWAY_STATE 
EXCHANGE_START_STATE 
EXCHANGE_STATE 
LOADING_STATE 
FULL_STATE 
61  {
62  DOWN_STATE = 0,
63  ATTEMPT_STATE = 1,
64  INIT_STATE = 2,
65  TWOWAY_STATE = 4,
67  EXCHANGE_STATE = 16,
68  LOADING_STATE = 32,
69  FULL_STATE = 64
70  };
Definition: OSPFNeighbor.h:64
Definition: OSPFNeighbor.h:66
Definition: OSPFNeighbor.h:65
Definition: OSPFNeighbor.h:62
Definition: OSPFNeighbor.h:63
Definition: OSPFNeighbor.h:68
Definition: OSPFNeighbor.h:69
Definition: OSPFNeighbor.h:67

Constructor & Destructor Documentation

inet::ospf::Neighbor::Neighbor ( RouterID  neighbor = NULL_ROUTERID)
36  :
37  neighborID(neighbor),
42 {
43  memset(&lastReceivedDDPacket, 0, sizeof(Neighbor::DDPacketID));
44  // setting only I and M bits is invalid -> good initializer
47  inactivityTimer = new cMessage();
49  inactivityTimer->setContextPointer(this);
50  inactivityTimer->setName("Neighbor::NeighborInactivityTimer");
51  pollTimer = new cMessage();
53  pollTimer->setContextPointer(this);
54  pollTimer->setName("Neighbor::NeighborPollTimer");
55  ddRetransmissionTimer = new cMessage();
57  ddRetransmissionTimer->setContextPointer(this);
58  ddRetransmissionTimer->setName("Neighbor::NeighborDDRetransmissionTimer");
59  updateRetransmissionTimer = new cMessage();
61  updateRetransmissionTimer->setContextPointer(this);
62  updateRetransmissionTimer->setName("Neighbor::Neighbor::NeighborUpdateRetransmissionTimer");
63  requestRetransmissionTimer = new cMessage();
65  requestRetransmissionTimer->setContextPointer(this);
66  requestRetransmissionTimer->setName("Neighbor::NeighborRequestRetransmissionTimer");
67  state = new NeighborStateDown;
68  previousState = nullptr;
69 }
NeighborState * state
Definition: OSPFNeighbor.h:92
cMessage * requestRetransmissionTimer
Definition: OSPFNeighbor.h:99
const IPv4Address NULL_IPV4ADDRESS(0, 0, 0, 0)
short neighborsRouterDeadInterval
Definition: OSPFNeighbor.h:112
RouterID neighborID
Definition: OSPFNeighbor.h:105
DesignatedRouterID neighborsDesignatedRouter
Definition: OSPFNeighbor.h:109
bool M_More
Definition: OSPFPacket_m.h:767
cMessage * inactivityTimer
Definition: OSPFNeighbor.h:94
DDPacketID lastReceivedDDPacket
Definition: OSPFNeighbor.h:104
const DesignatedRouterID NULL_DESIGNATEDROUTERID
Definition: OSPFcommon.h:164
cMessage * updateRetransmissionTimer
Definition: OSPFNeighbor.h:97
DesignatedRouterID neighborsBackupDesignatedRouter
Definition: OSPFNeighbor.h:110
cMessage * pollTimer
Definition: OSPFNeighbor.h:95
Definition: OSPFTimer.h:32
IPv4Address neighborIPAddress
Definition: OSPFNeighbor.h:107
cMessage * ddRetransmissionTimer
Definition: OSPFNeighbor.h:96
bool I_Init
Definition: OSPFPacket_m.h:766
NeighborState * previousState
Definition: OSPFNeighbor.h:93
Definition: OSPFTimer.h:31
OSPFDDOptions ddOptions
Definition: OSPFNeighbor.h:79
inet::ospf::Neighbor::~Neighbor ( )
virtual
72 {
73  reset();
74  MessageHandler *messageHandler = parentInterface->getArea()->getRouter()->getMessageHandler();
75  messageHandler->clearTimer(inactivityTimer);
76  messageHandler->clearTimer(pollTimer);
77  delete inactivityTimer;
78  delete pollTimer;
79  delete ddRetransmissionTimer;
82  if (previousState != nullptr) {
83  delete previousState;
84  }
85  delete state;
86 }
NeighborState * state
Definition: OSPFNeighbor.h:92
cMessage * requestRetransmissionTimer
Definition: OSPFNeighbor.h:99
void reset()
Definition: OSPFNeighbor.cc:102
Router * getRouter()
Definition: OSPFArea.h:80
Interface * parentInterface
Definition: OSPFNeighbor.h:119
cMessage * inactivityTimer
Definition: OSPFNeighbor.h:94
cMessage * updateRetransmissionTimer
Definition: OSPFNeighbor.h:97
cMessage * pollTimer
Definition: OSPFNeighbor.h:95
Area * getArea()
Definition: OSPFInterface.h:174
void clearTimer(cMessage *timer)
Definition: MessageHandler.cc:367
MessageHandler * getMessageHandler()
Definition: OSPFRouter.h:77
cMessage * ddRetransmissionTimer
Definition: OSPFNeighbor.h:96
NeighborState * previousState
Definition: OSPFNeighbor.h:93

Member Function Documentation

void inet::ospf::Neighbor::addToRequestList ( OSPFLSAHeader lsaHeader)

Referenced by inet::ospf::DatabaseDescriptionHandler::processDDPacket().

513 {
514  linkStateRequestList.push_back(new OSPFLSAHeader(*lsaHeader));
515 }
std::list< OSPFLSAHeader * > linkStateRequestList
Definition: OSPFNeighbor.h:115
void inet::ospf::Neighbor::addToRetransmissionList ( OSPFLSA lsa)

If the LSA is already on the retransmission list then it is replaced, else a copy of the LSA is added to the end of the retransmission list.

Parameters
lsa[in] The LSA to be added.
415 {
416  auto it = linkStateRetransmissionList.begin();
417  for ( ; it != linkStateRetransmissionList.end(); it++) {
418  if (((*it)->getHeader().getLinkStateID() == lsa->getHeader().getLinkStateID()) &&
419  ((*it)->getHeader().getAdvertisingRouter().getInt() == lsa->getHeader().getAdvertisingRouter().getInt()))
420  {
421  break;
422  }
423  }
424 
425  OSPFLSA *lsaCopy = nullptr;
426  switch (lsa->getHeader().getLsType()) {
427  case ROUTERLSA_TYPE:
428  lsaCopy = new OSPFRouterLSA(*(check_and_cast<OSPFRouterLSA *>(lsa)));
429  break;
430 
431  case NETWORKLSA_TYPE:
432  lsaCopy = new OSPFNetworkLSA(*(check_and_cast<OSPFNetworkLSA *>(lsa)));
433  break;
434 
437  lsaCopy = new OSPFSummaryLSA(*(check_and_cast<OSPFSummaryLSA *>(lsa)));
438  break;
439 
441  lsaCopy = new OSPFASExternalLSA(*(check_and_cast<OSPFASExternalLSA *>(lsa)));
442  break;
443 
444  default:
445  ASSERT(false); // error
446  break;
447  }
448 
449  if (it != linkStateRetransmissionList.end()) {
450  delete (*it);
451  *it = static_cast<OSPFLSA *>(lsaCopy);
452  }
453  else {
454  linkStateRetransmissionList.push_back(static_cast<OSPFLSA *>(lsaCopy));
455  }
456 }
Definition: OSPFPacket_m.h:246
std::list< OSPFLSA * > linkStateRetransmissionList
Definition: OSPFNeighbor.h:113
Definition: OSPFPacket_m.h:245
Definition: OSPFPacket_m.h:249
Definition: OSPFPacket_m.h:247
Definition: OSPFPacket_m.h:248
void inet::ospf::Neighbor::addToTransmittedLSAList ( LSAKeyType  lsaKey)

Referenced by inet::ospf::Interface::floodLSA().

577 {
578  TransmittedLSA transmit;
579 
580  transmit.lsaKey = lsaKey;
581  transmit.age = 0;
582 
583  transmittedLSAs.push_back(transmit);
584 }
std::list< TransmittedLSA > transmittedLSAs
Definition: OSPFNeighbor.h:116
void inet::ospf::Neighbor::ageTransmittedLSAList ( )
599 {
600  auto it = transmittedLSAs.begin();
601  while ((it != transmittedLSAs.end()) && (it->age == MIN_LS_ARRIVAL)) {
602  transmittedLSAs.pop_front();
603  it = transmittedLSAs.begin();
604  }
605  for (it = transmittedLSAs.begin(); it != transmittedLSAs.end(); it++) {
606  it->age++;
607  }
608 }
#define MIN_LS_ARRIVAL
Definition: OSPFcommon.h:35
std::list< TransmittedLSA > transmittedLSAs
Definition: OSPFNeighbor.h:116
void inet::ospf::Neighbor::changeState ( NeighborState newState,
NeighborState currentState 
)
private

Referenced by inet::ospf::NeighborState::changeState().

89 {
90  if (previousState != nullptr) {
91  delete previousState;
92  }
93  state = newState;
94  previousState = currentState;
95 }
NeighborState * state
Definition: OSPFNeighbor.h:92
NeighborState * previousState
Definition: OSPFNeighbor.h:93
void inet::ospf::Neighbor::clearRequestRetransmissionTimer ( )

Referenced by inet::ospf::NeighborStateExchange::processEvent(), inet::ospf::NeighborStateLoading::processEvent(), inet::ospf::DatabaseDescriptionHandler::processPacket(), removeFromRequestList(), and reset().

570 {
571  MessageHandler *messageHandler = parentInterface->getArea()->getRouter()->getMessageHandler();
572  messageHandler->clearTimer(requestRetransmissionTimer);
574 }
cMessage * requestRetransmissionTimer
Definition: OSPFNeighbor.h:99
Router * getRouter()
Definition: OSPFArea.h:80
Interface * parentInterface
Definition: OSPFNeighbor.h:119
Area * getArea()
Definition: OSPFInterface.h:174
void clearTimer(cMessage *timer)
Definition: MessageHandler.cc:367
bool requestRetransmissionTimerActive
Definition: OSPFNeighbor.h:100
MessageHandler * getMessageHandler()
Definition: OSPFRouter.h:77
void inet::ospf::Neighbor::clearUpdateRetransmissionTimer ( )

Referenced by inet::ospf::LinkStateAcknowledgementHandler::processPacket(), and reset().

506 {
507  MessageHandler *messageHandler = parentInterface->getArea()->getRouter()->getMessageHandler();
508  messageHandler->clearTimer(updateRetransmissionTimer);
510 }
bool updateRetransmissionTimerActive
Definition: OSPFNeighbor.h:98
Router * getRouter()
Definition: OSPFArea.h:80
Interface * parentInterface
Definition: OSPFNeighbor.h:119
cMessage * updateRetransmissionTimer
Definition: OSPFNeighbor.h:97
Area * getArea()
Definition: OSPFInterface.h:174
void clearTimer(cMessage *timer)
Definition: MessageHandler.cc:367
MessageHandler * getMessageHandler()
Definition: OSPFRouter.h:77
void inet::ospf::Neighbor::createDatabaseSummary ( )

Referenced by inet::ospf::NeighborStateExchangeStart::processEvent().

282 {
283  Area *area = parentInterface->getArea();
284  unsigned long routerLSACount = area->getRouterLSACount();
285 
286  /* Note: OSPF specification says:
287  * "LSAs whose age is equal to MaxAge are instead added to the neighbor's
288  * Link state retransmission list."
289  * But this task has been already done during the aging of the database. (???)
290  * So we'll skip this.
291  */
292  for (unsigned long i = 0; i < routerLSACount; i++) {
293  if (area->getRouterLSA(i)->getHeader().getLsAge() < MAX_AGE) {
294  OSPFLSAHeader *routerLSA = new OSPFLSAHeader(area->getRouterLSA(i)->getHeader());
295  databaseSummaryList.push_back(routerLSA);
296  }
297  }
298 
299  unsigned long networkLSACount = area->getNetworkLSACount();
300  for (unsigned long j = 0; j < networkLSACount; j++) {
301  if (area->getNetworkLSA(j)->getHeader().getLsAge() < MAX_AGE) {
302  OSPFLSAHeader *networkLSA = new OSPFLSAHeader(area->getNetworkLSA(j)->getHeader());
303  databaseSummaryList.push_back(networkLSA);
304  }
305  }
306 
307  unsigned long summaryLSACount = area->getSummaryLSACount();
308  for (unsigned long k = 0; k < summaryLSACount; k++) {
309  if (area->getSummaryLSA(k)->getHeader().getLsAge() < MAX_AGE) {
310  OSPFLSAHeader *summaryLSA = new OSPFLSAHeader(area->getSummaryLSA(k)->getHeader());
311  databaseSummaryList.push_back(summaryLSA);
312  }
313  }
314 
316  (area->getExternalRoutingCapability()))
317  {
318  Router *router = area->getRouter();
319  unsigned long asExternalLSACount = router->getASExternalLSACount();
320 
321  for (unsigned long m = 0; m < asExternalLSACount; m++) {
322  if (router->getASExternalLSA(m)->getHeader().getLsAge() < MAX_AGE) {
323  OSPFLSAHeader *asExternalLSA = new OSPFLSAHeader(router->getASExternalLSA(m)->getHeader());
324  databaseSummaryList.push_back(asExternalLSA);
325  }
326  }
327  }
328 }
Definition: OSPFInterface.h:60
Interface * parentInterface
Definition: OSPFNeighbor.h:119
unsigned long getRouterLSACount() const
Definition: OSPFArea.h:83
#define MAX_AGE
Definition: OSPFcommon.h:36
Area * getArea()
Definition: OSPFInterface.h:174
OSPFInterfaceType getType() const
Definition: OSPFInterface.h:132
std::list< OSPFLSAHeader * > databaseSummaryList
Definition: OSPFNeighbor.h:114
const double k
Definition: QAM16Modulation.cc:24
value< double, units::m > m
Definition: Units.h:1047
void inet::ospf::Neighbor::deleteLastSentDDPacket ( )

Referenced by inet::ospf::NeighborStateFull::processEvent(), and inet::ospf::NeighborStateLoading::processEvent().

768 {
769  if (lastTransmittedDDPacket != nullptr) {
771  lastTransmittedDDPacket = nullptr;
772  }
773 }
OSPFDatabaseDescriptionPacket * lastTransmittedDDPacket
Definition: OSPFNeighbor.h:117
bool inet::ospf::Neighbor::designatedRoutersAreSetUp ( ) const
inline

Referenced by inet::ospf::HelloHandler::processPacket().

193 { return designatedRoutersSetUp; }
bool designatedRoutersSetUp
Definition: OSPFNeighbor.h:111
OSPFLSAHeader * inet::ospf::Neighbor::findOnRequestList ( LSAKeyType  lsaKey)
551 {
552  for (auto & elem : linkStateRequestList) {
553  if (((elem)->getLinkStateID() == lsaKey.linkStateID) &&
554  ((elem)->getAdvertisingRouter() == lsaKey.advertisingRouter))
555  {
556  return elem;
557  }
558  }
559  return nullptr;
560 }
std::list< OSPFLSAHeader * > linkStateRequestList
Definition: OSPFNeighbor.h:115
OSPFLSA * inet::ospf::Neighbor::findOnRetransmissionList ( LSAKeyType  lsaKey)

Referenced by inet::ospf::LinkStateAcknowledgementHandler::processPacket().

487 {
488  for (auto & elem : linkStateRetransmissionList) {
489  if (((elem)->getHeader().getLinkStateID() == lsaKey.linkStateID) &&
490  ((elem)->getHeader().getAdvertisingRouter() == lsaKey.advertisingRouter))
491  {
492  return elem;
493  }
494  }
495  return nullptr;
496 }
std::list< OSPFLSA * > linkStateRetransmissionList
Definition: OSPFNeighbor.h:113
DesignatedRouterID inet::ospf::Neighbor::getBackupDesignatedRouter ( ) const
inline

Referenced by inet::ospf::InterfaceState::calculateDesignatedRouter(), and inet::ospf::HelloHandler::processPacket().

DesignatedRouterID neighborsBackupDesignatedRouter
Definition: OSPFNeighbor.h:110
DatabaseExchangeRelationshipType inet::ospf::Neighbor::getDatabaseExchangeRelationship ( ) const
inline

Referenced by inet::ospf::DatabaseDescriptionHandler::processDDPacket(), and inet::ospf::DatabaseDescriptionHandler::processPacket().

DatabaseExchangeRelationshipType databaseExchangeRelationship
Definition: OSPFNeighbor.h:101
unsigned long inet::ospf::Neighbor::getDatabaseSummaryListCount ( ) const
inline

Referenced by inet::ospf::DatabaseDescriptionHandler::processDDPacket().

195 { return databaseSummaryList.size(); }
std::list< OSPFLSAHeader * > databaseSummaryList
Definition: OSPFNeighbor.h:114
unsigned long inet::ospf::Neighbor::getDDSequenceNumber ( ) const
inline

Referenced by inet::ospf::DatabaseDescriptionHandler::processPacket().

173 { return ddSequenceNumber; }
unsigned long ddSequenceNumber
Definition: OSPFNeighbor.h:103
DesignatedRouterID inet::ospf::Neighbor::getDesignatedRouter ( ) const
inline

Referenced by inet::ospf::InterfaceState::calculateDesignatedRouter(), and inet::ospf::HelloHandler::processPacket().

167 { return neighborsDesignatedRouter; }
DesignatedRouterID neighborsDesignatedRouter
Definition: OSPFNeighbor.h:109
const Interface* inet::ospf::Neighbor::getInterface ( ) const
inline
184 { return parentInterface; }
Interface * parentInterface
Definition: OSPFNeighbor.h:119
DDPacketID inet::ospf::Neighbor::getLastReceivedDDPacket ( ) const
inline

Referenced by inet::ospf::DatabaseDescriptionHandler::processPacket().

177 { return lastReceivedDDPacket; }
DDPacketID lastReceivedDDPacket
Definition: OSPFNeighbor.h:104
OSPFOptions inet::ospf::Neighbor::getOptions ( ) const
inline
175 { return neighborOptions; }
OSPFOptions neighborOptions
Definition: OSPFNeighbor.h:108
const char * inet::ospf::Neighbor::getStateString ( Neighbor::NeighborStateType  stateType)
static

Referenced by inet::ospf::MessageHandler::printEvent().

147 {
148  switch (stateType) {
149  case DOWN_STATE:
150  return "Down";
151 
152  case ATTEMPT_STATE:
153  return "Attempt";
154 
155  case INIT_STATE:
156  return "Init";
157 
158  case TWOWAY_STATE:
159  return "TwoWay";
160 
162  return "ExchangeStart";
163 
164  case EXCHANGE_STATE:
165  return "Exchange";
166 
167  case LOADING_STATE:
168  return "Loading";
169 
170  case FULL_STATE:
171  return "Full";
172 
173  default:
174  ASSERT(false);
175  break;
176  }
177  return "";
178 }
Definition: OSPFNeighbor.h:64
Definition: OSPFNeighbor.h:66
Definition: OSPFNeighbor.h:65
Definition: OSPFNeighbor.h:62
Definition: OSPFNeighbor.h:63
Definition: OSPFNeighbor.h:68
Definition: OSPFNeighbor.h:69
Definition: OSPFNeighbor.h:67
unsigned long inet::ospf::Neighbor::getUniqueULong ( )

Referenced by initFirstAdjacency().

136 {
137  // FIXME!!! Should come from a global unique number generator module.
138  return ddSequenceNumberInitSeed++;
139 }
static unsigned long ddSequenceNumberInitSeed
Definition: OSPFNeighbor.h:122
cMessage* inet::ospf::Neighbor::getUpdateRetransmissionTimer ( )
inline
189 { return updateRetransmissionTimer; }
cMessage * updateRetransmissionTimer
Definition: OSPFNeighbor.h:97
void inet::ospf::Neighbor::initFirstAdjacency ( )

Referenced by inet::ospf::NeighborStateInit::processEvent(), and inet::ospf::NeighborStateTwoWay::processEvent().

130 {
132  firstAdjacencyInited = true;
133 }
bool firstAdjacencyInited
Definition: OSPFNeighbor.h:102
unsigned long ddSequenceNumber
Definition: OSPFNeighbor.h:103
unsigned long getUniqueULong()
Definition: OSPFNeighbor.cc:135
bool inet::ospf::Neighbor::isFirstAdjacencyInited ( ) const
inline
bool inet::ospf::Neighbor::isLinkStateRequestListEmpty ( LSAKeyType  lsaKey) const

Referenced by inet::ospf::NeighborStateExchange::processEvent(), inet::ospf::DatabaseDescriptionHandler::processPacket(), and inet::ospf::LinkStateUpdateHandler::processPacket().

475 {
476  for (auto lsa : linkStateRetransmissionList) {
477  if ((lsa->getHeader().getLinkStateID() == lsaKey.linkStateID) &&
478  (lsa->getHeader().getAdvertisingRouter() == lsaKey.advertisingRouter))
479  {
480  return true;
481  }
482  }
483  return false;
484 }
std::list< OSPFLSA * > linkStateRetransmissionList
Definition: OSPFNeighbor.h:113
bool inet::ospf::Neighbor::isLinkStateRequestListEmpty ( ) const
inline
198 { return linkStateRequestList.empty(); }
std::list< OSPFLSAHeader * > linkStateRequestList
Definition: OSPFNeighbor.h:115
bool inet::ospf::Neighbor::isLinkStateRetransmissionListEmpty ( ) const
inline

Referenced by inet::ospf::LinkStateAcknowledgementHandler::processPacket().

199 { return linkStateRetransmissionList.empty(); }
std::list< OSPFLSA * > linkStateRetransmissionList
Definition: OSPFNeighbor.h:113
bool inet::ospf::Neighbor::isLSAOnRequestList ( LSAKeyType  lsaKey) const

Referenced by inet::ospf::LinkStateUpdateHandler::processPacket().

539 {
540  for (auto lsaHeader : linkStateRequestList) {
541  if ((lsaHeader->getLinkStateID() == lsaKey.linkStateID) &&
542  (lsaHeader->getAdvertisingRouter() == lsaKey.advertisingRouter))
543  {
544  return true;
545  }
546  }
547  return false;
548 }
std::list< OSPFLSAHeader * > linkStateRequestList
Definition: OSPFNeighbor.h:115
bool inet::ospf::Neighbor::isOnTransmittedLSAList ( LSAKeyType  lsaKey) const

Referenced by inet::ospf::LinkStateUpdateHandler::processPacket().

587 {
588  for (const auto & elem : transmittedLSAs) {
589  if ((elem.lsaKey.linkStateID == lsaKey.linkStateID) &&
590  (elem.lsaKey.advertisingRouter == lsaKey.advertisingRouter))
591  {
592  return true;
593  }
594  }
595  return false;
596 }
std::list< TransmittedLSA > transmittedLSAs
Definition: OSPFNeighbor.h:116
bool inet::ospf::Neighbor::isRequestRetransmissionTimerActive ( ) const
inline

Referenced by inet::ospf::DatabaseDescriptionHandler::processPacket().

bool requestRetransmissionTimerActive
Definition: OSPFNeighbor.h:100
bool inet::ospf::Neighbor::isUpdateRetransmissionTimerActive ( ) const
inline

Referenced by inet::ospf::Interface::floodLSA().

bool updateRetransmissionTimerActive
Definition: OSPFNeighbor.h:98
bool inet::ospf::Neighbor::needAdjacency ( )

Referenced by inet::ospf::NeighborStateExchange::processEvent(), inet::ospf::NeighborStateTwoWay::processEvent(), inet::ospf::NeighborStateLoading::processEvent(), inet::ospf::NeighborStateInit::processEvent(), inet::ospf::NeighborStateFull::processEvent(), and inet::ospf::NeighborStateExchangeStart::processEvent().

384 {
387  DesignatedRouterID dRouter = parentInterface->getDesignatedRouter();
388  DesignatedRouterID backupDRouter = parentInterface->getBackupDesignatedRouter();
389 
390  if ((interfaceType == Interface::POINTTOPOINT) ||
391  (interfaceType == Interface::POINTTOMULTIPOINT) ||
392  (interfaceType == Interface::VIRTUAL) ||
393  (dRouter.routerID == routerID) ||
394  (backupDRouter.routerID == routerID) ||
395  ((neighborsDesignatedRouter.routerID == dRouter.routerID) ||
397  (neighborsDesignatedRouter.ipInterfaceAddress == dRouter.ipInterfaceAddress))) ||
398  ((neighborsBackupDesignatedRouter.routerID == backupDRouter.routerID) ||
400  (neighborsBackupDesignatedRouter.ipInterfaceAddress == backupDRouter.ipInterfaceAddress))))
401  {
402  return true;
403  }
404  else {
405  return false;
406  }
407 }
IPv4Address ipInterfaceAddress
Definition: OSPFcommon.h:156
Definition: OSPFInterface.h:60
Router * getRouter()
Definition: OSPFArea.h:80
RouterID routerID
Definition: OSPFcommon.h:155
bool designatedRoutersSetUp
Definition: OSPFNeighbor.h:111
DesignatedRouterID neighborsDesignatedRouter
Definition: OSPFNeighbor.h:109
Definition: OSPFInterface.h:56
RouterID getRouterID() const
Definition: OSPFRouter.h:72
Interface * parentInterface
Definition: OSPFNeighbor.h:119
DesignatedRouterID getDesignatedRouter() const
Definition: OSPFInterface.h:167
DesignatedRouterID getBackupDesignatedRouter() const
Definition: OSPFInterface.h:168
DesignatedRouterID neighborsBackupDesignatedRouter
Definition: OSPFNeighbor.h:110
Definition: OSPFInterface.h:59
Area * getArea()
Definition: OSPFInterface.h:174
OSPFInterfaceType getType() const
Definition: OSPFInterface.h:132
IPv4Address RouterID
Definition: OSPFcommon.h:137
OSPFInterfaceType
Definition: OSPFInterface.h:54
void inet::ospf::Neighbor::popFirstLinkStateRequest ( )
inline
200 { linkStateRequestList.pop_front(); }
std::list< OSPFLSAHeader * > linkStateRequestList
Definition: OSPFNeighbor.h:115
void inet::ospf::Neighbor::removeFromRequestList ( LSAKeyType  lsaKey)
518 {
519  auto it = linkStateRequestList.begin();
520  while (it != linkStateRequestList.end()) {
521  if (((*it)->getLinkStateID() == lsaKey.linkStateID) &&
522  ((*it)->getAdvertisingRouter() == lsaKey.advertisingRouter))
523  {
524  delete (*it);
525  it = linkStateRequestList.erase(it);
526  }
527  else {
528  it++;
529  }
530  }
531 
532  if ((getState() == Neighbor::LOADING_STATE) && (linkStateRequestList.empty())) {
535  }
536 }
void processEvent(NeighborEventType event)
Definition: OSPFNeighbor.cc:97
void clearRequestRetransmissionTimer()
Definition: OSPFNeighbor.cc:569
std::list< OSPFLSAHeader * > linkStateRequestList
Definition: OSPFNeighbor.h:115
Definition: OSPFNeighbor.h:68
Definition: OSPFNeighbor.h:48
NeighborStateType getState() const
Definition: OSPFNeighbor.cc:141
void inet::ospf::Neighbor::removeFromRetransmissionList ( LSAKeyType  lsaKey)

Referenced by inet::ospf::LinkStateAcknowledgementHandler::processPacket(), and inet::ospf::LinkStateUpdateHandler::processPacket().

459 {
460  auto it = linkStateRetransmissionList.begin();
461  while (it != linkStateRetransmissionList.end()) {
462  if (((*it)->getHeader().getLinkStateID() == lsaKey.linkStateID) &&
463  ((*it)->getHeader().getAdvertisingRouter() == lsaKey.advertisingRouter))
464  {
465  delete (*it);
466  it = linkStateRetransmissionList.erase(it);
467  }
468  else {
469  it++;
470  }
471  }
472 }
std::list< OSPFLSA * > linkStateRetransmissionList
Definition: OSPFNeighbor.h:113
void inet::ospf::Neighbor::reset ( )

Referenced by inet::ospf::NeighborStateAttempt::processEvent(), inet::ospf::NeighborStateExchangeStart::processEvent(), inet::ospf::NeighborStateLoading::processEvent(), inet::ospf::NeighborStateInit::processEvent(), inet::ospf::NeighborStateFull::processEvent(), inet::ospf::NeighborStateTwoWay::processEvent(), inet::ospf::NeighborStateExchange::processEvent(), and ~Neighbor().

103 {
104  for (auto & elem : linkStateRetransmissionList)
105  {
106  delete (elem);
107  }
108  linkStateRetransmissionList.clear();
109 
110  for (auto & elem : databaseSummaryList) {
111  delete (elem);
112  }
113  databaseSummaryList.clear();
114  for (auto & elem : linkStateRequestList) {
115  delete (elem);
116  }
117  linkStateRequestList.clear();
118 
122 
123  if (lastTransmittedDDPacket != nullptr) {
125  lastTransmittedDDPacket = nullptr;
126  }
127 }
Router * getRouter()
Definition: OSPFArea.h:80
void clearUpdateRetransmissionTimer()
Definition: OSPFNeighbor.cc:505
void clearRequestRetransmissionTimer()
Definition: OSPFNeighbor.cc:569
std::list< OSPFLSAHeader * > linkStateRequestList
Definition: OSPFNeighbor.h:115
Interface * parentInterface
Definition: OSPFNeighbor.h:119
Area * getArea()
Definition: OSPFInterface.h:174
std::list< OSPFLSA * > linkStateRetransmissionList
Definition: OSPFNeighbor.h:113
void clearTimer(cMessage *timer)
Definition: MessageHandler.cc:367
std::list< OSPFLSAHeader * > databaseSummaryList
Definition: OSPFNeighbor.h:114
OSPFDatabaseDescriptionPacket * lastTransmittedDDPacket
Definition: OSPFNeighbor.h:117
MessageHandler * getMessageHandler()
Definition: OSPFRouter.h:77
cMessage * ddRetransmissionTimer
Definition: OSPFNeighbor.h:96
bool inet::ospf::Neighbor::retransmitDatabaseDescriptionPacket ( )

Referenced by inet::ospf::NeighborStateExchangeStart::processEvent(), and inet::ospf::DatabaseDescriptionHandler::processPacket().

261 {
262  if (lastTransmittedDDPacket != nullptr) {
263  OSPFDatabaseDescriptionPacket *ddPacket = new OSPFDatabaseDescriptionPacket(*lastTransmittedDDPacket);
264  MessageHandler *messageHandler = parentInterface->getArea()->getRouter()->getMessageHandler();
266 
268  messageHandler->sendPacket(ddPacket, IPv4Address::ALL_OSPF_ROUTERS_MCAST, parentInterface->getIfIndex(), ttl);
269  }
270  else {
271  messageHandler->sendPacket(ddPacket, neighborIPAddress, parentInterface->getIfIndex(), ttl);
272  }
273 
274  return true;
275  }
276  else {
277  return false;
278  }
279 }
#define VIRTUAL_LINK_TTL
Definition: OSPFcommon.h:45
Definition: OSPFInterface.h:60
Router * getRouter()
Definition: OSPFArea.h:80
Definition: OSPFInterface.h:56
Interface * parentInterface
Definition: OSPFNeighbor.h:119
int getIfIndex() const
Definition: OSPFInterface.h:134
Area * getArea()
Definition: OSPFInterface.h:174
OSPFInterfaceType getType() const
Definition: OSPFInterface.h:132
OSPFDatabaseDescriptionPacket * lastTransmittedDDPacket
Definition: OSPFNeighbor.h:117
MessageHandler * getMessageHandler()
Definition: OSPFRouter.h:77
IPv4Address neighborIPAddress
Definition: OSPFNeighbor.h:107
uint8_t ttl
Definition: TCP_NSC.cc:87
static const IPv4Address ALL_OSPF_ROUTERS_MCAST
224.0.0.5 All OSPF routers (DR Others)
Definition: IPv4Address.h:110
void inet::ospf::Neighbor::retransmitUpdatePacket ( )

Referenced by inet::ospf::NeighborStateExchange::processEvent(), inet::ospf::NeighborStateLoading::processEvent(), and inet::ospf::NeighborStateFull::processEvent().

611 {
612  OSPFLinkStateUpdatePacket *updatePacket = new OSPFLinkStateUpdatePacket();
613 
614  updatePacket->setType(LINKSTATE_UPDATE_PACKET);
615  updatePacket->setRouterID(IPv4Address(parentInterface->getArea()->getRouter()->getRouterID()));
616  updatePacket->setAreaID(IPv4Address(parentInterface->getArea()->getAreaID()));
617  updatePacket->setAuthenticationType(parentInterface->getAuthenticationType());
618  AuthenticationKeyType authKey = parentInterface->getAuthenticationKey();
619  for (int i = 0; i < 8; i++) {
620  updatePacket->setAuthentication(i, authKey.bytes[i]);
621  }
622 
623  bool packetFull = false;
624  unsigned short lsaCount = 0;
625  unsigned long packetLength = IP_MAX_HEADER_BYTES + OSPF_LSA_HEADER_LENGTH;
626  auto it = linkStateRetransmissionList.begin();
627 
628  while (!packetFull && (it != linkStateRetransmissionList.end())) {
629  LSAType lsaType = static_cast<LSAType>((*it)->getHeader().getLsType());
630  OSPFRouterLSA *routerLSA = (lsaType == ROUTERLSA_TYPE) ? dynamic_cast<OSPFRouterLSA *>(*it) : nullptr;
631  OSPFNetworkLSA *networkLSA = (lsaType == NETWORKLSA_TYPE) ? dynamic_cast<OSPFNetworkLSA *>(*it) : nullptr;
632  OSPFSummaryLSA *summaryLSA = ((lsaType == SUMMARYLSA_NETWORKS_TYPE) ||
633  (lsaType == SUMMARYLSA_ASBOUNDARYROUTERS_TYPE)) ? dynamic_cast<OSPFSummaryLSA *>(*it) : nullptr;
634  OSPFASExternalLSA *asExternalLSA = (lsaType == AS_EXTERNAL_LSA_TYPE) ? dynamic_cast<OSPFASExternalLSA *>(*it) : nullptr;
635  long lsaSize = 0;
636  bool includeLSA = false;
637 
638  switch (lsaType) {
639  case ROUTERLSA_TYPE:
640  if (routerLSA != nullptr) {
641  lsaSize = calculateLSASize(routerLSA);
642  }
643  break;
644 
645  case NETWORKLSA_TYPE:
646  if (networkLSA != nullptr) {
647  lsaSize = calculateLSASize(networkLSA);
648  }
649  break;
650 
653  if (summaryLSA != nullptr) {
654  lsaSize = calculateLSASize(summaryLSA);
655  }
656  break;
657 
659  if (asExternalLSA != nullptr) {
660  lsaSize = calculateLSASize(asExternalLSA);
661  }
662  break;
663 
664  default:
665  break;
666  }
667 
668  if (packetLength + lsaSize < parentInterface->getMTU()) {
669  includeLSA = true;
670  lsaCount++;
671  }
672  else {
673  if ((lsaCount == 0) && (packetLength + lsaSize < IPV4_DATAGRAM_LENGTH)) {
674  includeLSA = true;
675  lsaCount++;
676  packetFull = true;
677  }
678  }
679 
680  if (includeLSA) {
681  packetLength += lsaSize;
682  switch (lsaType) {
683  case ROUTERLSA_TYPE:
684  if (routerLSA != nullptr) {
685  unsigned int routerLSACount = updatePacket->getRouterLSAsArraySize();
686 
687  updatePacket->setRouterLSAsArraySize(routerLSACount + 1);
688  updatePacket->setRouterLSAs(routerLSACount, *routerLSA);
689 
690  unsigned short lsAge = updatePacket->getRouterLSAs(routerLSACount).getHeader().getLsAge();
691  if (lsAge < MAX_AGE - parentInterface->getTransmissionDelay()) {
692  updatePacket->getRouterLSAs(routerLSACount).getHeader().setLsAge(lsAge + parentInterface->getTransmissionDelay());
693  }
694  else {
695  updatePacket->getRouterLSAs(routerLSACount).getHeader().setLsAge(MAX_AGE);
696  }
697  }
698  break;
699 
700  case NETWORKLSA_TYPE:
701  if (networkLSA != nullptr) {
702  unsigned int networkLSACount = updatePacket->getNetworkLSAsArraySize();
703 
704  updatePacket->setNetworkLSAsArraySize(networkLSACount + 1);
705  updatePacket->setNetworkLSAs(networkLSACount, *networkLSA);
706 
707  unsigned short lsAge = updatePacket->getNetworkLSAs(networkLSACount).getHeader().getLsAge();
708  if (lsAge < MAX_AGE - parentInterface->getTransmissionDelay()) {
709  updatePacket->getNetworkLSAs(networkLSACount).getHeader().setLsAge(lsAge + parentInterface->getTransmissionDelay());
710  }
711  else {
712  updatePacket->getNetworkLSAs(networkLSACount).getHeader().setLsAge(MAX_AGE);
713  }
714  }
715  break;
716 
719  if (summaryLSA != nullptr) {
720  unsigned int summaryLSACount = updatePacket->getSummaryLSAsArraySize();
721 
722  updatePacket->setSummaryLSAsArraySize(summaryLSACount + 1);
723  updatePacket->setSummaryLSAs(summaryLSACount, *summaryLSA);
724 
725  unsigned short lsAge = updatePacket->getSummaryLSAs(summaryLSACount).getHeader().getLsAge();
726  if (lsAge < MAX_AGE - parentInterface->getTransmissionDelay()) {
727  updatePacket->getSummaryLSAs(summaryLSACount).getHeader().setLsAge(lsAge + parentInterface->getTransmissionDelay());
728  }
729  else {
730  updatePacket->getSummaryLSAs(summaryLSACount).getHeader().setLsAge(MAX_AGE);
731  }
732  }
733  break;
734 
736  if (asExternalLSA != nullptr) {
737  unsigned int asExternalLSACount = updatePacket->getAsExternalLSAsArraySize();
738 
739  updatePacket->setAsExternalLSAsArraySize(asExternalLSACount + 1);
740  updatePacket->setAsExternalLSAs(asExternalLSACount, *asExternalLSA);
741 
742  unsigned short lsAge = updatePacket->getAsExternalLSAs(asExternalLSACount).getHeader().getLsAge();
743  if (lsAge < MAX_AGE - parentInterface->getTransmissionDelay()) {
744  updatePacket->getAsExternalLSAs(asExternalLSACount).getHeader().setLsAge(lsAge + parentInterface->getTransmissionDelay());
745  }
746  else {
747  updatePacket->getAsExternalLSAs(asExternalLSACount).getHeader().setLsAge(MAX_AGE);
748  }
749  }
750  break;
751 
752  default:
753  break;
754  }
755  }
756 
757  it++;
758  }
759 
760  updatePacket->setByteLength(packetLength - IP_MAX_HEADER_BYTES);
761 
762  MessageHandler *messageHandler = parentInterface->getArea()->getRouter()->getMessageHandler();
764  messageHandler->sendPacket(updatePacket, neighborIPAddress, parentInterface->getIfIndex(), ttl);
765 }
#define VIRTUAL_LINK_TTL
Definition: OSPFcommon.h:45
Definition: OSPFInterface.h:60
Router * getRouter()
Definition: OSPFArea.h:80
short getTransmissionDelay() const
Definition: OSPFInterface.h:146
unsigned int calculateLSASize(const OSPFRouterLSA *routerLSA)
Definition: LSA.cc:77
RouterID getRouterID() const
Definition: OSPFRouter.h:72
AreaID getAreaID() const
Definition: OSPFArea.h:64
AuthenticationKeyType getAuthenticationKey() const
Definition: OSPFInterface.h:160
Interface * parentInterface
Definition: OSPFNeighbor.h:119
const int IP_MAX_HEADER_BYTES
Definition: IPv4Datagram_m.h:44
Definition: OSPFPacket_m.h:246
int getIfIndex() const
Definition: OSPFInterface.h:134
#define IPV4_DATAGRAM_LENGTH
Definition: OSPFcommon.h:47
#define MAX_AGE
Definition: OSPFcommon.h:36
Area * getArea()
Definition: OSPFInterface.h:174
#define OSPF_LSA_HEADER_LENGTH
Definition: OSPFcommon.h:49
std::list< OSPFLSA * > linkStateRetransmissionList
Definition: OSPFNeighbor.h:113
Definition: OSPFPacket_m.h:245
LSAType
Enum generated from inet/routing/ospfv2/OSPFPacket.msg:84 by nedtool.
Definition: OSPFPacket_m.h:244
AuthenticationType getAuthenticationType() const
Definition: OSPFInterface.h:158
Definition: OSPFPacket_m.h:249
OSPFInterfaceType getType() const
Definition: OSPFInterface.h:132
Definition: OSPFPacket_m.h:56
MessageHandler * getMessageHandler()
Definition: OSPFRouter.h:77
IPv4Address neighborIPAddress
Definition: OSPFNeighbor.h:107
Definition: OSPFPacket_m.h:247
uint8_t ttl
Definition: TCP_NSC.cc:87
Definition: OSPFPacket_m.h:248
void inet::ospf::Neighbor::sendDatabaseDescriptionPacket ( bool  init = false)

Referenced by inet::ospf::DatabaseDescriptionHandler::processDDPacket(), inet::ospf::NeighborStateExchangeStart::processEvent(), inet::ospf::NeighborStateLoading::processEvent(), inet::ospf::NeighborStateInit::processEvent(), inet::ospf::NeighborStateFull::processEvent(), inet::ospf::NeighborStateTwoWay::processEvent(), inet::ospf::NeighborStateExchange::processEvent(), and inet::ospf::DatabaseDescriptionHandler::processPacket().

181 {
182  OSPFDatabaseDescriptionPacket *ddPacket = new OSPFDatabaseDescriptionPacket();
183 
184  ddPacket->setType(DATABASE_DESCRIPTION_PACKET);
185  ddPacket->setRouterID(IPv4Address(parentInterface->getArea()->getRouter()->getRouterID()));
186  ddPacket->setAreaID(IPv4Address(parentInterface->getArea()->getAreaID()));
187  ddPacket->setAuthenticationType(parentInterface->getAuthenticationType());
188  AuthenticationKeyType authKey = parentInterface->getAuthenticationKey();
189  for (int i = 0; i < 8; i++) {
190  ddPacket->setAuthentication(i, authKey.bytes[i]);
191  }
192 
194  ddPacket->setInterfaceMTU(parentInterface->getMTU());
195  }
196  else {
197  ddPacket->setInterfaceMTU(0);
198  }
199 
200  OSPFOptions options;
201  memset(&options, 0, sizeof(OSPFOptions));
202  options.E_ExternalRoutingCapability = parentInterface->getArea()->getExternalRoutingCapability();
203  ddPacket->setOptions(options);
204 
205  ddPacket->setDdSequenceNumber(ddSequenceNumber);
206 
210  long packetSize = OSPF_HEADER_LENGTH + OSPF_DD_HEADER_LENGTH;
211 
212  if (init || databaseSummaryList.empty()) {
213  ddPacket->setLsaHeadersArraySize(0);
214  }
215  else {
216  // delete included LSAs from summary list
217  // (they are still in lastTransmittedDDPacket)
218  while ((!databaseSummaryList.empty()) && (packetSize <= (maxPacketSize - OSPF_LSA_HEADER_LENGTH))) {
219  unsigned long headerCount = ddPacket->getLsaHeadersArraySize();
220  OSPFLSAHeader *lsaHeader = *(databaseSummaryList.begin());
221  ddPacket->setLsaHeadersArraySize(headerCount + 1);
222  ddPacket->setLsaHeaders(headerCount, *lsaHeader);
223  delete lsaHeader;
224  databaseSummaryList.pop_front();
225  packetSize += OSPF_LSA_HEADER_LENGTH;
226  }
227  }
228 
229  OSPFDDOptions ddOptions;
230  memset(&ddOptions, 0, sizeof(OSPFDDOptions));
231  if (init) {
232  ddOptions.I_Init = true;
233  ddOptions.M_More = true;
234  ddOptions.MS_MasterSlave = true;
235  }
236  else {
237  ddOptions.I_Init = false;
238  ddOptions.M_More = (databaseSummaryList.empty()) ? false : true;
239  ddOptions.MS_MasterSlave = (databaseExchangeRelationship == Neighbor::MASTER) ? true : false;
240  }
241  ddPacket->setDdOptions(ddOptions);
242 
243  ddPacket->setByteLength(packetSize);
244 
245  MessageHandler *messageHandler = parentInterface->getArea()->getRouter()->getMessageHandler();
247 
248  if (lastTransmittedDDPacket != nullptr)
250  lastTransmittedDDPacket = ddPacket->dup();
251 
253  messageHandler->sendPacket(ddPacket, IPv4Address::ALL_OSPF_ROUTERS_MCAST, parentInterface->getIfIndex(), ttl);
254  }
255  else {
256  messageHandler->sendPacket(ddPacket, neighborIPAddress, parentInterface->getIfIndex(), ttl);
257  }
258 }
#define VIRTUAL_LINK_TTL
Definition: OSPFcommon.h:45
#define OSPF_DD_HEADER_LENGTH
Definition: OSPFcommon.h:51
unsigned short getMTU() const
Definition: OSPFInterface.h:136
Definition: OSPFInterface.h:60
Router * getRouter()
Definition: OSPFArea.h:80
Definition: OSPFPacket_m.h:54
Definition: OSPFInterface.h:56
RouterID getRouterID() const
Definition: OSPFRouter.h:72
AreaID getAreaID() const
Definition: OSPFArea.h:64
AuthenticationKeyType getAuthenticationKey() const
Definition: OSPFInterface.h:160
Interface * parentInterface
Definition: OSPFNeighbor.h:119
const int IP_MAX_HEADER_BYTES
Definition: IPv4Datagram_m.h:44
int getIfIndex() const
Definition: OSPFInterface.h:134
#define IPV4_DATAGRAM_LENGTH
Definition: OSPFcommon.h:47
unsigned long ddSequenceNumber
Definition: OSPFNeighbor.h:103
Area * getArea()
Definition: OSPFInterface.h:174
#define OSPF_LSA_HEADER_LENGTH
Definition: OSPFcommon.h:49
AuthenticationType getAuthenticationType() const
Definition: OSPFInterface.h:158
OSPFInterfaceType getType() const
Definition: OSPFInterface.h:132
#define OSPF_HEADER_LENGTH
Definition: OSPFcommon.h:48
std::list< OSPFLSAHeader * > databaseSummaryList
Definition: OSPFNeighbor.h:114
DatabaseExchangeRelationshipType databaseExchangeRelationship
Definition: OSPFNeighbor.h:101
Definition: OSPFNeighbor.h:73
OSPFDatabaseDescriptionPacket * lastTransmittedDDPacket
Definition: OSPFNeighbor.h:117
MessageHandler * getMessageHandler()
Definition: OSPFRouter.h:77
IPv4Address neighborIPAddress
Definition: OSPFNeighbor.h:107
virtual OSPFDatabaseDescriptionPacket * dup() const override
Definition: OSPFPacket_m.h:816
bool getExternalRoutingCapability() const
Definition: OSPFArea.h:72
uint8_t ttl
Definition: TCP_NSC.cc:87
static const IPv4Address ALL_OSPF_ROUTERS_MCAST
224.0.0.5 All OSPF routers (DR Others)
Definition: IPv4Address.h:110
void inet::ospf::Neighbor::sendLinkStateRequestPacket ( )

Referenced by inet::ospf::NeighborStateExchange::processEvent(), inet::ospf::NeighborStateLoading::processEvent(), and inet::ospf::DatabaseDescriptionHandler::processPacket().

331 {
332  OSPFLinkStateRequestPacket *requestPacket = new OSPFLinkStateRequestPacket();
333 
334  requestPacket->setType(LINKSTATE_REQUEST_PACKET);
335  requestPacket->setRouterID(IPv4Address(parentInterface->getArea()->getRouter()->getRouterID()));
336  requestPacket->setAreaID(IPv4Address(parentInterface->getArea()->getAreaID()));
337  requestPacket->setAuthenticationType(parentInterface->getAuthenticationType());
338  AuthenticationKeyType authKey = parentInterface->getAuthenticationKey();
339  for (int i = 0; i < 8; i++) {
340  requestPacket->setAuthentication(i, authKey.bytes[i]);
341  }
342 
346  long packetSize = OSPF_HEADER_LENGTH;
347 
348  if (linkStateRequestList.empty()) {
349  requestPacket->setRequestsArraySize(0);
350  }
351  else {
352  auto it = linkStateRequestList.begin();
353 
354  while ((it != linkStateRequestList.end()) && (packetSize <= (maxPacketSize - OSPF_REQUEST_LENGTH))) {
355  unsigned long requestCount = requestPacket->getRequestsArraySize();
356  OSPFLSAHeader *requestHeader = (*it);
357  LSARequest request;
358 
359  request.lsType = requestHeader->getLsType();
360  request.linkStateID = requestHeader->getLinkStateID();
361  request.advertisingRouter = requestHeader->getAdvertisingRouter();
362 
363  requestPacket->setRequestsArraySize(requestCount + 1);
364  requestPacket->setRequests(requestCount, request);
365 
366  packetSize += OSPF_REQUEST_LENGTH;
367  it++;
368  }
369  }
370 
371  requestPacket->setByteLength(packetSize);
372 
373  MessageHandler *messageHandler = parentInterface->getArea()->getRouter()->getMessageHandler();
376  messageHandler->sendPacket(requestPacket, IPv4Address::ALL_OSPF_ROUTERS_MCAST, parentInterface->getIfIndex(), ttl);
377  }
378  else {
379  messageHandler->sendPacket(requestPacket, neighborIPAddress, parentInterface->getIfIndex(), ttl);
380  }
381 }
#define VIRTUAL_LINK_TTL
Definition: OSPFcommon.h:45
unsigned short getMTU() const
Definition: OSPFInterface.h:136
Definition: OSPFInterface.h:60
Router * getRouter()
Definition: OSPFArea.h:80
#define OSPF_REQUEST_LENGTH
Definition: OSPFcommon.h:52
Definition: OSPFInterface.h:56
RouterID getRouterID() const
Definition: OSPFRouter.h:72
AreaID getAreaID() const
Definition: OSPFArea.h:64
Definition: OSPFPacket_m.h:55
AuthenticationKeyType getAuthenticationKey() const
Definition: OSPFInterface.h:160
std::list< OSPFLSAHeader * > linkStateRequestList
Definition: OSPFNeighbor.h:115
Interface * parentInterface
Definition: OSPFNeighbor.h:119
const int IP_MAX_HEADER_BYTES
Definition: IPv4Datagram_m.h:44
int getIfIndex() const
Definition: OSPFInterface.h:134
#define IPV4_DATAGRAM_LENGTH
Definition: OSPFcommon.h:47
Area * getArea()
Definition: OSPFInterface.h:174
AuthenticationType getAuthenticationType() const
Definition: OSPFInterface.h:158
OSPFInterfaceType getType() const
Definition: OSPFInterface.h:132
#define OSPF_HEADER_LENGTH
Definition: OSPFcommon.h:48
MessageHandler * getMessageHandler()
Definition: OSPFRouter.h:77
IPv4Address neighborIPAddress
Definition: OSPFNeighbor.h:107
uint8_t ttl
Definition: TCP_NSC.cc:87
static const IPv4Address ALL_OSPF_ROUTERS_MCAST
224.0.0.5 All OSPF routers (DR Others)
Definition: IPv4Address.h:110
void inet::ospf::Neighbor::setAddress ( IPv4Address  address)
inline
void inet::ospf::Neighbor::setBackupDesignatedRouter ( DesignatedRouterID  routerID)
inline

Referenced by inet::ospf::HelloHandler::processPacket().

168 { neighborsBackupDesignatedRouter = routerID; }
DesignatedRouterID neighborsBackupDesignatedRouter
Definition: OSPFNeighbor.h:110
void inet::ospf::Neighbor::setDatabaseExchangeRelationship ( DatabaseExchangeRelationshipType  relation)
inline

Referenced by inet::ospf::DatabaseDescriptionHandler::processPacket().

179 { databaseExchangeRelationship = relation; }
DatabaseExchangeRelationshipType databaseExchangeRelationship
Definition: OSPFNeighbor.h:101
void inet::ospf::Neighbor::setDDSequenceNumber ( unsigned long  sequenceNumber)
inline

Referenced by inet::ospf::DatabaseDescriptionHandler::processDDPacket(), and inet::ospf::DatabaseDescriptionHandler::processPacket().

172 { ddSequenceNumber = sequenceNumber; }
unsigned long ddSequenceNumber
Definition: OSPFNeighbor.h:103
void inet::ospf::Neighbor::setDesignatedRouter ( DesignatedRouterID  routerID)
inline

Referenced by inet::ospf::HelloHandler::processPacket().

166 { neighborsDesignatedRouter = routerID; }
DesignatedRouterID neighborsDesignatedRouter
Definition: OSPFNeighbor.h:109
void inet::ospf::Neighbor::setInterface ( Interface intf)
inline

Referenced by inet::ospf::Interface::addNeighbor().

182 { parentInterface = intf; }
Interface * parentInterface
Definition: OSPFNeighbor.h:119
void inet::ospf::Neighbor::setLastReceivedDDPacket ( DDPacketID  packetID)
inline

Referenced by inet::ospf::DatabaseDescriptionHandler::processPacket().

176 { lastReceivedDDPacket = packetID; }
DDPacketID lastReceivedDDPacket
Definition: OSPFNeighbor.h:104
void inet::ospf::Neighbor::setNeighborID ( RouterID  id)
inline

Referenced by inet::ospf::OSPFConfigReader::loadVirtualLink(), and inet::ospf::HelloHandler::processPacket().

160 { neighborID = id; }
RouterID neighborID
Definition: OSPFNeighbor.h:105
uint16_t id
Definition: TCP_NSC.cc:85
void inet::ospf::Neighbor::setOptions ( OSPFOptions  options)
inline

Referenced by inet::ospf::DatabaseDescriptionHandler::processPacket().

174 { neighborOptions = options; }
OSPFOptions neighborOptions
Definition: OSPFNeighbor.h:108
void inet::ospf::Neighbor::setPriority ( unsigned char  priority)
inline

Referenced by inet::ospf::OSPFConfigReader::loadInterfaceParameters(), and inet::ospf::HelloHandler::processPacket().

162 { neighborPriority = priority; }
unsigned char neighborPriority
Definition: OSPFNeighbor.h:106
void inet::ospf::Neighbor::setRouterDeadInterval ( short  interval)
inline

Referenced by inet::ospf::HelloHandler::processPacket().

170 { neighborsRouterDeadInterval = interval; }
short neighborsRouterDeadInterval
Definition: OSPFNeighbor.h:112
void inet::ospf::Neighbor::setupDesignatedRouters ( bool  setUp)
inline

Referenced by inet::ospf::HelloHandler::processPacket().

194 { designatedRoutersSetUp = setUp; }
bool designatedRoutersSetUp
Definition: OSPFNeighbor.h:111
void inet::ospf::Neighbor::startRequestRetransmissionTimer ( )

Referenced by inet::ospf::NeighborStateExchange::processEvent(), inet::ospf::NeighborStateLoading::processEvent(), and inet::ospf::DatabaseDescriptionHandler::processPacket().

563 {
564  MessageHandler *messageHandler = parentInterface->getArea()->getRouter()->getMessageHandler();
567 }
short getRetransmissionInterval() const
Definition: OSPFInterface.h:144
cMessage * requestRetransmissionTimer
Definition: OSPFNeighbor.h:99
Router * getRouter()
Definition: OSPFArea.h:80
void startTimer(cMessage *timer, simtime_t delay)
Definition: MessageHandler.cc:372
Interface * parentInterface
Definition: OSPFNeighbor.h:119
Area * getArea()
Definition: OSPFInterface.h:174
bool requestRetransmissionTimerActive
Definition: OSPFNeighbor.h:100
MessageHandler * getMessageHandler()
Definition: OSPFRouter.h:77
void inet::ospf::Neighbor::startUpdateRetransmissionTimer ( )

Referenced by inet::ospf::Interface::floodLSA(), inet::ospf::NeighborStateLoading::processEvent(), inet::ospf::NeighborStateFull::processEvent(), and inet::ospf::NeighborStateExchange::processEvent().

499 {
500  MessageHandler *messageHandler = parentInterface->getArea()->getRouter()->getMessageHandler();
503 }
short getRetransmissionInterval() const
Definition: OSPFInterface.h:144
bool updateRetransmissionTimerActive
Definition: OSPFNeighbor.h:98
Router * getRouter()
Definition: OSPFArea.h:80
void startTimer(cMessage *timer, simtime_t delay)
Definition: MessageHandler.cc:372
Interface * parentInterface
Definition: OSPFNeighbor.h:119
cMessage * updateRetransmissionTimer
Definition: OSPFNeighbor.h:97
Area * getArea()
Definition: OSPFInterface.h:174
MessageHandler * getMessageHandler()
Definition: OSPFRouter.h:77

Friends And Related Function Documentation

friend class NeighborState
friend

Member Data Documentation

DatabaseExchangeRelationshipType inet::ospf::Neighbor::databaseExchangeRelationship = (DatabaseExchangeRelationshipType)-1
private
std::list<OSPFLSAHeader *> inet::ospf::Neighbor::databaseSummaryList
private
cMessage* inet::ospf::Neighbor::ddRetransmissionTimer = nullptr
private

Referenced by Neighbor(), reset(), and ~Neighbor().

unsigned long inet::ospf::Neighbor::ddSequenceNumber = 0
private
unsigned long inet::ospf::Neighbor::ddSequenceNumberInitSeed = 0
staticprivate

Referenced by getUniqueULong().

bool inet::ospf::Neighbor::designatedRoutersSetUp = false
private

Referenced by needAdjacency().

bool inet::ospf::Neighbor::firstAdjacencyInited = false
private

Referenced by initFirstAdjacency().

cMessage* inet::ospf::Neighbor::inactivityTimer = nullptr
private

Referenced by Neighbor(), and ~Neighbor().

DDPacketID inet::ospf::Neighbor::lastReceivedDDPacket
private

Referenced by Neighbor().

OSPFDatabaseDescriptionPacket* inet::ospf::Neighbor::lastTransmittedDDPacket = nullptr
private
std::list<OSPFLSAHeader *> inet::ospf::Neighbor::linkStateRequestList
private
std::list<OSPFLSA *> inet::ospf::Neighbor::linkStateRetransmissionList
private
RouterID inet::ospf::Neighbor::neighborID
private
OSPFOptions inet::ospf::Neighbor::neighborOptions
private
unsigned char inet::ospf::Neighbor::neighborPriority = 0
private
DesignatedRouterID inet::ospf::Neighbor::neighborsBackupDesignatedRouter
private

Referenced by needAdjacency().

DesignatedRouterID inet::ospf::Neighbor::neighborsDesignatedRouter
private

Referenced by needAdjacency().

short inet::ospf::Neighbor::neighborsRouterDeadInterval = 0
private
cMessage* inet::ospf::Neighbor::pollTimer = nullptr
private

Referenced by Neighbor(), and ~Neighbor().

NeighborState* inet::ospf::Neighbor::previousState = nullptr
private

Referenced by changeState(), Neighbor(), and ~Neighbor().

cMessage* inet::ospf::Neighbor::requestRetransmissionTimer = nullptr
private
bool inet::ospf::Neighbor::requestRetransmissionTimerActive = false
private
NeighborState* inet::ospf::Neighbor::state = nullptr
private
std::list<TransmittedLSA> inet::ospf::Neighbor::transmittedLSAs
private
cMessage* inet::ospf::Neighbor::updateRetransmissionTimer = nullptr
private
bool inet::ospf::Neighbor::updateRetransmissionTimerActive = false
private

The documentation for this class was generated from the following files: