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

#include <OSPFInterface.h>

Public Types

enum  InterfaceEventType {
  INTERFACE_UP = 0, HELLO_TIMER = 1, WAIT_TIMER = 2, ACKNOWLEDGEMENT_TIMER = 3,
  BACKUP_SEEN = 4, NEIGHBOR_CHANGE = 5, LOOP_INDICATION = 6, UNLOOP_INDICATION = 7,
  INTERFACE_DOWN = 8
}
 
enum  OSPFInterfaceType {
  UNKNOWN_TYPE = 0, POINTTOPOINT = 1, BROADCAST = 2, NBMA = 3,
  POINTTOMULTIPOINT = 4, VIRTUAL = 5
}
 
enum  InterfaceStateType {
  DOWN_STATE = 0, LOOPBACK_STATE = 1, WAITING_STATE = 2, POINTTOPOINT_STATE = 3,
  NOT_DESIGNATED_ROUTER_STATE = 4, BACKUP_STATE = 5, DESIGNATED_ROUTER_STATE = 6
}
 

Public Member Functions

 Interface (OSPFInterfaceType ifType=UNKNOWN_TYPE)
 
virtual ~Interface ()
 
void processEvent (InterfaceEventType event)
 
void reset ()
 
void sendHelloPacket (IPv4Address destination, short ttl=1)
 
void sendLSAcknowledgement (OSPFLSAHeader *lsaHeader, IPv4Address destination)
 
NeighborgetNeighborByID (RouterID neighborID)
 
NeighborgetNeighborByAddress (IPv4Address address)
 
void addNeighbor (Neighbor *neighbor)
 
InterfaceStateType getState () const
 
bool hasAnyNeighborInStates (int states) const
 
void removeFromAllRetransmissionLists (LSAKeyType lsaKey)
 
bool isOnAnyRetransmissionList (LSAKeyType lsaKey) const
 
bool floodLSA (OSPFLSA *lsa, Interface *intf=nullptr, Neighbor *neighbor=nullptr)
 
void addDelayedAcknowledgement (OSPFLSAHeader &lsaHeader)
 
void sendDelayedAcknowledgements ()
 
void ageTransmittedLSALists ()
 
OSPFLinkStateUpdatePacketcreateUpdatePacket (OSPFLSA *lsa)
 
void setType (OSPFInterfaceType ifType)
 
OSPFInterfaceType getType () const
 
void setIfIndex (IInterfaceTable *ift, int index)
 
int getIfIndex () const
 
void setMTU (unsigned short ifMTU)
 
unsigned short getMTU () const
 
void setAreaID (AreaID areaId)
 
AreaID getAreaID () const
 
void setTransitAreaID (AreaID areaId)
 
AreaID getTransitAreaID () const
 
void setOutputCost (Metric cost)
 
Metric getOutputCost () const
 
void setRetransmissionInterval (short interval)
 
short getRetransmissionInterval () const
 
void setTransmissionDelay (short delay)
 
short getTransmissionDelay () const
 
void setAcknowledgementDelay (short delay)
 
short getAcknowledgementDelay () const
 
void setRouterPriority (unsigned char priority)
 
unsigned char getRouterPriority () const
 
void setHelloInterval (short interval)
 
short getHelloInterval () const
 
void setPollInterval (short interval)
 
short getPollInterval () const
 
void setRouterDeadInterval (short interval)
 
short getRouterDeadInterval () const
 
void setAuthenticationType (AuthenticationType type)
 
AuthenticationType getAuthenticationType () const
 
void setAuthenticationKey (AuthenticationKeyType key)
 
AuthenticationKeyType getAuthenticationKey () const
 
void setAddressRange (IPv4AddressRange range)
 
IPv4AddressRange getAddressRange () const
 
cMessage * getHelloTimer ()
 
cMessage * getWaitTimer ()
 
cMessage * getAcknowledgementTimer ()
 
DesignatedRouterID getDesignatedRouter () const
 
DesignatedRouterID getBackupDesignatedRouter () const
 
unsigned long getNeighborCount () const
 
NeighborgetNeighbor (unsigned long i)
 
const NeighborgetNeighbor (unsigned long i) const
 
void setArea (Area *area)
 
AreagetArea ()
 
const AreagetArea () const
 

Static Public Member Functions

static const char * getStateString (InterfaceStateType stateType)
 

Private Member Functions

void changeState (InterfaceState *newState, InterfaceState *currentState)
 

Private Attributes

OSPFInterfaceType interfaceType
 
InterfaceStatestate
 
InterfaceStatepreviousState
 
int ifIndex
 
unsigned short mtu
 
IPv4AddressRange interfaceAddressRange
 
AreaID areaID
 
AreaID transitAreaID
 
short helloInterval
 
short pollInterval
 
short routerDeadInterval
 
short interfaceTransmissionDelay
 
unsigned char routerPriority
 
cMessage * helloTimer
 
cMessage * waitTimer
 
cMessage * acknowledgementTimer
 
std::map< RouterID, Neighbor * > neighboringRoutersByID
 
std::map< IPv4Address, Neighbor * > neighboringRoutersByAddress
 
std::vector< Neighbor * > neighboringRouters
 
std::map< IPv4Address, std::list< OSPFLSAHeader > > delayedAcknowledgements
 
DesignatedRouterID designatedRouter
 
DesignatedRouterID backupDesignatedRouter
 
Metric interfaceOutputCost
 
short retransmissionInterval
 
short acknowledgementDelay
 
AuthenticationType authenticationType
 
AuthenticationKeyType authenticationKey
 
AreaparentArea
 

Friends

class InterfaceState
 

Member Enumeration Documentation

Enumerator
INTERFACE_UP 
HELLO_TIMER 
WAIT_TIMER 
ACKNOWLEDGEMENT_TIMER 
BACKUP_SEEN 
NEIGHBOR_CHANGE 
LOOP_INDICATION 
UNLOOP_INDICATION 
INTERFACE_DOWN 
42  {
43  INTERFACE_UP = 0,
44  HELLO_TIMER = 1,
45  WAIT_TIMER = 2,
47  BACKUP_SEEN = 4,
48  NEIGHBOR_CHANGE = 5,
49  LOOP_INDICATION = 6,
51  INTERFACE_DOWN = 8
52  };
Definition: OSPFInterface.h:47
Definition: OSPFInterface.h:48
Definition: OSPFInterface.h:45
Definition: OSPFInterface.h:46
Definition: OSPFInterface.h:44
Definition: OSPFInterface.h:50
Definition: OSPFInterface.h:43
Definition: OSPFInterface.h:51
Definition: OSPFInterface.h:49
Enumerator
DOWN_STATE 
LOOPBACK_STATE 
WAITING_STATE 
POINTTOPOINT_STATE 
NOT_DESIGNATED_ROUTER_STATE 
BACKUP_STATE 
DESIGNATED_ROUTER_STATE 
63  {
64  DOWN_STATE = 0,
65  LOOPBACK_STATE = 1,
66  WAITING_STATE = 2,
69  BACKUP_STATE = 5,
71  };
Definition: OSPFInterface.h:66
Definition: OSPFInterface.h:65
Definition: OSPFInterface.h:64
Definition: OSPFInterface.h:69
Definition: OSPFInterface.h:67
Enumerator
UNKNOWN_TYPE 
POINTTOPOINT 
BROADCAST 
NBMA 
POINTTOMULTIPOINT 
VIRTUAL 
54  {
55  UNKNOWN_TYPE = 0,
56  POINTTOPOINT = 1,
57  BROADCAST = 2,
58  NBMA = 3,
60  VIRTUAL = 5
61  };
Definition: OSPFInterface.h:60
Definition: OSPFInterface.h:55
Definition: OSPFInterface.h:56
Definition: OSPFInterface.h:58
Definition: OSPFInterface.h:57
Definition: OSPFInterface.h:59

Constructor & Destructor Documentation

inet::ospf::Interface::Interface ( Interface::OSPFInterfaceType  ifType = UNKNOWN_TYPE)
34  :
35  interfaceType(ifType),
36  ifIndex(0),
37  mtu(0),
41  helloInterval(10),
42  pollInterval(120),
45  routerPriority(0),
52  parentArea(nullptr)
53 {
54  state = new InterfaceStateDown;
55  previousState = nullptr;
56  helloTimer = new cMessage();
58  helloTimer->setContextPointer(this);
59  helloTimer->setName("Interface::InterfaceHelloTimer");
60  waitTimer = new cMessage();
62  waitTimer->setContextPointer(this);
63  waitTimer->setName("Interface::InterfaceWaitTimer");
64  acknowledgementTimer = new cMessage();
66  acknowledgementTimer->setContextPointer(this);
67  acknowledgementTimer->setName("Interface::InterfaceAcknowledgementTimer");
68  memset(authenticationKey.bytes, 0, 8 * sizeof(char));
69 }
short interfaceTransmissionDelay
Definition: OSPFInterface.h:85
char bytes[8]
Definition: OSPFcommon.h:74
short helloInterval
Definition: OSPFInterface.h:82
int ifIndex
Definition: OSPFInterface.h:77
short acknowledgementDelay
Definition: OSPFInterface.h:98
unsigned short mtu
Definition: OSPFInterface.h:78
const AreaID BACKBONE_AREAID(0, 0, 0, 0)
cMessage * acknowledgementTimer
Definition: OSPFInterface.h:89
Definition: OSPFTimer.h:28
Definition: OSPFcommon.h:67
const DesignatedRouterID NULL_DESIGNATEDROUTERID
Definition: OSPFcommon.h:164
short routerDeadInterval
Definition: OSPFInterface.h:84
Area * parentArea
Definition: OSPFInterface.h:102
DesignatedRouterID backupDesignatedRouter
Definition: OSPFInterface.h:95
OSPFInterfaceType interfaceType
Definition: OSPFInterface.h:74
InterfaceState * previousState
Definition: OSPFInterface.h:76
InterfaceState * state
Definition: OSPFInterface.h:75
short retransmissionInterval
Definition: OSPFInterface.h:97
AuthenticationKeyType authenticationKey
Definition: OSPFInterface.h:100
unsigned char routerPriority
Definition: OSPFInterface.h:86
AreaID transitAreaID
Definition: OSPFInterface.h:81
IPv4AddressRange interfaceAddressRange
Definition: OSPFInterface.h:79
AreaID areaID
Definition: OSPFInterface.h:80
AuthenticationType authenticationType
Definition: OSPFInterface.h:99
cMessage * helloTimer
Definition: OSPFInterface.h:87
cMessage * waitTimer
Definition: OSPFInterface.h:88
short pollInterval
Definition: OSPFInterface.h:83
Metric interfaceOutputCost
Definition: OSPFInterface.h:96
DesignatedRouterID designatedRouter
Definition: OSPFInterface.h:94
Definition: OSPFTimer.h:29
const IPv4AddressRange NULL_IPV4ADDRESSRANGE(IPv4Address(0, 0, 0, 0), IPv4Address(0, 0, 0, 0))
inet::ospf::Interface::~Interface ( )
virtual
72 {
73  MessageHandler *messageHandler = parentArea->getRouter()->getMessageHandler();
74  messageHandler->clearTimer(helloTimer);
75  delete helloTimer;
76  messageHandler->clearTimer(waitTimer);
77  delete waitTimer;
78  messageHandler->clearTimer(acknowledgementTimer);
79  delete acknowledgementTimer;
80  if (previousState != nullptr) {
81  delete previousState;
82  }
83  delete state;
84  long neighborCount = neighboringRouters.size();
85  for (long i = 0; i < neighborCount; i++) {
86  delete neighboringRouters[i];
87  }
88 }
Router * getRouter()
Definition: OSPFArea.h:80
cMessage * acknowledgementTimer
Definition: OSPFInterface.h:89
std::vector< Neighbor * > neighboringRouters
Definition: OSPFInterface.h:92
Area * parentArea
Definition: OSPFInterface.h:102
InterfaceState * previousState
Definition: OSPFInterface.h:76
InterfaceState * state
Definition: OSPFInterface.h:75
void clearTimer(cMessage *timer)
Definition: MessageHandler.cc:367
cMessage * helloTimer
Definition: OSPFInterface.h:87
cMessage * waitTimer
Definition: OSPFInterface.h:88
MessageHandler * getMessageHandler()
Definition: OSPFRouter.h:77

Member Function Documentation

void inet::ospf::Interface::addDelayedAcknowledgement ( OSPFLSAHeader lsaHeader)

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

530 {
535  {
537  }
538  else {
540  }
541  }
542  else {
543  long neighborCount = neighboringRouters.size();
544  for (long i = 0; i < neighborCount; i++) {
546  delayedAcknowledgements[neighboringRouters[i]->getAddress()].push_back(lsaHeader);
547  }
548  }
549  }
550 }
std::map< IPv4Address, std::list< OSPFLSAHeader > > delayedAcknowledgements
Definition: OSPFInterface.h:93
std::vector< Neighbor * > neighboringRouters
Definition: OSPFInterface.h:92
const DesignatedRouterID NULL_DESIGNATEDROUTERID
Definition: OSPFcommon.h:164
OSPFInterfaceType interfaceType
Definition: OSPFInterface.h:74
Definition: OSPFInterface.h:57
Definition: OSPFInterface.h:69
DesignatedRouterID designatedRouter
Definition: OSPFInterface.h:94
Definition: OSPFNeighbor.h:67
static const IPv4Address ALL_OSPF_DESIGNATED_ROUTERS_MCAST
224.0.0.6 All OSPF Designated Routers
Definition: IPv4Address.h:111
InterfaceStateType getState() const
Definition: OSPFInterface.cc:230
static const IPv4Address ALL_OSPF_ROUTERS_MCAST
224.0.0.5 All OSPF routers (DR Others)
Definition: IPv4Address.h:110
void inet::ospf::Interface::addNeighbor ( Neighbor neighbor)

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

223 {
224  neighboringRoutersByID[neighbor->getNeighborID()] = neighbor;
225  neighboringRoutersByAddress[neighbor->getAddress()] = neighbor;
226  neighbor->setInterface(this);
227  neighboringRouters.push_back(neighbor);
228 }
std::map< RouterID, Neighbor * > neighboringRoutersByID
Definition: OSPFInterface.h:90
std::vector< Neighbor * > neighboringRouters
Definition: OSPFInterface.h:92
std::map< IPv4Address, Neighbor * > neighboringRoutersByAddress
Definition: OSPFInterface.h:91
void inet::ospf::Interface::ageTransmittedLSALists ( )
611 {
612  long neighborCount = neighboringRouters.size();
613  for (long i = 0; i < neighborCount; i++) {
614  neighboringRouters[i]->ageTransmittedLSAList();
615  }
616 }
std::vector< Neighbor * > neighboringRouters
Definition: OSPFInterface.h:92
void inet::ospf::Interface::changeState ( InterfaceState newState,
InterfaceState currentState 
)
private

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

102 {
103  if (previousState != nullptr) {
104  delete previousState;
105  }
106  state = newState;
107  previousState = currentState;
108 }
InterfaceState * previousState
Definition: OSPFInterface.h:76
InterfaceState * state
Definition: OSPFInterface.h:75
OSPFLinkStateUpdatePacket * inet::ospf::Interface::createUpdatePacket ( OSPFLSA lsa)

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

434 {
435  LSAType lsaType = static_cast<LSAType>(lsa->getHeader().getLsType());
436  OSPFRouterLSA *routerLSA = (lsaType == ROUTERLSA_TYPE) ? dynamic_cast<OSPFRouterLSA *>(lsa) : nullptr;
437  OSPFNetworkLSA *networkLSA = (lsaType == NETWORKLSA_TYPE) ? dynamic_cast<OSPFNetworkLSA *>(lsa) : nullptr;
438  OSPFSummaryLSA *summaryLSA = ((lsaType == SUMMARYLSA_NETWORKS_TYPE) ||
439  (lsaType == SUMMARYLSA_ASBOUNDARYROUTERS_TYPE)) ? dynamic_cast<OSPFSummaryLSA *>(lsa) : nullptr;
440  OSPFASExternalLSA *asExternalLSA = (lsaType == AS_EXTERNAL_LSA_TYPE) ? dynamic_cast<OSPFASExternalLSA *>(lsa) : nullptr;
441 
442  if (((lsaType == ROUTERLSA_TYPE) && (routerLSA != nullptr)) ||
443  ((lsaType == NETWORKLSA_TYPE) && (networkLSA != nullptr)) ||
444  (((lsaType == SUMMARYLSA_NETWORKS_TYPE) || (lsaType == SUMMARYLSA_ASBOUNDARYROUTERS_TYPE)) && (summaryLSA != nullptr)) ||
445  ((lsaType == AS_EXTERNAL_LSA_TYPE) && (asExternalLSA != nullptr)))
446  {
447  OSPFLinkStateUpdatePacket *updatePacket = new OSPFLinkStateUpdatePacket();
448  long packetLength = OSPF_HEADER_LENGTH + sizeof(uint32_t); // OSPF header + place for number of advertisements
449 
450  updatePacket->setType(LINKSTATE_UPDATE_PACKET);
451  updatePacket->setRouterID(IPv4Address(parentArea->getRouter()->getRouterID()));
452  updatePacket->setAreaID(IPv4Address(areaID));
453  updatePacket->setAuthenticationType(authenticationType);
454  for (int j = 0; j < 8; j++) {
455  updatePacket->setAuthentication(j, authenticationKey.bytes[j]);
456  }
457 
458  updatePacket->setNumberOfLSAs(1);
459 
460  switch (lsaType) {
461  case ROUTERLSA_TYPE: {
462  updatePacket->setRouterLSAsArraySize(1);
463  updatePacket->setRouterLSAs(0, *routerLSA);
464  unsigned short lsAge = updatePacket->getRouterLSAs(0).getHeader().getLsAge();
465  if (lsAge < MAX_AGE - interfaceTransmissionDelay) {
466  updatePacket->getRouterLSAs(0).getHeader().setLsAge(lsAge + interfaceTransmissionDelay);
467  }
468  else {
469  updatePacket->getRouterLSAs(0).getHeader().setLsAge(MAX_AGE);
470  }
471  packetLength += calculateLSASize(routerLSA);
472  }
473  break;
474 
475  case NETWORKLSA_TYPE: {
476  updatePacket->setNetworkLSAsArraySize(1);
477  updatePacket->setNetworkLSAs(0, *networkLSA);
478  unsigned short lsAge = updatePacket->getNetworkLSAs(0).getHeader().getLsAge();
479  if (lsAge < MAX_AGE - interfaceTransmissionDelay) {
480  updatePacket->getNetworkLSAs(0).getHeader().setLsAge(lsAge + interfaceTransmissionDelay);
481  }
482  else {
483  updatePacket->getNetworkLSAs(0).getHeader().setLsAge(MAX_AGE);
484  }
485  packetLength += calculateLSASize(networkLSA);
486  }
487  break;
488 
491  updatePacket->setSummaryLSAsArraySize(1);
492  updatePacket->setSummaryLSAs(0, *summaryLSA);
493  unsigned short lsAge = updatePacket->getSummaryLSAs(0).getHeader().getLsAge();
494  if (lsAge < MAX_AGE - interfaceTransmissionDelay) {
495  updatePacket->getSummaryLSAs(0).getHeader().setLsAge(lsAge + interfaceTransmissionDelay);
496  }
497  else {
498  updatePacket->getSummaryLSAs(0).getHeader().setLsAge(MAX_AGE);
499  }
500  packetLength += calculateLSASize(summaryLSA);
501  }
502  break;
503 
504  case AS_EXTERNAL_LSA_TYPE: {
505  updatePacket->setAsExternalLSAsArraySize(1);
506  updatePacket->setAsExternalLSAs(0, *asExternalLSA);
507  unsigned short lsAge = updatePacket->getAsExternalLSAs(0).getHeader().getLsAge();
508  if (lsAge < MAX_AGE - interfaceTransmissionDelay) {
509  updatePacket->getAsExternalLSAs(0).getHeader().setLsAge(lsAge + interfaceTransmissionDelay);
510  }
511  else {
512  updatePacket->getAsExternalLSAs(0).getHeader().setLsAge(MAX_AGE);
513  }
514  packetLength += calculateLSASize(asExternalLSA);
515  }
516  break;
517 
518  default:
519  throw cRuntimeError("Invalid LSA type: %d", lsaType);
520  }
521 
522  updatePacket->setByteLength(packetLength);
523 
524  return updatePacket;
525  }
526  return nullptr;
527 }
short interfaceTransmissionDelay
Definition: OSPFInterface.h:85
Router * getRouter()
Definition: OSPFArea.h:80
char bytes[8]
Definition: OSPFcommon.h:74
unsigned int calculateLSASize(const OSPFRouterLSA *routerLSA)
Definition: LSA.cc:77
RouterID getRouterID() const
Definition: OSPFRouter.h:72
Definition: OSPFPacket_m.h:246
Area * parentArea
Definition: OSPFInterface.h:102
AuthenticationKeyType authenticationKey
Definition: OSPFInterface.h:100
#define MAX_AGE
Definition: OSPFcommon.h:36
Definition: OSPFPacket_m.h:245
LSAType
Enum generated from inet/routing/ospfv2/OSPFPacket.msg:84 by nedtool.
Definition: OSPFPacket_m.h:244
AreaID areaID
Definition: OSPFInterface.h:80
Definition: OSPFPacket_m.h:249
#define OSPF_HEADER_LENGTH
Definition: OSPFcommon.h:48
AuthenticationType authenticationType
Definition: OSPFInterface.h:99
Definition: OSPFPacket_m.h:56
Definition: OSPFPacket_m.h:247
Definition: OSPFPacket_m.h:248
bool inet::ospf::Interface::floodLSA ( OSPFLSA lsa,
Interface intf = nullptr,
Neighbor neighbor = nullptr 
)
See also
RFC2328 Section 13.3.
301 {
302  bool floodedBackOut = false;
303 
304  if (
305  (
306  (lsa->getHeader().getLsType() == AS_EXTERNAL_LSA_TYPE) &&
309  ) ||
310  (
311  (lsa->getHeader().getLsType() != AS_EXTERNAL_LSA_TYPE) &&
312  (
313  (
314  (areaID != BACKBONE_AREAID) &&
316  ) ||
318  )
319  )
320  )
321  {
322  long neighborCount = neighboringRouters.size();
323  bool lsaAddedToRetransmissionList = false;
324  LinkStateID linkStateID = lsa->getHeader().getLinkStateID();
325  LSAKeyType lsaKey;
326 
327  lsaKey.linkStateID = linkStateID;
328  lsaKey.advertisingRouter = lsa->getHeader().getAdvertisingRouter();
329 
330  for (long i = 0; i < neighborCount; i++) { // (1)
331  if (neighboringRouters[i]->getState() < Neighbor::EXCHANGE_STATE) { // (1) (a)
332  continue;
333  }
334  if (neighboringRouters[i]->getState() < Neighbor::FULL_STATE) { // (1) (b)
335  OSPFLSAHeader *requestLSAHeader = neighboringRouters[i]->findOnRequestList(lsaKey);
336  if (requestLSAHeader != nullptr) {
337  // operator< and operator== on OSPFLSAHeaders determines which one is newer(less means older)
338  if (lsa->getHeader() < (*requestLSAHeader)) {
339  continue;
340  }
341  if (operator==(lsa->getHeader(), (*requestLSAHeader))) {
342  neighboringRouters[i]->removeFromRequestList(lsaKey);
343  continue;
344  }
345  neighboringRouters[i]->removeFromRequestList(lsaKey);
346  }
347  }
348  if (neighbor == neighboringRouters[i]) { // (1) (c)
349  continue;
350  }
351  neighboringRouters[i]->addToRetransmissionList(lsa); // (1) (d)
352  lsaAddedToRetransmissionList = true;
353  }
354  if (lsaAddedToRetransmissionList) { // (2)
355  if ((intf != this) ||
356  ((neighbor != nullptr) &&
357  (neighbor->getNeighborID() != designatedRouter.routerID) &&
358  (neighbor->getNeighborID() != backupDesignatedRouter.routerID))) // (3)
359  {
360  if ((intf != this) || (getState() != Interface::BACKUP_STATE)) { // (4)
361  OSPFLinkStateUpdatePacket *updatePacket = createUpdatePacket(lsa); // (5)
362 
363  if (updatePacket != nullptr) {
365  MessageHandler *messageHandler = parentArea->getRouter()->getMessageHandler();
366 
371  {
372  messageHandler->sendPacket(updatePacket, IPv4Address::ALL_OSPF_ROUTERS_MCAST, ifIndex, ttl);
373  for (long k = 0; k < neighborCount; k++) {
374  neighboringRouters[k]->addToTransmittedLSAList(lsaKey);
375  if (!neighboringRouters[k]->isUpdateRetransmissionTimerActive()) {
376  neighboringRouters[k]->startUpdateRetransmissionTimer();
377  }
378  }
379  }
380  else {
381  messageHandler->sendPacket(updatePacket, IPv4Address::ALL_OSPF_DESIGNATED_ROUTERS_MCAST, ifIndex, ttl);
382  Neighbor *dRouter = getNeighborByID(designatedRouter.routerID);
383  Neighbor *backupDRouter = getNeighborByID(backupDesignatedRouter.routerID);
384  if (dRouter != nullptr) {
385  dRouter->addToTransmittedLSAList(lsaKey);
386  if (!dRouter->isUpdateRetransmissionTimerActive()) {
387  dRouter->startUpdateRetransmissionTimer();
388  }
389  }
390  if (backupDRouter != nullptr) {
391  backupDRouter->addToTransmittedLSAList(lsaKey);
392  if (!backupDRouter->isUpdateRetransmissionTimerActive()) {
393  backupDRouter->startUpdateRetransmissionTimer();
394  }
395  }
396  }
397  }
398  else {
400  messageHandler->sendPacket(updatePacket, IPv4Address::ALL_OSPF_ROUTERS_MCAST, ifIndex, ttl);
401  if (neighborCount > 0) {
402  neighboringRouters[0]->addToTransmittedLSAList(lsaKey);
403  if (!neighboringRouters[0]->isUpdateRetransmissionTimerActive()) {
404  neighboringRouters[0]->startUpdateRetransmissionTimer();
405  }
406  }
407  }
408  else {
409  for (long m = 0; m < neighborCount; m++) {
411  messageHandler->sendPacket(updatePacket, neighboringRouters[m]->getAddress(), ifIndex, ttl);
412  neighboringRouters[m]->addToTransmittedLSAList(lsaKey);
413  if (!neighboringRouters[m]->isUpdateRetransmissionTimerActive()) {
414  neighboringRouters[m]->startUpdateRetransmissionTimer();
415  }
416  }
417  }
418  }
419  }
420 
421  if (intf == this) {
422  floodedBackOut = true;
423  }
424  }
425  }
426  }
427  }
428  }
429 
430  return floodedBackOut;
431 }
#define VIRTUAL_LINK_TTL
Definition: OSPFcommon.h:45
Definition: OSPFInterface.h:60
Router * getRouter()
Definition: OSPFArea.h:80
RouterID routerID
Definition: OSPFcommon.h:155
Neighbor * getNeighborByID(RouterID neighborID)
Definition: OSPFInterface.cc:198
int ifIndex
Definition: OSPFInterface.h:77
Definition: OSPFInterface.h:56
const AreaID BACKBONE_AREAID(0, 0, 0, 0)
IPv4Address LinkStateID
Definition: OSPFcommon.h:139
std::vector< Neighbor * > neighboringRouters
Definition: OSPFInterface.h:92
const DesignatedRouterID NULL_DESIGNATEDROUTERID
Definition: OSPFcommon.h:164
Area * parentArea
Definition: OSPFInterface.h:102
DesignatedRouterID backupDesignatedRouter
Definition: OSPFInterface.h:95
OSPFInterfaceType interfaceType
Definition: OSPFInterface.h:74
Definition: OSPFInterface.h:57
OSPFLinkStateUpdatePacket * createUpdatePacket(OSPFLSA *lsa)
Definition: OSPFInterface.cc:433
Definition: OSPFInterface.h:69
AreaID areaID
Definition: OSPFInterface.h:80
void sendPacket(OSPFPacket *packet, IPv4Address destination, int outputIfIndex, short ttl=1)
Definition: MessageHandler.cc:305
Definition: OSPFPacket_m.h:249
Definition: OSPFNeighbor.h:69
MessageHandler * getMessageHandler()
Definition: OSPFRouter.h:77
DesignatedRouterID designatedRouter
Definition: OSPFInterface.h:94
const double k
Definition: QAM16Modulation.cc:24
Definition: OSPFNeighbor.h:67
static const IPv4Address ALL_OSPF_DESIGNATED_ROUTERS_MCAST
224.0.0.6 All OSPF Designated Routers
Definition: IPv4Address.h:111
bool getExternalRoutingCapability() const
Definition: OSPFArea.h:72
InterfaceStateType getState() const
Definition: OSPFInterface.cc:230
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
value< double, units::m > m
Definition: Units.h:1047
short inet::ospf::Interface::getAcknowledgementDelay ( ) const
inline

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

148 { return acknowledgementDelay; }
short acknowledgementDelay
Definition: OSPFInterface.h:98
cMessage* inet::ospf::Interface::getAcknowledgementTimer ( )
inline

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

166 { return acknowledgementTimer; }
cMessage * acknowledgementTimer
Definition: OSPFInterface.h:89
Area* inet::ospf::Interface::getArea ( )
inline

Referenced by inet::ospf::LinkStateUpdateHandler::acknowledgeLSA(), inet::ospf::InterfaceState::changeState(), inet::ospf::NeighborState::changeState(), inet::ospf::Neighbor::clearRequestRetransmissionTimer(), inet::ospf::Neighbor::clearUpdateRetransmissionTimer(), inet::ospf::Neighbor::createDatabaseSummary(), inet::ospf::Neighbor::needAdjacency(), inet::ospf::DatabaseDescriptionHandler::processDDPacket(), inet::ospf::InterfaceStateDown::processEvent(), inet::ospf::NeighborStateTwoWay::processEvent(), inet::ospf::NeighborStateFull::processEvent(), inet::ospf::InterfaceStateNotDesignatedRouter::processEvent(), inet::ospf::NeighborStateExchange::processEvent(), inet::ospf::InterfaceStatePointToPoint::processEvent(), inet::ospf::InterfaceStateWaiting::processEvent(), inet::ospf::NeighborStateLoading::processEvent(), inet::ospf::InterfaceStateBackup::processEvent(), inet::ospf::NeighborStateAttempt::processEvent(), inet::ospf::NeighborStateInit::processEvent(), inet::ospf::NeighborStateExchangeStart::processEvent(), inet::ospf::NeighborStateDown::processEvent(), inet::ospf::InterfaceStateDesignatedRouter::processEvent(), inet::ospf::LinkStateRequestHandler::processPacket(), inet::ospf::HelloHandler::processPacket(), inet::ospf::Neighbor::reset(), inet::ospf::Neighbor::retransmitDatabaseDescriptionPacket(), inet::ospf::Neighbor::retransmitUpdatePacket(), inet::ospf::Neighbor::sendDatabaseDescriptionPacket(), inet::ospf::Neighbor::sendLinkStateRequestPacket(), inet::ospf::Neighbor::startRequestRetransmissionTimer(), inet::ospf::Neighbor::startUpdateRetransmissionTimer(), and inet::ospf::Neighbor::~Neighbor().

174 { return parentArea; }
Area * parentArea
Definition: OSPFInterface.h:102
const Area* inet::ospf::Interface::getArea ( ) const
inline
175 { return parentArea; }
Area * parentArea
Definition: OSPFInterface.h:102
AreaID inet::ospf::Interface::getAreaID ( ) const
inline

Referenced by inet::ospf::OSPFConfigReader::loadVirtualLink(), and inet::ospf::Area::originateSummaryLSA().

138 { return areaID; }
AreaID areaID
Definition: OSPFInterface.h:80
DesignatedRouterID inet::ospf::Interface::getBackupDesignatedRouter ( ) const
inline

Referenced by inet::ospf::Neighbor::needAdjacency(), and inet::ospf::InterfaceStateNotDesignatedRouter::processEvent().

168 { return backupDesignatedRouter; }
DesignatedRouterID backupDesignatedRouter
Definition: OSPFInterface.h:95
unsigned short inet::ospf::Interface::getMTU ( ) const
inline
const Neighbor* inet::ospf::Interface::getNeighbor ( unsigned long  i) const
inline
171 { return neighboringRouters[i]; }
std::vector< Neighbor * > neighboringRouters
Definition: OSPFInterface.h:92
Neighbor * inet::ospf::Interface::getNeighborByAddress ( IPv4Address  address)

Referenced by inet::ospf::Area::originateRouterLSA(), inet::ospf::HelloHandler::processPacket(), and inet::ospf::MessageHandler::processPacket().

210 {
211  auto neighborIt =
212  neighboringRoutersByAddress.find(address);
213 
214  if (neighborIt != neighboringRoutersByAddress.end()) {
215  return neighborIt->second;
216  }
217  else {
218  return nullptr;
219  }
220 }
std::map< IPv4Address, Neighbor * > neighboringRoutersByAddress
Definition: OSPFInterface.h:91
Neighbor * inet::ospf::Interface::getNeighborByID ( RouterID  neighborID)

Referenced by inet::ospf::LinkStateUpdateHandler::acknowledgeLSA(), floodLSA(), inet::ospf::HelloHandler::processPacket(), and inet::ospf::MessageHandler::processPacket().

199 {
200  auto neighborIt = neighboringRoutersByID.find(neighborID);
201  if (neighborIt != neighboringRoutersByID.end()) {
202  return neighborIt->second;
203  }
204  else {
205  return nullptr;
206  }
207 }
std::map< RouterID, Neighbor * > neighboringRoutersByID
Definition: OSPFInterface.h:90
Metric inet::ospf::Interface::getOutputCost ( ) const
inline

Referenced by inet::ospf::Area::originateRouterLSA().

142 { return interfaceOutputCost; }
Metric interfaceOutputCost
Definition: OSPFInterface.h:96
short inet::ospf::Interface::getRouterDeadInterval ( ) const
inline
unsigned char inet::ospf::Interface::getRouterPriority ( ) const
inline
const char * inet::ospf::Interface::getStateString ( Interface::InterfaceStateType  stateType)
static

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

236 {
237  switch (stateType) {
238  case DOWN_STATE:
239  return "Down";
240 
241  case LOOPBACK_STATE:
242  return "Loopback";
243 
244  case WAITING_STATE:
245  return "Waiting";
246 
247  case POINTTOPOINT_STATE:
248  return "PointToPoint";
249 
251  return "NotDesignatedRouter";
252 
253  case BACKUP_STATE:
254  return "Backup";
255 
257  return "DesignatedRouter";
258 
259  default:
260  ASSERT(false);
261  break;
262  }
263  return "";
264 }
Definition: OSPFInterface.h:66
Definition: OSPFInterface.h:65
Definition: OSPFInterface.h:64
Definition: OSPFInterface.h:69
Definition: OSPFInterface.h:67
AreaID inet::ospf::Interface::getTransitAreaID ( ) const
inline
short inet::ospf::Interface::getTransmissionDelay ( ) const
inline

Referenced by inet::ospf::Neighbor::retransmitUpdatePacket().

146 { return interfaceTransmissionDelay; }
short interfaceTransmissionDelay
Definition: OSPFInterface.h:85
OSPFInterfaceType inet::ospf::Interface::getType ( ) const
inline

Referenced by inet::ospf::LinkStateUpdateHandler::acknowledgeLSA(), inet::ospf::InterfaceState::changeState(), inet::ospf::Neighbor::createDatabaseSummary(), inet::ospf::Neighbor::needAdjacency(), inet::ospf::Area::originateRouterLSA(), inet::ospf::MessageHandler::printEvent(), inet::ospf::NeighborStateExchange::processEvent(), inet::ospf::NeighborStateDown::processEvent(), inet::ospf::NeighborStateInit::processEvent(), inet::ospf::NeighborStateLoading::processEvent(), inet::ospf::InterfaceStateBackup::processEvent(), inet::ospf::NeighborStateTwoWay::processEvent(), inet::ospf::InterfaceStateDesignatedRouter::processEvent(), inet::ospf::NeighborStateAttempt::processEvent(), inet::ospf::InterfaceStateDown::processEvent(), inet::ospf::InterfaceStateWaiting::processEvent(), inet::ospf::InterfaceStatePointToPoint::processEvent(), inet::ospf::InterfaceStateNotDesignatedRouter::processEvent(), inet::ospf::NeighborStateExchangeStart::processEvent(), inet::ospf::NeighborStateFull::processEvent(), inet::ospf::LinkStateRequestHandler::processPacket(), inet::ospf::HelloHandler::processPacket(), inet::ospf::LinkStateUpdateHandler::processPacket(), inet::ospf::MessageHandler::processPacket(), inet::ospf::Neighbor::retransmitDatabaseDescriptionPacket(), inet::ospf::Neighbor::retransmitUpdatePacket(), inet::ospf::Neighbor::sendDatabaseDescriptionPacket(), and inet::ospf::Neighbor::sendLinkStateRequestPacket().

132 { return interfaceType; }
OSPFInterfaceType interfaceType
Definition: OSPFInterface.h:74
cMessage* inet::ospf::Interface::getWaitTimer ( )
inline

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

165 { return waitTimer; }
cMessage * waitTimer
Definition: OSPFInterface.h:88
bool inet::ospf::Interface::hasAnyNeighborInStates ( int  states) const

Referenced by inet::ospf::Area::ageDatabase(), inet::ospf::Area::originateNetworkLSA(), and inet::ospf::Area::originateRouterLSA().

267 {
268  long neighborCount = neighboringRouters.size();
269  for (long i = 0; i < neighborCount; i++) {
270  Neighbor::NeighborStateType neighborState = neighboringRouters[i]->getState();
271  if (neighborState & states) {
272  return true;
273  }
274  }
275  return false;
276 }
NeighborStateType
Definition: OSPFNeighbor.h:61
std::vector< Neighbor * > neighboringRouters
Definition: OSPFInterface.h:92
bool inet::ospf::Interface::isOnAnyRetransmissionList ( LSAKeyType  lsaKey) const
287 {
288  long neighborCount = neighboringRouters.size();
289  for (long i = 0; i < neighborCount; i++) {
290  if (neighboringRouters[i]->isLinkStateRequestListEmpty(lsaKey)) {
291  return true;
292  }
293  }
294  return false;
295 }
std::vector< Neighbor * > neighboringRouters
Definition: OSPFInterface.h:92
void inet::ospf::Interface::processEvent ( Interface::InterfaceEventType  event)

Referenced by inet::ospf::Area::calculateShortestPathTree(), inet::ospf::MessageHandler::handleTimer(), inet::ospf::OSPFConfigReader::loadInterfaceParameters(), and inet::ospf::HelloHandler::processPacket().

111 {
112  state->processEvent(this, event);
113 }
virtual void processEvent(Interface *intf, Interface::InterfaceEventType event)=0
InterfaceState * state
Definition: OSPFInterface.h:75
void inet::ospf::Interface::removeFromAllRetransmissionLists ( LSAKeyType  lsaKey)
279 {
280  long neighborCount = neighboringRouters.size();
281  for (long i = 0; i < neighborCount; i++) {
282  neighboringRouters[i]->removeFromRetransmissionList(lsaKey);
283  }
284 }
std::vector< Neighbor * > neighboringRouters
Definition: OSPFInterface.h:92
void inet::ospf::Interface::reset ( )

Referenced by inet::ospf::InterfaceStateBackup::processEvent(), inet::ospf::InterfaceStateWaiting::processEvent(), inet::ospf::InterfaceStatePointToPoint::processEvent(), inet::ospf::InterfaceStateNotDesignatedRouter::processEvent(), inet::ospf::InterfaceStateLoopback::processEvent(), inet::ospf::InterfaceStateDown::processEvent(), and inet::ospf::InterfaceStateDesignatedRouter::processEvent().

116 {
117  MessageHandler *messageHandler = parentArea->getRouter()->getMessageHandler();
118  messageHandler->clearTimer(helloTimer);
119  messageHandler->clearTimer(waitTimer);
120  messageHandler->clearTimer(acknowledgementTimer);
123  long neighborCount = neighboringRouters.size();
124  for (long i = 0; i < neighborCount; i++) {
126  }
127 }
Definition: OSPFNeighbor.h:52
Router * getRouter()
Definition: OSPFArea.h:80
cMessage * acknowledgementTimer
Definition: OSPFInterface.h:89
std::vector< Neighbor * > neighboringRouters
Definition: OSPFInterface.h:92
const DesignatedRouterID NULL_DESIGNATEDROUTERID
Definition: OSPFcommon.h:164
Area * parentArea
Definition: OSPFInterface.h:102
DesignatedRouterID backupDesignatedRouter
Definition: OSPFInterface.h:95
void clearTimer(cMessage *timer)
Definition: MessageHandler.cc:367
cMessage * helloTimer
Definition: OSPFInterface.h:87
cMessage * waitTimer
Definition: OSPFInterface.h:88
MessageHandler * getMessageHandler()
Definition: OSPFRouter.h:77
DesignatedRouterID designatedRouter
Definition: OSPFInterface.h:94
void inet::ospf::Interface::sendDelayedAcknowledgements ( )

Referenced by inet::ospf::InterfaceStateBackup::processEvent(), inet::ospf::InterfaceStateWaiting::processEvent(), inet::ospf::InterfaceStatePointToPoint::processEvent(), inet::ospf::InterfaceStateNotDesignatedRouter::processEvent(), and inet::ospf::InterfaceStateDesignatedRouter::processEvent().

553 {
554  MessageHandler *messageHandler = parentArea->getRouter()->getMessageHandler();
556 
557  for (auto & elem : delayedAcknowledgements)
558  {
559  int ackCount = elem.second.size();
560  if (ackCount > 0) {
561  while (!(elem.second.empty())) {
562  OSPFLinkStateAcknowledgementPacket *ackPacket = new OSPFLinkStateAcknowledgementPacket();
563  long packetSize = IP_MAX_HEADER_BYTES + OSPF_HEADER_LENGTH;
564 
565  ackPacket->setType(LINKSTATE_ACKNOWLEDGEMENT_PACKET);
566  ackPacket->setRouterID(IPv4Address(parentArea->getRouter()->getRouterID()));
567  ackPacket->setAreaID(IPv4Address(areaID));
568  ackPacket->setAuthenticationType(authenticationType);
569  for (int i = 0; i < 8; i++) {
570  ackPacket->setAuthentication(i, authenticationKey.bytes[i]);
571  }
572 
573  while ((!(elem.second.empty())) && (packetSize <= (maxPacketSize - OSPF_LSA_HEADER_LENGTH))) {
574  unsigned long headerCount = ackPacket->getLsaHeadersArraySize();
575  ackPacket->setLsaHeadersArraySize(headerCount + 1);
576  ackPacket->setLsaHeaders(headerCount, *(elem.second.begin()));
577  elem.second.pop_front();
578  packetSize += OSPF_LSA_HEADER_LENGTH;
579  }
580 
581  ackPacket->setByteLength(packetSize - IP_MAX_HEADER_BYTES);
582 
584 
589  {
590  messageHandler->sendPacket(ackPacket, IPv4Address::ALL_OSPF_ROUTERS_MCAST, ifIndex, ttl);
591  }
592  else {
593  messageHandler->sendPacket(ackPacket, IPv4Address::ALL_OSPF_DESIGNATED_ROUTERS_MCAST, ifIndex, ttl);
594  }
595  }
596  else {
598  messageHandler->sendPacket(ackPacket, IPv4Address::ALL_OSPF_ROUTERS_MCAST, ifIndex, ttl);
599  }
600  else {
601  messageHandler->sendPacket(ackPacket, elem.first, ifIndex, ttl);
602  }
603  }
604  }
605  }
606  }
607  messageHandler->startTimer(acknowledgementTimer, acknowledgementDelay);
608 }
#define VIRTUAL_LINK_TTL
Definition: OSPFcommon.h:45
Definition: OSPFInterface.h:60
Router * getRouter()
Definition: OSPFArea.h:80
char bytes[8]
Definition: OSPFcommon.h:74
int ifIndex
Definition: OSPFInterface.h:77
short acknowledgementDelay
Definition: OSPFInterface.h:98
unsigned short mtu
Definition: OSPFInterface.h:78
std::map< IPv4Address, std::list< OSPFLSAHeader > > delayedAcknowledgements
Definition: OSPFInterface.h:93
Definition: OSPFInterface.h:56
RouterID getRouterID() const
Definition: OSPFRouter.h:72
cMessage * acknowledgementTimer
Definition: OSPFInterface.h:89
const int IP_MAX_HEADER_BYTES
Definition: IPv4Datagram_m.h:44
const DesignatedRouterID NULL_DESIGNATEDROUTERID
Definition: OSPFcommon.h:164
Area * parentArea
Definition: OSPFInterface.h:102
OSPFInterfaceType interfaceType
Definition: OSPFInterface.h:74
Definition: OSPFInterface.h:57
AuthenticationKeyType authenticationKey
Definition: OSPFInterface.h:100
#define IPV4_DATAGRAM_LENGTH
Definition: OSPFcommon.h:47
#define OSPF_LSA_HEADER_LENGTH
Definition: OSPFcommon.h:49
Definition: OSPFInterface.h:69
AreaID areaID
Definition: OSPFInterface.h:80
#define OSPF_HEADER_LENGTH
Definition: OSPFcommon.h:48
AuthenticationType authenticationType
Definition: OSPFInterface.h:99
MessageHandler * getMessageHandler()
Definition: OSPFRouter.h:77
DesignatedRouterID designatedRouter
Definition: OSPFInterface.h:94
static const IPv4Address ALL_OSPF_DESIGNATED_ROUTERS_MCAST
224.0.0.6 All OSPF Designated Routers
Definition: IPv4Address.h:111
InterfaceStateType getState() const
Definition: OSPFInterface.cc:230
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::Interface::sendHelloPacket ( IPv4Address  destination,
short  ttl = 1 
)

Referenced by inet::ospf::InterfaceStateBackup::processEvent(), inet::ospf::NeighborStateDown::processEvent(), inet::ospf::InterfaceStateWaiting::processEvent(), inet::ospf::InterfaceStatePointToPoint::processEvent(), inet::ospf::InterfaceStateNotDesignatedRouter::processEvent(), inet::ospf::InterfaceStateDesignatedRouter::processEvent(), and inet::ospf::HelloHandler::processPacket().

130 {
131  OSPFOptions options;
132  OSPFHelloPacket *helloPacket = new OSPFHelloPacket();
133  std::vector<IPv4Address> neighbors;
134 
135  helloPacket->setRouterID(IPv4Address(parentArea->getRouter()->getRouterID()));
136  helloPacket->setAreaID(IPv4Address(parentArea->getAreaID()));
137  helloPacket->setAuthenticationType(authenticationType);
138  for (int i = 0; i < 8; i++) {
139  helloPacket->setAuthentication(i, authenticationKey.bytes[i]);
140  }
141 
142  if (((interfaceType == POINTTOPOINT) &&
144  (interfaceType == VIRTUAL))
145  {
146  helloPacket->setNetworkMask(NULL_IPV4ADDRESS);
147  }
148  else {
149  helloPacket->setNetworkMask(interfaceAddressRange.mask);
150  }
151  memset(&options, 0, sizeof(OSPFOptions));
152  options.E_ExternalRoutingCapability = parentArea->getExternalRoutingCapability();
153  helloPacket->setOptions(options);
154  helloPacket->setHelloInterval(helloInterval);
155  helloPacket->setRouterPriority(routerPriority);
156  helloPacket->setRouterDeadInterval(routerDeadInterval);
157  helloPacket->setDesignatedRouter(designatedRouter.ipInterfaceAddress);
158  helloPacket->setBackupDesignatedRouter(backupDesignatedRouter.ipInterfaceAddress);
159  long neighborCount = neighboringRouters.size();
160  for (long j = 0; j < neighborCount; j++) {
162  neighbors.push_back(neighboringRouters[j]->getAddress());
163  }
164  }
165  unsigned int initedNeighborCount = neighbors.size();
166  helloPacket->setNeighborArraySize(initedNeighborCount);
167  for (unsigned int k = 0; k < initedNeighborCount; k++) {
168  helloPacket->setNeighbor(k, neighbors[k]);
169  }
170 
171  helloPacket->setByteLength(OSPF_HEADER_LENGTH + OSPF_HELLO_HEADER_LENGTH + initedNeighborCount * 4);
172 
173  parentArea->getRouter()->getMessageHandler()->sendPacket(helloPacket, destination, ifIndex, ttl);
174 }
Definition: OSPFNeighbor.h:64
const IPv4Address NULL_IPV4ADDRESS(0, 0, 0, 0)
IPv4Address ipInterfaceAddress
Definition: OSPFcommon.h:156
Definition: OSPFInterface.h:60
Router * getRouter()
Definition: OSPFArea.h:80
char bytes[8]
Definition: OSPFcommon.h:74
short helloInterval
Definition: OSPFInterface.h:82
int ifIndex
Definition: OSPFInterface.h:77
Definition: OSPFInterface.h:56
RouterID getRouterID() const
Definition: OSPFRouter.h:72
AreaID getAreaID() const
Definition: OSPFArea.h:64
std::vector< Neighbor * > neighboringRouters
Definition: OSPFInterface.h:92
short routerDeadInterval
Definition: OSPFInterface.h:84
IPv4Address address
Definition: OSPFcommon.h:79
Area * parentArea
Definition: OSPFInterface.h:102
DesignatedRouterID backupDesignatedRouter
Definition: OSPFInterface.h:95
OSPFInterfaceType interfaceType
Definition: OSPFInterface.h:74
AuthenticationKeyType authenticationKey
Definition: OSPFInterface.h:100
#define OSPF_HELLO_HEADER_LENGTH
Definition: OSPFcommon.h:50
unsigned char routerPriority
Definition: OSPFInterface.h:86
IPv4AddressRange interfaceAddressRange
Definition: OSPFInterface.h:79
void sendPacket(OSPFPacket *packet, IPv4Address destination, int outputIfIndex, short ttl=1)
Definition: MessageHandler.cc:305
#define OSPF_HEADER_LENGTH
Definition: OSPFcommon.h:48
AuthenticationType authenticationType
Definition: OSPFInterface.h:99
IPv4Address mask
Definition: OSPFcommon.h:80
MessageHandler * getMessageHandler()
Definition: OSPFRouter.h:77
DesignatedRouterID designatedRouter
Definition: OSPFInterface.h:94
const double k
Definition: QAM16Modulation.cc:24
bool getExternalRoutingCapability() const
Definition: OSPFArea.h:72
InterfaceStateType getState() const
Definition: OSPFInterface.cc:230
uint8_t ttl
Definition: TCP_NSC.cc:87
void inet::ospf::Interface::sendLSAcknowledgement ( OSPFLSAHeader lsaHeader,
IPv4Address  destination 
)

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

177 {
178  OSPFOptions options;
179  OSPFLinkStateAcknowledgementPacket *lsAckPacket = new OSPFLinkStateAcknowledgementPacket();
180 
181  lsAckPacket->setType(LINKSTATE_ACKNOWLEDGEMENT_PACKET);
182  lsAckPacket->setRouterID(IPv4Address(parentArea->getRouter()->getRouterID()));
183  lsAckPacket->setAreaID(IPv4Address(parentArea->getAreaID()));
184  lsAckPacket->setAuthenticationType(authenticationType);
185  for (int i = 0; i < 8; i++) {
186  lsAckPacket->setAuthentication(i, authenticationKey.bytes[i]);
187  }
188 
189  lsAckPacket->setLsaHeadersArraySize(1);
190  lsAckPacket->setLsaHeaders(0, *lsaHeader);
191 
192  lsAckPacket->setByteLength(OSPF_HEADER_LENGTH + OSPF_LSA_HEADER_LENGTH);
193 
195  parentArea->getRouter()->getMessageHandler()->sendPacket(lsAckPacket, destination, ifIndex, ttl);
196 }
#define VIRTUAL_LINK_TTL
Definition: OSPFcommon.h:45
Definition: OSPFInterface.h:60
Router * getRouter()
Definition: OSPFArea.h:80
char bytes[8]
Definition: OSPFcommon.h:74
int ifIndex
Definition: OSPFInterface.h:77
RouterID getRouterID() const
Definition: OSPFRouter.h:72
AreaID getAreaID() const
Definition: OSPFArea.h:64
Area * parentArea
Definition: OSPFInterface.h:102
OSPFInterfaceType interfaceType
Definition: OSPFInterface.h:74
AuthenticationKeyType authenticationKey
Definition: OSPFInterface.h:100
#define OSPF_LSA_HEADER_LENGTH
Definition: OSPFcommon.h:49
void sendPacket(OSPFPacket *packet, IPv4Address destination, int outputIfIndex, short ttl=1)
Definition: MessageHandler.cc:305
#define OSPF_HEADER_LENGTH
Definition: OSPFcommon.h:48
AuthenticationType authenticationType
Definition: OSPFInterface.h:99
MessageHandler * getMessageHandler()
Definition: OSPFRouter.h:77
uint8_t ttl
Definition: TCP_NSC.cc:87
void inet::ospf::Interface::setAcknowledgementDelay ( short  delay)
inline
147 { acknowledgementDelay = delay; }
short acknowledgementDelay
Definition: OSPFInterface.h:98
void inet::ospf::Interface::setAddressRange ( IPv4AddressRange  range)
inline

Referenced by inet::ospf::Area::calculateShortestPathTree().

161 { interfaceAddressRange = range; }
IPv4AddressRange interfaceAddressRange
Definition: OSPFInterface.h:79
void inet::ospf::Interface::setArea ( Area area)
inline

Referenced by inet::ospf::Area::addInterface().

173 { parentArea = area; }
Area * parentArea
Definition: OSPFInterface.h:102
void inet::ospf::Interface::setAreaID ( AreaID  areaId)
inline

Referenced by inet::ospf::OSPFConfigReader::loadInterfaceParameters().

137 { areaID = areaId; }
AreaID areaID
Definition: OSPFInterface.h:80
void inet::ospf::Interface::setAuthenticationKey ( AuthenticationKeyType  key)
inline

Referenced by inet::ospf::OSPFConfigReader::loadAuthenticationConfig().

159 { authenticationKey = key; }
AuthenticationKeyType authenticationKey
Definition: OSPFInterface.h:100
void inet::ospf::Interface::setAuthenticationType ( AuthenticationType  type)
inline

Referenced by inet::ospf::OSPFConfigReader::loadAuthenticationConfig().

157 { authenticationType = type; }
AuthenticationType authenticationType
Definition: OSPFInterface.h:99
void inet::ospf::Interface::setHelloInterval ( short  interval)
inline
void inet::ospf::Interface::setIfIndex ( IInterfaceTable ift,
int  index 
)

Referenced by inet::ospf::Area::calculateShortestPathTree(), and inet::ospf::OSPFConfigReader::loadInterfaceParameters().

91 {
92  ifIndex = index;
94  InterfaceEntry *routingInterface = ift->getInterfaceById(ifIndex);
95  interfaceAddressRange.address = routingInterface->ipv4Data()->getIPAddress();
96  interfaceAddressRange.mask = routingInterface->ipv4Data()->getNetmask();
97  mtu = routingInterface->getMTU();
98  }
99 }
Definition: OSPFInterface.h:55
int ifIndex
Definition: OSPFInterface.h:77
unsigned short mtu
Definition: OSPFInterface.h:78
IPv4Address address
Definition: OSPFcommon.h:79
OSPFInterfaceType interfaceType
Definition: OSPFInterface.h:74
IPv4AddressRange interfaceAddressRange
Definition: OSPFInterface.h:79
IPv4Address mask
Definition: OSPFcommon.h:80
void inet::ospf::Interface::setMTU ( unsigned short  ifMTU)
inline
135 { mtu = ifMTU; }
unsigned short mtu
Definition: OSPFInterface.h:78
void inet::ospf::Interface::setOutputCost ( Metric  cost)
inline
void inet::ospf::Interface::setPollInterval ( short  interval)
inline

Referenced by inet::ospf::OSPFConfigReader::loadInterfaceParameters().

153 { pollInterval = interval; }
short pollInterval
Definition: OSPFInterface.h:83
void inet::ospf::Interface::setRetransmissionInterval ( short  interval)
inline
void inet::ospf::Interface::setRouterDeadInterval ( short  interval)
inline
void inet::ospf::Interface::setRouterPriority ( unsigned char  priority)
inline

Referenced by inet::ospf::OSPFConfigReader::loadInterfaceParameters().

149 { routerPriority = priority; }
unsigned char routerPriority
Definition: OSPFInterface.h:86
void inet::ospf::Interface::setTransitAreaID ( AreaID  areaId)
inline

Referenced by inet::ospf::OSPFConfigReader::loadVirtualLink().

139 { transitAreaID = areaId; }
AreaID transitAreaID
Definition: OSPFInterface.h:81
void inet::ospf::Interface::setTransmissionDelay ( short  delay)
inline
void inet::ospf::Interface::setType ( OSPFInterfaceType  ifType)
inline

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

131 { interfaceType = ifType; }
OSPFInterfaceType interfaceType
Definition: OSPFInterface.h:74

Friends And Related Function Documentation

friend class InterfaceState
friend

Member Data Documentation

short inet::ospf::Interface::acknowledgementDelay
private
cMessage* inet::ospf::Interface::acknowledgementTimer
private
AreaID inet::ospf::Interface::areaID
private
AuthenticationType inet::ospf::Interface::authenticationType
private
DesignatedRouterID inet::ospf::Interface::backupDesignatedRouter
private
std::map<IPv4Address, std::list<OSPFLSAHeader> > inet::ospf::Interface::delayedAcknowledgements
private
short inet::ospf::Interface::helloInterval
private

Referenced by sendHelloPacket().

cMessage* inet::ospf::Interface::helloTimer
private

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

int inet::ospf::Interface::ifIndex
private
IPv4AddressRange inet::ospf::Interface::interfaceAddressRange
private
Metric inet::ospf::Interface::interfaceOutputCost
private
short inet::ospf::Interface::interfaceTransmissionDelay
private

Referenced by createUpdatePacket().

unsigned short inet::ospf::Interface::mtu
private
std::map<IPv4Address, Neighbor *> inet::ospf::Interface::neighboringRoutersByAddress
private
std::map<RouterID, Neighbor *> inet::ospf::Interface::neighboringRoutersByID
private

Referenced by addNeighbor(), and getNeighborByID().

short inet::ospf::Interface::pollInterval
private
InterfaceState* inet::ospf::Interface::previousState
private

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

short inet::ospf::Interface::retransmissionInterval
private
short inet::ospf::Interface::routerDeadInterval
private

Referenced by sendHelloPacket().

unsigned char inet::ospf::Interface::routerPriority
private
InterfaceState* inet::ospf::Interface::state
private
AreaID inet::ospf::Interface::transitAreaID
private
cMessage* inet::ospf::Interface::waitTimer
private

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


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