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

Implements a next hop forwarding protocol that routes datagrams through the network. More...

#include <NextHopForwarding.h>

Inheritance diagram for inet::NextHopForwarding:
inet::OperationalBase inet::NetfilterBase inet::INetworkProtocol inet::DefaultProtocolRegistrationListener inet::OperationalMixin< cSimpleModule > inet::INetfilter inet::IProtocolRegistrationListener inet::ILifecycle

Classes

struct  QueuedDatagramForHook
 Represents an NextHopDatagram, queued by a Hook. More...
 
struct  SocketDescriptor
 

Public Member Functions

 NextHopForwarding ()
 
 ~NextHopForwarding ()
 
virtual void handleRegisterService (const Protocol &protocol, cGate *gate, ServicePrimitive servicePrimitive) override
 
virtual void handleRegisterProtocol (const Protocol &protocol, cGate *gate, ServicePrimitive servicePrimitive) override
 
virtual void registerHook (int priority, IHook *hook) override
 Adds the provided hook to the list of registered hooks that will be called by the network layer when it processes datagrams. More...
 
virtual void unregisterHook (IHook *hook) override
 Removes the provided hook from the list of registered hooks. More...
 
virtual void dropQueuedDatagram (const Packet *datagram) override
 Requests the network layer to drop the datagram, because it's no longer needed. More...
 
virtual void reinjectQueuedDatagram (const Packet *datagram) override
 Requests the network layer to restart the processing of the datagram. More...
 
- 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
virtual ~NetfilterBase ()
 
- Public Member Functions inherited from inet::INetfilter
virtual ~INetfilter ()
 
- Public Member Functions inherited from inet::INetworkProtocol
virtual ~INetworkProtocol ()
 
- Public Member Functions inherited from inet::DefaultProtocolRegistrationListener
virtual void handleRegisterServiceGroup (const ProtocolGroup &protocolGroup, cGate *gate, ServicePrimitive servicePrimitive) override
 
virtual void handleRegisterProtocolGroup (const ProtocolGroup &protocolGroup, cGate *gate, ServicePrimitive servicePrimitive) override
 
virtual void handleRegisterAnyService (cGate *gate, ServicePrimitive servicePrimitive) override
 
virtual void handleRegisterAnyProtocol (cGate *gate, ServicePrimitive servicePrimitive) override
 

Protected Types

typedef std::list< QueuedDatagramForHookDatagramQueueForHooks
 
- Protected Types inherited from inet::OperationalMixin< cSimpleModule >
enum  State
 

Protected Member Functions

virtual const NetworkInterfacegetSourceInterfaceFrom (Packet *packet)
 
virtual void refreshDisplay () const override
 
virtual void handlePacketFromNetwork (Packet *datagram)
 Handle NextHopDatagram messages arriving from lower layer. More...
 
virtual void handlePacketFromHL (Packet *packet)
 Handle packets from transport or ICMP. More...
 
virtual void routePacket (Packet *datagram, const NetworkInterface *destIE, const L3Address &nextHop, bool fromHL)
 Performs routing. More...
 
virtual void routeMulticastPacket (Packet *datagram, const NetworkInterface *destIE, const NetworkInterface *fromIE)
 Forwards packets to all multicast destinations, using sendDatagramToOutput(). More...
 
virtual void encapsulate (Packet *transportPacket, const NetworkInterface *&destIE)
 Encapsulate packet coming from higher layers into NextHopDatagram, using the control info attached to the packet. More...
 
virtual void decapsulate (Packet *datagram)
 Decapsulate and return encapsulated packet. More...
 
virtual void sendDatagramToHL (Packet *datagram)
 Send datagrams up to the higher layers. More...
 
virtual void sendDatagramToOutput (Packet *datagram, const NetworkInterface *ie, L3Address nextHop)
 Last TTL check, then send datagram on the given interface. More...
 
virtual void datagramPreRouting (Packet *datagram, const NetworkInterface *inIE, const NetworkInterface *destIE, const L3Address &nextHop)
 
virtual void datagramLocalIn (Packet *datagram, const NetworkInterface *inIE)
 
virtual void datagramLocalOut (Packet *datagram, const NetworkInterface *destIE, const L3Address &nextHop)
 
virtual IHook::Result datagramPreRoutingHook (Packet *datagram)
 
virtual IHook::Result datagramForwardHook (Packet *datagram)
 
virtual IHook::Result datagramPostRoutingHook (Packet *datagram)
 
virtual IHook::Result datagramLocalInHook (Packet *datagram)
 
virtual IHook::Result datagramLocalOutHook (Packet *datagram)
 
virtual void initialize (int stage) override
 Initialization. More...
 
virtual void handleMessageWhenUp (cMessage *msg) override
 
void handleCommand (Request *msg)
 
virtual bool isInitializeStage (int stage) const override
 ILifecycle method. More...
 
virtual bool isModuleStartStage (int stage) const override
 
virtual bool isModuleStopStage (int stage) const override
 
virtual void handleStartOperation (LifecycleOperation *operation) override
 
virtual void handleStopOperation (LifecycleOperation *operation) override
 
virtual void handleCrashOperation (LifecycleOperation *operation) override
 
virtual void stop ()
 
virtual void start ()
 
virtual void flush ()
 
- 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 ()
 

Protected Attributes

ModuleRefByPar< IInterfaceTableinterfaceTable
 
ModuleRefByPar< NextHopRoutingTableroutingTable
 
ModuleRefByPar< IArparp
 
int defaultHopLimit
 
std::set< const Protocol * > upperProtocols
 
std::map< int, SocketDescriptor * > socketIdToSocketDescriptor
 
DatagramQueueForHooks queuedDatagramsForHooks
 
int numLocalDeliver
 
int numDropped
 
int numUnroutable
 
int numForwarded
 
- Protected Attributes inherited from inet::OperationalMixin< cSimpleModule >
State operationalState
 
simtime_t lastChange
 
Operation activeOperation
 
cMessage * activeOperationTimeout
 
cMessage * activeOperationExtraTimer
 
- Protected Attributes inherited from inet::NetfilterBase
std::multimap< int, IHook * > hooks
 

Detailed Description

Implements a next hop forwarding protocol that routes datagrams through the network.

Routing decisions are based on a next hop routing table, but it also supports the netfilter interface to allow routing protocols to kick in. It doesn't provide datagram fragmentation and reassembling.

Member Typedef Documentation

◆ DatagramQueueForHooks

Constructor & Destructor Documentation

◆ NextHopForwarding()

inet::NextHopForwarding::NextHopForwarding ( )
31  :
32  defaultHopLimit(-1),
33  numLocalDeliver(0),
34  numDropped(0),
35  numUnroutable(0),
36  numForwarded(0)
37 {
38 }

◆ ~NextHopForwarding()

inet::NextHopForwarding::~NextHopForwarding ( )
41 {
42  for (auto it : socketIdToSocketDescriptor)
43  delete it.second;
44  for (auto& elem : queuedDatagramsForHooks) {
45  delete elem.datagram;
46  }
48 }

Member Function Documentation

◆ datagramForwardHook()

INetfilter::IHook::Result inet::NextHopForwarding::datagramForwardHook ( Packet datagram)
protectedvirtual
752 {
753  for (auto& elem : hooks) {
754  IHook::Result r = elem.second->datagramForwardHook(datagram);
755  switch (r) {
756  case IHook::ACCEPT:
757  break; // continue iteration
758 
759  case IHook::DROP:
760  delete datagram;
761  return r;
762 
763  case IHook::QUEUE:
764  queuedDatagramsForHooks.push_back(QueuedDatagramForHook(datagram, INetfilter::IHook::FORWARD));
765  return r;
766 
767  case IHook::STOLEN:
768  return r;
769 
770  default:
771  throw cRuntimeError("Unknown Hook::Result value: %d", (int)r);
772  }
773  }
774  return IHook::ACCEPT;
775 }

◆ datagramLocalIn()

void inet::NextHopForwarding::datagramLocalIn ( Packet datagram,
const NetworkInterface inIE 
)
protectedvirtual
652 {
653  sendDatagramToHL(packet);
654 }

Referenced by reinjectQueuedDatagram().

◆ datagramLocalInHook()

INetfilter::IHook::Result inet::NextHopForwarding::datagramLocalInHook ( Packet datagram)
protectedvirtual
804 {
805  L3Address address;
806  for (auto& elem : hooks) {
807  IHook::Result r = elem.second->datagramLocalInHook(datagram);
808  switch (r) {
809  case IHook::ACCEPT:
810  break; // continue iteration
811 
812  case IHook::DROP:
813  delete datagram;
814  return r;
815 
816  case IHook::QUEUE:
817  queuedDatagramsForHooks.push_back(QueuedDatagramForHook(datagram, INetfilter::IHook::LOCALIN));
818  return r;
819 
820  case IHook::STOLEN:
821  return r;
822 
823  default:
824  throw cRuntimeError("Unknown Hook::Result value: %d", (int)r);
825  }
826  }
827  return IHook::ACCEPT;
828 }

Referenced by routePacket().

◆ datagramLocalOut()

void inet::NextHopForwarding::datagramLocalOut ( Packet datagram,
const NetworkInterface destIE,
const L3Address nextHop 
)
protectedvirtual
657 {
658  const auto& header = datagram->peekAtFront<NextHopForwardingHeader>();
659  // route packet
660  if (!header->getDestinationAddress().isMulticast())
661  routePacket(datagram, destIE, nextHop, true);
662  else
663  routeMulticastPacket(datagram, destIE, nullptr);
664 }

Referenced by handlePacketFromHL(), and reinjectQueuedDatagram().

◆ datagramLocalOutHook()

INetfilter::IHook::Result inet::NextHopForwarding::datagramLocalOutHook ( Packet datagram)
protectedvirtual
831 {
832  for (auto& elem : hooks) {
833  IHook::Result r = elem.second->datagramLocalOutHook(datagram);
834  switch (r) {
835  case IHook::ACCEPT:
836  break; // continue iteration
837 
838  case IHook::DROP:
839  delete datagram;
840  return r;
841 
842  case IHook::QUEUE:
843  queuedDatagramsForHooks.push_back(QueuedDatagramForHook(datagram, INetfilter::IHook::LOCALOUT));
844  return r;
845 
846  case IHook::STOLEN:
847  return r;
848 
849  default:
850  throw cRuntimeError("Unknown Hook::Result value: %d", (int)r);
851  }
852  }
853  return IHook::ACCEPT;
854 }

Referenced by handlePacketFromHL().

◆ datagramPostRoutingHook()

INetfilter::IHook::Result inet::NextHopForwarding::datagramPostRoutingHook ( Packet datagram)
protectedvirtual
778 {
779  for (auto& elem : hooks) {
780  IHook::Result r = elem.second->datagramPostRoutingHook(datagram);
781  switch (r) {
782  case IHook::ACCEPT:
783  break; // continue iteration
784 
785  case IHook::DROP:
786  delete datagram;
787  return r;
788 
789  case IHook::QUEUE:
790  queuedDatagramsForHooks.push_back(QueuedDatagramForHook(datagram, INetfilter::IHook::POSTROUTING));
791  return r;
792 
793  case IHook::STOLEN:
794  return r;
795 
796  default:
797  throw cRuntimeError("Unknown Hook::Result value: %d", (int)r);
798  }
799  }
800  return IHook::ACCEPT;
801 }

◆ datagramPreRouting()

void inet::NextHopForwarding::datagramPreRouting ( Packet datagram,
const NetworkInterface inIE,
const NetworkInterface destIE,
const L3Address nextHop 
)
protectedvirtual
642 {
643  const auto& header = datagram->peekAtFront<NextHopForwardingHeader>();
644  // route packet
645  if (!header->getDestinationAddress().isMulticast())
646  routePacket(datagram, destIE, nextHop, false);
647  else
648  routeMulticastPacket(datagram, destIE, inIE);
649 }

Referenced by handlePacketFromNetwork(), and reinjectQueuedDatagram().

◆ datagramPreRoutingHook()

INetfilter::IHook::Result inet::NextHopForwarding::datagramPreRoutingHook ( Packet datagram)
protectedvirtual
724 {
725  for (auto& elem : hooks) {
726  IHook::Result r = elem.second->datagramPreRoutingHook(datagram);
727  switch (r) {
728  case IHook::ACCEPT:
729  break; // continue iteration
730 
731  case IHook::DROP:
732  delete datagram;
733  return r;
734 
735  case IHook::QUEUE:
736  if (datagram->getOwner() != this)
737  throw cRuntimeError("Model error: netfilter hook changed the owner of queued datagram '%s'", datagram->getFullName());
738  queuedDatagramsForHooks.push_back(QueuedDatagramForHook(datagram, INetfilter::IHook::PREROUTING));
739  return r;
740 
741  case IHook::STOLEN:
742  return r;
743 
744  default:
745  throw cRuntimeError("Unknown Hook::Result value: %d", (int)r);
746  }
747  }
748  return IHook::ACCEPT;
749 }

Referenced by handlePacketFromNetwork().

◆ decapsulate()

void inet::NextHopForwarding::decapsulate ( Packet datagram)
protectedvirtual

Decapsulate and return encapsulated packet.

466 {
467  // decapsulate transport packet
468  const NetworkInterface *fromIE = getSourceInterfaceFrom(packet);
469  const auto& header = packet->popAtFront<NextHopForwardingHeader>();
470 
471  // create and fill in control info
472  if (fromIE) {
473  auto ifTag = packet->addTagIfAbsent<InterfaceInd>();
474  ifTag->setInterfaceId(fromIE->getInterfaceId());
475  }
476 
477  ASSERT(header->getPayloadLengthField() <= packet->getDataLength());
478  // drop padding
479  packet->setBackOffset(packet->getFrontOffset() + header->getPayloadLengthField());
480 
481  // attach control info
482  auto payloadProtocol = header->getProtocol();
483  packet->addTagIfAbsent<PacketProtocolTag>()->setProtocol(payloadProtocol);
484  packet->addTagIfAbsent<DispatchProtocolReq>()->setProtocol(payloadProtocol);
485  auto networkProtocolInd = packet->addTagIfAbsent<NetworkProtocolInd>();
486  networkProtocolInd->setProtocol(&Protocol::nextHopForwarding);
487  networkProtocolInd->setNetworkProtocolHeader(header);
488  auto l3AddressInd = packet->addTagIfAbsent<L3AddressInd>();
489  l3AddressInd->setSrcAddress(header->getSourceAddress());
490  l3AddressInd->setDestAddress(header->getDestinationAddress());
491  packet->addTagIfAbsent<HopLimitInd>()->setHopLimit(header->getHopLimit());
492 }

Referenced by sendDatagramToHL().

◆ dropQueuedDatagram()

void inet::NextHopForwarding::dropQueuedDatagram ( const Packet daragram)
overridevirtual

Requests the network layer to drop the datagram, because it's no longer needed.

This function may be used by a reactive routing protocol when it cancels the route discovery process.

Implements inet::INetfilter.

679 {
680  Enter_Method("dropDatagram()");
681  for (auto iter = queuedDatagramsForHooks.begin(); iter != queuedDatagramsForHooks.end(); iter++) {
682  if (iter->datagram == datagram) {
683  delete datagram;
684  queuedDatagramsForHooks.erase(iter);
685  return;
686  }
687  }
688 }

◆ encapsulate()

void inet::NextHopForwarding::encapsulate ( Packet transportPacket,
const NetworkInterface *&  destIE 
)
protectedvirtual

Encapsulate packet coming from higher layers into NextHopDatagram, using the control info attached to the packet.

495 {
496  auto header = makeShared<NextHopForwardingHeader>();
497  header->setChunkLength(B(par("headerLength")));
498  auto& l3AddressReq = transportPacket->removeTag<L3AddressReq>();
499  L3Address src = l3AddressReq->getSrcAddress();
500  L3Address dest = l3AddressReq->getDestAddress();
501 
502  header->setProtocol(transportPacket->getTag<PacketProtocolTag>()->getProtocol());
503 
504  auto& hopLimitReq = transportPacket->removeTagIfPresent<HopLimitReq>();
505  short ttl = (hopLimitReq != nullptr) ? hopLimitReq->getHopLimit() : -1;
506 
507  // set source and destination address
508  header->setDestinationAddress(dest);
509 
510  // multicast interface option, but allow interface selection for unicast packets as well
511  const auto& ifTag = transportPacket->findTag<InterfaceReq>();
512  destIE = ifTag ? interfaceTable->getInterfaceById(ifTag->getInterfaceId()) : nullptr;
513 
514  // when source address was given, use it; otherwise it'll get the address
515  // of the outgoing interface after routing
516  if (!src.isUnspecified()) {
517  // if interface parameter does not match existing interface, do not send datagram
518  if (routingTable->getInterfaceByAddress(src) == nullptr)
519  throw cRuntimeError("Wrong source address %s in (%s)%s: no interface with such address",
520  src.str().c_str(), transportPacket->getClassName(), transportPacket->getFullName());
521  header->setSourceAddress(src);
522  }
523 
524  // set other fields
525  if (ttl != -1) {
526  ASSERT(ttl > 0);
527  }
528  else if (false) // TODO datagram->getDestinationAddress().isLinkLocalMulticast())
529  ttl = 1;
530  else
531  ttl = defaultHopLimit;
532 
533  header->setHopLimit(ttl);
534 
535  // setting NextHopForwarding options is currently not supported
536 
537  delete transportPacket->removeControlInfo();
538  header->setPayloadLengthField(transportPacket->getDataLength());
539 
541 }

Referenced by handlePacketFromHL().

◆ flush()

void inet::NextHopForwarding::flush ( )
protectedvirtual
884 {
885  EV_DEBUG << "NextHopForwarding::flush(): packets in hooks: " << queuedDatagramsForHooks.size() << endl;
886  for (auto& elem : queuedDatagramsForHooks) {
887  delete elem.datagram;
888  }
889  queuedDatagramsForHooks.clear();
890 
891 // fragbuf.flush();
892 }

Referenced by stop().

◆ getSourceInterfaceFrom()

const NetworkInterface * inet::NextHopForwarding::getSourceInterfaceFrom ( Packet packet)
protectedvirtual
160 {
161  const auto& interfaceInd = packet->findTag<InterfaceInd>();
162  return interfaceInd != nullptr ? interfaceTable->getInterfaceById(interfaceInd->getInterfaceId()) : nullptr;
163 }

Referenced by decapsulate().

◆ handleCommand()

void inet::NextHopForwarding::handleCommand ( Request msg)
protected
118 {
119  if (auto *command = dynamic_cast<L3SocketBindCommand *>(request->getControlInfo())) {
120  int socketId = request->getTag<SocketReq>()->getSocketId();
121  SocketDescriptor *descriptor = new SocketDescriptor(socketId, command->getProtocol()->getId(), command->getLocalAddress());
122  socketIdToSocketDescriptor[socketId] = descriptor;
123  delete request;
124  }
125  else if (auto *command = dynamic_cast<L3SocketConnectCommand *>(request->getControlInfo())) {
126  int socketId = request->getTag<SocketReq>()->getSocketId();
127  if (!containsKey(socketIdToSocketDescriptor, socketId))
128  throw cRuntimeError("L3Socket: should use bind() before connect()");
129  socketIdToSocketDescriptor[socketId]->remoteAddress = command->getRemoteAddress();
130  delete request;
131  }
132  else if (dynamic_cast<L3SocketCloseCommand *>(request->getControlInfo()) != nullptr) {
133  int socketId = request->getTag<SocketReq>()->getSocketId();
134  auto it = socketIdToSocketDescriptor.find(socketId);
135  if (it != socketIdToSocketDescriptor.end()) {
136  delete it->second;
137  socketIdToSocketDescriptor.erase(it);
138  auto indication = new Indication("closed", L3_I_SOCKET_CLOSED);
139  auto ctrl = new L3SocketClosedIndication();
140  indication->setControlInfo(ctrl);
141  indication->addTag<SocketInd>()->setSocketId(socketId);
142  send(indication, "transportOut");
143  }
144  delete request;
145  }
146  else if (dynamic_cast<L3SocketDestroyCommand *>(request->getControlInfo()) != nullptr) {
147  int socketId = request->getTag<SocketReq>()->getSocketId();
148  auto it = socketIdToSocketDescriptor.find(socketId);
149  if (it != socketIdToSocketDescriptor.end()) {
150  delete it->second;
151  socketIdToSocketDescriptor.erase(it);
152  }
153  delete request;
154  }
155  else
156  throw cRuntimeError("Invalid command: (%s)%s", request->getClassName(), request->getName());
157 }

Referenced by handleMessageWhenUp().

◆ handleCrashOperation()

void inet::NextHopForwarding::handleCrashOperation ( LifecycleOperation operation)
overrideprotectedvirtual

Implements inet::OperationalMixin< cSimpleModule >.

867 {
868  stop();
869 }

◆ handleMessageWhenUp()

void inet::NextHopForwarding::handleMessageWhenUp ( cMessage *  msg)
overrideprotectedvirtual

Implements inet::OperationalMixin< cSimpleModule >.

102 {
103  if (msg->arrivedOn("transportIn")) { // TODO packet->getArrivalGate()->getBaseId() == transportInGateBaseId
104  if (auto request = dynamic_cast<Request *>(msg))
105  handleCommand(request);
106  else
107  handlePacketFromHL(check_and_cast<Packet *>(msg));
108  }
109  else if (msg->arrivedOn("queueIn")) { // from network
110  EV_INFO << "Received " << msg << " from network.\n";
111  handlePacketFromNetwork(check_and_cast<Packet *>(msg));
112  }
113  else
114  throw cRuntimeError("message arrived on unknown gate '%s'", msg->getArrivalGate()->getName());
115 }

◆ handlePacketFromHL()

void inet::NextHopForwarding::handlePacketFromHL ( Packet packet)
protectedvirtual

Handle packets from transport or ICMP.

Invokes encapsulate(), then routePacket().

212 {
213  // if no interface exists, do not send datagram
214  if (interfaceTable->getNumInterfaces() == 0) {
215  EV_INFO << "No interfaces exist, dropping packet\n";
216  PacketDropDetails details;
217  details.setReason(NO_INTERFACE_FOUND);
218  emit(packetDroppedSignal, packet, &details);
219  delete packet;
220  return;
221  }
222 
223  // encapsulate and send
224  const NetworkInterface *destIE; // will be filled in by encapsulate()
225  encapsulate(packet, destIE);
226 
227  L3Address nextHop;
228  if (datagramLocalOutHook(packet) != IHook::ACCEPT)
229  return;
230 
231  const auto& destIeTag = packet->findTag<InterfaceReq>();
232  destIE = destIeTag ? interfaceTable->getInterfaceById(destIeTag->getInterfaceId()) : nullptr;
233  const auto& nextHopTag = packet->findTag<NextHopAddressReq>();
234  nextHop = (nextHopTag) ? nextHopTag->getNextHopAddress() : L3Address();
235 
236  datagramLocalOut(packet, destIE, nextHop);
237 }

Referenced by handleMessageWhenUp().

◆ handlePacketFromNetwork()

void inet::NextHopForwarding::handlePacketFromNetwork ( Packet datagram)
protectedvirtual

Handle NextHopDatagram messages arriving from lower layer.

Decrements TTL, then invokes routePacket().

166 {
167  if (packet->hasBitError()) {
168  // TODO emit packetDropped signal
169  EV_WARN << "CRC error found, drop packet\n";
170  PacketDropDetails details;
171  details.setReason(INCORRECTLY_RECEIVED);
172  emit(packetDroppedSignal, packet, &details);
173  delete packet;
174  return;
175  }
176 
177  const auto& header = packet->peekAtFront<NextHopForwardingHeader>();
178  packet->addTagIfAbsent<NetworkProtocolInd>()->setProtocol(&Protocol::nextHopForwarding);
179  packet->addTagIfAbsent<NetworkProtocolInd>()->setNetworkProtocolHeader(header);
180  B totalLength = header->getChunkLength() + header->getPayloadLengthField();
181  if (totalLength > packet->getDataLength()) {
182  EV_WARN << "length error found, drop packet\n";
183  PacketDropDetails details;
184  details.setReason(INCORRECTLY_RECEIVED);
185  emit(packetDroppedSignal, packet, &details);
186  delete packet;
187  return;
188  }
189 
190  // remove lower layer paddings:
191  if (totalLength < packet->getDataLength()) {
192  packet->setBackOffset(packet->getFrontOffset() + totalLength);
193  }
194 
195  const NetworkInterface *inIE = interfaceTable->getInterfaceById(packet->getTag<InterfaceInd>()->getInterfaceId());
196  const NetworkInterface *destIE = nullptr;
197 
198  EV_DETAIL << "Received datagram `" << packet->getName() << "' with dest=" << header->getDestAddr() << " from " << header->getSrcAddr() << " in interface" << inIE->getInterfaceName() << "\n";
199 
200  if (datagramPreRoutingHook(packet) != IHook::ACCEPT)
201  return;
202 
203  inIE = interfaceTable->getInterfaceById(packet->getTag<InterfaceInd>()->getInterfaceId());
204  const auto& destIeTag = packet->findTag<InterfaceReq>();
205  destIE = destIeTag ? interfaceTable->getInterfaceById(destIeTag->getInterfaceId()) : nullptr;
206  const auto& nextHopTag = packet->findTag<NextHopAddressReq>();
207  L3Address nextHop = (nextHopTag) ? nextHopTag->getNextHopAddress() : L3Address();
208  datagramPreRouting(packet, inIE, destIE, nextHop);
209 }

Referenced by handleMessageWhenUp().

◆ handleRegisterProtocol()

void inet::NextHopForwarding::handleRegisterProtocol ( const Protocol protocol,
cGate *  gate,
ServicePrimitive  servicePrimitive 
)
overridevirtual

Reimplemented from inet::DefaultProtocolRegistrationListener.

79 {
80  Enter_Method("handleRegisterProtocol");
81  if (!strcmp("transportOut", gate->getBaseName()))
82  upperProtocols.insert(&protocol);
83 }

◆ handleRegisterService()

void inet::NextHopForwarding::handleRegisterService ( const Protocol protocol,
cGate *  gate,
ServicePrimitive  servicePrimitive 
)
overridevirtual

Reimplemented from inet::DefaultProtocolRegistrationListener.

74 {
75  Enter_Method("handleRegisterService");
76 }

◆ handleStartOperation()

void inet::NextHopForwarding::handleStartOperation ( LifecycleOperation operation)
overrideprotectedvirtual

Implements inet::OperationalMixin< cSimpleModule >.

857 {
858  start();
859 }

◆ handleStopOperation()

void inet::NextHopForwarding::handleStopOperation ( LifecycleOperation operation)
overrideprotectedvirtual

Implements inet::OperationalMixin< cSimpleModule >.

862 {
863  stop();
864 }

◆ initialize()

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

Initialization.

Reimplemented from inet::OperationalMixin< cSimpleModule >.

51 {
53 
54  if (stage == INITSTAGE_LOCAL) {
55  interfaceTable.reference(this, "interfaceTableModule", true);
56  routingTable.reference(this, "routingTableModule", true);
57  arp.reference(this, "arpModule", true);
58 
59  defaultHopLimit = par("hopLimit");
61 
62  WATCH(numLocalDeliver);
63  WATCH(numDropped);
64  WATCH(numUnroutable);
65  WATCH(numForwarded);
66  }
67  else if (stage == INITSTAGE_NETWORK_LAYER) {
68  registerService(Protocol::nextHopForwarding, gate("transportIn"), gate("transportOut"));
69  registerProtocol(Protocol::nextHopForwarding, gate("queueOut"), gate("queueIn"));
70  }
71 }

◆ isInitializeStage()

virtual bool inet::NextHopForwarding::isInitializeStage ( int  stage) const
inlineoverrideprotectedvirtual

ILifecycle method.

Implements inet::OperationalMixin< cSimpleModule >.

174 { return stage == INITSTAGE_NETWORK_LAYER; }

◆ isModuleStartStage()

virtual bool inet::NextHopForwarding::isModuleStartStage ( int  stage) const
inlineoverrideprotectedvirtual

◆ isModuleStopStage()

virtual bool inet::NextHopForwarding::isModuleStopStage ( int  stage) const
inlineoverrideprotectedvirtual

◆ refreshDisplay()

void inet::NextHopForwarding::refreshDisplay ( ) const
overrideprotectedvirtual
86 {
88 
89  char buf[80] = "";
90  if (numForwarded > 0)
91  sprintf(buf + strlen(buf), "fwd:%d ", numForwarded);
92  if (numLocalDeliver > 0)
93  sprintf(buf + strlen(buf), "up:%d ", numLocalDeliver);
94  if (numDropped > 0)
95  sprintf(buf + strlen(buf), "DROP:%d ", numDropped);
96  if (numUnroutable > 0)
97  sprintf(buf + strlen(buf), "UNROUTABLE:%d ", numUnroutable);
98  getDisplayString().setTagArg("t", 0, buf);
99 }

◆ registerHook()

void inet::NextHopForwarding::registerHook ( int  priority,
IHook hook 
)
overridevirtual

Adds the provided hook to the list of registered hooks that will be called by the network layer when it processes datagrams.

Reimplemented from inet::NetfilterBase.

667 {
668  Enter_Method("registerHook()");
669  NetfilterBase::registerHook(priority, hook);
670 }

◆ reinjectQueuedDatagram()

void inet::NextHopForwarding::reinjectQueuedDatagram ( const Packet datagram)
overridevirtual

Requests the network layer to restart the processing of the datagram.

This function may be used by a reactive routing protocol when it completes the route discovery process.

Implements inet::INetfilter.

691 {
692  Enter_Method("reinjectDatagram()");
693  for (auto iter = queuedDatagramsForHooks.begin(); iter != queuedDatagramsForHooks.end(); iter++) {
694  if (iter->datagram == datagram) {
695  Packet *datagram = iter->datagram;
696  const NetworkInterface *inIE = iter->inIE;
697  const NetworkInterface *outIE = iter->outIE;
698  const L3Address& nextHop = iter->nextHop;
699  INetfilter::IHook::Type hookType = iter->hookType;
700  switch (hookType) {
702  datagramPreRouting(datagram, inIE, outIE, nextHop);
703  break;
704 
706  datagramLocalIn(datagram, inIE);
707  break;
708 
710  datagramLocalOut(datagram, outIE, nextHop);
711  break;
712 
713  default:
714  throw cRuntimeError("Re-injection of datagram queued for this hook not implemented");
715  break;
716  }
717  queuedDatagramsForHooks.erase(iter);
718  return;
719  }
720  }
721 }

◆ routeMulticastPacket()

void inet::NextHopForwarding::routeMulticastPacket ( Packet datagram,
const NetworkInterface destIE,
const NetworkInterface fromIE 
)
protectedvirtual

Forwards packets to all multicast destinations, using sendDatagramToOutput().

332 {
333  const auto& header = datagram->peekAtFront<NextHopForwardingHeader>();
334  L3Address destAddr = header->getDestinationAddress();
335  // if received from the network...
336  if (fromIE != nullptr) {
337  //TODO decrement hopLimit before forward frame to another host
338 
339  // check for local delivery
340  if (routingTable->isLocalMulticastAddress(destAddr))
341  sendDatagramToHL(datagram);
342 //
343 // // don't forward if NextHopForwarding forwarding is off
344 // if (!rt->isForwardingEnabled())
345 // {
346 // delete datagram;
347 // return;
348 // }
349 //
350 // // don't forward if dest address is link-scope
351 // if (destAddr.isLinkLocalMulticast())
352 // {
353 // delete datagram;
354 // return;
355 // }
356  }
357  else {
358  //TODO
359  for (int i = 0; i < interfaceTable->getNumInterfaces(); ++i) {
360  const NetworkInterface *destIE = interfaceTable->getInterface(i);
361  if (!destIE->isLoopback())
362  sendDatagramToOutput(datagram->dup(), destIE, header->getDestinationAddress());
363  }
364  delete datagram;
365  }
366 
367 // Address destAddr = datagram->getDestinationAddress();
368 // EV << "Routing multicast datagram `" << datagram->getName() << "' with dest=" << destAddr << "\n";
369 //
370 // numMulticast++;
371 //
372 // // DVMRP: process datagram only if sent locally or arrived on the shortest
373 // // route (provided routing table already contains srcAddr); otherwise
374 // // discard and continue.
375 // const NetworkInterface *shortestPathIE = rt->getInterfaceForDestinationAddr(datagram->getSourceAddress());
376 // if (fromIE!=nullptr && shortestPathIE!=nullptr && fromIE!=shortestPathIE)
377 // {
378 // // FIXME count dropped
379 // EV << "Packet dropped.\n";
380 // delete datagram;
381 // return;
382 // }
383 //
384 // // if received from the network...
385 // if (fromIE!=nullptr)
386 // {
387 // // check for local delivery
388 // if (rt->isLocalMulticastAddress(destAddr))
389 // {
390 // NextHopDatagram *datagramCopy = datagram->dup();
391 //
392 // // FIXME code from the MPLS model: set packet dest address to routerId (???)
393 // datagramCopy->setDestinationAddress(rt->getRouterId());
394 //
395 // reassembleAndDeliver(datagramCopy);
396 // }
397 //
398 // // don't forward if NextHopForwarding forwarding is off
399 // if (!rt->isForwardingEnabled())
400 // {
401 // delete datagram;
402 // return;
403 // }
404 //
405 // // don't forward if dest address is link-scope
406 // if (destAddr.isLinkLocalMulticast())
407 // {
408 // delete datagram;
409 // return;
410 // }
411 //
412 // }
413 //
414 // // routed explicitly via multicast interface
415 // if (destIE!=nullptr)
416 // {
417 // ASSERT(datagram->getDestinationAddress().isMulticast());
418 //
419 // EV << "multicast packet explicitly routed via output interface " << destIE->getName() << endl;
420 //
421 // // set datagram source address if not yet set
422 // if (datagram->getSourceAddress().isUnspecified())
423 // datagram->setSourceAddress(destIE->getProtocolData<Ipv4InterfaceData>()->getGenericAddress());
424 //
425 // // send
426 // sendDatagramToOutput(datagram, destIE, datagram->getDestinationAddress());
427 //
428 // return;
429 // }
430 //
431 // // now: routing
432 // MulticastRoutes routes = rt->getMulticastRoutesFor(destAddr);
433 // if (routes.size()==0)
434 // {
435 // // no destination: delete datagram
436 // delete datagram;
437 // }
438 // else
439 // {
440 // // copy original datagram for multiple destinations
441 // for (unsigned int i=0; i<routes.size(); i++)
442 // {
443 // const NetworkInterface *destIE = routes[i].interf;
444 //
445 // // don't forward to input port
446 // if (destIE && destIE!=fromIE)
447 // {
448 // NextHopDatagram *datagramCopy = datagram->dup();
449 //
450 // // set datagram source address if not yet set
451 // if (datagramCopy->getSourceAddress().isUnspecified())
452 // datagramCopy->setSourceAddress(destIE->getProtocolData<Ipv4InterfaceData>()->getGenericAddress());
453 //
454 // // send
455 // Address nextHop = routes[i].gateway;
456 // sendDatagramToOutput(datagramCopy, destIE, nextHop);
457 // }
458 // }
459 //
460 // // only copies sent, delete original datagram
461 // delete datagram;
462 // }
463 }

Referenced by datagramLocalOut(), and datagramPreRouting().

◆ routePacket()

void inet::NextHopForwarding::routePacket ( Packet datagram,
const NetworkInterface destIE,
const L3Address nextHop,
bool  fromHL 
)
protectedvirtual

Performs routing.

Based on the routing decision, it dispatches to sendDatagramToHL() for local packets, to sendDatagramToOutput() for forwarded packets, to handleMulticastPacket() for multicast packets, or drops the packet if it's unroutable or forwarding is off.

240 {
241  // TODO add option handling code here
242 
243  auto header = datagram->peekAtFront<NextHopForwardingHeader>();
244  L3Address destAddr = header->getDestinationAddress();
245 
246  EV_INFO << "Routing datagram `" << datagram->getName() << "' with dest=" << destAddr << ": ";
247 
248  // check for local delivery
249  if (routingTable->isLocalAddress(destAddr)) {
250  EV_INFO << "local delivery\n";
251  if (fromHL && header->getSourceAddress().isUnspecified()) {
252  datagram->trimFront();
253  const auto& newHeader = removeNetworkProtocolHeader<NextHopForwardingHeader>(datagram);
254  newHeader->setSourceAddress(destAddr); // allows two apps on the same host to communicate
256  header = newHeader;
257  }
258  numLocalDeliver++;
259 
261  return;
262 
263  sendDatagramToHL(datagram);
264  return;
265  }
266 
267  // if datagram arrived from input gate and forwarding is off, delete datagram
268  if (!fromHL && !routingTable->isForwardingEnabled()) {
269  EV_INFO << "forwarding off, dropping packet\n";
270  numDropped++;
271  delete datagram;
272  return;
273  }
274 
275  if (!fromHL) {
276  datagram->trim();
277  }
278 
279  // if output port was explicitly requested, use that, otherwise use NextHopForwarding routing
280  // TODO see Ipv4, using destIE here leaves nextHope unspecified
281  L3Address nextHop;
282  if (destIE && !requestedNextHop.isUnspecified()) {
283  EV_DETAIL << "using manually specified output interface " << destIE->getInterfaceName() << "\n";
284  nextHop = requestedNextHop;
285  }
286  else {
287  // use NextHopForwarding routing (lookup in routing table)
288  const NextHopRoute *re = routingTable->findBestMatchingRoute(destAddr);
289 
290  // error handling: destination address does not exist in routing table:
291  // throw packet away and continue
292  if (re == nullptr) {
293  EV_INFO << "unroutable, discarding packet\n";
294  numUnroutable++;
295  PacketDropDetails details;
296  details.setReason(NO_ROUTE_FOUND);
297  emit(packetDroppedSignal, datagram, &details);
298  delete datagram;
299  return;
300  }
301 
302  // extract interface and next-hop address from routing table entry
303  destIE = re->getInterface();
304  nextHop = re->getNextHopAsGeneric();
305  }
306 
307  if (!fromHL) {
308  datagram->trimFront();
309  const auto& newHeader = removeNetworkProtocolHeader<NextHopForwardingHeader>(datagram);
310  newHeader->setHopLimit(header->getHopLimit() - 1);
312  header = newHeader;
313  }
314 
315  // set datagram source address if not yet set
316  if (header->getSourceAddress().isUnspecified()) {
317  datagram->trimFront();
318  const auto& newHeader = removeNetworkProtocolHeader<NextHopForwardingHeader>(datagram);
319  newHeader->setSourceAddress(destIE->getProtocolData<NextHopInterfaceData>()->getAddress());
321  header = newHeader;
322  }
323 
324  // default: send datagram to fragmentation
325  EV_INFO << "output interface is " << destIE->getInterfaceName() << ", next-hop address: " << nextHop << "\n";
326  numForwarded++;
327 
328  sendDatagramToOutput(datagram, destIE, nextHop);
329 }

Referenced by datagramLocalOut(), and datagramPreRouting().

◆ sendDatagramToHL()

void inet::NextHopForwarding::sendDatagramToHL ( Packet datagram)
protectedvirtual

Send datagrams up to the higher layers.

544 {
545  const auto& header = packet->peekAtFront<NextHopForwardingHeader>();
546  const Protocol *protocol = header->getProtocol();
547  decapsulate(packet);
548  // deliver to sockets
549  auto localAddress(header->getDestAddr());
550  auto remoteAddress(header->getSrcAddr());
551  bool hasSocket = false;
552  for (const auto& elem : socketIdToSocketDescriptor) {
553  if (elem.second->protocolId == protocol->getId()
554  && (elem.second->localAddress.isUnspecified() || elem.second->localAddress == localAddress)
555  && (elem.second->remoteAddress.isUnspecified() || elem.second->remoteAddress == remoteAddress))
556  {
557  auto *packetCopy = packet->dup();
558  packetCopy->setKind(L3_I_DATA);
559  packetCopy->addTagIfAbsent<SocketInd>()->setSocketId(elem.second->socketId);
560  EV_INFO << "Passing up to socket " << elem.second->socketId << "\n";
561  emit(packetSentToUpperSignal, packetCopy);
562  send(packetCopy, "transportOut");
563  hasSocket = true;
564  }
565  }
566 
568  EV_INFO << "Passing up to protocol " << *protocol << "\n";
569  emit(packetSentToUpperSignal, packet);
570  send(packet, "transportOut");
571  numLocalDeliver++;
572  }
573  else {
574  if (!hasSocket) {
575  EV_ERROR << "Transport protocol '" << protocol->getName() << "' not connected, discarding packet\n";
576  // TODO send an ICMP error: protocol unreachable
577 // sendToIcmp(datagram, inputInterfaceId, ICMP_DESTINATION_UNREACHABLE, ICMP_DU_PROTOCOL_UNREACHABLE);
578  }
579  delete packet;
580  }
581 }

Referenced by datagramLocalIn(), routeMulticastPacket(), and routePacket().

◆ sendDatagramToOutput()

void inet::NextHopForwarding::sendDatagramToOutput ( Packet datagram,
const NetworkInterface ie,
L3Address  nextHop 
)
protectedvirtual

Last TTL check, then send datagram on the given interface.

584 {
585  delete datagram->removeControlInfo();
586 
587  if (datagram->getByteLength() > ie->getMtu())
588  throw cRuntimeError("datagram too large"); // TODO refine
589 
590  const auto& header = datagram->peekAtFront<NextHopForwardingHeader>();
591  // hop counter check
592  if (header->getHopLimit() <= 0) {
593  EV_INFO << "datagram hopLimit reached zero, discarding\n";
594  delete datagram; // TODO stats counter???
595  return;
596  }
597 
598  if (!ie->isBroadcast()) {
599  EV_DETAIL << "output interface " << ie->getInterfaceName() << " is not broadcast, skipping ARP\n";
600  // Peer to peer interface, no broadcast, no MACAddress. // packet->addTagIfAbsent<MACAddressReq>()->setDestinationAddress(macAddress);
601  datagram->addTagIfAbsent<InterfaceReq>()->setInterfaceId(ie->getInterfaceId());
602  datagram->addTagIfAbsent<DispatchProtocolInd>()->setProtocol(&Protocol::nextHopForwarding);
603  datagram->addTagIfAbsent<PacketProtocolTag>()->setProtocol(&Protocol::nextHopForwarding);
604  auto protocol = ie->getProtocol();
605  if (protocol != nullptr)
606  datagram->addTagIfAbsent<DispatchProtocolReq>()->setProtocol(protocol);
607  else
608  datagram->removeTagIfPresent<DispatchProtocolReq>();
609  send(datagram, "queueOut");
610  return;
611  }
612 
613  // determine what address to look up in ARP cache
614  if (nextHop.isUnspecified()) {
615  nextHop = header->getDestinationAddress();
616  EV_WARN << "no next-hop address, using destination address " << nextHop << " (proxy ARP)\n";
617  }
618 
619  // send out datagram to NIC, with control info attached
620  MacAddress nextHopMAC = arp->resolveL3Address(nextHop, ie);
621  if (nextHopMAC == MacAddress::UNSPECIFIED_ADDRESS) {
622  throw cRuntimeError("ARP couldn't resolve the '%s' address", nextHop.str().c_str());
623  }
624  else {
625  // add control info with MAC address
626  datagram->addTagIfAbsent<MacAddressReq>()->setDestAddress(nextHopMAC);
627  datagram->addTagIfAbsent<InterfaceReq>()->setInterfaceId(ie->getInterfaceId());
628  datagram->addTagIfAbsent<DispatchProtocolInd>()->setProtocol(&Protocol::nextHopForwarding);
629  datagram->addTagIfAbsent<PacketProtocolTag>()->setProtocol(&Protocol::nextHopForwarding);
630  auto protocol = ie->getProtocol();
631  if (protocol != nullptr)
632  datagram->addTagIfAbsent<DispatchProtocolReq>()->setProtocol(protocol);
633  else
634  datagram->removeTagIfPresent<DispatchProtocolReq>();
635 
636  // send out
637  send(datagram, "queueOut");
638  }
639 }

Referenced by routeMulticastPacket(), and routePacket().

◆ start()

void inet::NextHopForwarding::start ( )
protectedvirtual
872 {
873 }

Referenced by handleStartOperation().

◆ stop()

void inet::NextHopForwarding::stop ( )
protectedvirtual
876 {
877  flush();
878  for (auto it : socketIdToSocketDescriptor)
879  delete it.second;
881 }

Referenced by handleCrashOperation(), and handleStopOperation().

◆ unregisterHook()

void inet::NextHopForwarding::unregisterHook ( IHook hook)
overridevirtual

Removes the provided hook from the list of registered hooks.

Reimplemented from inet::NetfilterBase.

673 {
674  Enter_Method("unregisterHook()");
676 }

Member Data Documentation

◆ arp

ModuleRefByPar<IArp> inet::NextHopForwarding::arp
protected

Referenced by initialize(), and sendDatagramToOutput().

◆ defaultHopLimit

int inet::NextHopForwarding::defaultHopLimit
protected

Referenced by encapsulate(), and initialize().

◆ interfaceTable

◆ numDropped

int inet::NextHopForwarding::numDropped
protected

◆ numForwarded

int inet::NextHopForwarding::numForwarded
protected

◆ numLocalDeliver

int inet::NextHopForwarding::numLocalDeliver
protected

◆ numUnroutable

int inet::NextHopForwarding::numUnroutable
protected

◆ queuedDatagramsForHooks

◆ routingTable

ModuleRefByPar<NextHopRoutingTable> inet::NextHopForwarding::routingTable
protected

◆ socketIdToSocketDescriptor

std::map<int, SocketDescriptor *> inet::NextHopForwarding::socketIdToSocketDescriptor
protected

◆ upperProtocols

std::set<const Protocol *> inet::NextHopForwarding::upperProtocols
protected

The documentation for this class was generated from the following files:
inet::NextHopForwarding::handleCommand
void handleCommand(Request *msg)
Definition: NextHopForwarding.cc:117
inet::NextHopForwarding::defaultHopLimit
int defaultHopLimit
Definition: NextHopForwarding.h:71
inet::INetfilter::IHook::Type
Type
Definition: INetfilter.h:31
inet::NextHopForwarding::datagramLocalInHook
virtual IHook::Result datagramLocalInHook(Packet *datagram)
Definition: NextHopForwarding.cc:803
inet::NextHopForwarding::routePacket
virtual void routePacket(Packet *datagram, const NetworkInterface *destIE, const L3Address &nextHop, bool fromHL)
Performs routing.
Definition: NextHopForwarding.cc:239
inet::L3_I_DATA
@ L3_I_DATA
Definition: L3SocketCommand_m.h:84
inet::NextHopForwarding::socketIdToSocketDescriptor
std::map< int, SocketDescriptor * > socketIdToSocketDescriptor
Definition: NextHopForwarding.h:75
protocol
removed DscpReq Ipv4ControlInfo Ipv6ControlInfo up L3AddressInd DispatchProtocolReq L4PortInd Ipv4ControlInfo Ipv6ControlInfo down protocol
Definition: IUdp-gates.txt:25
inet::NextHopForwarding::upperProtocols
std::set< const Protocol * > upperProtocols
Definition: NextHopForwarding.h:74
inet::NO_INTERFACE_FOUND
@ NO_INTERFACE_FOUND
Definition: Simsignals_m.h:74
inet::NextHopForwarding::flush
virtual void flush()
Definition: NextHopForwarding.cc:883
inet::ModuleStopOperation::STAGE_NETWORK_LAYER
@ STAGE_NETWORK_LAYER
Definition: ModuleOperations.h:53
inet::INCORRECTLY_RECEIVED
@ INCORRECTLY_RECEIVED
Definition: Simsignals_m.h:71
inet::INetfilter::IHook::STOLEN
@ STOLEN
doesn't allow datagram to pass to next hook, but won't be deleted
Definition: INetfilter.h:43
inet::OperationalMixin< cSimpleModule >::initialize
virtual void initialize(int stage) override
Definition: OperationalMixinImpl.h:26
inet::ModuleStartOperation::STAGE_NETWORK_LAYER
@ STAGE_NETWORK_LAYER
Definition: ModuleOperations.h:29
InterfaceReq
removed InterfaceReq
Definition: IUdp-gates.txt:11
DispatchProtocolReq
removed DscpReq Ipv4ControlInfo Ipv6ControlInfo up L3AddressInd DispatchProtocolReq L4PortInd Ipv4ControlInfo Ipv6ControlInfo down DispatchProtocolReq
Definition: IUdp-gates.txt:25
inet::INITSTAGE_NETWORK_LAYER
INET_API InitStage INITSTAGE_NETWORK_LAYER
Initialization of network layer protocols.
L3AddressInd
removed DscpReq Ipv4ControlInfo Ipv6ControlInfo up L3AddressInd L3AddressInd
Definition: IUdp-gates.txt:20
inet::INetfilter::IHook::FORWARD
@ FORWARD
Definition: INetfilter.h:34
inet::NextHopForwarding::datagramLocalOutHook
virtual IHook::Result datagramLocalOutHook(Packet *datagram)
Definition: NextHopForwarding.cc:830
inet::NextHopForwarding::routingTable
ModuleRefByPar< NextHopRoutingTable > routingTable
Definition: NextHopForwarding.h:67
inet::NetfilterBase::registerHook
virtual void registerHook(int priority, INetfilter::IHook *hook) override
Adds the provided hook to the list of registered hooks that will be called by the network layer when ...
Definition: INetfilter.h:137
inet::NextHopForwarding::getSourceInterfaceFrom
virtual const NetworkInterface * getSourceInterfaceFrom(Packet *packet)
Definition: NextHopForwarding.cc:159
inet::NextHopForwarding::start
virtual void start()
Definition: NextHopForwarding.cc:871
inet::NO_ROUTE_FOUND
@ NO_ROUTE_FOUND
Definition: Simsignals_m.h:75
inet::Protocol::nextHopForwarding
static const Protocol nextHopForwarding
Definition: Protocol.h:128
inet::registerService
void registerService(const Protocol &protocol, cGate *gate, ServicePrimitive servicePrimitive)
Registers a service primitive (SDU processing) at the given gate.
Definition: IProtocolRegistrationListener.cc:14
inet::NextHopForwarding::numUnroutable
int numUnroutable
Definition: NextHopForwarding.h:84
inet::insertNetworkProtocolHeader
void insertNetworkProtocolHeader(Packet *packet, const Protocol &protocol, const Ptr< NetworkHeaderBase > &header)
Definition: L3Tools.cc:70
inet::packetDroppedSignal
simsignal_t packetDroppedSignal
Definition: Simsignals.cc:85
inet::NextHopForwarding::handlePacketFromNetwork
virtual void handlePacketFromNetwork(Packet *datagram)
Handle NextHopDatagram messages arriving from lower layer.
Definition: NextHopForwarding.cc:165
PacketProtocolTag
removed DscpReq Ipv4ControlInfo Ipv6ControlInfo up L3AddressInd DispatchProtocolReq L4PortInd Ipv4ControlInfo Ipv6ControlInfo down PacketProtocolTag
Definition: IUdp-gates.txt:25
inet::NextHopForwarding::sendDatagramToHL
virtual void sendDatagramToHL(Packet *datagram)
Send datagrams up to the higher layers.
Definition: NextHopForwarding.cc:543
inet::NextHopForwarding::numLocalDeliver
int numLocalDeliver
Definition: NextHopForwarding.h:82
ctrl
removed ctrl
Definition: IUdp-gates.txt:7
inet::units::units::B
intscale< b, 1, 8 > B
Definition: Units.h:1168
inet::NextHopForwarding::handlePacketFromHL
virtual void handlePacketFromHL(Packet *packet)
Handle packets from transport or ICMP.
Definition: NextHopForwarding.cc:211
inet::INetfilter::IHook::QUEUE
@ QUEUE
queues the datagram for later re-injection (e.g. when route discovery completes)
Definition: INetfilter.h:42
inet::INetfilter::IHook::Result
Result
Definition: INetfilter.h:39
inet::contains
bool contains(const std::vector< T > &v, const Tk &a)
Definition: stlutils.h:65
inet::NetfilterBase::unregisterHook
virtual void unregisterHook(INetfilter::IHook *hook) override
Removes the provided hook from the list of registered hooks.
Definition: INetfilter.h:142
inet::NextHopForwarding::numDropped
int numDropped
Definition: NextHopForwarding.h:83
HopLimitReq
removed HopLimitReq
Definition: IUdp-gates.txt:11
inet::NextHopForwarding::datagramPreRouting
virtual void datagramPreRouting(Packet *datagram, const NetworkInterface *inIE, const NetworkInterface *destIE, const L3Address &nextHop)
Definition: NextHopForwarding.cc:641
inet::NextHopForwarding::arp
ModuleRefByPar< IArp > arp
Definition: NextHopForwarding.h:68
inet::INITSTAGE_LOCAL
INET_API InitStage INITSTAGE_LOCAL
Initialization of local state that don't use or affect other modules includes:
inet::NextHopForwarding::datagramLocalIn
virtual void datagramLocalIn(Packet *datagram, const NetworkInterface *inIE)
Definition: NextHopForwarding.cc:651
inet::NextHopForwarding::stop
virtual void stop()
Definition: NextHopForwarding.cc:875
inet::NextHopForwarding::routeMulticastPacket
virtual void routeMulticastPacket(Packet *datagram, const NetworkInterface *destIE, const NetworkInterface *fromIE)
Forwards packets to all multicast destinations, using sendDatagramToOutput().
Definition: NextHopForwarding.cc:331
inet::NextHopForwarding::decapsulate
virtual void decapsulate(Packet *datagram)
Decapsulate and return encapsulated packet.
Definition: NextHopForwarding.cc:465
inet::INetfilter::IHook::PREROUTING
@ PREROUTING
Definition: INetfilter.h:32
inet::NextHopForwarding::encapsulate
virtual void encapsulate(Packet *transportPacket, const NetworkInterface *&destIE)
Encapsulate packet coming from higher layers into NextHopDatagram, using the control info attached to...
Definition: NextHopForwarding.cc:494
inet::NextHopForwarding::numForwarded
int numForwarded
Definition: NextHopForwarding.h:85
inet::NextHopForwarding::datagramLocalOut
virtual void datagramLocalOut(Packet *datagram, const NetworkInterface *destIE, const L3Address &nextHop)
Definition: NextHopForwarding.cc:656
inet::NetfilterBase::hooks
std::multimap< int, IHook * > hooks
Definition: INetfilter.h: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::NextHopForwarding::queuedDatagramsForHooks
DatagramQueueForHooks queuedDatagramsForHooks
Definition: NextHopForwarding.h:79
inet::INetfilter::IHook::ACCEPT
@ ACCEPT
allows the datagram to pass to the next hook
Definition: INetfilter.h:40
inet::packetSentToUpperSignal
simsignal_t packetSentToUpperSignal
Definition: Simsignals.cc:87
inet::MacAddress::UNSPECIFIED_ADDRESS
static const MacAddress UNSPECIFIED_ADDRESS
The unspecified MAC address, 00:00:00:00:00:00.
Definition: MacAddress.h:31
inet::L3_I_SOCKET_CLOSED
@ L3_I_SOCKET_CLOSED
Definition: L3SocketCommand_m.h:85
inet::NextHopForwarding::interfaceTable
ModuleRefByPar< IInterfaceTable > interfaceTable
Definition: NextHopForwarding.h:66
inet::OperationalMixin< cSimpleModule >::refreshDisplay
virtual void refreshDisplay() const override
Definition: OperationalMixinImpl.h:200
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::NextHopForwarding::datagramPreRoutingHook
virtual IHook::Result datagramPreRoutingHook(Packet *datagram)
Definition: NextHopForwarding.cc:723
inet::NextHopForwarding::sendDatagramToOutput
virtual void sendDatagramToOutput(Packet *datagram, const NetworkInterface *ie, L3Address nextHop)
Last TTL check, then send datagram on the given interface.
Definition: NextHopForwarding.cc:583
inet::INetfilter::IHook::LOCALIN
@ LOCALIN
Definition: INetfilter.h:33
inet::INetfilter::IHook::POSTROUTING
@ POSTROUTING
Definition: INetfilter.h:35
inet::INetfilter::IHook::LOCALOUT
@ LOCALOUT
Definition: INetfilter.h:36
inet::containsKey
bool containsKey(const std::map< K, V, _C > &m, const Tk &a)
Definition: stlutils.h:80