|
INET Framework for OMNeT++/OMNEST
|
Implementation of the Routing Information Protocol.
More...
#include <Rip.h>
|
| virtual int | numInitStages () const override |
| |
| virtual void | initialize (int stage) override |
| |
| virtual void | handleMessageWhenUp (cMessage *msg) override |
| |
| virtual void | receiveSignal (cComponent *source, simsignal_t signalID, cObject *obj, cObject *details) override |
| | Listen on interface/route changes and update private data structures. More...
|
| |
| virtual void | handleStartOperation (LifecycleOperation *operation) override |
| |
| virtual void | handleStopOperation (LifecycleOperation *operation) override |
| |
| virtual void | handleCrashOperation (LifecycleOperation *operation) override |
| |
| virtual void | startRIPRouting () |
| |
| virtual void | stopRIPRouting () |
| |
| virtual RipRoute * | importRoute (IRoute *route, RipRoute::RouteType type, int metric=1, uint16_t routeTag=0) |
| | Adds a new route the RIP routing table for an existing IRoute. More...
|
| |
| virtual void | sendRIPRequest (const RipNetworkInterface &ripInterface) |
| | Sends a RIP request to routers on the specified link. More...
|
| |
| virtual void | processRequest (Packet *pk) |
| | Processes a request received from a RIP router or a monitoring process. More...
|
| |
| virtual void | processUpdate (bool triggered) |
| | This method called when a triggered or regular update timer expired. More...
|
| |
| virtual void | sendRoutes (const L3Address &address, int port, const RipNetworkInterface &ripInterface, bool changedOnly) |
| | Send all or changed part of the routing table to address/port on the specified interface. More...
|
| |
| virtual void | processResponse (Packet *pk) |
| | Processes the RIP response and updates the routing table. More...
|
| |
| virtual bool | isValidResponse (Packet *packet) |
| |
| virtual void | updateRoute (RipRoute *route, const NetworkInterface *ie, const L3Address &nextHop, int metric, uint16_t routeTag, const L3Address &from) |
| | Updates an existing route with the information learned from a RIP packet. More...
|
| |
| virtual void | addRoute (const L3Address &dest, int prefixLength, const NetworkInterface *ie, const L3Address &nextHop, int metric, uint16_t routeTag, const L3Address &from) |
| | RFC 2453 3.9.2: More...
|
| |
| virtual void | checkExpiredRoutes () |
| | Should be called regularly to handle expiry and purge of routes. More...
|
| |
| virtual void | invalidateRoute (RipRoute *route) |
| |
| virtual RouteVector::iterator | purgeRoute (RipRoute *route) |
| | Removes the route from the routing table. More...
|
| |
| virtual void | triggerUpdate () |
| | Sets the update timer to trigger an update in the [1s,5s] interval. More...
|
| |
| virtual void | sendPacket (Packet *packet, const L3Address &destAddr, int destPort, const NetworkInterface *destInterface) |
| | Sends the packet to the specified destination. More...
|
| |
| virtual bool | isInitializeStage (int stage) const override |
| |
| virtual bool | isModuleStartStage (int stage) const override |
| |
| virtual bool | isModuleStopStage (int stage) const override |
| |
| virtual int | numInitStages () const override |
| |
| virtual void | refreshDisplay () const override |
| |
| virtual void | handleMessage (cMessage *msg) override |
| |
| virtual void | handleMessageWhenDown (cMessage *msg) |
| |
| virtual bool | handleOperationStage (LifecycleOperation *operation, IDoneCallback *doneCallback) override |
| | Perform one stage of a lifecycle operation. More...
|
| |
| virtual State | getInitialOperationalState () const |
| | Returns initial operational state: OPERATING or NOT_OPERATING. More...
|
| |
| virtual void | handleActiveOperationTimeout (cMessage *message) |
| |
| virtual bool | isUp () const |
| | utility functions More...
|
| |
| virtual bool | isDown () const |
| |
| virtual void | setOperationalState (State newState) |
| |
| virtual void | scheduleOperationTimeout (simtime_t timeout) |
| |
| virtual void | setupActiveOperation (LifecycleOperation *operation, IDoneCallback *doneCallback, State) |
| |
| virtual void | delayActiveOperationFinish (simtime_t timeout) |
| |
| virtual void | startActiveOperationExtraTime (simtime_t delay=SIMTIME_ZERO) |
| |
| virtual void | startActiveOperationExtraTimeOrFinish (simtime_t extraTime) |
| |
| virtual void | finishActiveOperation () |
| |
Implementation of the Routing Information Protocol.
This module supports RIPv2 (RFC 2453) and RIPng (RFC 2080).
RIP is a distance vector routing protocol. Each RIP router periodically sends its whole routing table to neighbor routers, and updates its own routing table according to the received information. If a route changed the router might send a notification to its neighbors immediately (or rather with a small delay) which contains only the changed routes (triggered updates).
TODO
- Initially the router knows only the routes to the directly connected networks, and the routes that were manually configured. As it receives route updates from the neighbors it learns routes to remote networks. It should be possible to cooperate with other routing protocols that work in the same AS (e.g. OSPF) or with exterior protocols that connects this AS to other ASs (e.g. BGP). This requires some configurable criteria which routes of the routing table should be advertise by the RIP router, e.g. 'advertise the default route added by BGP with RIP metric 1'.
- There is no merging of subnet routes. RFC 2453 3.7 suggests that subnetted network routes should not be advertised outside the subnetted network.
◆ InterfaceVector
◆ RouteVector
◆ Mode
◆ Rip()
◆ ~Rip()
◆ addRipInterface()
| void inet::Rip::addRipInterface |
( |
const NetworkInterface * |
ie, |
|
|
cXMLElement * |
config |
|
) |
| |
|
private |
1041 RipNetworkInterface ripInterface(ie);
1046 const char *metricAttr = config->getAttribute(
"metric");
1049 int metric = atoi(metricAttr);
1051 throw cRuntimeError(
"RIP: invalid metric in <interface> element at %s: %s", config->getSourceLocation(), metricAttr);
1052 ripInterface.metric = metric;
1055 const char *ripModeAttr = config->getAttribute(
"mode");
1057 strcmp(ripModeAttr,
"NoRIP") == 0 ?
NO_RIP :
1058 strcmp(ripModeAttr,
"PASSIVE") == 0 ?
PASSIVE :
1066 throw cRuntimeError(
"RIP: invalid mode attribute in <interface> element at %s: %s",
1067 config->getSourceLocation(), ripModeAttr);
1068 ripInterface.mode =
mode;
Referenced by receiveSignal(), and startRIPRouting().
◆ addRoute()
RFC 2453 3.9.2:
Adding a route to the routing table consists of:
- Setting the destination address to the destination address in the RTE
- Setting the metric to the newly calculated metric
- Set the next hop address to be the address of the router from which the datagram came
- Initialize the timeout for the route. If the garbage-collection timer is running for this route, stop it
- Set the route change flag
- Signal the output process to trigger an update
805 EV_DEBUG <<
"Add route to " << dest <<
"/" << prefixLength <<
": "
806 <<
"nextHop=" << nextHop <<
" metric=" << metric << std::endl;
808 IRoute *route =
createRoute(dest, prefixLength, ie, nextHop, metric);
811 ripRoute->setFrom(from);
812 ripRoute->setLastUpdateTime(simTime());
813 ripRoute->setChanged(
true);
Referenced by processResponse().
◆ checkExpiredRoutes()
| void inet::Rip::checkExpiredRoutes |
( |
| ) |
|
|
protectedvirtual |
Should be called regularly to handle expiry and purge of routes.
906 RipRoute *ripRoute = (*iter);
908 simtime_t now = simTime();
Referenced by sendRoutes().
◆ createRoute()
1106 IRoute *route =
rt->createRoute();
1109 route->setDestination(dest);
1110 route->setNextHop(nextHop);
1111 route->setPrefixLength(prefixLength);
1112 route->setMetric(metric);
1114 route->setInterface(
const_cast<NetworkInterface *
>(ie));
1116 route->setSource(
this);
1118 EV_DETAIL <<
"Adding new route " << route << endl;
1119 rt->addRoute(route);
Referenced by addRoute(), and updateRoute().
◆ deleteRipInterface()
1083 bool emitNumRoutesSignal =
false;
1085 if ((*it)->getInterface() == ie) {
1088 emitNumRoutesSignal =
true;
1093 if (emitNumRoutesSignal)
Referenced by receiveSignal().
◆ findRipInterfaceById()
◆ findRipRoute() [1/4]
1024 if ((elem)->getRoute() == route)
◆ findRipRoute() [2/4]
| RipRoute * inet::Rip::findRipRoute |
( |
const L3Address & |
destAddress, |
|
|
int |
prefixLength |
|
) |
| |
|
private |
◆ findRipRoute() [3/4]
1015 if ((elem)->getType() ==
type && (elem)->getDestination() == destination && (elem)->getPrefixLength() == prefixLength)
◆ findRipRoute() [4/4]
1033 if ((elem)->getType() ==
type && (elem)->getInterface() == ie)
◆ getInterfaceMetric()
◆ handleCrashOperation()
◆ handleMessageWhenUp()
| void inet::Rip::handleMessageWhenUp |
( |
cMessage * |
msg | ) |
|
|
overrideprotectedvirtual |
Implements inet::OperationalMixin< cSimpleModule >.
130 if (msg->isSelfMessage()) {
146 throw cRuntimeError(
"unknown self message");
149 Packet *pk = check_and_cast<Packet *>(msg);
150 unsigned char command = pk->peekAtFront<RipPacket>()->getCommand();
156 throw cRuntimeError(
"RIP: unknown command (%d)", (
int)command);
159 EV_DETAIL <<
"Ignoring UDP error report\n";
163 EV_DETAIL <<
"Ignoring UDP socket closed indication\n";
167 throw cRuntimeError(
"RIP: unknown msg kind (%d)", (
int)msg->getKind());
◆ handleStartOperation()
◆ handleStopOperation()
◆ importRoute()
Adds a new route the RIP routing table for an existing IRoute.
This route will be advertised with the specified metric and routeTag fields.
267 RipRoute *ripRoute =
new RipRoute(route,
type, metric, routeTag);
269 NetworkInterface *ie = check_and_cast<NetworkInterface *>(route->getSource());
270 ripRoute->setInterface(ie);
Referenced by receiveSignal(), and startRIPRouting().
◆ initialize()
| void inet::Rip::initialize |
( |
int |
stage | ) |
|
|
overrideprotectedvirtual |
Reimplemented from inet::OperationalMixin< cSimpleModule >.
96 ift.reference(
this,
"interfaceTableModule",
true);
97 rt.reference(
this,
"routingTableModule",
true);
100 const char *
m = par(
"mode");
102 throw cRuntimeError(
"Missing 'mode' parameter.");
103 else if (!strcmp(
m,
"RIPv2"))
105 else if (!strcmp(
m,
"RIPng"))
108 throw cRuntimeError(
"Unrecognized 'mode' parameter: %s",
m);
◆ invalidateRoute()
| void inet::Rip::invalidateRoute |
( |
RipRoute * |
route | ) |
|
|
protectedvirtual |
934 EV_INFO <<
"invalidating route dest:" << ripRoute->getDestination() <<
"\n";
936 IRoute *route = ripRoute->getRoute();
938 ripRoute->setRoute(
nullptr);
939 rt->deleteRoute(route);
942 ripRoute->setChanged(
true);
943 ripRoute->setLastInvalidationTime(simTime());
Referenced by checkExpiredRoutes(), handleStopOperation(), receiveSignal(), and updateRoute().
◆ isDefaultRoute()
| bool inet::Rip::isDefaultRoute |
( |
const IRoute * |
route | ) |
|
|
inlineprivate |
◆ isLocalInterfaceRoute()
| bool inet::Rip::isLocalInterfaceRoute |
( |
const IRoute * |
route | ) |
|
|
inlineprivate |
173 NetworkInterface *ie =
dynamic_cast<NetworkInterface *
>(route->getSource());
174 return ie && !ie->isLoopback();
Referenced by receiveSignal(), and startRIPRouting().
◆ isLoopbackInterfaceRoute()
| bool inet::Rip::isLoopbackInterfaceRoute |
( |
const IRoute * |
route | ) |
|
|
inlineprivate |
168 NetworkInterface *ie =
dynamic_cast<NetworkInterface *
>(route->getSource());
169 return ie && ie->isLoopback();
Referenced by receiveSignal(), and startRIPRouting().
◆ isValidResponse()
| bool inet::Rip::isValidResponse |
( |
Packet * |
packet | ) |
|
|
protectedvirtual |
724 EV_WARN <<
"source port is not " <<
ripUdpPort <<
"\n";
728 L3Address srcAddr = packet->getTag<
L3AddressInd>()->getSrcAddress();
731 if (
rt->isLocalAddress(srcAddr)) {
732 EV_WARN <<
"received own response\n";
737 if (!srcAddr.isLinkLocal()) {
738 EV_WARN <<
"source address is not link-local: " << srcAddr <<
"\n";
741 if (packet->getTag<HopLimitInd>()->getHopLimit() != 255) {
742 EV_WARN <<
"ttl is not 255";
748 if (!
ift->isNeighborAddress(srcAddr)) {
749 EV_WARN <<
"source is not directly connected " << srcAddr <<
"\n";
754 const auto& ripPacket = packet->peekAtFront<RipPacket>();
756 int numEntries = ripPacket->getEntryArraySize();
757 for (
int i = 0; i < numEntries; ++i) {
758 const RipEntry& entry = ripPacket->getEntry(i);
768 if (!entry.address.isUnicast()) {
769 EV_WARN <<
"destination address of an entry is not unicast: " << entry.address <<
"\n";
774 if (entry.address.isLinkLocal()) {
775 EV_WARN <<
"destination address of an entry is link-local: " << entry.address <<
"\n";
Referenced by processResponse().
◆ numInitStages()
| virtual int inet::Rip::numInitStages |
( |
| ) |
const |
|
inlineoverrideprotectedvirtual |
◆ processRequest()
| void inet::Rip::processRequest |
( |
Packet * |
packet | ) |
|
|
protectedvirtual |
Processes a request received from a RIP router or a monitoring process.
The request processing follows the guidelines described in RFC 2453 3.9.1.
There are two cases:
- the request enumerates the requested prefixes There is an RipEntry for each requested route in the packet. The RIP module simply looks up the prefix in its table, and if it sets the metric field of the entry to the metric of the found route, or to infinity (16) if not found. Once all entries are have been filled in, change the command from Request to Response, and sent the packet back to the requester. If there are no entries in the request, then no response is sent; the request is silently discarded.
- the whole routing table is requested In this case the RipPacket contains only one entry, with addressFamilyId 0, and metric 16 (infinity). In this case the whole routing table is sent, using the normal output process (sendRoutes() method).
473 const auto& ripPacket = dynamicPtrCast<RipPacket>(packet->peekAtFront<RipPacket>()->dupShared());
475 int numEntries = ripPacket->getEntryArraySize();
476 if (numEntries == 0) {
477 EV_INFO <<
"received empty request, ignoring.\n";
482 L3Address srcAddr = packet->getTag<
L3AddressInd>()->getSrcAddress();
483 int srcPort = packet->getTag<
L4PortInd>()->getSrcPort();
484 int interfaceId = packet->getTag<InterfaceInd>()->getInterfaceId();
486 EV_INFO <<
"received request from " << srcAddr <<
"\n";
488 for (
int i = 0; i < numEntries; ++i) {
489 RipEntry& entry = ripPacket->getEntryForUpdate(i);
490 switch (entry.addressFamilyId) {
495 sendRoutes(srcAddr, srcPort, *ripInterface,
false);
500 throw cRuntimeError(
"RIP: invalid request.");
505 RipRoute *ripRoute =
findRipRoute(entry.address, entry.prefixLength);
512 throw cRuntimeError(
"RIP: request has invalid addressFamilyId: %d.", (
int)entry.addressFamilyId);
517 Packet *outPacket =
new Packet(
"RIP response");
518 outPacket->insertAtBack(ripPacket);
Referenced by handleMessageWhenUp().
◆ processResponse()
| void inet::Rip::processResponse |
( |
Packet * |
packet | ) |
|
|
protectedvirtual |
Processes the RIP response and updates the routing table.
First it validates the packet to avoid corrupting the routing table with a wrong packet. Valid responses must come from a neighboring RIP router.
Next each RipEntry is processed one by one. Check that destination address and metric are valid. Then compute the new metric by adding the metric of the interface to the metric found in the entry.
If there is no route to the destination, and the new metric is not infinity, then add a new route to the routing table.
If there is an existing route to the destination,
- validate packet
- for each entry: metric = MIN(p.metric + cost of if it arrived at, infinity) if there is no route for the dest address: add new route to the routing table unless the metric is infinity else: if received from the route.gateway reinitialize timeout if (received from route.gateway AND route.metric != metric) OR metric < route.metric updateRoute(route)
648 EV_INFO <<
"dropping invalid response.\n";
654 L3Address srcAddr = packet->getTag<
L3AddressInd>()->getSrcAddress();
655 int interfaceId = packet->getTag<InterfaceInd>()->getInterfaceId();
660 EV_INFO <<
"dropping unexpected RIP response.\n";
666 const auto& ripPacket = packet->peekAtFront<RipPacket>();
668 EV_INFO <<
"response received from " << srcAddr <<
"\n";
669 int numEntries = ripPacket->getEntryArraySize();
670 for (
int i = 0; i < numEntries; ++i) {
671 const RipEntry& entry = ripPacket->getEntry(i);
673 L3Address nextHop = entry.nextHop.isUnspecified() ? srcAddr : entry.nextHop;
675 RipRoute *ripRoute =
findRipRoute(entry.address, entry.prefixLength);
678 int routeMetric = ripRoute->getMetric();
679 L3Address fromAddr = ripRoute->getFrom();
684 if (fromAddr == srcAddr)
685 ripRoute->setLastUpdateTime(simTime());
687 if (metric < routeMetric || (fromAddr == srcAddr && routeMetric != metric)) {
688 bool preventRouteUpdate =
false;
692 EV_DEBUG <<
"hold-down timer prevents update to route " << ripRoute->getDestination() << std::endl;
693 preventRouteUpdate =
true;
696 IRoute *route = ripRoute->getRoute();
697 if (route && route->getMetric() <= metric) {
698 EV_DEBUG <<
"existing route " << ripRoute->getDestination() <<
" has a better metric" << std::endl;
699 preventRouteUpdate =
true;
704 if (!preventRouteUpdate)
705 updateRoute(ripRoute, incomingIe->ie, nextHop, metric, entry.routeTag, srcAddr);
713 addRoute(entry.address, entry.prefixLength, incomingIe->ie, nextHop, metric, entry.routeTag, srcAddr);
Referenced by handleMessageWhenUp().
◆ processUpdate()
| void inet::Rip::processUpdate |
( |
bool |
triggered | ) |
|
|
protectedvirtual |
This method called when a triggered or regular update timer expired.
It either sends the changed/all routes to neighbors.
439 EV_INFO <<
"sending triggered updates on all interfaces.\n";
441 EV_INFO <<
"sending regular updates on all interfaces\n";
444 if (ripInterface.ie->isUp())
449 ripRoute->setChanged(
false);
Referenced by handleMessageWhenUp().
◆ purgeRoute()
| Rip::RouteVector::iterator inet::Rip::purgeRoute |
( |
RipRoute * |
route | ) |
|
|
protectedvirtual |
Removes the route from the routing table.
954 EV_INFO <<
"purging route dest:" << ripRoute->getDestination() <<
"\n";
956 IRoute *route = ripRoute->getRoute();
958 ripRoute->setRoute(
nullptr);
959 rt->deleteRoute(route);
Referenced by checkExpiredRoutes().
◆ receiveSignal()
| void inet::Rip::receiveSignal |
( |
cComponent * |
source, |
|
|
simsignal_t |
signalID, |
|
|
cObject * |
obj, |
|
|
cObject * |
details |
|
) |
| |
|
overrideprotectedvirtual |
Listen on interface/route changes and update private data structures.
304 Enter_Method(
"%s", cComponent::getSignalName(signalID));
306 const NetworkInterface *ie;
307 const NetworkInterfaceChangeDetails *change;
311 ie = check_and_cast<const NetworkInterface *>(obj);
312 if (ie->isMulticast() && !ie->isLoopback()) {
313 cXMLElementList config = par(
"ripConfig").xmlValue()->getChildrenByTagName(
"interface");
314 int i = InterfaceMatcher(config).findMatchingSelector(ie);
321 ie = check_and_cast<const NetworkInterface *>(obj);
325 change = check_and_cast<const NetworkInterfaceChangeDetails *>(obj);
326 auto fieldId = change->getFieldId();
328 ie = change->getNetworkInterface();
331 if ((elem)->getInterface() == ie) {
337 if (ripInterfacePtr && ripInterfacePtr->mode !=
NO_RIP && ripInterfacePtr->mode !=
PASSIVE)
344 const IRoute *route = check_and_cast<const IRoute *>(obj);
346 if ((elem)->getRoute() == route) {
347 (elem)->setRoute(
nullptr);
348 if (route->getSource() !=
this) {
356 IRoute *route =
const_cast<IRoute *
>(check_and_cast<const IRoute *>(obj));
357 if (route->getSource() !=
this) {
361 NetworkInterface *ie = check_and_cast<NetworkInterface *>(route->getSource());
365 ripRoute->setRoute(route);
366 ripRoute->setMetric(ripIe ? ripIe->metric : 1);
367 ripRoute->setChanged(
true);
372 if (!ripIe || ripIe->mode !=
NO_RIP)
382 const IRoute *route = check_and_cast<const IRoute *>(obj);
383 if (route->getSource() !=
this) {
387 bool changed = route->getDestinationAsGeneric() != ripRoute->getDestination() ||
388 route->getPrefixLength() != ripRoute->getPrefixLength() ||
389 route->getNextHopAsGeneric() != ripRoute->getNextHop() ||
390 route->getInterface() != ripRoute->getInterface();
391 ripRoute->setDestination(route->getDestinationAsGeneric());
392 ripRoute->setPrefixLength(route->getPrefixLength());
393 ripRoute->setNextHop(route->getNextHopAsGeneric());
394 ripRoute->setInterface(route->getInterface());
396 ripRoute->setChanged(
true);
403 throw cRuntimeError(
"Unexpected signal: %s", getSignalName(signalID));
◆ sendPacket()
Sends the packet to the specified destination.
If the destAddr is a multicast, then the destInterface must be specified.
980 if (destAddr.isMulticast()) {
981 packet->addTagIfAbsent<
InterfaceReq>()->setInterfaceId(destInterface->getInterfaceId());
Referenced by sendRIPRequest(), and sendRoutes().
◆ sendRIPRequest()
Sends a RIP request to routers on the specified link.
283 const auto& packet = makeShared<RipPacket>();
285 packet->setEntryArraySize(1);
286 RipEntry& entry = packet->getEntryForUpdate(0);
291 EV_INFO <<
"sending RIP request from " << ripInterface.ie->getInterfaceName() <<
"\n";
293 Packet *pk =
new Packet(
"RIP request");
294 pk->insertAtBack(packet);
Referenced by receiveSignal(), and startRIPRouting().
◆ sendRoutes()
Send all or changed part of the routing table to address/port on the specified interface.
This method is called by regular updates (every 30s), triggered updates (when some route changed), and when RIP requests are processed.
529 if (ripInterface.mode ==
NO_RIP)
532 if (ripInterface.mode ==
PASSIVE) {
533 EV_DEBUG <<
"No update is sent from passive interface " << ripInterface.ie->getFullName() << std::endl;
538 EV_DEBUG <<
"Sending " << (changedOnly ?
"changed" :
"all") <<
" routes on " << ripInterface.ie->getFullName() << std::endl;
542 Packet *pk =
new Packet(
"RIP response");
543 auto packet = makeShared<RipPacket>();
545 packet->setEntryArraySize(maxEntries);
557 if (!ripRoute->isChanged())
567 int metric = ripRoute->getMetric();
568 if (ripRoute->getInterface() == ripInterface.ie) {
575 EV_DEBUG <<
"Add entry for " << ripRoute->getDestination() <<
"/" << ripRoute->getPrefixLength() <<
": "
576 <<
" metric=" << metric << std::endl;
579 RipEntry& entry = packet->getEntryForUpdate(
k++);
581 entry.address = ripRoute->getDestination();
582 entry.prefixLength = ripRoute->getPrefixLength();
584 entry.routeTag = ripRoute->getRouteTag();
585 entry.metric = metric;
588 if (
k >= maxEntries) {
590 pk->insertAtBack(packet);
593 sendPacket(pk, address, port, ripInterface.ie);
594 pk =
new Packet(
"RIP response");
595 packet = makeShared<RipPacket>();
597 packet->setEntryArraySize(maxEntries);
604 packet->setEntryArraySize(
k);
606 pk->insertAtBack(packet);
609 sendPacket(pk, address, port, ripInterface.ie);
Referenced by handleStopOperation(), processRequest(), and processUpdate().
◆ startRIPRouting()
| void inet::Rip::startRIPRouting |
( |
| ) |
|
|
protectedvirtual |
174 cXMLElementList interfaceElements = par(
"ripConfig").xmlValue()->getChildrenByTagName(
"interface");
175 InterfaceMatcher matcher(interfaceElements);
178 for (
int k = 0;
k <
ift->getNumInterfaces(); ++
k) {
179 NetworkInterface *ie =
ift->getInterface(
k);
180 if (ie->isMulticast() && !ie->isLoopback()) {
181 int i = matcher.findMatchingSelector(ie);
187 for (
int i = 0; i <
rt->getNumRoutes(); ++i) {
188 IRoute *route =
rt->getRoute(i);
192 NetworkInterface *ie = check_and_cast<NetworkInterface *>(route->getSource());
194 if (!ripIe || ripIe->mode !=
NO_RIP)
200 const L3Address& destAddr = route->getDestinationAsGeneric();
201 if (!destAddr.isMulticast() && !destAddr.isLinkLocal())
Referenced by handleMessageWhenUp().
◆ stopRIPRouting()
| void inet::Rip::stopRIPRouting |
( |
| ) |
|
|
protectedvirtual |
◆ triggerUpdate()
| void inet::Rip::triggerUpdate |
( |
| ) |
|
|
protectedvirtual |
Sets the update timer to trigger an update in the [1s,5s] interval.
If the update is already scheduled, it does nothing.
888 double delay = par(
"triggeredUpdateDelay");
892 EV_DETAIL <<
"scheduling triggered update \n";
Referenced by addRoute(), invalidateRoute(), receiveSignal(), and updateRoute().
◆ updateRoute()
Updates an existing route with the information learned from a RIP packet.
If the metric is infinite (16), then the route is invalidated. It triggers an update, so neighbor routers are notified about the change.
RFC 2453 3.9.2:
Do the following actions:
- Adopt the route from the datagram (i.e., put the new metric in and adjust the next hop address, if necessary).
- Set the route change flag and signal the output process to trigger an update
- If the new metric is infinity, start the deletion process (described above); otherwise, re-initialize the timeout
838 EV_DEBUG <<
"Updating route to " << ripRoute->getDestination() <<
"/" << ripRoute->getPrefixLength() <<
": "
839 <<
"nextHop=" << nextHop <<
" metric=" << metric << std::endl;
841 int oldMetric = ripRoute->getMetric();
843 ripRoute->setInterface(
const_cast<NetworkInterface *
>(ie));
844 ripRoute->setMetric(metric);
845 ripRoute->setFrom(from);
846 ripRoute->setRouteTag(routeTag);
849 IRoute *route = ripRoute->getRoute();
851 rt->deleteRoute(route);
853 ripRoute->setNextHop(nextHop);
854 IRoute *newRoute =
createRoute(ripRoute->getDestination(), ripRoute->getPrefixLength(), ie, nextHop, metric);
855 ripRoute->setRoute(newRoute);
859 IRoute *route = ripRoute->getRoute();
861 rt->deleteRoute(route);
863 ripRoute->setRoute(
nullptr);
864 ripRoute->setNextHop(nextHop);
867 IRoute *newRoute =
createRoute(ripRoute->getDestination(), ripRoute->getPrefixLength(), ie, nextHop, metric);
868 ripRoute->setRoute(newRoute);
872 ripRoute->setChanged(
true);
878 ripRoute->setLastUpdateTime(simTime());
Referenced by processResponse().
◆ addressType
◆ badResponseSignal
| simsignal_t inet::Rip::badResponseSignal = registerSignal("badResponse") |
|
staticprivate |
◆ holdDownTime
| simtime_t inet::Rip::holdDownTime |
|
private |
◆ host
| cModule* inet::Rip::host = nullptr |
|
private |
◆ ift
◆ mode
| Mode inet::Rip::mode = static_cast<Mode>(-1) |
|
private |
◆ numRoutesSignal
| simsignal_t inet::Rip::numRoutesSignal = registerSignal("numRoutes") |
|
staticprivate |
◆ rcvdResponseSignal
| simsignal_t inet::Rip::rcvdResponseSignal = registerSignal("rcvdResponse") |
|
staticprivate |
◆ ripInterfaces
◆ ripRoutingTable
Referenced by addRoute(), checkExpiredRoutes(), deleteRipInterface(), findRipRoute(), handleStopOperation(), importRoute(), initialize(), processUpdate(), purgeRoute(), receiveSignal(), sendRoutes(), stopRIPRouting(), and ~Rip().
◆ ripUdpPort
| int inet::Rip::ripUdpPort = -1 |
|
private |
◆ routeExpiryTime
| simtime_t inet::Rip::routeExpiryTime |
|
private |
◆ routePurgeTime
| simtime_t inet::Rip::routePurgeTime |
|
private |
◆ rt
◆ sentRequestSignal
| simsignal_t inet::Rip::sentRequestSignal = registerSignal("sentRequest") |
|
staticprivate |
◆ sentUpdateSignal
| simsignal_t inet::Rip::sentUpdateSignal = registerSignal("sentUpdate") |
|
staticprivate |
◆ shutdownTime
| simtime_t inet::Rip::shutdownTime |
|
private |
◆ shutdownTimer
| cMessage* inet::Rip::shutdownTimer = nullptr |
|
private |
◆ socket
◆ startupTimer
| cMessage* inet::Rip::startupTimer = nullptr |
|
private |
◆ triggeredUpdate
| bool inet::Rip::triggeredUpdate = false |
|
private |
◆ triggeredUpdateTimer
| cMessage* inet::Rip::triggeredUpdateTimer = nullptr |
|
private |
◆ updateInterval
| simtime_t inet::Rip::updateInterval |
|
private |
◆ updateTimer
| cMessage* inet::Rip::updateTimer = nullptr |
|
private |
The documentation for this class was generated from the following files:
void setOutputGate(cGate *toUdp)
Sets the gate on which to send to UDP.
Definition: UdpSocket.h:117
simtime_t routePurgeTime
Definition: Rip.h:103
void setTimeToLive(int ttl)
Set the TTL (Ipv6: Hop Limit) field on sent packets.
Definition: UdpSocket.cc:112
@ F_STATE
Definition: NetworkInterface.h:146
@ RIP_AF_NONE
Definition: RipPacket_m.h:90
cMessage * startupTimer
Definition: Rip.h:96
@ RIP_REQUEST
Definition: RipPacket_m.h:68
virtual void startRIPRouting()
Definition: Rip.cc:170
RipNetworkInterface * findRipInterfaceById(int interfaceId)
Definition: Rip.cc:994
State operationalState
Definition: OperationalMixin.h:23
virtual void checkExpiredRoutes()
Should be called regularly to handle expiry and purge of routes.
Definition: Rip.cc:901
virtual RipRoute * importRoute(IRoute *route, RipRoute::RouteType type, int metric=1, uint16_t routeTag=0)
Adds a new route the RIP routing table for an existing IRoute.
Definition: Rip.cc:263
void bind(int localPort)
Bind the socket to a local port number.
Definition: UdpSocket.cc:34
IRoute * createRoute(const L3Address &dest, int prefixLength, const NetworkInterface *ie, const L3Address &nextHop, int metric)
Definition: Rip.cc:1103
virtual int getMaxPrefixLength() const =0
virtual void triggerUpdate()
Sets the update timer to trigger an update in the [1s,5s] interval.
Definition: Rip.cc:885
void sendTo(Packet *msg, L3Address destAddr, int destPort)
Sends a data packet to the given address and port.
Definition: UdpSocket.cc:69
static simsignal_t numRoutesSignal
Definition: Rip.h:113
@ RIP
managed by the given routing protocol
Definition: IRoute.h:34
static simsignal_t sentRequestSignal
Definition: Rip.h:109
@ RIPv2
Definition: Rip.h:82
RipMode
Enumerated parameter to control how the Rip module advertises the routes to its neighbors.
Definition: Rip.h:28
void addRipInterface(const NetworkInterface *ie, cXMLElement *config)
Definition: Rip.cc:1039
double min(const double a, const double b)
Returns the minimum of a and b.
Definition: SctpAssociation.h:261
cModule * getContainingNode(const cModule *from)
Find the node containing the given module.
Definition: ModuleAccess.cc:40
virtual void initialize(int stage) override
Definition: OperationalMixinImpl.h:26
simsignal_t routeChangedSignal
Definition: Simsignals.cc:43
removed InterfaceReq
Definition: IUdp-gates.txt:11
simtime_t holdDownTime
Definition: Rip.h:104
virtual void addRoute(const L3Address &dest, int prefixLength, const NetworkInterface *ie, const L3Address &nextHop, int metric, uint16_t routeTag, const L3Address &from)
RFC 2453 3.9.2:
Definition: Rip.cc:802
Mode mode
Definition: Rip.h:99
#define RIP_INFINITE_METRIC
Definition: Rip.h:22
@ RIP_RESPONSE
Definition: RipPacket_m.h:69
removed DscpReq Ipv4ControlInfo Ipv6ControlInfo up L3AddressInd L3AddressInd
Definition: IUdp-gates.txt:20
std::vector< T >::iterator find(std::vector< T > &v, const Tk &a)
Definition: stlutils.h:44
void deleteRipInterface(const NetworkInterface *ie)
Definition: Rip.cc:1074
@ NO_SPLIT_HORIZON
Definition: Rip.h:31
simtime_t updateInterval
Definition: Rip.h:101
bool triggeredUpdate
Definition: Rip.h:106
virtual L3Address getLinkLocalAddress(const NetworkInterface *ie) const =0
Returns the first valid link-local address of the interface, or UNSPECIFIED_ADDRESS if there's none.
cMessage * triggeredUpdateTimer
Definition: Rip.h:95
virtual RouteVector::iterator purgeRoute(RipRoute *route)
Removes the route from the routing table.
Definition: Rip.cc:950
static simsignal_t badResponseSignal
Definition: Rip.h:112
RouteVector ripRoutingTable
Definition: Rip.h:92
cMessage * shutdownTimer
Definition: Rip.h:97
simsignal_t interfaceDeletedSignal
Definition: Simsignals.cc:31
@ F_CARRIER
Definition: NetworkInterface.h:146
UdpSocket socket
Definition: Rip.h:93
virtual void invalidateRoute(RipRoute *route)
Definition: Rip.cc:932
bool isLocalInterfaceRoute(const IRoute *route)
Definition: Rip.h:172
intscale< b, 1, 8 > B
Definition: Units.h:1168
@ SPLIT_HORIZON_POISON_REVERSE
Definition: Rip.h:33
virtual L3Address getUnspecifiedAddress() const =0
bool isDefaultRoute(const IRoute *route)
Definition: Rip.h:177
cModule * host
Definition: Rip.h:86
@ UDP_I_SOCKET_CLOSED
Definition: UdpControlInfo_m.h:159
bool isLoopbackInterfaceRoute(const IRoute *route)
Definition: Rip.h:167
simtime_t shutdownTime
Definition: Rip.h:105
@ SPLIT_HORIZON
Definition: Rip.h:32
virtual void updateRoute(RipRoute *route, const NetworkInterface *ie, const L3Address &nextHop, int metric, uint16_t routeTag, const L3Address &from)
Updates an existing route with the information learned from a RIP packet.
Definition: Rip.cc:836
int getInterfaceMetric(NetworkInterface *ie)
Definition: Rip.cc:1097
removed type
Definition: IUdp-gates.txt:7
virtual void processRequest(Packet *pk)
Processes a request received from a RIP router or a monitoring process.
Definition: Rip.cc:471
void joinMulticastGroup(const L3Address &multicastAddr, int interfaceId=-1)
Adds the socket to the given multicast group, that is, UDP packets arriving to the given multicast ad...
Definition: UdpSocket.cc:175
simsignal_t interfaceStateChangedSignal
Definition: Simsignals.cc:32
INET_API InitStage INITSTAGE_LOCAL
Initialization of local state that don't use or affect other modules includes:
@ NO_RIP
Definition: Rip.h:29
InterfaceVector ripInterfaces
Definition: Rip.h:91
int ripUdpPort
Definition: Rip.h:100
@ dRIP
Definition: IRoute.h:69
@ RIPng
Definition: Rip.h:82
virtual void close() override
Unbinds the socket.
Definition: UdpSocket.cc:87
virtual void processResponse(Packet *pk)
Processes the RIP response and updates the routing table.
Definition: Rip.cc:642
@ RIP_ROUTE_DEFAULT
Definition: RipRouteData.h:25
virtual L3Address getLinkLocalRIPRoutersMulticastAddress() const =0
simsignal_t routeAddedSignal
Definition: Simsignals.cc:41
virtual void sendRIPRequest(const RipNetworkInterface &ripInterface)
Sends a RIP request to routers on the specified link.
Definition: Rip.cc:281
#define NUM_INIT_STAGES
Definition: InitStageRegistry.h:73
const B UDP_HEADER_LENGTH
Definition: UdpHeader_m.h:51
const B IPv6_HEADER_BYTES
Definition: Ipv6Consts.h:15
double max(const double a, const double b)
Returns the maximum of a and b.
Definition: SctpAssociation.h:266
const double k
Definition: Qam1024Modulation.cc:14
simtime_t routeExpiryTime
Definition: Rip.h:102
@ RIP_AF_INET
Definition: RipPacket_m.h:91
removed DscpReq Ipv4ControlInfo Ipv6ControlInfo up L3AddressInd L4PortInd
Definition: IUdp-gates.txt:20
cMessage * updateTimer
Definition: Rip.h:94
static simsignal_t rcvdResponseSignal
Definition: Rip.h:111
@ UDP_I_DATA
Definition: UdpControlInfo_m.h:157
RipRoute * findRipRoute(const L3Address &destAddress, int prefixLength)
Definition: Rip.cc:1003
virtual void delayActiveOperationFinish(simtime_t timeout)
Definition: OperationalMixinImpl.h:161
IL3AddressType * addressType
Definition: Rip.h:89
ModuleRefByPar< IInterfaceTable > ift
Definition: Rip.h:87
#define Enter_Method(...)
Definition: SelfDoc.h:71
@ RIP_ROUTE_RTE
Definition: RipRouteData.h:23
simsignal_t routeDeletedSignal
Definition: Simsignals.cc:42
const value_type & get() const
Definition: Units.h:108
virtual void processUpdate(bool triggered)
This method called when a triggered or regular update timer expired.
Definition: Rip.cc:436
virtual void sendPacket(Packet *packet, const L3Address &destAddr, int destPort, const NetworkInterface *destInterface)
Sends the packet to the specified destination.
Definition: Rip.cc:978
virtual void stopRIPRouting()
Definition: Rip.cc:232
RouteType
Definition: RipRouteData.h:22
static simsignal_t sentUpdateSignal
Definition: Rip.h:110
const B RIP_HEADER_SIZE
Definition: RipPacket_m.h:50
value< double, units::m > m
Definition: Units.h:1233
ModuleRefByPar< IRoutingTable > rt
Definition: Rip.h:88
virtual void finishActiveOperation()
Definition: OperationalMixinImpl.h:188
const B RIP_RTE_SIZE
Definition: RipPacket_m.h:51
simsignal_t interfaceCreatedSignal
Definition: Simsignals.cc:30
@ RIP_ROUTE_INTERFACE
Definition: RipRouteData.h:27
@ PASSIVE
Definition: Rip.h:30
void setMulticastLoop(bool value)
The boolean value specifies whether sent multicast packets should be looped back to the local sockets...
Definition: UdpSocket.cc:157
@ UDP_I_ERROR
Definition: UdpControlInfo_m.h:158
virtual void sendRoutes(const L3Address &address, int port, const RipNetworkInterface &ripInterface, bool changedOnly)
Send all or changed part of the routing table to address/port on the specified interface.
Definition: Rip.cc:527
@ RIP_ROUTE_STATIC
Definition: RipRouteData.h:24
virtual bool isValidResponse(Packet *packet)
Definition: Rip.cc:720