|
INET Framework for OMNeT++/OMNEST
|
This class implements the Greedy Perimeter Stateless Routing for Wireless Networks.
More...
#include <Gpsr.h>
|
| void | processSelfMessage (cMessage *message) |
| |
| void | processMessage (cMessage *message) |
| |
| void | scheduleBeaconTimer () |
| |
| void | processBeaconTimer () |
| |
| void | schedulePurgeNeighborsTimer () |
| |
| void | processPurgeNeighborsTimer () |
| |
| void | sendUdpPacket (Packet *packet) |
| |
| void | processUdpPacket (Packet *packet) |
| |
| const Ptr< GpsrBeacon > | createBeacon () |
| |
| void | sendBeacon (const Ptr< GpsrBeacon > &beacon) |
| |
| void | processBeacon (Packet *packet) |
| |
| GpsrOption * | createGpsrOption (L3Address destination) |
| |
| int | computeOptionLength (GpsrOption *gpsrOption) |
| |
| void | setGpsrOptionOnNetworkDatagram (Packet *packet, const Ptr< const NetworkHeaderBase > &networkHeader, GpsrOption *gpsrOption) |
| |
| GpsrOption * | findGpsrOptionInNetworkDatagramForUpdate (const Ptr< NetworkHeaderBase > &networkHeader) |
| |
| const GpsrOption * | findGpsrOptionInNetworkDatagram (const Ptr< const NetworkHeaderBase > &networkHeader) const |
| |
| GpsrOption * | getGpsrOptionFromNetworkDatagramForUpdate (const Ptr< NetworkHeaderBase > &networkHeader) |
| |
| const GpsrOption * | getGpsrOptionFromNetworkDatagram (const Ptr< const NetworkHeaderBase > &networkHeader) const |
| |
| void | configureInterfaces () |
| |
| Coord | lookupPositionInGlobalRegistry (const L3Address &address) const |
| |
| void | storePositionInGlobalRegistry (const L3Address &address, const Coord &position) const |
| |
| void | storeSelfPositionInGlobalRegistry () const |
| |
| Coord | computeIntersectionInsideLineSegments (Coord &begin1, Coord &end1, Coord &begin2, Coord &end2) const |
| |
| Coord | getNeighborPosition (const L3Address &address) const |
| |
| double | getVectorAngle (Coord vector) const |
| |
| double | getNeighborAngle (const L3Address &address) const |
| |
| std::string | getHostName () const |
| |
| L3Address | getSelfAddress () const |
| |
| L3Address | getSenderNeighborAddress (const Ptr< const NetworkHeaderBase > &networkHeader) const |
| |
| simtime_t | getNextNeighborExpiration () |
| |
| void | purgeNeighbors () |
| |
| std::vector< L3Address > | getPlanarNeighbors () const |
| |
| std::vector< L3Address > | getPlanarNeighborsCounterClockwise (double startAngle) const |
| |
| L3Address | findNextHop (const L3Address &destination, GpsrOption *gpsrOption) |
| |
| L3Address | findGreedyRoutingNextHop (const L3Address &destination, GpsrOption *gpsrOption) |
| |
| L3Address | findPerimeterRoutingNextHop (const L3Address &destination, GpsrOption *gpsrOption) |
| |
| Result | routeDatagram (Packet *datagram, GpsrOption *gpsrOption) |
| |
| virtual Result | datagramPreRoutingHook (Packet *datagram) override |
| | This is the first hook called by the network protocol before it routes a datagram that was received from the lower layer. More...
|
| |
| virtual Result | datagramForwardHook (Packet *datagram) override |
| | This is the second hook called by the network protocol before it sends a datagram to the lower layer. More...
|
| |
| virtual Result | datagramPostRoutingHook (Packet *datagram) override |
| | This is the last hook called by the network protocol before it sends a datagram to the lower layer. More...
|
| |
| virtual Result | datagramLocalInHook (Packet *datagram) override |
| | This is the last hook called by the network protocol before it sends a datagram to the upper layer. More...
|
| |
| virtual Result | datagramLocalOutHook (Packet *datagram) override |
| | This is the first hook called by the network protocol before it routes a datagram that was received from the upper layer. More...
|
| |
| virtual void | handleStartOperation (LifecycleOperation *operation) override |
| |
| virtual void | handleStopOperation (LifecycleOperation *operation) override |
| |
| virtual void | handleCrashOperation (LifecycleOperation *operation) override |
| |
| virtual void | receiveSignal (cComponent *source, simsignal_t signalID, cObject *obj, cObject *details) override |
| |
This class implements the Greedy Perimeter Stateless Routing for Wireless Networks.
The implementation supports both GG and RNG planarization algorithms.
For more information on the routing algorithm, see the GPSR paper http://www.eecs.harvard.edu/~htk/publication/2000-mobi-karp-kung.pdf
◆ Gpsr()
◆ ~Gpsr()
◆ computeIntersectionInsideLineSegments()
316 if (begin1 == begin2 || begin1 == end2 || end1 == begin2 || end1 == end2)
319 double x1 = begin1.
x;
320 double y1 = begin1.y;
323 double x3 = begin2.x;
324 double y3 = begin2.y;
327 double a = determinant(x1, y1, x2, y2);
328 double b = determinant(x3, y3, x4, y4);
329 double c = determinant(x1 - x2, y1 - y2, x3 - x4, y3 - y4);
330 double x = determinant(a, x1 - x2,
b, x3 - x4) /
c;
331 double y = determinant(a, y1 - y2,
b, y3 - y4) /
c;
332 if ((x <= x1 && x <= x2) || (x >= x1 && x >= x2) || (x <= x3 && x <= x4) || (x >= x3 && x >= x4) ||
333 (y <= y1 && y <= y2) || (y >= y1 && y >= y2) || (y <= y3 && y <= y4) || (y >= y3 && y >= y4))
336 return Coord(x, y, 0);
Referenced by findPerimeterRoutingNextHop().
◆ computeOptionLength()
| int inet::Gpsr::computeOptionLength |
( |
GpsrOption * |
gpsrOption | ) |
|
|
private |
261 int routingModeBytes = 1;
269 return tlBytes + routingModeBytes + positionsBytes + addressesBytes;
Referenced by createGpsrOption().
◆ configureInterfaces()
| void inet::Gpsr::configureInterfaces |
( |
| ) |
|
|
private |
279 cPatternMatcher interfaceMatcher(
interfaces,
false,
true,
false);
281 NetworkInterface *networkInterface =
interfaceTable->getInterface(i);
282 if (networkInterface->isMulticast() && interfaceMatcher.matches(networkInterface->getInterfaceName()))
Referenced by handleStartOperation().
◆ createBeacon()
| const Ptr< GpsrBeacon > inet::Gpsr::createBeacon |
( |
| ) |
|
|
private |
211 const auto& beacon = makeShared<GpsrBeacon>();
213 beacon->setPosition(
mobility->getCurrentPosition());
Referenced by processBeaconTimer().
◆ createGpsrOption()
◆ datagramForwardHook()
| virtual Result inet::Gpsr::datagramForwardHook |
( |
Packet * |
datagram | ) |
|
|
inlineoverrideprivatevirtual |
This is the second hook called by the network protocol before it sends a datagram to the lower layer.
This is done after the datagramPreRoutingHook or the datagramLocalInHook is called and the datagram is routed.
Implements inet::INetfilter::IHook.
◆ datagramLocalInHook()
| virtual Result inet::Gpsr::datagramLocalInHook |
( |
Packet * |
datagram | ) |
|
|
inlineoverrideprivatevirtual |
This is the last hook called by the network protocol before it sends a datagram to the upper layer.
This is done after the datagramPreRoutingHook is called and the datagram is routed.
Implements inet::INetfilter::IHook.
◆ datagramLocalOutHook()
This is the first hook called by the network protocol before it routes a datagram that was received from the upper layer.
The nextHopAddress is ignored when the outputNetworkInterface is a nullptr. After this is done
Implements inet::INetfilter::IHook.
764 const L3Address& destination = networkHeader->getDestinationAddress();
765 if (destination.isMulticast() || destination.isBroadcast() ||
routingTable->isLocalAddress(destination))
768 GpsrOption *gpsrOption =
createGpsrOption(networkHeader->getDestinationAddress());
◆ datagramPostRoutingHook()
| virtual Result inet::Gpsr::datagramPostRoutingHook |
( |
Packet * |
datagram | ) |
|
|
inlineoverrideprivatevirtual |
This is the last hook called by the network protocol before it sends a datagram to the lower layer.
Implements inet::INetfilter::IHook.
◆ datagramPreRoutingHook()
This is the first hook called by the network protocol before it routes a datagram that was received from the lower layer.
The nextHopAddress is ignored when the outputNetworkInterface is nullptr.
Implements inet::INetfilter::IHook.
750 const L3Address& destination = networkHeader->getDestinationAddress();
751 if (destination.isMulticast() || destination.isBroadcast() ||
routingTable->isLocalAddress(destination))
◆ findGpsrOptionInNetworkDatagram()
660 const GpsrOption *gpsrOption =
nullptr;
662 #ifdef INET_WITH_IPv4
663 if (
auto ipv4Header = dynamicPtrCast<const Ipv4Header>(networkHeader)) {
664 gpsrOption = check_and_cast_nullable<const GpsrOption *>(ipv4Header->findOptionByType(
IPOPTION_TLV_GPSR));
668 #ifdef INET_WITH_IPv6
669 if (
auto ipv6Header = dynamicPtrCast<const Ipv6Header>(networkHeader)) {
670 const Ipv6HopByHopOptionsHeader *hdr = check_and_cast_nullable<const Ipv6HopByHopOptionsHeader *>(ipv6Header->findExtensionHeaderByType(
IP_PROT_IPv6EXT_HOP));
671 if (hdr !=
nullptr) {
674 gpsrOption = check_and_cast<const GpsrOption *>(hdr->getTlvOptions().getTlvOption(i));
679 #ifdef INET_WITH_NEXTHOP
680 if (
auto nextHopHeader = dynamicPtrCast<const NextHopForwardingHeader>(networkHeader)) {
683 gpsrOption = check_and_cast<const GpsrOption *>(nextHopHeader->getTlvOptions().getTlvOption(i));
Referenced by getGpsrOptionFromNetworkDatagram().
◆ findGpsrOptionInNetworkDatagramForUpdate()
694 GpsrOption *gpsrOption =
nullptr;
696 #ifdef INET_WITH_IPv4
697 if (
auto ipv4Header = dynamicPtrCast<Ipv4Header>(networkHeader)) {
698 gpsrOption = check_and_cast_nullable<GpsrOption *>(ipv4Header->findMutableOptionByType(
IPOPTION_TLV_GPSR));
702 #ifdef INET_WITH_IPv6
703 if (
auto ipv6Header = dynamicPtrCast<Ipv6Header>(networkHeader)) {
704 Ipv6HopByHopOptionsHeader *hdr = check_and_cast_nullable<Ipv6HopByHopOptionsHeader *>(ipv6Header->findExtensionHeaderByTypeForUpdate(
IP_PROT_IPv6EXT_HOP));
705 if (hdr !=
nullptr) {
708 gpsrOption = check_and_cast<GpsrOption *>(hdr->getTlvOptionsForUpdate().getTlvOptionForUpdate(i));
713 #ifdef INET_WITH_NEXTHOP
714 if (
auto nextHopHeader = dynamicPtrCast<NextHopForwardingHeader>(networkHeader)) {
717 gpsrOption = check_and_cast<GpsrOption *>(nextHopHeader->getTlvOptionsForUpdate().getTlvOptionForUpdate(i));
Referenced by getGpsrOptionFromNetworkDatagramForUpdate().
◆ findGreedyRoutingNextHop()
489 EV_DEBUG <<
"Finding next hop using greedy routing: destination = " << destination << endl;
491 Coord selfPosition =
mobility->getCurrentPosition();
492 Coord destinationPosition = gpsrOption->getDestinationPosition();
493 double bestDistance = (destinationPosition - selfPosition).length();
494 L3Address bestNeighbor;
496 for (
auto& neighborAddress : neighborAddresses) {
498 double neighborDistance = (destinationPosition - neighborPosition).length();
499 if (neighborDistance < bestDistance) {
500 bestDistance = neighborDistance;
501 bestNeighbor = neighborAddress;
504 if (bestNeighbor.isUnspecified()) {
505 EV_DEBUG <<
"Switching to perimeter routing: destination = " << destination << endl;
509 gpsrOption->setPerimeterRoutingStartPosition(selfPosition);
510 gpsrOption->setPerimeterRoutingForwardPosition(selfPosition);
511 gpsrOption->setCurrentFaceFirstSenderAddress(selfAddress);
512 gpsrOption->setCurrentFaceFirstReceiverAddress(L3Address());
Referenced by findNextHop(), and findPerimeterRoutingNextHop().
◆ findNextHop()
480 switch (gpsrOption->getRoutingMode()) {
483 default:
throw cRuntimeError(
"Unknown routing mode");
Referenced by routeDatagram().
◆ findPerimeterRoutingNextHop()
521 EV_DEBUG <<
"Finding next hop using perimeter routing: destination = " << destination << endl;
523 Coord selfPosition =
mobility->getCurrentPosition();
524 Coord perimeterRoutingStartPosition = gpsrOption->getPerimeterRoutingStartPosition();
525 Coord destinationPosition = gpsrOption->getDestinationPosition();
526 double selfDistance = (destinationPosition - selfPosition).length();
527 double perimeterRoutingStartDistance = (destinationPosition - perimeterRoutingStartPosition).length();
528 if (selfDistance < perimeterRoutingStartDistance) {
529 EV_DEBUG <<
"Switching to greedy routing: destination = " << destination << endl;
533 gpsrOption->setPerimeterRoutingStartPosition(Coord());
534 gpsrOption->setPerimeterRoutingForwardPosition(Coord());
535 gpsrOption->setCurrentFaceFirstSenderAddress(L3Address());
536 gpsrOption->setCurrentFaceFirstReceiverAddress(L3Address());
540 const L3Address& firstSenderAddress = gpsrOption->getCurrentFaceFirstSenderAddress();
541 const L3Address& firstReceiverAddress = gpsrOption->getCurrentFaceFirstReceiverAddress();
542 auto senderNeighborAddress = gpsrOption->getSenderAddress();
544 L3Address selectedNeighborAddress;
546 for (
auto& neighborAddress : neighborAddresses) {
549 if (std::isnan(intersection.x)) {
550 selectedNeighborAddress = neighborAddress;
554 EV_DEBUG <<
"Edge to next hop intersects: intersection = " << intersection <<
", nextNeighbor = " << selectedNeighborAddress <<
", firstSender = " << firstSenderAddress <<
", firstReceiver = " << firstReceiverAddress <<
", destination = " << destination << endl;
555 gpsrOption->setCurrentFaceFirstSenderAddress(selfAddress);
556 gpsrOption->setCurrentFaceFirstReceiverAddress(L3Address());
557 gpsrOption->setPerimeterRoutingForwardPosition(intersection);
560 if (selectedNeighborAddress.isUnspecified()) {
561 EV_DEBUG <<
"No suitable planar graph neighbor found in perimeter routing: firstSender = " << firstSenderAddress <<
", firstReceiver = " << firstReceiverAddress <<
", destination = " << destination << endl;
564 else if (firstSenderAddress == selfAddress && firstReceiverAddress == selectedNeighborAddress) {
565 EV_DEBUG <<
"End of perimeter reached: firstSender = " << firstSenderAddress <<
", firstReceiver = " << firstReceiverAddress <<
", destination = " << destination << endl;
571 if (gpsrOption->getCurrentFaceFirstReceiverAddress().isUnspecified())
572 gpsrOption->setCurrentFaceFirstReceiverAddress(selectedNeighborAddress);
573 return selectedNeighborAddress;
Referenced by findGreedyRoutingNextHop(), and findNextHop().
◆ getGpsrOptionFromNetworkDatagram()
◆ getGpsrOptionFromNetworkDatagramForUpdate()
737 if (gpsrOption ==
nullptr)
738 throw cRuntimeError(
"Gpsr option not found in datagram!");
◆ getHostName()
| std::string inet::Gpsr::getHostName |
( |
| ) |
const |
|
private |
369 return host->getFullName();
◆ getNeighborAngle()
| double inet::Gpsr::getNeighborAngle |
( |
const L3Address & |
address | ) |
const |
|
private |
◆ getNeighborPosition()
| Coord inet::Gpsr::getNeighborPosition |
( |
const L3Address & |
address | ) |
const |
|
private |
◆ getNextNeighborExpiration()
| simtime_t inet::Gpsr::getNextNeighborExpiration |
( |
| ) |
|
|
private |
◆ getPlanarNeighbors()
| std::vector< L3Address > inet::Gpsr::getPlanarNeighbors |
( |
| ) |
const |
|
private |
418 std::vector<L3Address> planarNeighbors;
420 Coord selfPosition =
mobility->getCurrentPosition();
421 for (
auto it = neighborAddresses.begin(); it != neighborAddresses.end(); it++) {
422 auto neighborAddress = *it;
425 return neighborAddresses;
427 double neighborDistance = (neighborPosition - selfPosition).length();
428 for (
auto& witnessAddress : neighborAddresses) {
430 double witnessDistance = (witnessPosition - selfPosition).length();
431 double neighborWitnessDistance = (witnessPosition - neighborPosition).length();
432 if (neighborAddress == witnessAddress)
434 else if (neighborDistance >
std::max(witnessDistance, neighborWitnessDistance))
439 Coord middlePosition = (selfPosition + neighborPosition) / 2;
440 double neighborDistance = (neighborPosition - middlePosition).length();
441 for (
auto& witnessAddress : neighborAddresses) {
443 double witnessDistance = (witnessPosition - middlePosition).length();
444 if (neighborAddress == witnessAddress)
446 else if (witnessDistance < neighborDistance)
451 throw cRuntimeError(
"Unknown planarization mode");
452 planarNeighbors.push_back(*it);
455 return planarNeighbors;
Referenced by getPlanarNeighborsCounterClockwise().
◆ getPlanarNeighborsCounterClockwise()
| std::vector< L3Address > inet::Gpsr::getPlanarNeighborsCounterClockwise |
( |
double |
startAngle | ) |
const |
|
private |
461 std::sort(neighborAddresses.begin(), neighborAddresses.end(), [&] (
const L3Address& address1,
const L3Address& address2) {
463 auto angle1 = getNeighborAngle(address1) - startAngle;
464 auto angle2 = getNeighborAngle(address2) - startAngle;
469 return angle1 < angle2;
471 return neighborAddresses;
Referenced by findPerimeterRoutingNextHop().
◆ getSelfAddress()
| L3Address inet::Gpsr::getSelfAddress |
( |
| ) |
const |
|
private |
◆ getSenderNeighborAddress()
395 return gpsrOption->getSenderAddress();
◆ getVectorAngle()
| double inet::Gpsr::getVectorAngle |
( |
Coord |
vector | ) |
const |
|
private |
◆ handleCrashOperation()
◆ handleMessageWhenUp()
| void inet::Gpsr::handleMessageWhenUp |
( |
cMessage * |
message | ) |
|
|
overrideprotectedvirtual |
◆ handleStartOperation()
◆ handleStopOperation()
◆ initialize()
| void inet::Gpsr::initialize |
( |
int |
stage | ) |
|
|
overrideprotectedvirtual |
Reimplemented from inet::OperationalMixin< cSimpleModule >.
70 const char *planarizationModeString = par(
"planarizationMode");
71 if (!strcmp(planarizationModeString,
""))
73 else if (!strcmp(planarizationModeString,
"GG"))
75 else if (!strcmp(planarizationModeString,
"RNG"))
78 throw cRuntimeError(
"Unknown planarization mode");
88 mobility = check_and_cast<IMobility *>(
host->getSubmodule(
"mobility"));
89 routingTable.reference(
this,
"routingTableModule",
true);
◆ lookupPositionInGlobalRegistry()
| Coord inet::Gpsr::lookupPositionInGlobalRegistry |
( |
const L3Address & |
address | ) |
const |
|
private |
◆ numInitStages()
| virtual int inet::Gpsr::numInitStages |
( |
| ) |
const |
|
inlineoverrideprotectedvirtual |
◆ processBeacon()
| void inet::Gpsr::processBeacon |
( |
Packet * |
packet | ) |
|
|
private |
239 const auto& beacon = packet->peekAtFront<GpsrBeacon>();
240 EV_INFO <<
"Processing beacon: address = " << beacon->getAddress() <<
", position = " << beacon->getPosition() << endl;
Referenced by processUdpPacket().
◆ processBeaconTimer()
| void inet::Gpsr::processBeaconTimer |
( |
| ) |
|
|
private |
149 EV_DEBUG <<
"Processing beacon timer" << endl;
151 if (!selfAddress.isUnspecified()) {
Referenced by processSelfMessage().
◆ processMessage()
| void inet::Gpsr::processMessage |
( |
cMessage * |
message | ) |
|
|
private |
131 if (
auto pk =
dynamic_cast<Packet *
>(message))
134 throw cRuntimeError(
"Unknown message");
Referenced by handleMessageWhenUp().
◆ processPurgeNeighborsTimer()
| void inet::Gpsr::processPurgeNeighborsTimer |
( |
| ) |
|
|
private |
◆ processSelfMessage()
| void inet::Gpsr::processSelfMessage |
( |
cMessage * |
message | ) |
|
|
private |
◆ processUdpPacket()
| void inet::Gpsr::processUdpPacket |
( |
Packet * |
packet | ) |
|
|
private |
◆ purgeNeighbors()
| void inet::Gpsr::purgeNeighbors |
( |
| ) |
|
|
private |
◆ receiveSignal()
| void inet::Gpsr::receiveSignal |
( |
cComponent * |
source, |
|
|
simsignal_t |
signalID, |
|
|
cObject * |
obj, |
|
|
cObject * |
details |
|
) |
| |
|
overrideprivatevirtual |
806 Enter_Method(
"%s", cComponent::getSignalName(signalID));
809 EV_WARN <<
"Received link break" << endl;
◆ routeDatagram()
585 const L3Address& source = networkHeader->getSourceAddress();
586 const L3Address& destination = networkHeader->getDestinationAddress();
587 EV_INFO <<
"Finding next hop: source = " << source <<
", destination = " << destination << endl;
588 auto nextHop =
findNextHop(destination, gpsrOption);
589 datagram->addTagIfAbsent<NextHopAddressReq>()->setNextHopAddress(nextHop);
590 if (nextHop.isUnspecified()) {
591 EV_WARN <<
"No next hop found, dropping packet: source = " << source <<
", destination = " << destination << endl;
597 EV_INFO <<
"Next hop found: source = " << source <<
", destination = " << destination <<
", nextHop: " << nextHop << endl;
600 datagram->addTagIfAbsent<
InterfaceReq>()->setInterfaceId(networkInterface->getInterfaceId());
Referenced by datagramLocalOutHook(), and datagramPreRoutingHook().
◆ scheduleBeaconTimer()
| void inet::Gpsr::scheduleBeaconTimer |
( |
| ) |
|
|
private |
◆ schedulePurgeNeighborsTimer()
| void inet::Gpsr::schedulePurgeNeighborsTimer |
( |
| ) |
|
|
private |
◆ sendBeacon()
| void inet::Gpsr::sendBeacon |
( |
const Ptr< GpsrBeacon > & |
beacon | ) |
|
|
private |
220 EV_INFO <<
"Sending beacon: address = " << beacon->getAddress() <<
", position = " << beacon->getPosition() << endl;
221 Packet *udpPacket =
new Packet(
"GPSRBeacon");
222 udpPacket->insertAtBack(beacon);
223 auto udpHeader = makeShared<UdpHeader>();
227 udpPacket->insertAtFront(udpHeader);
228 auto addresses = udpPacket->addTag<L3AddressReq>();
231 udpPacket->addTag<
HopLimitReq>()->setHopLimit(255);
Referenced by processBeaconTimer().
◆ sendUdpPacket()
| void inet::Gpsr::sendUdpPacket |
( |
Packet * |
packet | ) |
|
|
private |
◆ setGpsrOptionOnNetworkDatagram()
608 #ifdef INET_WITH_IPv4
609 if (dynamicPtrCast<const Ipv4Header>(networkHeader)) {
610 auto ipv4Header = removeNetworkProtocolHeader<Ipv4Header>(packet);
612 B oldHlen = ipv4Header->calculateHeaderByteLength();
613 ASSERT(ipv4Header->getHeaderLength() == oldHlen);
614 ipv4Header->addOption(gpsrOption);
615 B newHlen = ipv4Header->calculateHeaderByteLength();
616 ipv4Header->setHeaderLength(newHlen);
617 ipv4Header->addChunkLength(newHlen - oldHlen);
618 ipv4Header->setTotalLengthField(ipv4Header->getTotalLengthField() + newHlen - oldHlen);
623 #ifdef INET_WITH_IPv6
624 if (dynamicPtrCast<const Ipv6Header>(networkHeader)) {
625 auto ipv6Header = removeNetworkProtocolHeader<Ipv6Header>(packet);
627 B oldHlen = ipv6Header->calculateHeaderByteLength();
628 Ipv6HopByHopOptionsHeader *hdr = check_and_cast_nullable<Ipv6HopByHopOptionsHeader *>(ipv6Header->findExtensionHeaderByTypeForUpdate(
IP_PROT_IPv6EXT_HOP));
629 if (hdr ==
nullptr) {
630 hdr =
new Ipv6HopByHopOptionsHeader();
631 hdr->setByteLength(
B(8));
632 ipv6Header->addExtensionHeader(hdr);
634 hdr->getTlvOptionsForUpdate().appendTlvOption(gpsrOption);
635 hdr->setByteLength(
B(
utils::roundUp(2 +
B(hdr->getTlvOptions().getLength()).get(), 8)));
636 B newHlen = ipv6Header->calculateHeaderByteLength();
637 ipv6Header->addChunkLength(newHlen - oldHlen);
642 #ifdef INET_WITH_NEXTHOP
643 if (dynamicPtrCast<const NextHopForwardingHeader>(networkHeader)) {
644 auto nextHopHeader = removeNetworkProtocolHeader<NextHopForwardingHeader>(packet);
646 int oldHlen = nextHopHeader->getTlvOptions().getLength();
647 nextHopHeader->getTlvOptionsForUpdate().appendTlvOption(gpsrOption);
648 int newHlen = nextHopHeader->getTlvOptions().getLength();
649 nextHopHeader->addChunkLength(
B(newHlen - oldHlen));
Referenced by datagramLocalOutHook().
◆ storePositionInGlobalRegistry()
| void inet::Gpsr::storePositionInGlobalRegistry |
( |
const L3Address & |
address, |
|
|
const Coord & |
position |
|
) |
| const |
|
private |
◆ storeSelfPositionInGlobalRegistry()
| void inet::Gpsr::storeSelfPositionInGlobalRegistry |
( |
| ) |
const |
|
private |
◆ addressType
◆ beaconInterval
| simtime_t inet::Gpsr::beaconInterval |
|
private |
◆ beaconTimer
| cMessage* inet::Gpsr::beaconTimer = nullptr |
|
private |
◆ displayBubbles
| bool inet::Gpsr::displayBubbles |
|
private |
◆ globalPositionTable
◆ host
| cModule* inet::Gpsr::host = nullptr |
|
private |
◆ interfaces
| const char* inet::Gpsr::interfaces = nullptr |
|
private |
◆ interfaceTable
◆ maxJitter
| simtime_t inet::Gpsr::maxJitter |
|
private |
◆ mobility
| opp_component_ptr<IMobility> inet::Gpsr::mobility |
|
private |
◆ neighborPositionTable
◆ neighborValidityInterval
| simtime_t inet::Gpsr::neighborValidityInterval |
|
private |
◆ networkProtocol
◆ outputInterface
| const char* inet::Gpsr::outputInterface = nullptr |
|
private |
◆ planarizationMode
◆ positionByteLength
| int inet::Gpsr::positionByteLength = -1 |
|
private |
◆ purgeNeighborsTimer
| cMessage* inet::Gpsr::purgeNeighborsTimer = nullptr |
|
private |
◆ routingTable
The documentation for this class was generated from the following files:
#define GPSR_UDP_PORT
Definition: GpsrDefs.h:13
@ IP_PROT_IPv6EXT_HOP
Definition: IpProtocolId_m.h:111
#define CHK(x)
Definition: INETDefs.h:87
GpsrOption * findGpsrOptionInNetworkDatagramForUpdate(const Ptr< NetworkHeaderBase > &networkHeader)
Definition: Gpsr.cc:692
cModule * host
Definition: Gpsr.h:48
opp_component_ptr< IMobility > mobility
Definition: Gpsr.h:49
void clear()
Definition: PositionTable.cc:55
const value< double, compose< units::m, pow< units::s, -1 > > > c(299792458)
GpsrOption * createGpsrOption(L3Address destination)
Definition: Gpsr.cc:249
void processBeacon(Packet *packet)
Definition: Gpsr.cc:237
int getAddressByteLength() const
Definition: IL3AddressType.h:25
@ NEXTHOP_TLVOPTION_TLV_GPSR
Definition: NextHopForwardingHeader_m.h:72
int computeOptionLength(GpsrOption *gpsrOption)
Definition: Gpsr.cc:258
std::vector< L3Address > getPlanarNeighbors() const
Definition: Gpsr.cc:416
void sort(std::vector< T > &v)
Definition: stlutils.h:129
L3Address findGreedyRoutingNextHop(const L3Address &destination, GpsrOption *gpsrOption)
Definition: Gpsr.cc:487
cMessage * purgeNeighborsTimer
Definition: Gpsr.h:62
int positionByteLength
Definition: Gpsr.h:58
simsignal_t linkBrokenSignal
Definition: Simsignals.cc:22
Coord computeIntersectionInsideLineSegments(Coord &begin1, Coord &end1, Coord &begin2, Coord &end2) const
Definition: Gpsr.cc:313
PositionTable neighborPositionTable
Definition: Gpsr.h:63
static const Coord ZERO
Definition: Coord.h:27
static const Protocol ipv4
Definition: Protocol.h:93
static const Protocol ipv6
Definition: Protocol.h:94
void storePositionInGlobalRegistry(const L3Address &address, const Coord &position) const
Definition: Gpsr.cc:300
void configureInterfaces()
Definition: Gpsr.cc:276
static PositionTable globalPositionTable
Definition: Gpsr.h:55
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
const char * interfaces
Definition: Gpsr.h:41
removed InterfaceReq
Definition: IUdp-gates.txt:11
IL3AddressType * addressType
Definition: Gpsr.h:50
removed DscpReq Ipv4ControlInfo Ipv6ControlInfo up L3AddressInd DispatchProtocolReq L4PortInd Ipv4ControlInfo Ipv6ControlInfo down DispatchProtocolReq
Definition: IUdp-gates.txt:25
double x
Definition: Coord.h:36
L3Address findPerimeterRoutingNextHop(const L3Address &destination, GpsrOption *gpsrOption)
Definition: Gpsr.cc:519
@ CRC_DISABLED
Definition: CrcMode_m.h:56
void setPosition(const L3Address &address, const Coord &coord)
Definition: PositionTable.cc:33
static const Protocol nextHopForwarding
Definition: Protocol.h:128
virtual L3Address getLinkLocalManetRoutersMulticastAddress() const =0
void insertNetworkProtocolHeader(Packet *packet, const Protocol &protocol, const Ptr< NetworkHeaderBase > &header)
Definition: L3Tools.cc:70
L3Address findNextHop(const L3Address &destination, GpsrOption *gpsrOption)
Definition: Gpsr.cc:478
void purgeNeighbors()
Definition: Gpsr.cc:411
removed DscpReq Ipv4ControlInfo Ipv6ControlInfo up L3AddressInd DispatchProtocolReq L4PortInd Ipv4ControlInfo Ipv6ControlInfo down PacketProtocolTag
Definition: IUdp-gates.txt:25
const GpsrOption * getGpsrOptionFromNetworkDatagram(const Ptr< const NetworkHeaderBase > &networkHeader) const
Definition: Gpsr.cc:726
@ GPSR_GG_PLANARIZATION
Definition: Gpsr_m.h:86
void processPurgeNeighborsTimer()
Definition: Gpsr.cc:182
void schedulePurgeNeighborsTimer()
Definition: Gpsr.cc:163
static const Protocol manet
Definition: Protocol.h:99
double getVectorAngle(Coord vector) const
Definition: Gpsr.cc:349
void sendBeacon(const Ptr< GpsrBeacon > &beacon)
Definition: Gpsr.cc:218
intscale< b, 1, 8 > B
Definition: Units.h:1168
void removeOldPositions(simtime_t timestamp)
Definition: PositionTable.cc:45
void sendUdpPacket(Packet *packet)
Definition: Gpsr.cc:193
const Ptr< const NetworkHeaderBase > getNetworkProtocolHeader(Packet *packet)
Definition: L3Tools.cc:43
@ GPSR_PERIMETER_ROUTING
Definition: Gpsr_m.h:67
cMessage * beaconTimer
Definition: Gpsr.h:61
const char * outputInterface
Definition: Gpsr.h:52
@ GPSR_NO_PLANARIZATION
Definition: Gpsr_m.h:85
ModuleRefByPar< IRoutingTable > routingTable
Definition: Gpsr.h:53
Coord lookupPositionInGlobalRegistry(const L3Address &address) const
Definition: Gpsr.cc:294
@ GPSR_RNG_PLANARIZATION
Definition: Gpsr_m.h:87
removed HopLimitReq
Definition: IUdp-gates.txt:11
void scheduleBeaconTimer()
Definition: Gpsr.cc:141
@ GPSR_GREEDY_ROUTING
Definition: Gpsr_m.h:66
simtime_t maxJitter
Definition: Gpsr.h:43
bool displayBubbles
Definition: Gpsr.h:45
int roundUp(int numToRound, int multiple)
Rounding up to the nearest multiple of a number.
Definition: INETUtils.h:70
ModuleRefByPar< IInterfaceTable > interfaceTable
Definition: Gpsr.h:51
INET_API InitStage INITSTAGE_LOCAL
Initialization of local state that don't use or affect other modules includes:
ModuleRefByPar< INetfilter > networkProtocol
Definition: Gpsr.h:54
void processSelfMessage(cMessage *message)
Definition: Gpsr.cc:119
@ IPv6TLVOPTION_TLV_GPSR
Definition: Ipv6ExtensionHeaders_m.h:82
value< int64_t, units::b > b
Definition: Units.h:1241
double getNeighborAngle(const L3Address &address) const
Definition: Gpsr.cc:358
#define NUM_INIT_STAGES
Definition: InitStageRegistry.h:73
double max(const double a, const double b)
Returns the maximum of a and b.
Definition: SctpAssociation.h:266
Coord getPosition(const L3Address &address) const
Definition: PositionTable.cc:27
@ IPOPTION_TLV_GPSR
Definition: Ipv4Header_m.h:142
Result routeDatagram(Packet *datagram, GpsrOption *gpsrOption)
Definition: Gpsr.cc:582
simtime_t beaconInterval
Definition: Gpsr.h:42
@ IPv6
Definition: L3Address.h:36
simtime_t neighborValidityInterval
Definition: Gpsr.h:44
void processMessage(cMessage *message)
Definition: Gpsr.cc:129
@ DROP
doesn't allow the datagram to pass to the next hook, will be deleted
Definition: INetfilter.h:41
#define Enter_Method(...)
Definition: SelfDoc.h:71
const GpsrOption * findGpsrOptionInNetworkDatagram(const Ptr< const NetworkHeaderBase > &networkHeader) const
Definition: Gpsr.cc:658
static const Coord NIL
Constant with all values set to 0.
Definition: Coord.h:26
void processUdpPacket(Packet *packet)
Definition: Gpsr.cc:198
@ ACCEPT
allows the datagram to pass to the next hook
Definition: INetfilter.h:40
IL3AddressType * getAddressType() const
Definition: L3Address.cc:59
void processBeaconTimer()
Definition: Gpsr.cc:147
virtual const Protocol * getNetworkProtocol() const =0
void setGpsrOptionOnNetworkDatagram(Packet *packet, const Ptr< const NetworkHeaderBase > &networkHeader, GpsrOption *gpsrOption)
Definition: Gpsr.cc:605
L3Address getSelfAddress() const
Definition: Gpsr.cc:372
void registerProtocol(const Protocol &protocol, cGate *gate, ServicePrimitive servicePrimitive)
Registers a protocol primitive (PDU processing) at the given gate.
Definition: IProtocolRegistrationListener.cc:83
Coord getNeighborPosition(const L3Address &address) const
Definition: Gpsr.cc:340
simtime_t getNextNeighborExpiration()
Definition: Gpsr.cc:402
std::vector< L3Address > getPlanarNeighborsCounterClockwise(double startAngle) const
Definition: Gpsr.cc:458
#define M_PI
Definition: INETMath.h:52
GpsrPlanarizationMode planarizationMode
Definition: Gpsr.h:40
INET_API InitStage INITSTAGE_ROUTING_PROTOCOLS
Initialization of routing protocols.
std::vector< L3Address > getAddresses() const
Definition: PositionTable.cc:14
void storeSelfPositionInGlobalRegistry() const
Definition: Gpsr.cc:306
const Ptr< GpsrBeacon > createBeacon()
Definition: Gpsr.cc:209
simtime_t getOldestPosition() const
Definition: PositionTable.cc:60