INET Framework for OMNeT++/OMNEST
inet::Gpsr Class Reference

This class implements the Greedy Perimeter Stateless Routing for Wireless Networks. More...

#include <Gpsr.h>

Inheritance diagram for inet::Gpsr:
inet::RoutingProtocolBase inet::NetfilterBase::HookBase inet::OperationalBase inet::INetfilter::IHook inet::OperationalMixin< cSimpleModule > inet::ILifecycle

Public Member Functions

 Gpsr ()
 
virtual ~Gpsr ()
 
- Public Member Functions inherited from inet::RoutingProtocolBase
 RoutingProtocolBase ()
 
- Public Member Functions inherited from inet::OperationalMixin< cSimpleModule >
virtual ~OperationalMixin ()
 }@ More...
 
- Public Member Functions inherited from inet::ILifecycle
virtual ~ILifecycle ()
 
- Public Member Functions inherited from inet::NetfilterBase::HookBase
virtual ~HookBase ()
 
void registeredTo (INetfilter *nf)
 
void unregisteredFrom (INetfilter *nf)
 
bool isRegisteredHook (INetfilter *nf)
 
- Public Member Functions inherited from inet::INetfilter::IHook
virtual ~IHook ()
 

Protected Member Functions

virtual int numInitStages () const override
 
void initialize (int stage) override
 
void handleMessageWhenUp (cMessage *message) override
 
- Protected Member Functions inherited from inet::RoutingProtocolBase
virtual bool isInitializeStage (int stage) const override
 
virtual bool isModuleStartStage (int stage) const override
 
virtual bool isModuleStopStage (int stage) const override
 
- Protected Member Functions inherited from inet::OperationalMixin< cSimpleModule >
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 ()
 

Private Member Functions

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< GpsrBeaconcreateBeacon ()
 
void sendBeacon (const Ptr< GpsrBeacon > &beacon)
 
void processBeacon (Packet *packet)
 
GpsrOptioncreateGpsrOption (L3Address destination)
 
int computeOptionLength (GpsrOption *gpsrOption)
 
void setGpsrOptionOnNetworkDatagram (Packet *packet, const Ptr< const NetworkHeaderBase > &networkHeader, GpsrOption *gpsrOption)
 
GpsrOptionfindGpsrOptionInNetworkDatagramForUpdate (const Ptr< NetworkHeaderBase > &networkHeader)
 
const GpsrOptionfindGpsrOptionInNetworkDatagram (const Ptr< const NetworkHeaderBase > &networkHeader) const
 
GpsrOptiongetGpsrOptionFromNetworkDatagramForUpdate (const Ptr< NetworkHeaderBase > &networkHeader)
 
const GpsrOptiongetGpsrOptionFromNetworkDatagram (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< L3AddressgetPlanarNeighbors () const
 
std::vector< L3AddressgetPlanarNeighborsCounterClockwise (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
 

Private Attributes

GpsrPlanarizationMode planarizationMode = static_cast<GpsrPlanarizationMode>(-1)
 
const char * interfaces = nullptr
 
simtime_t beaconInterval
 
simtime_t maxJitter
 
simtime_t neighborValidityInterval
 
bool displayBubbles
 
cModule * host = nullptr
 
opp_component_ptr< IMobilitymobility
 
IL3AddressTypeaddressType = nullptr
 
ModuleRefByPar< IInterfaceTableinterfaceTable
 
const char * outputInterface = nullptr
 
ModuleRefByPar< IRoutingTableroutingTable
 
ModuleRefByPar< INetfilternetworkProtocol
 
int positionByteLength = -1
 
cMessage * beaconTimer = nullptr
 
cMessage * purgeNeighborsTimer = nullptr
 
PositionTable neighborPositionTable
 

Static Private Attributes

static PositionTable globalPositionTable
 

Additional Inherited Members

- Public Types inherited from inet::INetfilter::IHook
enum  Type {
  PREROUTING, LOCALIN, FORWARD, POSTROUTING,
  LOCALOUT
}
 
enum  Result { ACCEPT, DROP, QUEUE, STOLEN }
 
- Protected Types inherited from inet::OperationalMixin< cSimpleModule >
enum  State
 
- Protected Attributes inherited from inet::OperationalMixin< cSimpleModule >
State operationalState
 
simtime_t lastChange
 
Operation activeOperation
 
cMessage * activeOperationTimeout
 
cMessage * activeOperationExtraTimer
 
- Protected Attributes inherited from inet::NetfilterBase::HookBase
std::vector< INetfilter * > netfilters
 

Detailed Description

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

Constructor & Destructor Documentation

◆ Gpsr()

inet::Gpsr::Gpsr ( )
48 {
49 }

◆ ~Gpsr()

inet::Gpsr::~Gpsr ( )
virtual
52 {
53  cancelAndDelete(beaconTimer);
54  cancelAndDelete(purgeNeighborsTimer);
55 }

Member Function Documentation

◆ computeIntersectionInsideLineSegments()

Coord inet::Gpsr::computeIntersectionInsideLineSegments ( Coord begin1,
Coord end1,
Coord begin2,
Coord end2 
) const
private
314 {
315  // NOTE: we must explicitly avoid computing the intersection points inside due to double instability
316  if (begin1 == begin2 || begin1 == end2 || end1 == begin2 || end1 == end2)
317  return Coord::NIL;
318  else {
319  double x1 = begin1.x;
320  double y1 = begin1.y;
321  double x2 = end1.x;
322  double y2 = end1.y;
323  double x3 = begin2.x;
324  double y3 = begin2.y;
325  double x4 = end2.x;
326  double y4 = end2.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))
334  return Coord::NIL;
335  else
336  return Coord(x, y, 0);
337  }
338 }

Referenced by findPerimeterRoutingNextHop().

◆ computeOptionLength()

int inet::Gpsr::computeOptionLength ( GpsrOption gpsrOption)
private
259 {
260  // routingMode
261  int routingModeBytes = 1;
262  // destinationPosition, perimeterRoutingStartPosition, perimeterRoutingForwardPosition
263  int positionsBytes = 3 * positionByteLength;
264  // currentFaceFirstSenderAddress, currentFaceFirstReceiverAddress, senderAddress
265  int addressesBytes = 3 * getSelfAddress().getAddressType()->getAddressByteLength();
266  // type and length
267  int tlBytes = 1 + 1;
268 
269  return tlBytes + routingModeBytes + positionsBytes + addressesBytes;
270 }

Referenced by createGpsrOption().

◆ configureInterfaces()

void inet::Gpsr::configureInterfaces ( )
private
277 {
278  // join multicast groups
279  cPatternMatcher interfaceMatcher(interfaces, false, true, false);
280  for (int i = 0; i < interfaceTable->getNumInterfaces(); i++) {
281  NetworkInterface *networkInterface = interfaceTable->getInterface(i);
282  if (networkInterface->isMulticast() && interfaceMatcher.matches(networkInterface->getInterfaceName()))
283  networkInterface->joinMulticastGroup(addressType->getLinkLocalManetRoutersMulticastAddress());
284  }
285 }

Referenced by handleStartOperation().

◆ createBeacon()

const Ptr< GpsrBeacon > inet::Gpsr::createBeacon ( )
private
210 {
211  const auto& beacon = makeShared<GpsrBeacon>();
212  beacon->setAddress(getSelfAddress());
213  beacon->setPosition(mobility->getCurrentPosition());
214  beacon->setChunkLength(B(getSelfAddress().getAddressType()->getAddressByteLength() + positionByteLength));
215  return beacon;
216 }

Referenced by processBeaconTimer().

◆ createGpsrOption()

GpsrOption * inet::Gpsr::createGpsrOption ( L3Address  destination)
private
250 {
251  GpsrOption *gpsrOption = new GpsrOption();
252  gpsrOption->setRoutingMode(GPSR_GREEDY_ROUTING);
253  gpsrOption->setDestinationPosition(lookupPositionInGlobalRegistry(destination));
254  gpsrOption->setLength(computeOptionLength(gpsrOption));
255  return gpsrOption;
256 }

Referenced by datagramLocalOutHook().

◆ 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.

145 { return ACCEPT; }

◆ 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.

147 { return ACCEPT; }

◆ datagramLocalOutHook()

INetfilter::IHook::Result inet::Gpsr::datagramLocalOutHook ( Packet datagram)
overrideprivatevirtual

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.

761 {
762  Enter_Method("datagramLocalOutHook");
763  const auto& networkHeader = getNetworkProtocolHeader(packet);
764  const L3Address& destination = networkHeader->getDestinationAddress();
765  if (destination.isMulticast() || destination.isBroadcast() || routingTable->isLocalAddress(destination))
766  return ACCEPT;
767  else {
768  GpsrOption *gpsrOption = createGpsrOption(networkHeader->getDestinationAddress());
769  setGpsrOptionOnNetworkDatagram(packet, networkHeader, gpsrOption);
770  return routeDatagram(packet, gpsrOption);
771  }
772 }

◆ 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.

146 { return ACCEPT; }

◆ datagramPreRoutingHook()

INetfilter::IHook::Result inet::Gpsr::datagramPreRoutingHook ( Packet datagram)
overrideprivatevirtual

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.

747 {
748  Enter_Method("datagramPreRoutingHook");
749  const auto& networkHeader = getNetworkProtocolHeader(datagram);
750  const L3Address& destination = networkHeader->getDestinationAddress();
751  if (destination.isMulticast() || destination.isBroadcast() || routingTable->isLocalAddress(destination))
752  return ACCEPT;
753  else {
754  // KLUDGE this allows overwriting the GPSR option inside
755  auto gpsrOption = const_cast<GpsrOption *>(getGpsrOptionFromNetworkDatagram(networkHeader));
756  return routeDatagram(datagram, gpsrOption);
757  }
758 }

◆ findGpsrOptionInNetworkDatagram()

const GpsrOption * inet::Gpsr::findGpsrOptionInNetworkDatagram ( const Ptr< const NetworkHeaderBase > &  networkHeader) const
private
659 {
660  const GpsrOption *gpsrOption = nullptr;
661 
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));
665  }
666  else
667 #endif
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) {
672  int i = (hdr->getTlvOptions().findByType(IPv6TLVOPTION_TLV_GPSR));
673  if (i >= 0)
674  gpsrOption = check_and_cast<const GpsrOption *>(hdr->getTlvOptions().getTlvOption(i));
675  }
676  }
677  else
678 #endif
679 #ifdef INET_WITH_NEXTHOP
680  if (auto nextHopHeader = dynamicPtrCast<const NextHopForwardingHeader>(networkHeader)) {
681  int i = (nextHopHeader->getTlvOptions().findByType(NEXTHOP_TLVOPTION_TLV_GPSR));
682  if (i >= 0)
683  gpsrOption = check_and_cast<const GpsrOption *>(nextHopHeader->getTlvOptions().getTlvOption(i));
684  }
685  else
686 #endif
687  {
688  }
689  return gpsrOption;
690 }

Referenced by getGpsrOptionFromNetworkDatagram().

◆ findGpsrOptionInNetworkDatagramForUpdate()

GpsrOption * inet::Gpsr::findGpsrOptionInNetworkDatagramForUpdate ( const Ptr< NetworkHeaderBase > &  networkHeader)
private
693 {
694  GpsrOption *gpsrOption = nullptr;
695 
696 #ifdef INET_WITH_IPv4
697  if (auto ipv4Header = dynamicPtrCast<Ipv4Header>(networkHeader)) {
698  gpsrOption = check_and_cast_nullable<GpsrOption *>(ipv4Header->findMutableOptionByType(IPOPTION_TLV_GPSR));
699  }
700  else
701 #endif
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) {
706  int i = (hdr->getTlvOptions().findByType(IPv6TLVOPTION_TLV_GPSR));
707  if (i >= 0)
708  gpsrOption = check_and_cast<GpsrOption *>(hdr->getTlvOptionsForUpdate().getTlvOptionForUpdate(i));
709  }
710  }
711  else
712 #endif
713 #ifdef INET_WITH_NEXTHOP
714  if (auto nextHopHeader = dynamicPtrCast<NextHopForwardingHeader>(networkHeader)) {
715  int i = (nextHopHeader->getTlvOptions().findByType(NEXTHOP_TLVOPTION_TLV_GPSR));
716  if (i >= 0)
717  gpsrOption = check_and_cast<GpsrOption *>(nextHopHeader->getTlvOptionsForUpdate().getTlvOptionForUpdate(i));
718  }
719  else
720 #endif
721  {
722  }
723  return gpsrOption;
724 }

Referenced by getGpsrOptionFromNetworkDatagramForUpdate().

◆ findGreedyRoutingNextHop()

L3Address inet::Gpsr::findGreedyRoutingNextHop ( const L3Address destination,
GpsrOption gpsrOption 
)
private
488 {
489  EV_DEBUG << "Finding next hop using greedy routing: destination = " << destination << endl;
490  L3Address selfAddress = getSelfAddress();
491  Coord selfPosition = mobility->getCurrentPosition();
492  Coord destinationPosition = gpsrOption->getDestinationPosition();
493  double bestDistance = (destinationPosition - selfPosition).length();
494  L3Address bestNeighbor;
495  std::vector<L3Address> neighborAddresses = neighborPositionTable.getAddresses();
496  for (auto& neighborAddress : neighborAddresses) {
497  Coord neighborPosition = neighborPositionTable.getPosition(neighborAddress);
498  double neighborDistance = (destinationPosition - neighborPosition).length();
499  if (neighborDistance < bestDistance) {
500  bestDistance = neighborDistance;
501  bestNeighbor = neighborAddress;
502  }
503  }
504  if (bestNeighbor.isUnspecified()) {
505  EV_DEBUG << "Switching to perimeter routing: destination = " << destination << endl;
506  if (displayBubbles && hasGUI())
507  getContainingNode(host)->bubble("Switching to perimeter routing");
508  gpsrOption->setRoutingMode(GPSR_PERIMETER_ROUTING);
509  gpsrOption->setPerimeterRoutingStartPosition(selfPosition);
510  gpsrOption->setPerimeterRoutingForwardPosition(selfPosition);
511  gpsrOption->setCurrentFaceFirstSenderAddress(selfAddress);
512  gpsrOption->setCurrentFaceFirstReceiverAddress(L3Address());
513  return findPerimeterRoutingNextHop(destination, gpsrOption);
514  }
515  else
516  return bestNeighbor;
517 }

Referenced by findNextHop(), and findPerimeterRoutingNextHop().

◆ findNextHop()

L3Address inet::Gpsr::findNextHop ( const L3Address destination,
GpsrOption gpsrOption 
)
private
479 {
480  switch (gpsrOption->getRoutingMode()) {
481  case GPSR_GREEDY_ROUTING: return findGreedyRoutingNextHop(destination, gpsrOption);
482  case GPSR_PERIMETER_ROUTING: return findPerimeterRoutingNextHop(destination, gpsrOption);
483  default: throw cRuntimeError("Unknown routing mode");
484  }
485 }

Referenced by routeDatagram().

◆ findPerimeterRoutingNextHop()

L3Address inet::Gpsr::findPerimeterRoutingNextHop ( const L3Address destination,
GpsrOption gpsrOption 
)
private
520 {
521  EV_DEBUG << "Finding next hop using perimeter routing: destination = " << destination << endl;
522  L3Address selfAddress = getSelfAddress();
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;
530  if (displayBubbles && hasGUI())
531  getContainingNode(host)->bubble("Switching to greedy routing");
532  gpsrOption->setRoutingMode(GPSR_GREEDY_ROUTING);
533  gpsrOption->setPerimeterRoutingStartPosition(Coord());
534  gpsrOption->setPerimeterRoutingForwardPosition(Coord());
535  gpsrOption->setCurrentFaceFirstSenderAddress(L3Address());
536  gpsrOption->setCurrentFaceFirstReceiverAddress(L3Address());
537  return findGreedyRoutingNextHop(destination, gpsrOption);
538  }
539  else {
540  const L3Address& firstSenderAddress = gpsrOption->getCurrentFaceFirstSenderAddress();
541  const L3Address& firstReceiverAddress = gpsrOption->getCurrentFaceFirstReceiverAddress();
542  auto senderNeighborAddress = gpsrOption->getSenderAddress();
543  auto neighborAngle = senderNeighborAddress.isUnspecified() ? getVectorAngle(destinationPosition - mobility->getCurrentPosition()) : getNeighborAngle(senderNeighborAddress);
544  L3Address selectedNeighborAddress;
545  std::vector<L3Address> neighborAddresses = getPlanarNeighborsCounterClockwise(neighborAngle);
546  for (auto& neighborAddress : neighborAddresses) {
547  Coord neighborPosition = getNeighborPosition(neighborAddress);
548  Coord intersection = computeIntersectionInsideLineSegments(perimeterRoutingStartPosition, destinationPosition, selfPosition, neighborPosition);
549  if (std::isnan(intersection.x)) {
550  selectedNeighborAddress = neighborAddress;
551  break;
552  }
553  else {
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);
558  }
559  }
560  if (selectedNeighborAddress.isUnspecified()) {
561  EV_DEBUG << "No suitable planar graph neighbor found in perimeter routing: firstSender = " << firstSenderAddress << ", firstReceiver = " << firstReceiverAddress << ", destination = " << destination << endl;
562  return L3Address();
563  }
564  else if (firstSenderAddress == selfAddress && firstReceiverAddress == selectedNeighborAddress) {
565  EV_DEBUG << "End of perimeter reached: firstSender = " << firstSenderAddress << ", firstReceiver = " << firstReceiverAddress << ", destination = " << destination << endl;
566  if (displayBubbles && hasGUI())
567  getContainingNode(host)->bubble("End of perimeter reached");
568  return L3Address();
569  }
570  else {
571  if (gpsrOption->getCurrentFaceFirstReceiverAddress().isUnspecified())
572  gpsrOption->setCurrentFaceFirstReceiverAddress(selectedNeighborAddress);
573  return selectedNeighborAddress;
574  }
575  }
576 }

Referenced by findGreedyRoutingNextHop(), and findNextHop().

◆ getGpsrOptionFromNetworkDatagram()

const GpsrOption * inet::Gpsr::getGpsrOptionFromNetworkDatagram ( const Ptr< const NetworkHeaderBase > &  networkHeader) const
private
727 {
728  const GpsrOption *gpsrOption = findGpsrOptionInNetworkDatagram(networkHeader);
729  if (gpsrOption == nullptr)
730  throw cRuntimeError("Gpsr option not found in datagram!");
731  return gpsrOption;
732 }

Referenced by datagramPreRoutingHook(), and getSenderNeighborAddress().

◆ getGpsrOptionFromNetworkDatagramForUpdate()

GpsrOption * inet::Gpsr::getGpsrOptionFromNetworkDatagramForUpdate ( const Ptr< NetworkHeaderBase > &  networkHeader)
private
735 {
736  GpsrOption *gpsrOption = findGpsrOptionInNetworkDatagramForUpdate(networkHeader);
737  if (gpsrOption == nullptr)
738  throw cRuntimeError("Gpsr option not found in datagram!");
739  return gpsrOption;
740 }

◆ getHostName()

std::string inet::Gpsr::getHostName ( ) const
private
368 {
369  return host->getFullName();
370 }

◆ getNeighborAngle()

double inet::Gpsr::getNeighborAngle ( const L3Address address) const
private
359 {
360  return getVectorAngle(getNeighborPosition(address) - mobility->getCurrentPosition());
361 }

Referenced by findPerimeterRoutingNextHop().

◆ getNeighborPosition()

Coord inet::Gpsr::getNeighborPosition ( const L3Address address) const
private
341 {
342  return neighborPositionTable.getPosition(address);
343 }

Referenced by findPerimeterRoutingNextHop(), and getNeighborAngle().

◆ getNextNeighborExpiration()

simtime_t inet::Gpsr::getNextNeighborExpiration ( )
private
403 {
404  simtime_t oldestPosition = neighborPositionTable.getOldestPosition();
405  if (oldestPosition == SimTime::getMaxTime())
406  return oldestPosition;
407  else
408  return oldestPosition + neighborValidityInterval;
409 }

Referenced by schedulePurgeNeighborsTimer().

◆ getPlanarNeighbors()

std::vector< L3Address > inet::Gpsr::getPlanarNeighbors ( ) const
private
417 {
418  std::vector<L3Address> planarNeighbors;
419  std::vector<L3Address> neighborAddresses = neighborPositionTable.getAddresses();
420  Coord selfPosition = mobility->getCurrentPosition();
421  for (auto it = neighborAddresses.begin(); it != neighborAddresses.end(); it++) {
422  auto neighborAddress = *it;
423  Coord neighborPosition = neighborPositionTable.getPosition(neighborAddress);
425  return neighborAddresses;
427  double neighborDistance = (neighborPosition - selfPosition).length();
428  for (auto& witnessAddress : neighborAddresses) {
429  Coord witnessPosition = neighborPositionTable.getPosition(witnessAddress);
430  double witnessDistance = (witnessPosition - selfPosition).length();
431  double neighborWitnessDistance = (witnessPosition - neighborPosition).length();
432  if (neighborAddress == witnessAddress)
433  continue;
434  else if (neighborDistance > std::max(witnessDistance, neighborWitnessDistance))
435  goto eliminate;
436  }
437  }
439  Coord middlePosition = (selfPosition + neighborPosition) / 2;
440  double neighborDistance = (neighborPosition - middlePosition).length();
441  for (auto& witnessAddress : neighborAddresses) {
442  Coord witnessPosition = neighborPositionTable.getPosition(witnessAddress);
443  double witnessDistance = (witnessPosition - middlePosition).length();
444  if (neighborAddress == witnessAddress)
445  continue;
446  else if (witnessDistance < neighborDistance)
447  goto eliminate;
448  }
449  }
450  else
451  throw cRuntimeError("Unknown planarization mode");
452  planarNeighbors.push_back(*it);
453  eliminate:;
454  }
455  return planarNeighbors;
456 }

Referenced by getPlanarNeighborsCounterClockwise().

◆ getPlanarNeighborsCounterClockwise()

std::vector< L3Address > inet::Gpsr::getPlanarNeighborsCounterClockwise ( double  startAngle) const
private
459 {
460  std::vector<L3Address> neighborAddresses = getPlanarNeighbors();
461  std::sort(neighborAddresses.begin(), neighborAddresses.end(), [&] (const L3Address& address1, const L3Address& address2) {
462  // NOTE: make sure the neighbor at startAngle goes to the end
463  auto angle1 = getNeighborAngle(address1) - startAngle;
464  auto angle2 = getNeighborAngle(address2) - startAngle;
465  if (angle1 <= 0)
466  angle1 += 2 * M_PI;
467  if (angle2 <= 0)
468  angle2 += 2 * M_PI;
469  return angle1 < angle2;
470  });
471  return neighborAddresses;
472 }

Referenced by findPerimeterRoutingNextHop().

◆ getSelfAddress()

L3Address inet::Gpsr::getSelfAddress ( ) const
private
373 {
374  // TODO choose self address based on a new 'interfaces' parameter
375  L3Address ret = routingTable->getRouterIdAsGeneric();
376 #ifdef INET_WITH_IPv6
377  if (ret.getType() == L3Address::IPv6) {
378  for (int i = 0; i < interfaceTable->getNumInterfaces(); i++) {
379  NetworkInterface *ie = interfaceTable->getInterface(i);
380  if ((!ie->isLoopback())) {
381  if (auto ipv6Data = ie->findProtocolData<Ipv6InterfaceData>()) {
382  ret = ipv6Data->getPreferredAddress();
383  break;
384  }
385  }
386  }
387  }
388 #endif
389  return ret;
390 }

Referenced by computeOptionLength(), createBeacon(), findGreedyRoutingNextHop(), findPerimeterRoutingNextHop(), initialize(), processBeaconTimer(), routeDatagram(), sendBeacon(), and storeSelfPositionInGlobalRegistry().

◆ getSenderNeighborAddress()

L3Address inet::Gpsr::getSenderNeighborAddress ( const Ptr< const NetworkHeaderBase > &  networkHeader) const
private
393 {
394  const GpsrOption *gpsrOption = getGpsrOptionFromNetworkDatagram(networkHeader);
395  return gpsrOption->getSenderAddress();
396 }

◆ getVectorAngle()

double inet::Gpsr::getVectorAngle ( Coord  vector) const
private
350 {
351  ASSERT(vector != Coord::ZERO);
352  double angle = atan2(-vector.y, vector.x);
353  if (angle < 0)
354  angle += 2 * M_PI;
355  return angle;
356 }

Referenced by findPerimeterRoutingNextHop(), and getNeighborAngle().

◆ handleCrashOperation()

void inet::Gpsr::handleCrashOperation ( LifecycleOperation operation)
overrideprivatevirtual

Implements inet::OperationalMixin< cSimpleModule >.

794 {
796  cancelEvent(beaconTimer);
797  cancelEvent(purgeNeighborsTimer);
798 }

◆ handleMessageWhenUp()

void inet::Gpsr::handleMessageWhenUp ( cMessage *  message)
overrideprotectedvirtual

Implements inet::OperationalMixin< cSimpleModule >.

108 {
109  if (message->isSelfMessage())
110  processSelfMessage(message);
111  else
112  processMessage(message);
113 }

◆ handleStartOperation()

void inet::Gpsr::handleStartOperation ( LifecycleOperation operation)
overrideprivatevirtual

◆ handleStopOperation()

void inet::Gpsr::handleStopOperation ( LifecycleOperation operation)
overrideprivatevirtual

Implements inet::OperationalMixin< cSimpleModule >.

786 {
787  // TODO send a beacon to remove ourself from peers neighbor position table
789  cancelEvent(beaconTimer);
790  cancelEvent(purgeNeighborsTimer);
791 }

◆ initialize()

void inet::Gpsr::initialize ( int  stage)
overrideprotectedvirtual

Reimplemented from inet::OperationalMixin< cSimpleModule >.

62 {
63  if (stage == INITSTAGE_ROUTING_PROTOCOLS)
65 
67 
68  if (stage == INITSTAGE_LOCAL) {
69  // Gpsr parameters
70  const char *planarizationModeString = par("planarizationMode");
71  if (!strcmp(planarizationModeString, ""))
73  else if (!strcmp(planarizationModeString, "GG"))
75  else if (!strcmp(planarizationModeString, "RNG"))
77  else
78  throw cRuntimeError("Unknown planarization mode");
79  interfaces = par("interfaces");
80  beaconInterval = par("beaconInterval");
81  maxJitter = par("maxJitter");
82  neighborValidityInterval = par("neighborValidityInterval");
83  displayBubbles = par("displayBubbles");
84  // context
85  host = getContainingNode(this);
86  interfaceTable.reference(this, "interfaceTableModule", true);
87  outputInterface = par("outputInterface");
88  mobility = check_and_cast<IMobility *>(host->getSubmodule("mobility"));
89  routingTable.reference(this, "routingTableModule", true);
90  networkProtocol.reference(this, "networkProtocolModule", true);
91  // internal
92  beaconTimer = new cMessage("BeaconTimer");
93  purgeNeighborsTimer = new cMessage("PurgeNeighborsTimer");
94  // packet size
95  positionByteLength = par("positionByteLength");
96  // KLUDGE implement position registry protocol
98  }
99  else if (stage == INITSTAGE_ROUTING_PROTOCOLS) {
100  registerProtocol(Protocol::manet, gate("ipOut"), gate("ipIn"));
101  host->subscribe(linkBrokenSignal, this);
102  networkProtocol->registerHook(0, this);
103  WATCH(neighborPositionTable);
104  }
105 }

◆ lookupPositionInGlobalRegistry()

Coord inet::Gpsr::lookupPositionInGlobalRegistry ( const L3Address address) const
private
295 {
296  // KLUDGE implement position registry protocol
297  return globalPositionTable.getPosition(address);
298 }

Referenced by createGpsrOption().

◆ numInitStages()

virtual int inet::Gpsr::numInitStages ( ) const
inlineoverrideprotectedvirtual
71 { return NUM_INIT_STAGES; }

◆ processBeacon()

void inet::Gpsr::processBeacon ( Packet packet)
private
238 {
239  const auto& beacon = packet->peekAtFront<GpsrBeacon>();
240  EV_INFO << "Processing beacon: address = " << beacon->getAddress() << ", position = " << beacon->getPosition() << endl;
241  neighborPositionTable.setPosition(beacon->getAddress(), beacon->getPosition());
242  delete packet;
243 }

Referenced by processUdpPacket().

◆ processBeaconTimer()

void inet::Gpsr::processBeaconTimer ( )
private
148 {
149  EV_DEBUG << "Processing beacon timer" << endl;
150  const L3Address selfAddress = getSelfAddress();
151  if (!selfAddress.isUnspecified()) {
154  }
157 }

Referenced by processSelfMessage().

◆ processMessage()

void inet::Gpsr::processMessage ( cMessage *  message)
private
130 {
131  if (auto pk = dynamic_cast<Packet *>(message))
132  processUdpPacket(pk);
133  else
134  throw cRuntimeError("Unknown message");
135 }

Referenced by handleMessageWhenUp().

◆ processPurgeNeighborsTimer()

void inet::Gpsr::processPurgeNeighborsTimer ( )
private
183 {
184  EV_DEBUG << "Processing purge neighbors timer" << endl;
185  purgeNeighbors();
187 }

Referenced by processSelfMessage().

◆ processSelfMessage()

void inet::Gpsr::processSelfMessage ( cMessage *  message)
private
120 {
121  if (message == beaconTimer)
123  else if (message == purgeNeighborsTimer)
125  else
126  throw cRuntimeError("Unknown self message");
127 }

Referenced by handleMessageWhenUp().

◆ processUdpPacket()

void inet::Gpsr::processUdpPacket ( Packet packet)
private
199 {
200  packet->popAtFront<UdpHeader>();
201  processBeacon(packet);
203 }

Referenced by processMessage().

◆ purgeNeighbors()

void inet::Gpsr::purgeNeighbors ( )
private

◆ receiveSignal()

void inet::Gpsr::receiveSignal ( cComponent *  source,
simsignal_t  signalID,
cObject *  obj,
cObject *  details 
)
overrideprivatevirtual
805 {
806  Enter_Method("%s", cComponent::getSignalName(signalID));
807 
808  if (signalID == linkBrokenSignal) {
809  EV_WARN << "Received link break" << endl;
810  // TODO remove the neighbor
811  }
812 }

◆ routeDatagram()

INetfilter::IHook::Result inet::Gpsr::routeDatagram ( Packet datagram,
GpsrOption gpsrOption 
)
private
583 {
584  const auto& networkHeader = getNetworkProtocolHeader(datagram);
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;
592  if (displayBubbles && hasGUI())
593  getContainingNode(host)->bubble("No next hop found, dropping packet");
594  return DROP;
595  }
596  else {
597  EV_INFO << "Next hop found: source = " << source << ", destination = " << destination << ", nextHop: " << nextHop << endl;
598  gpsrOption->setSenderAddress(getSelfAddress());
599  auto networkInterface = CHK(interfaceTable->findInterfaceByName(outputInterface));
600  datagram->addTagIfAbsent<InterfaceReq>()->setInterfaceId(networkInterface->getInterfaceId());
601  return ACCEPT;
602  }
603 }

Referenced by datagramLocalOutHook(), and datagramPreRoutingHook().

◆ scheduleBeaconTimer()

void inet::Gpsr::scheduleBeaconTimer ( )
private
142 {
143  EV_DEBUG << "Scheduling beacon timer" << endl;
144  scheduleAfter(beaconInterval + uniform(-1, 1) * maxJitter, beaconTimer);
145 }

Referenced by handleStartOperation(), and processBeaconTimer().

◆ schedulePurgeNeighborsTimer()

void inet::Gpsr::schedulePurgeNeighborsTimer ( )
private
164 {
165  EV_DEBUG << "Scheduling purge neighbors timer" << endl;
166  simtime_t nextExpiration = getNextNeighborExpiration();
167  if (nextExpiration == SimTime::getMaxTime()) {
168  if (purgeNeighborsTimer->isScheduled())
169  cancelEvent(purgeNeighborsTimer);
170  }
171  else {
172  if (!purgeNeighborsTimer->isScheduled())
173  scheduleAt(nextExpiration, purgeNeighborsTimer);
174  else {
175  if (purgeNeighborsTimer->getArrivalTime() != nextExpiration) {
176  rescheduleAt(nextExpiration, purgeNeighborsTimer);
177  }
178  }
179  }
180 }

Referenced by processBeaconTimer(), processPurgeNeighborsTimer(), and processUdpPacket().

◆ sendBeacon()

void inet::Gpsr::sendBeacon ( const Ptr< GpsrBeacon > &  beacon)
private
219 {
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>();
224  udpHeader->setSourcePort(GPSR_UDP_PORT);
225  udpHeader->setDestinationPort(GPSR_UDP_PORT);
226  udpHeader->setCrcMode(CRC_DISABLED);
227  udpPacket->insertAtFront(udpHeader);
228  auto addresses = udpPacket->addTag<L3AddressReq>();
229  addresses->setSrcAddress(getSelfAddress());
230  addresses->setDestAddress(addressType->getLinkLocalManetRoutersMulticastAddress());
231  udpPacket->addTag<HopLimitReq>()->setHopLimit(255);
232  udpPacket->addTag<PacketProtocolTag>()->setProtocol(&Protocol::manet);
233  udpPacket->addTag<DispatchProtocolReq>()->setProtocol(addressType->getNetworkProtocol());
234  sendUdpPacket(udpPacket);
235 }

Referenced by processBeaconTimer().

◆ sendUdpPacket()

void inet::Gpsr::sendUdpPacket ( Packet packet)
private
194 {
195  send(packet, "ipOut");
196 }

Referenced by sendBeacon().

◆ setGpsrOptionOnNetworkDatagram()

void inet::Gpsr::setGpsrOptionOnNetworkDatagram ( Packet packet,
const Ptr< const NetworkHeaderBase > &  networkHeader,
GpsrOption gpsrOption 
)
private
606 {
607  packet->trimFront();
608 #ifdef INET_WITH_IPv4
609  if (dynamicPtrCast<const Ipv4Header>(networkHeader)) {
610  auto ipv4Header = removeNetworkProtocolHeader<Ipv4Header>(packet);
611  gpsrOption->setType(IPOPTION_TLV_GPSR);
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);
619  insertNetworkProtocolHeader(packet, Protocol::ipv4, ipv4Header);
620  }
621  else
622 #endif
623 #ifdef INET_WITH_IPv6
624  if (dynamicPtrCast<const Ipv6Header>(networkHeader)) {
625  auto ipv6Header = removeNetworkProtocolHeader<Ipv6Header>(packet);
626  gpsrOption->setType(IPv6TLVOPTION_TLV_GPSR);
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);
633  }
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);
638  insertNetworkProtocolHeader(packet, Protocol::ipv6, ipv6Header);
639  }
640  else
641 #endif
642 #ifdef INET_WITH_NEXTHOP
643  if (dynamicPtrCast<const NextHopForwardingHeader>(networkHeader)) {
644  auto nextHopHeader = removeNetworkProtocolHeader<NextHopForwardingHeader>(packet);
645  gpsrOption->setType(NEXTHOP_TLVOPTION_TLV_GPSR);
646  int oldHlen = nextHopHeader->getTlvOptions().getLength();
647  nextHopHeader->getTlvOptionsForUpdate().appendTlvOption(gpsrOption);
648  int newHlen = nextHopHeader->getTlvOptions().getLength();
649  nextHopHeader->addChunkLength(B(newHlen - oldHlen));
651  }
652  else
653 #endif
654  {
655  }
656 }

Referenced by datagramLocalOutHook().

◆ storePositionInGlobalRegistry()

void inet::Gpsr::storePositionInGlobalRegistry ( const L3Address address,
const Coord position 
) const
private
301 {
302  // KLUDGE implement position registry protocol
303  globalPositionTable.setPosition(address, position);
304 }

Referenced by storeSelfPositionInGlobalRegistry().

◆ storeSelfPositionInGlobalRegistry()

void inet::Gpsr::storeSelfPositionInGlobalRegistry ( ) const
private
307 {
308  auto selfAddress = getSelfAddress();
309  if (!selfAddress.isUnspecified())
310  storePositionInGlobalRegistry(selfAddress, mobility->getCurrentPosition());
311 }

Referenced by handleStartOperation(), and processBeaconTimer().

Member Data Documentation

◆ addressType

IL3AddressType* inet::Gpsr::addressType = nullptr
private

◆ beaconInterval

simtime_t inet::Gpsr::beaconInterval
private

Referenced by initialize(), and scheduleBeaconTimer().

◆ beaconTimer

cMessage* inet::Gpsr::beaconTimer = nullptr
private

◆ displayBubbles

bool inet::Gpsr::displayBubbles
private

◆ globalPositionTable

PositionTable inet::Gpsr::globalPositionTable
staticprivate

◆ host

cModule* inet::Gpsr::host = nullptr
private

◆ interfaces

const char* inet::Gpsr::interfaces = nullptr
private

Referenced by configureInterfaces(), and initialize().

◆ interfaceTable

ModuleRefByPar<IInterfaceTable> inet::Gpsr::interfaceTable
private

◆ maxJitter

simtime_t inet::Gpsr::maxJitter
private

Referenced by initialize(), and scheduleBeaconTimer().

◆ mobility

◆ neighborPositionTable

◆ neighborValidityInterval

simtime_t inet::Gpsr::neighborValidityInterval
private

◆ networkProtocol

ModuleRefByPar<INetfilter> inet::Gpsr::networkProtocol
private

Referenced by initialize().

◆ outputInterface

const char* inet::Gpsr::outputInterface = nullptr
private

Referenced by initialize(), and routeDatagram().

◆ planarizationMode

GpsrPlanarizationMode inet::Gpsr::planarizationMode = static_cast<GpsrPlanarizationMode>(-1)
private

Referenced by getPlanarNeighbors(), and initialize().

◆ 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:
GPSR_UDP_PORT
#define GPSR_UDP_PORT
Definition: GpsrDefs.h:13
inet::IP_PROT_IPv6EXT_HOP
@ IP_PROT_IPv6EXT_HOP
Definition: IpProtocolId_m.h:111
CHK
#define CHK(x)
Definition: INETDefs.h:87
inet::Gpsr::findGpsrOptionInNetworkDatagramForUpdate
GpsrOption * findGpsrOptionInNetworkDatagramForUpdate(const Ptr< NetworkHeaderBase > &networkHeader)
Definition: Gpsr.cc:692
inet::Gpsr::host
cModule * host
Definition: Gpsr.h:48
inet::Gpsr::mobility
opp_component_ptr< IMobility > mobility
Definition: Gpsr.h:49
inet::PositionTable::clear
void clear()
Definition: PositionTable.cc:55
inet::units::constants::c
const value< double, compose< units::m, pow< units::s, -1 > > > c(299792458)
inet::Gpsr::createGpsrOption
GpsrOption * createGpsrOption(L3Address destination)
Definition: Gpsr.cc:249
inet::Gpsr::processBeacon
void processBeacon(Packet *packet)
Definition: Gpsr.cc:237
inet::IL3AddressType::getAddressByteLength
int getAddressByteLength() const
Definition: IL3AddressType.h:25
inet::NEXTHOP_TLVOPTION_TLV_GPSR
@ NEXTHOP_TLVOPTION_TLV_GPSR
Definition: NextHopForwardingHeader_m.h:72
inet::Gpsr::computeOptionLength
int computeOptionLength(GpsrOption *gpsrOption)
Definition: Gpsr.cc:258
inet::Gpsr::getPlanarNeighbors
std::vector< L3Address > getPlanarNeighbors() const
Definition: Gpsr.cc:416
inet::sort
void sort(std::vector< T > &v)
Definition: stlutils.h:129
inet::Gpsr::findGreedyRoutingNextHop
L3Address findGreedyRoutingNextHop(const L3Address &destination, GpsrOption *gpsrOption)
Definition: Gpsr.cc:487
inet::Gpsr::purgeNeighborsTimer
cMessage * purgeNeighborsTimer
Definition: Gpsr.h:62
inet::Gpsr::positionByteLength
int positionByteLength
Definition: Gpsr.h:58
inet::linkBrokenSignal
simsignal_t linkBrokenSignal
Definition: Simsignals.cc:22
inet::Gpsr::computeIntersectionInsideLineSegments
Coord computeIntersectionInsideLineSegments(Coord &begin1, Coord &end1, Coord &begin2, Coord &end2) const
Definition: Gpsr.cc:313
inet::Gpsr::neighborPositionTable
PositionTable neighborPositionTable
Definition: Gpsr.h:63
inet::Coord::ZERO
static const Coord ZERO
Definition: Coord.h:27
inet::Protocol::ipv4
static const Protocol ipv4
Definition: Protocol.h:93
inet::Protocol::ipv6
static const Protocol ipv6
Definition: Protocol.h:94
inet::Gpsr::storePositionInGlobalRegistry
void storePositionInGlobalRegistry(const L3Address &address, const Coord &position) const
Definition: Gpsr.cc:300
inet::Gpsr::configureInterfaces
void configureInterfaces()
Definition: Gpsr.cc:276
inet::Gpsr::globalPositionTable
static PositionTable globalPositionTable
Definition: Gpsr.h:55
inet::getContainingNode
cModule * getContainingNode(const cModule *from)
Find the node containing the given module.
Definition: ModuleAccess.cc:40
inet::OperationalMixin< cSimpleModule >::initialize
virtual void initialize(int stage) override
Definition: OperationalMixinImpl.h:26
inet::Gpsr::interfaces
const char * interfaces
Definition: Gpsr.h:41
InterfaceReq
removed InterfaceReq
Definition: IUdp-gates.txt:11
inet::Gpsr::addressType
IL3AddressType * addressType
Definition: Gpsr.h:50
DispatchProtocolReq
removed DscpReq Ipv4ControlInfo Ipv6ControlInfo up L3AddressInd DispatchProtocolReq L4PortInd Ipv4ControlInfo Ipv6ControlInfo down DispatchProtocolReq
Definition: IUdp-gates.txt:25
inet::Coord::x
double x
Definition: Coord.h:36
inet::Gpsr::findPerimeterRoutingNextHop
L3Address findPerimeterRoutingNextHop(const L3Address &destination, GpsrOption *gpsrOption)
Definition: Gpsr.cc:519
inet::CRC_DISABLED
@ CRC_DISABLED
Definition: CrcMode_m.h:56
inet::PositionTable::setPosition
void setPosition(const L3Address &address, const Coord &coord)
Definition: PositionTable.cc:33
inet::Protocol::nextHopForwarding
static const Protocol nextHopForwarding
Definition: Protocol.h:128
inet::IL3AddressType::getLinkLocalManetRoutersMulticastAddress
virtual L3Address getLinkLocalManetRoutersMulticastAddress() const =0
inet::insertNetworkProtocolHeader
void insertNetworkProtocolHeader(Packet *packet, const Protocol &protocol, const Ptr< NetworkHeaderBase > &header)
Definition: L3Tools.cc:70
inet::Gpsr::findNextHop
L3Address findNextHop(const L3Address &destination, GpsrOption *gpsrOption)
Definition: Gpsr.cc:478
inet::Gpsr::purgeNeighbors
void purgeNeighbors()
Definition: Gpsr.cc:411
PacketProtocolTag
removed DscpReq Ipv4ControlInfo Ipv6ControlInfo up L3AddressInd DispatchProtocolReq L4PortInd Ipv4ControlInfo Ipv6ControlInfo down PacketProtocolTag
Definition: IUdp-gates.txt:25
inet::Gpsr::getGpsrOptionFromNetworkDatagram
const GpsrOption * getGpsrOptionFromNetworkDatagram(const Ptr< const NetworkHeaderBase > &networkHeader) const
Definition: Gpsr.cc:726
inet::GPSR_GG_PLANARIZATION
@ GPSR_GG_PLANARIZATION
Definition: Gpsr_m.h:86
inet::Gpsr::processPurgeNeighborsTimer
void processPurgeNeighborsTimer()
Definition: Gpsr.cc:182
inet::Gpsr::schedulePurgeNeighborsTimer
void schedulePurgeNeighborsTimer()
Definition: Gpsr.cc:163
inet::Protocol::manet
static const Protocol manet
Definition: Protocol.h:99
inet::Gpsr::getVectorAngle
double getVectorAngle(Coord vector) const
Definition: Gpsr.cc:349
inet::Gpsr::sendBeacon
void sendBeacon(const Ptr< GpsrBeacon > &beacon)
Definition: Gpsr.cc:218
inet::units::units::B
intscale< b, 1, 8 > B
Definition: Units.h:1168
inet::PositionTable::removeOldPositions
void removeOldPositions(simtime_t timestamp)
Definition: PositionTable.cc:45
inet::Gpsr::sendUdpPacket
void sendUdpPacket(Packet *packet)
Definition: Gpsr.cc:193
inet::getNetworkProtocolHeader
const Ptr< const NetworkHeaderBase > getNetworkProtocolHeader(Packet *packet)
Definition: L3Tools.cc:43
inet::GPSR_PERIMETER_ROUTING
@ GPSR_PERIMETER_ROUTING
Definition: Gpsr_m.h:67
inet::Gpsr::beaconTimer
cMessage * beaconTimer
Definition: Gpsr.h:61
inet::Gpsr::outputInterface
const char * outputInterface
Definition: Gpsr.h:52
inet::GPSR_NO_PLANARIZATION
@ GPSR_NO_PLANARIZATION
Definition: Gpsr_m.h:85
inet::Gpsr::routingTable
ModuleRefByPar< IRoutingTable > routingTable
Definition: Gpsr.h:53
inet::Gpsr::lookupPositionInGlobalRegistry
Coord lookupPositionInGlobalRegistry(const L3Address &address) const
Definition: Gpsr.cc:294
inet::GPSR_RNG_PLANARIZATION
@ GPSR_RNG_PLANARIZATION
Definition: Gpsr_m.h:87
HopLimitReq
removed HopLimitReq
Definition: IUdp-gates.txt:11
inet::Gpsr::scheduleBeaconTimer
void scheduleBeaconTimer()
Definition: Gpsr.cc:141
inet::GPSR_GREEDY_ROUTING
@ GPSR_GREEDY_ROUTING
Definition: Gpsr_m.h:66
inet::Gpsr::maxJitter
simtime_t maxJitter
Definition: Gpsr.h:43
inet::Gpsr::displayBubbles
bool displayBubbles
Definition: Gpsr.h:45
inet::utils::roundUp
int roundUp(int numToRound, int multiple)
Rounding up to the nearest multiple of a number.
Definition: INETUtils.h:70
inet::Gpsr::interfaceTable
ModuleRefByPar< IInterfaceTable > interfaceTable
Definition: Gpsr.h:51
inet::INITSTAGE_LOCAL
INET_API InitStage INITSTAGE_LOCAL
Initialization of local state that don't use or affect other modules includes:
inet::Gpsr::networkProtocol
ModuleRefByPar< INetfilter > networkProtocol
Definition: Gpsr.h:54
inet::Gpsr::processSelfMessage
void processSelfMessage(cMessage *message)
Definition: Gpsr.cc:119
inet::IPv6TLVOPTION_TLV_GPSR
@ IPv6TLVOPTION_TLV_GPSR
Definition: Ipv6ExtensionHeaders_m.h:82
inet::units::values::b
value< int64_t, units::b > b
Definition: Units.h:1241
inet::Gpsr::getNeighborAngle
double getNeighborAngle(const L3Address &address) const
Definition: Gpsr.cc:358
NUM_INIT_STAGES
#define NUM_INIT_STAGES
Definition: InitStageRegistry.h:73
inet::sctp::max
double max(const double a, const double b)
Returns the maximum of a and b.
Definition: SctpAssociation.h:266
inet::PositionTable::getPosition
Coord getPosition(const L3Address &address) const
Definition: PositionTable.cc:27
inet::IPOPTION_TLV_GPSR
@ IPOPTION_TLV_GPSR
Definition: Ipv4Header_m.h:142
inet::Gpsr::routeDatagram
Result routeDatagram(Packet *datagram, GpsrOption *gpsrOption)
Definition: Gpsr.cc:582
inet::Gpsr::beaconInterval
simtime_t beaconInterval
Definition: Gpsr.h:42
inet::L3Address::IPv6
@ IPv6
Definition: L3Address.h:36
inet::Gpsr::neighborValidityInterval
simtime_t neighborValidityInterval
Definition: Gpsr.h:44
inet::Gpsr::processMessage
void processMessage(cMessage *message)
Definition: Gpsr.cc:129
inet::INetfilter::IHook::DROP
@ DROP
doesn't allow the datagram to pass to the next hook, will be deleted
Definition: INetfilter.h:41
Enter_Method
#define Enter_Method(...)
Definition: SelfDoc.h:71
inet::Gpsr::findGpsrOptionInNetworkDatagram
const GpsrOption * findGpsrOptionInNetworkDatagram(const Ptr< const NetworkHeaderBase > &networkHeader) const
Definition: Gpsr.cc:658
inet::Coord::NIL
static const Coord NIL
Constant with all values set to 0.
Definition: Coord.h:26
inet::Gpsr::processUdpPacket
void processUdpPacket(Packet *packet)
Definition: Gpsr.cc:198
inet::INetfilter::IHook::ACCEPT
@ ACCEPT
allows the datagram to pass to the next hook
Definition: INetfilter.h:40
inet::L3Address::getAddressType
IL3AddressType * getAddressType() const
Definition: L3Address.cc:59
inet::Gpsr::processBeaconTimer
void processBeaconTimer()
Definition: Gpsr.cc:147
inet::IL3AddressType::getNetworkProtocol
virtual const Protocol * getNetworkProtocol() const =0
inet::Gpsr::setGpsrOptionOnNetworkDatagram
void setGpsrOptionOnNetworkDatagram(Packet *packet, const Ptr< const NetworkHeaderBase > &networkHeader, GpsrOption *gpsrOption)
Definition: Gpsr.cc:605
inet::Gpsr::getSelfAddress
L3Address getSelfAddress() const
Definition: Gpsr.cc:372
inet::registerProtocol
void registerProtocol(const Protocol &protocol, cGate *gate, ServicePrimitive servicePrimitive)
Registers a protocol primitive (PDU processing) at the given gate.
Definition: IProtocolRegistrationListener.cc:83
inet::Gpsr::getNeighborPosition
Coord getNeighborPosition(const L3Address &address) const
Definition: Gpsr.cc:340
inet::Gpsr::getNextNeighborExpiration
simtime_t getNextNeighborExpiration()
Definition: Gpsr.cc:402
inet::Gpsr::getPlanarNeighborsCounterClockwise
std::vector< L3Address > getPlanarNeighborsCounterClockwise(double startAngle) const
Definition: Gpsr.cc:458
M_PI
#define M_PI
Definition: INETMath.h:52
inet::Gpsr::planarizationMode
GpsrPlanarizationMode planarizationMode
Definition: Gpsr.h:40
inet::INITSTAGE_ROUTING_PROTOCOLS
INET_API InitStage INITSTAGE_ROUTING_PROTOCOLS
Initialization of routing protocols.
inet::PositionTable::getAddresses
std::vector< L3Address > getAddresses() const
Definition: PositionTable.cc:14
inet::Gpsr::storeSelfPositionInGlobalRegistry
void storeSelfPositionInGlobalRegistry() const
Definition: Gpsr.cc:306
inet::Gpsr::createBeacon
const Ptr< GpsrBeacon > createBeacon()
Definition: Gpsr.cc:209
inet::PositionTable::getOldestPosition
simtime_t getOldestPosition() const
Definition: PositionTable.cc:60