51 OSPFLinkStateUpdatePacket *lsUpdatePacket = check_and_cast<OSPFLinkStateUpdatePacket *>(packet);
52 bool shouldRebuildRoutingTable =
false;
55 AreaID areaID = lsUpdatePacket->getAreaID();
58 unsigned int currentLSAIndex = 0;
60 EV_INFO <<
" Processing packet contents:\n";
63 unsigned int lsaCount = 0;
65 switch (currentType) {
67 lsaCount = lsUpdatePacket->getRouterLSAsArraySize();
71 lsaCount = lsUpdatePacket->getNetworkLSAsArraySize();
76 lsaCount = lsUpdatePacket->getSummaryLSAsArraySize();
80 lsaCount = lsUpdatePacket->getAsExternalLSAsArraySize();
84 throw cRuntimeError(
"Invalid currentType:%d", currentType);
87 for (
unsigned int i = 0; i < lsaCount; i++) {
90 switch (currentType) {
92 currentLSA = (&(lsUpdatePacket->getRouterLSAs(i)));
96 currentLSA = (&(lsUpdatePacket->getNetworkLSAs(i)));
101 currentLSA = (&(lsUpdatePacket->getSummaryLSAs(i)));
105 currentLSA = (&(lsUpdatePacket->getAsExternalLSAs(i)));
109 throw cRuntimeError(
"Invalid currentType:%d", currentType);
116 LSAType lsaType =
static_cast<LSAType>(currentLSA->getHeader().getLsType());
126 LSAProcessingMarker marker(currentLSAIndex++);
127 EV_DETAIL <<
" " << currentLSA->getHeader() <<
"\n";
130 if ((lsaType ==
AS_EXTERNAL_LSA_TYPE) && !(area !=
nullptr && area->getExternalRoutingCapability())) {
135 lsaKey.linkStateID = currentLSA->getHeader().getLinkStateID();
136 lsaKey.advertisingRouter = currentLSA->getHeader().getAdvertisingRouter();
138 OSPFLSA *lsaInDatabase =
router->
findLSA(lsaType, lsaKey, areaID);
140 AcknowledgementFlags ackFlags;
142 ackFlags.floodedBackOut =
false;
143 ackFlags.lsaIsNewer =
false;
144 ackFlags.lsaIsDuplicate =
false;
145 ackFlags.impliedAcknowledgement =
false;
146 ackFlags.lsaReachedMaxAge = (lsAge ==
MAX_AGE);
147 ackFlags.noLSAInstanceInDatabase = (lsaInDatabase ==
nullptr);
150 if ((ackFlags.lsaReachedMaxAge) && (ackFlags.noLSAInstanceInDatabase) && (!ackFlags.anyNeighborInExchangeOrLoadingState)) {
167 intf->sendLSAcknowledgement(&(currentLSA->getHeader()), neighbor->getAddress());
173 if (!ackFlags.noLSAInstanceInDatabase) {
175 ackFlags.lsaIsNewer = (lsaInDatabase->getHeader() < currentLSA->getHeader());
176 ackFlags.lsaIsDuplicate = (
operator==(lsaInDatabase->getHeader(), currentLSA->getHeader()));
178 if ((ackFlags.noLSAInstanceInDatabase) || (ackFlags.lsaIsNewer)) {
179 LSATrackingInfo *info = (!ackFlags.noLSAInstanceInDatabase) ? dynamic_cast<LSATrackingInfo *>(lsaInDatabase) :
nullptr;
180 if ((!ackFlags.noLSAInstanceInDatabase) &&
187 ackFlags.floodedBackOut =
router->
floodLSA(currentLSA, areaID, intf, neighbor);
188 if (!ackFlags.noLSAInstanceInDatabase) {
191 lsaKey.linkStateID = lsaInDatabase->getHeader().getLinkStateID();
192 lsaKey.advertisingRouter = lsaInDatabase->getHeader().getAdvertisingRouter();
200 OSPFASExternalLSA *externalLSA = &(lsUpdatePacket->getAsExternalLSAs(0));
202 IPv4Address externalAddr = currentLSA->getHeader().getLinkStateID();
203 int ifName = intf->getIfIndex();
208 EV_INFO <<
" (update installed)\n";
210 acknowledgeLSA(currentLSA->getHeader(), intf, ackFlags, lsUpdatePacket->getRouterID());
215 if (ackFlags.noLSAInstanceInDatabase) {
216 currentLSA->getHeader().setLsAge(
MAX_AGE);
220 if (ackFlags.lsaIsNewer) {
221 long sequenceNumber = currentLSA->getHeader().getLsSequenceNumber();
223 lsaInDatabase->getHeader().setLsAge(
MAX_AGE);
227 lsaInDatabase->getHeader().setLsSequenceNumber(sequenceNumber + 1);
235 if (neighbor->isLSAOnRequestList(lsaKey)) {
239 if (ackFlags.lsaIsDuplicate) {
240 if (neighbor->isLinkStateRequestListEmpty(lsaKey)) {
241 neighbor->removeFromRetransmissionList(lsaKey);
242 ackFlags.impliedAcknowledgement =
true;
244 acknowledgeLSA(currentLSA->getHeader(), intf, ackFlags, lsUpdatePacket->getRouterID());
247 if ((lsaInDatabase->getHeader().getLsAge() ==
MAX_AGE) &&
252 if (!neighbor->isOnTransmittedLSAList(lsaKey)) {
253 OSPFLinkStateUpdatePacket *updatePacket = intf->createUpdatePacket(lsaInDatabase);
254 if (updatePacket !=
nullptr) {
279 currentType =
static_cast<LSAType>(currentType + 1);
281 currentType =
static_cast<LSAType>(currentType + 1);
286 if (shouldRebuildRoutingTable) {
#define VIRTUAL_LINK_TTL
Definition: OSPFcommon.h:45
void printEvent(const char *eventString, const Interface *onInterface=nullptr, const Neighbor *forNeighbor=nullptr) const
Definition: MessageHandler.cc:377
void removeFromAllRetransmissionLists(LSAKeyType lsaKey)
Removes all LSAs from all Neighbor's retransmission lists which are identified by the input lsaKey...
Definition: OSPFRouter.cc:410
Definition: OSPFInterface.h:60
bool validateLSChecksum(OSPFLSA *lsa)
Definition: LinkStateUpdateHandler.h:44
Router * router
Definition: IMessageHandler.h:35
IPv4Address AreaID
Definition: OSPFcommon.h:138
#define MIN_LS_ARRIVAL
Definition: OSPFcommon.h:35
Definition: OSPFNeighbor.h:47
bool operator==(Neighbor::DDPacketID leftID, Neighbor::DDPacketID rightID)
Definition: OSPFNeighbor.h:203
#define OSPF_EXTERNAL_ROUTES_LEARNED_BY_BGP
Definition: OSPFcommon.h:61
Definition: OSPFInterface.h:56
RouterID getRouterID() const
Definition: OSPFRouter.h:72
Definition: OSPFPacket_m.h:246
bool hasAnyNeighborInStates(int states) const
Returns true if any Neighbor on any Interface in any of the Router's Areas is in any of the input sta...
Definition: OSPFRouter.cc:399
bool installLSA(OSPFLSA *lsa, AreaID areaID=BACKBONE_AREAID)
Installs a new LSA into the Router database.
Definition: OSPFRouter.cc:108
Definition: OSPFNeighbor.h:68
#define MAX_SEQUENCE_NUMBER
Definition: OSPFcommon.h:43
Definition: OSPFInterface.h:70
const DesignatedRouterID NULL_DESIGNATEDROUTERID
Definition: OSPFcommon.h:164
bool floodLSA(OSPFLSA *lsa, AreaID areaID=BACKBONE_AREAID, Interface *intf=nullptr, Neighbor *neighbor=nullptr)
Floods out the input lsa on a set of Interfaces.
Definition: OSPFRouter.cc:429
void addExternalRouteInIPTable(IPv4Address networkAddress, const OSPFASExternalLSAContents &externalRouteContents, int ifIndex)
Add an AS External Route in IPRoutingTable.
Definition: OSPFRouter.cc:1375
Definition: OSPFInterface.h:57
OSPFLSA * findLSA(LSAType lsaType, LSAKeyType lsaKey, AreaID areaID)
Find the LSA identified by the input lsaKey in the database.
Definition: OSPFRouter.cc:230
bool isLocalAddress(IPv4Address address) const
Returns true if the input IPv4 address falls into any of the Router's Areas' configured IPv4 address ...
Definition: OSPFRouter.cc:455
Area * getAreaByID(AreaID areaID)
Returns the pointer to the Area identified by the input areaID, if it's on the Area list...
Definition: OSPFRouter.cc:72
#define MAX_AGE
Definition: OSPFcommon.h:36
Definition: OSPFInterface.h:69
Definition: OSPFPacket_m.h:245
LSAType
Enum generated from inet/routing/ospfv2/OSPFPacket.msg:84 by nedtool.
Definition: OSPFPacket_m.h:244
void sendPacket(OSPFPacket *packet, IPv4Address destination, int outputIfIndex, short ttl=1)
Definition: MessageHandler.cc:305
Definition: OSPFPacket_m.h:249
MessageHandler * getMessageHandler()
Definition: OSPFRouter.h:77
virtual OSPFLSAHeader & getHeader()
Definition: OSPFNeighbor.h:67
static const IPv4Address ALL_OSPF_DESIGNATED_ROUTERS_MCAST
224.0.0.6 All OSPF Designated Routers
Definition: IPv4Address.h:111
void acknowledgeLSA(OSPFLSAHeader &lsaHeader, Interface *intf, AcknowledgementFlags acknowledgementFlags, RouterID lsaSource)
Definition: LinkStateUpdateHandler.cc:291
Definition: OSPFPacket_m.h:247
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 rebuildRoutingTable()
Rebuilds the routing table from scratch(based on the LSA database).
Definition: OSPFRouter.cc:704
Definition: OSPFPacket_m.h:248