|
INET Framework for OMNeT++/OMNEST
|
Implements the Ipv4 protocol.
More...
#include <Ipv4.h>
|
| | Ipv4 () |
| |
| virtual | ~Ipv4 () |
| |
| 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 |
| | registers a Hook to be executed during datagram processing More...
|
| |
| virtual void | unregisterHook (IHook *hook) override |
| | unregisters a Hook to be executed during datagram processing More...
|
| |
| virtual void | dropQueuedDatagram (const Packet *datagram) override |
| | drop a previously queued datagram More...
|
| |
| virtual void | reinjectQueuedDatagram (const Packet *datagram) override |
| | re-injects a previously queued datagram More...
|
| |
| virtual bool | isInitializeStage (int stage) const override |
| | ILifecycle methods. 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 | receiveSignal (cComponent *source, simsignal_t signalID, cObject *obj, cObject *details) override |
| | cListener method More...
|
| |
| virtual | ~OperationalMixin () |
| | }@ More...
|
| |
| virtual | ~ILifecycle () |
| |
| virtual | ~NetfilterBase () |
| |
| virtual | ~INetfilter () |
| |
| virtual | ~INetworkProtocol () |
| |
| 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 |
| |
|
| virtual const NetworkInterface * | getSourceInterface (Packet *packet) |
| |
| virtual const NetworkInterface * | getDestInterface (Packet *packet) |
| |
| virtual Ipv4Address | getNextHop (Packet *packet) |
| |
| virtual const NetworkInterface * | getShortestPathInterfaceToSource (const Ptr< const Ipv4Header > &ipv4Header) const |
| |
| virtual void | refreshDisplay () const override |
| |
| void | arpResolutionCompleted (IArp::Notification *entry) |
| |
| void | arpResolutionTimedOut (IArp::Notification *entry) |
| |
| bool | verifyCrc (const Ptr< const Ipv4Header > &ipv4Header) |
| |
| void | setComputedCrc (Ptr< Ipv4Header > &ipv4Header) |
| |
| virtual void | encapsulate (Packet *packet) |
| | Encapsulate packet coming from higher layers into Ipv4Header, using the given control info. More...
|
| |
| virtual void | handleIncomingDatagram (Packet *packet) |
| | Handle Ipv4Header messages arriving from lower layer. More...
|
| |
| virtual void | preroutingFinish (Packet *packet) |
| |
| virtual void | handlePacketFromHL (Packet *packet) |
| | Handle messages (typically packets to be send in Ipv4) from transport or ICMP. More...
|
| |
| virtual void | datagramLocalOut (Packet *packet) |
| | Routes and sends datagram received from higher layers. More...
|
| |
| virtual void | routeUnicastPacket (Packet *packet) |
| | Performs unicast routing. More...
|
| |
| void | routeUnicastPacketFinish (Packet *packet) |
| |
| virtual void | routeLocalBroadcastPacket (Packet *packet) |
| | Broadcasts the datagram on the specified interface. More...
|
| |
| virtual const NetworkInterface * | determineOutgoingInterfaceForMulticastDatagram (const Ptr< const Ipv4Header > &ipv4Header, const NetworkInterface *multicastIFOption) |
| | Determines the output interface for the given multicast datagram. More...
|
| |
| virtual void | forwardMulticastPacket (Packet *packet) |
| | Forwards packets to all multicast destinations, using fragmentAndSend(). More...
|
| |
| virtual void | reassembleAndDeliver (Packet *packet) |
| | Perform reassembly of fragmented datagrams, then send them up to the higher layers using sendToHL(). More...
|
| |
| virtual void | reassembleAndDeliverFinish (Packet *packet) |
| |
| virtual void | decapsulate (Packet *packet) |
| | Decapsulate packet. More...
|
| |
| virtual void | fragmentPostRouting (Packet *datagram) |
| | Call PostRouting Hook and continue with fragmentAndSend() if accepted. More...
|
| |
| virtual void | fragmentAndSend (Packet *packet) |
| | Fragment packet if needed, then send it to the selected interface using sendDatagramToOutput(). More...
|
| |
| virtual void | sendDatagramToOutput (Packet *packet) |
| | Send datagram on the given interface. More...
|
| |
| virtual MacAddress | resolveNextHopMacAddress (cPacket *packet, Ipv4Address nextHopAddr, const NetworkInterface *destIE) |
| |
| virtual void | sendPacketToNIC (Packet *packet) |
| |
| virtual void | sendIcmpError (Packet *packet, int inputInterfaceId, IcmpType type, IcmpCode code) |
| |
| virtual Packet * | prepareForForwarding (Packet *packet) const |
| |
| virtual int | numInitStages () const override |
| |
| virtual void | initialize (int stage) override |
| |
| virtual void | handleMessageWhenUp (cMessage *msg) override |
| |
| void | handleRequest (Request *request) |
| |
| IHook::Result | datagramPreRoutingHook (Packet *datagram) |
| | called before a packet arriving from the network is routed More...
|
| |
| IHook::Result | datagramForwardHook (Packet *datagram) |
| | called before a packet arriving from the network is delivered via the network More...
|
| |
| IHook::Result | datagramPostRoutingHook (Packet *datagram) |
| | called before a packet is delivered via the network More...
|
| |
| IHook::Result | datagramLocalInHook (Packet *datagram) |
| | called before a packet arriving from the network is delivered locally More...
|
| |
| IHook::Result | datagramLocalOutHook (Packet *datagram) |
| | called before a packet arriving locally is delivered More...
|
| |
| virtual void | start () |
| |
| virtual void | stop () |
| |
| virtual void | flush () |
| |
| 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 () |
| |
Implements the Ipv4 protocol.
◆ DatagramQueueForHooks
◆ PendingPackets
◆ Ipv4()
◆ ~Ipv4()
◆ arpResolutionCompleted()
1086 cPacketQueue& packetQueue = it->second;
1087 EV <<
"ARP resolution completed for " << entry->l3Address <<
". Sending " << packetQueue.getLength()
1088 <<
" waiting packets from the queue\n";
1090 while (!packetQueue.isEmpty()) {
1091 Packet *packet = check_and_cast<Packet *>(packetQueue.pop());
1092 EV <<
"Sending out queued packet " << packet <<
"\n";
1093 packet->addTagIfAbsent<
InterfaceReq>()->setInterfaceId(entry->ie->getInterfaceId());
1094 packet->addTagIfAbsent<MacAddressReq>()->setDestAddress(entry->macAddress);
Referenced by receiveSignal().
◆ arpResolutionTimedOut()
1107 cPacketQueue& packetQueue = it->second;
1108 EV <<
"ARP resolution failed for " << entry->l3Address <<
", dropping " << packetQueue.getLength() <<
" packets\n";
1109 for (
int i = 0; i < packetQueue.getLength(); i++) {
1110 auto packet = packetQueue.get(i);
1111 PacketDropDetails details;
1115 packetQueue.clear();
Referenced by receiveSignal().
◆ datagramForwardHook()
called before a packet arriving from the network is delivered via the network
1249 for (
auto& elem :
hooks) {
1267 throw cRuntimeError(
"Unknown Hook::Result value: %d", (
int)r);
Referenced by routeUnicastPacket().
◆ datagramLocalInHook()
called before a packet arriving from the network is delivered locally
1347 for (
auto& elem :
hooks) {
1358 if (packet->getOwner() !=
this)
1359 throw cRuntimeError(
"Model error: netfilter hook changed the owner of queued datagram '%s'", packet->getFullName());
1368 throw cRuntimeError(
"Unknown Hook::Result value: %d", (
int)r);
Referenced by reassembleAndDeliver().
◆ datagramLocalOut()
| void inet::Ipv4::datagramLocalOut |
( |
Packet * |
packet | ) |
|
|
protectedvirtual |
Routes and sends datagram received from higher layers.
Invokes datagramLocalOutHook(), then routePacket().
420 Ipv4Address requestedNextHopAddress =
getNextHop(packet);
422 const auto& ipv4Header = packet->peekAtFront<Ipv4Header>();
423 bool multicastLoop =
false;
425 if (mcr !=
nullptr) {
426 multicastLoop = mcr->getMulticastLoop();
430 Ipv4Address destAddr = ipv4Header->getDestAddress();
432 EV_DETAIL <<
"Sending datagram '" << packet->getName() <<
"' with destination = " << destAddr <<
"\n";
434 if (ipv4Header->getDestAddress().isMulticast()) {
436 packet->addTagIfAbsent<
InterfaceReq>()->setInterfaceId(destIE ? destIE->getInterfaceId() : -1);
439 if (multicastLoop && (!destIE || !destIE->isLoopback())) {
440 const NetworkInterface *loopbackIF =
ift->findFirstLoopbackInterface();
442 auto packetCopy = packet->dup();
443 packetCopy->addTagIfAbsent<
InterfaceReq>()->setInterfaceId(loopbackIF->getInterfaceId());
444 packetCopy->addTagIfAbsent<NextHopAddressReq>()->setNextHopAddress(destAddr);
451 packet->addTagIfAbsent<
InterfaceReq>()->setInterfaceId(destIE->getInterfaceId());
452 packet->addTagIfAbsent<NextHopAddressReq>()->setNextHopAddress(destAddr);
456 EV_ERROR <<
"No multicast interface, packet dropped\n";
458 PacketDropDetails details;
466 if (
rt->isLocalAddress(destAddr)) {
467 EV_INFO <<
"Delivering " << packet <<
" locally.\n";
468 if (destIE && !destIE->isLoopback()) {
469 EV_DETAIL <<
"datagram destination address is local, ignoring destination interface specified in the control info\n";
471 packet->addTagIfAbsent<
InterfaceReq>()->setInterfaceId(-1);
474 destIE =
ift->findFirstLoopbackInterface();
475 packet->addTagIfAbsent<
InterfaceReq>()->setInterfaceId(destIE ? destIE->getInterfaceId() : -1);
478 packet->addTagIfAbsent<NextHopAddressReq>()->setNextHopAddress(destAddr);
481 else if (destAddr.isLimitedBroadcastAddress() ||
rt->isLocalBroadcastAddress(destAddr))
484 packet->addTagIfAbsent<NextHopAddressReq>()->setNextHopAddress(requestedNextHopAddress);
Referenced by handlePacketFromHL(), and reinjectQueuedDatagram().
◆ datagramLocalOutHook()
called before a packet arriving locally is delivered
1376 for (
auto& elem :
hooks) {
1377 IHook::Result r = elem.second->datagramLocalOutHook(packet);
1394 throw cRuntimeError(
"Unknown Hook::Result value: %d", (
int)r);
Referenced by handlePacketFromHL().
◆ datagramPostRoutingHook()
called before a packet is delivered via the network
1275 for (
auto& elem :
hooks) {
1276 IHook::Result r = elem.second->datagramPostRoutingHook(packet);
1293 throw cRuntimeError(
"Unknown Hook::Result value: %d", (
int)r);
Referenced by fragmentPostRouting().
◆ datagramPreRoutingHook()
called before a packet arriving from the network is routed
1223 for (
auto& elem :
hooks) {
1224 IHook::Result r = elem.second->datagramPreRoutingHook(packet);
1241 throw cRuntimeError(
"Unknown Hook::Result value: %d", (
int)r);
Referenced by handleIncomingDatagram().
◆ decapsulate()
| void inet::Ipv4::decapsulate |
( |
Packet * |
packet | ) |
|
|
protectedvirtual |
Decapsulate packet.
790 const auto& ipv4Header = packet->popAtFront<Ipv4Header>();
793 packet->addTagIfAbsent<DscpInd>()->setDifferentiatedServicesCodePoint(ipv4Header->getDscp());
794 packet->addTagIfAbsent<EcnInd>()->setExplicitCongestionNotification(ipv4Header->getEcn());
795 packet->addTagIfAbsent<TosInd>()->setTos(ipv4Header->getTypeOfService());
802 auto l3AddressInd = packet->addTagIfAbsent<
L3AddressInd>();
803 l3AddressInd->setSrcAddress(ipv4Header->getSrcAddress());
804 l3AddressInd->setDestAddress(ipv4Header->getDestAddress());
805 packet->addTagIfAbsent<HopLimitInd>()->setHopLimit(ipv4Header->getTimeToLive());
Referenced by reassembleAndDeliverFinish().
◆ determineOutgoingInterfaceForMulticastDatagram()
Determines the output interface for the given multicast datagram.
498 const NetworkInterface *ie =
nullptr;
499 if (multicastIFOption) {
500 ie = multicastIFOption;
501 EV_DETAIL <<
"multicast packet routed by socket option via output interface " << ie->getInterfaceName() <<
"\n";
504 Ipv4Route *route =
rt->findBestMatchingRoute(ipv4Header->getDestAddress());
506 ie = route->getInterface();
508 EV_DETAIL <<
"multicast packet routed by routing table via output interface " << ie->getInterfaceName() <<
"\n";
511 ie =
rt->getInterfaceByAddress(ipv4Header->getSrcAddress());
513 EV_DETAIL <<
"multicast packet routed by source address via output interface " << ie->getInterfaceName() <<
"\n";
516 ie =
ift->findFirstMulticastInterface();
518 EV_DETAIL <<
"multicast packet routed via the first multicast interface " << ie->getInterfaceName() <<
"\n";
Referenced by datagramLocalOut().
◆ dropQueuedDatagram()
| void inet::Ipv4::dropQueuedDatagram |
( |
const Packet * |
datagram | ) |
|
|
overridevirtual |
drop a previously queued datagram
Implements inet::INetfilter.
1175 if (iter->packet == packet) {
◆ encapsulate()
| void inet::Ipv4::encapsulate |
( |
Packet * |
packet | ) |
|
|
protectedvirtual |
Encapsulate packet coming from higher layers into Ipv4Header, using the given control info.
Override if you subclassed controlInfo and/or want to add options etc to the datagram.
962 const auto& ipv4Header = makeShared<Ipv4Header>();
964 auto l3AddressReq = transportPacket->removeTag<L3AddressReq>();
965 Ipv4Address src = l3AddressReq->getSrcAddress().toIpv4();
966 bool nonLocalSrcAddress = l3AddressReq->getNonLocalSrcAddress();
967 Ipv4Address dest = l3AddressReq->getDestAddress().toIpv4();
971 auto hopLimitReq = transportPacket->removeTagIfPresent<
HopLimitReq>();
972 short ttl = (hopLimitReq !=
nullptr) ? hopLimitReq->getHopLimit() : -1;
973 bool dontFragment =
false;
974 if (
auto& dontFragmentReq = transportPacket->removeTagIfPresent<FragmentationReq>())
975 dontFragment = dontFragmentReq->getDontFragment();
978 ipv4Header->setDestAddress(dest);
982 if (!src.isUnspecified()) {
983 if (!nonLocalSrcAddress &&
rt->getInterfaceByAddress(src) ==
nullptr)
985 throw cRuntimeError(
"Wrong source address %s in (%s)%s: no interface with such address",
986 src.str().c_str(), transportPacket->getClassName(), transportPacket->getFullName());
988 ipv4Header->setSrcAddress(src);
992 if (
auto& tosReq = transportPacket->removeTagIfPresent<TosReq>()) {
993 ipv4Header->setTypeOfService(tosReq->getTos());
994 if (transportPacket->findTag<
DscpReq>())
995 throw cRuntimeError(
"TosReq and DscpReq found together");
996 if (transportPacket->findTag<EcnReq>())
997 throw cRuntimeError(
"TosReq and EcnReq found together");
998 transportPacket->addTag<TosInd>()->setTos(ipv4Header->getTypeOfService());
1000 if (
auto& dscpReq = transportPacket->removeTagIfPresent<
DscpReq>()) {
1001 ipv4Header->setDscp(dscpReq->getDifferentiatedServicesCodePoint());
1002 transportPacket->addTag<DscpInd>()->setDifferentiatedServicesCodePoint(ipv4Header->getDscp());
1004 if (
auto& ecnReq = transportPacket->removeTagIfPresent<EcnReq>()) {
1005 ipv4Header->setEcn(ecnReq->getExplicitCongestionNotification());
1006 transportPacket->addTag<EcnInd>()->setExplicitCongestionNotification(ipv4Header->getEcn());
1010 ipv4Header->setMoreFragments(
false);
1011 ipv4Header->setDontFragment(dontFragment);
1012 ipv4Header->setFragmentOffset(0);
1017 else if (ipv4Header->getDestAddress().isLinkLocalMulticast())
1019 else if (ipv4Header->getDestAddress().isMulticast())
1023 ipv4Header->setTimeToLive(ttl);
1025 if (
auto& optReq = transportPacket->removeTagIfPresent<Ipv4OptionsReq>()) {
1026 for (
size_t i = 0; i < optReq->getOptionArraySize(); i++) {
1027 auto opt = optReq->removeOption(i);
1028 ipv4Header->addOption(opt);
1029 ipv4Header->addChunkLength(
B(opt->getLength()));
1034 ipv4Header->setHeaderLength(ipv4Header->getChunkLength());
1035 ipv4Header->setTotalLengthField(ipv4Header->getChunkLength() + transportPacket->getDataLength());
1036 ipv4Header->setCrcMode(
crcMode);
1037 ipv4Header->setCrc(0);
1041 ipv4Header->setCrc(0xC00D);
1045 ipv4Header->setCrc(0xBAAD);
1048 ipv4Header->setCrc(0);
1053 throw cRuntimeError(
"Unknown CRC mode");
Referenced by handlePacketFromHL().
◆ flush()
| void inet::Ipv4::flush |
( |
| ) |
|
|
protectedvirtual |
1329 EV_DEBUG <<
"Ipv4::flush(): pending packets:\n";
1331 EV_DEBUG <<
"Ipv4::flush(): " << elem.first <<
": " << elem.second.str() << endl;
1332 elem.second.clear();
Referenced by stop(), and ~Ipv4().
◆ forwardMulticastPacket()
| void inet::Ipv4::forwardMulticastPacket |
( |
Packet * |
packet | ) |
|
|
protectedvirtual |
Forwards packets to all multicast destinations, using fragmentAndSend().
630 const NetworkInterface *fromIE =
ift->getInterfaceById(packet->getTag<InterfaceInd>()->getInterfaceId());
631 const auto& ipv4Header = packet->peekAtFront<Ipv4Header>();
632 const Ipv4Address& srcAddr = ipv4Header->getSrcAddress();
633 const Ipv4Address& destAddr = ipv4Header->getDestAddress();
634 ASSERT(destAddr.isMulticast());
635 ASSERT(!destAddr.isLinkLocalMulticast());
637 EV_INFO <<
"Forwarding multicast datagram `" << packet->getName() <<
"' with dest=" << destAddr <<
"\n";
641 const Ipv4MulticastRoute *route =
rt->findBestMatchingMulticastRoute(srcAddr, destAddr);
643 EV_WARN <<
"Multicast route does not exist, try to add.\n";
648 route =
rt->findBestMatchingMulticastRoute(srcAddr, destAddr);
651 EV_ERROR <<
"No route, packet dropped.\n";
653 PacketDropDetails details;
661 if (route->getInInterface() && fromIE != route->getInInterface()->getInterface()) {
662 EV_ERROR <<
"Did not arrive on input interface, packet dropped.\n";
666 PacketDropDetails details;
672 EV_ERROR <<
"Did not arrive on shortest path, packet dropped.\n";
674 PacketDropDetails details;
684 for (
unsigned int i = 0; i < route->getNumOutInterfaces(); i++) {
685 Ipv4MulticastRoute::OutInterface *outInterface = route->getOutInterface(i);
686 const NetworkInterface *destIE = outInterface->getInterface();
687 if (destIE != fromIE && outInterface->isEnabled()) {
688 int ttlThreshold = destIE->getProtocolData<Ipv4InterfaceData>()->getMulticastTtlThreshold();
689 if (ipv4Header->getTimeToLive() <= ttlThreshold)
690 EV_WARN <<
"Not forwarding to " << destIE->getInterfaceName() <<
" (ttl threshold reached)\n";
691 else if (outInterface->isLeaf() && !destIE->getProtocolData<Ipv4InterfaceData>()->hasMulticastListener(destAddr))
692 EV_WARN <<
"Not forwarding to " << destIE->getInterfaceName() <<
" (no listeners)\n";
694 EV_DETAIL <<
"Forwarding to " << destIE->getInterfaceName() <<
"\n";
695 auto packetCopy = packet->dup();
696 packetCopy->addTagIfAbsent<
InterfaceReq>()->setInterfaceId(destIE->getInterfaceId());
697 packetCopy->addTagIfAbsent<NextHopAddressReq>()->setNextHopAddress(destAddr);
Referenced by preroutingFinish().
◆ fragmentAndSend()
| void inet::Ipv4::fragmentAndSend |
( |
Packet * |
packet | ) |
|
|
protectedvirtual |
Fragment packet if needed, then send it to the selected interface using sendDatagramToOutput().
862 const NetworkInterface *destIE =
ift->getInterfaceById(packet->getTag<
InterfaceReq>()->getInterfaceId());
864 if (nextHopAddr.isUnspecified()) {
865 nextHopAddr = packet->peekAtFront<Ipv4Header>()->getDestAddress();
866 packet->addTagIfAbsent<NextHopAddressReq>()->setNextHopAddress(nextHopAddr);
869 const auto& ipv4Header = packet->peekAtFront<Ipv4Header>();
872 if (ipv4Header->getTimeToLive() <= 0) {
874 PacketDropDetails details;
877 EV_WARN <<
"datagram TTL reached zero, sending ICMP_TIME_EXCEEDED\n";
883 int mtu = destIE->getMtu();
886 if (mtu == 0 || packet->getByteLength() <= mtu) {
888 auto ipv4Header = removeNetworkProtocolHeader<Ipv4Header>(packet);
897 if (ipv4Header->getDontFragment()) {
898 PacketDropDetails details;
900 EV_WARN <<
"datagram larger than MTU and don't fragment bit set, sending ICMP_DESTINATION_UNREACHABLE\n";
901 icmp->sendPtbMessage(packet, mtu);
908 int headerLength =
B(ipv4Header->getHeaderLength()).get();
909 int payloadLength =
B(packet->getDataLength()).get() - headerLength;
910 int fragmentLength = ((mtu - headerLength) / 8) * 8;
911 int offsetBase = ipv4Header->getFragmentOffset();
912 if (fragmentLength <= 0)
913 throw cRuntimeError(
"Cannot fragment datagram: MTU=%d too small for header size (%d bytes)", mtu, headerLength);
915 int noOfFragments = (payloadLength + fragmentLength - 1) / fragmentLength;
916 EV_DETAIL <<
"Breaking datagram into " << noOfFragments <<
" fragments\n";
919 std::string fragMsgName = packet->getName();
920 fragMsgName +=
"-frag-";
923 while (offset < payloadLength) {
924 bool lastFragment = (offset + fragmentLength >= payloadLength);
926 int thisFragmentLength = lastFragment ? payloadLength - offset : fragmentLength;
928 std::string curFragName = fragMsgName + std::to_string(offset);
930 curFragName +=
"-last";
931 Packet *fragment =
new Packet(curFragName.c_str());
934 fragment->copyTags(*packet);
936 ASSERT(fragment->getByteLength() == 0);
937 auto fraghdr = staticPtrCast<Ipv4Header>(ipv4Header->dupShared());
938 const auto& fragData = packet->peekDataAt(
B(headerLength + offset),
B(thisFragmentLength));
939 ASSERT(fragData->getChunkLength() ==
B(thisFragmentLength));
940 fragment->insertAtBack(fragData);
944 fraghdr->setMoreFragments(
true);
946 fraghdr->setFragmentOffset(offsetBase + offset);
947 fraghdr->setTotalLengthField(
B(headerLength + thisFragmentLength));
951 fragment->insertAtFront(fraghdr);
952 ASSERT(fragment->getByteLength() == headerLength + thisFragmentLength);
954 offset += thisFragmentLength;
Referenced by fragmentPostRouting(), and reinjectQueuedDatagram().
◆ fragmentPostRouting()
| void inet::Ipv4::fragmentPostRouting |
( |
Packet * |
datagram | ) |
|
|
protectedvirtual |
◆ getDestInterface()
◆ getNextHop()
◆ getShortestPathInterfaceToSource()
◆ getSourceInterface()
◆ handleCrashOperation()
◆ handleIncomingDatagram()
| void inet::Ipv4::handleIncomingDatagram |
( |
Packet * |
packet | ) |
|
|
protectedvirtual |
Handle Ipv4Header messages arriving from lower layer.
Decrements TTL, then invokes routePacket().
255 int interfaceId = packet->getTag<InterfaceInd>()->getInterfaceId();
262 const auto& ipv4Header = packet->peekAtFront<Ipv4Header>();
263 packet->addTagIfAbsent<NetworkProtocolInd>()->setProtocol(&
Protocol::ipv4);
264 packet->addTagIfAbsent<NetworkProtocolInd>()->setNetworkProtocolHeader(ipv4Header);
267 EV_WARN <<
"CRC error found, drop packet\n";
268 PacketDropDetails details;
275 if (ipv4Header->getTotalLengthField() > packet->getDataLength()) {
276 EV_WARN <<
"length error found, sending ICMP_PARAMETER_PROBLEM\n";
282 if (ipv4Header->getTotalLengthField() < packet->getDataLength()) {
283 packet->setBackOffset(packet->getFrontOffset() + ipv4Header->getTotalLengthField());
287 if (packet->hasBitError()) {
290 double relativeHeaderLength =
B(ipv4Header->getHeaderLength()).get() / (double)
B(ipv4Header->getChunkLength()).get();
291 if (dblrand() <= relativeHeaderLength) {
292 EV_WARN <<
"bit error found, sending ICMP_PARAMETER_PROBLEM\n";
298 EV_DETAIL <<
"Received datagram `" << ipv4Header->getName() <<
"' with dest=" << ipv4Header->getDestAddress() <<
"\n";
Referenced by handleMessageWhenUp().
◆ handleMessageWhenUp()
| void inet::Ipv4::handleMessageWhenUp |
( |
cMessage * |
msg | ) |
|
|
overrideprotectedvirtual |
Implements inet::OperationalMixin< cSimpleModule >.
193 if (msg->arrivedOn(
"transportIn")) {
194 if (
auto request =
dynamic_cast<Request *
>(msg))
199 else if (msg->arrivedOn(
"queueIn")) {
200 EV_INFO <<
"Received " << msg <<
" from network.\n";
204 throw cRuntimeError(
"message arrived on unknown gate '%s'", msg->getArrivalGate()->getName());
◆ handlePacketFromHL()
| void inet::Ipv4::handlePacketFromHL |
( |
Packet * |
packet | ) |
|
|
protectedvirtual |
Handle messages (typically packets to be send in Ipv4) from transport or ICMP.
Invokes encapsulate(), then routePacket().
394 EV_INFO <<
"Received " << packet <<
" from upper layer.\n";
398 if (
ift->getNumInterfaces() == 0) {
399 EV_ERROR <<
"No interfaces exist, dropping packet\n";
401 PacketDropDetails details;
Referenced by handleMessageWhenUp().
◆ handleRegisterProtocol()
◆ handleRegisterService()
◆ handleRequest()
| void inet::Ipv4::handleRequest |
( |
Request * |
request | ) |
|
|
protected |
148 auto ctrl = request->getControlInfo();
150 throw cRuntimeError(
"Request '%s' arrived without controlinfo", request->getName());
151 else if (Ipv4SocketBindCommand *command =
dynamic_cast<Ipv4SocketBindCommand *
>(
ctrl)) {
152 int socketId = request->getTag<SocketReq>()->getSocketId();
153 SocketDescriptor *descriptor =
new SocketDescriptor(socketId, command->getProtocol()->getId(), command->getLocalAddress());
157 else if (Ipv4SocketConnectCommand *command =
dynamic_cast<Ipv4SocketConnectCommand *
>(
ctrl)) {
158 int socketId = request->getTag<SocketReq>()->getSocketId();
160 throw cRuntimeError(
"Ipv4Socket: should use bind() before connect()");
164 else if (
dynamic_cast<Ipv4SocketCloseCommand *
>(
ctrl) !=
nullptr) {
165 int socketId = request->getTag<SocketReq>()->getSocketId();
171 auto ctrl =
new Ipv4SocketClosedIndication();
172 indication->setControlInfo(
ctrl);
173 indication->addTag<SocketInd>()->setSocketId(socketId);
174 send(indication,
"transportOut");
178 else if (
dynamic_cast<Ipv4SocketDestroyCommand *
>(
ctrl) !=
nullptr) {
179 int socketId = request->getTag<SocketReq>()->getSocketId();
188 throw cRuntimeError(
"Unknown command: '%s' with %s", request->getName(),
ctrl->getClassName());
Referenced by handleMessageWhenUp().
◆ handleStartOperation()
◆ handleStopOperation()
◆ initialize()
| void inet::Ipv4::initialize |
( |
int |
stage | ) |
|
|
overrideprotectedvirtual |
Reimplemented from inet::OperationalMixin< cSimpleModule >.
69 ift.reference(
this,
"interfaceTableModule",
true);
70 rt.reference(
this,
"routingTableModule",
true);
71 arp.reference(
this,
"arpModule",
true);
72 icmp.reference(
this,
"icmpModule",
true);
76 const char *crcModeString = par(
"crcMode");
107 cModule *arpModule = check_and_cast<cModule *>(
arp.get());
◆ insertCrc()
| void inet::Ipv4::insertCrc |
( |
const Ptr< Ipv4Header > & |
ipv4Header | ) |
|
|
static |
◆ isInitializeStage()
| virtual bool inet::Ipv4::isInitializeStage |
( |
int |
stage | ) |
const |
|
inlineoverridevirtual |
◆ isModuleStartStage()
| virtual bool inet::Ipv4::isModuleStartStage |
( |
int |
stage | ) |
const |
|
inlineoverridevirtual |
◆ isModuleStopStage()
| virtual bool inet::Ipv4::isModuleStopStage |
( |
int |
stage | ) |
const |
|
inlineoverridevirtual |
◆ numInitStages()
| virtual int inet::Ipv4::numInitStages |
( |
| ) |
const |
|
inlineoverrideprotectedvirtual |
◆ prepareForForwarding()
| Packet * inet::Ipv4::prepareForForwarding |
( |
Packet * |
packet | ) |
const |
|
protectedvirtual |
306 const auto& ipv4Header = removeNetworkProtocolHeader<Ipv4Header>(packet);
307 ipv4Header->setTimeToLive(ipv4Header->getTimeToLive() - 1);
Referenced by preroutingFinish().
◆ preroutingFinish()
| void inet::Ipv4::preroutingFinish |
( |
Packet * |
packet | ) |
|
|
protectedvirtual |
314 const NetworkInterface *fromIE =
ift->getInterfaceById(packet->getTag<InterfaceInd>()->getInterfaceId());
317 const auto& ipv4Header = packet->peekAtFront<Ipv4Header>();
319 Ipv4Address destAddr = ipv4Header->getDestAddress();
323 if (fromIE->isLoopback()) {
326 else if (destAddr.isMulticast()) {
329 if (fromIE->getProtocolData<Ipv4InterfaceData>()->isMemberOfMulticastGroup(destAddr) ||
330 (
rt->isMulticastForwardingEnabled() && ipv4Header->getProtocolId() ==
IP_PROT_IGMP))
333 EV_WARN <<
"Skip local delivery of multicast datagram (input interface not in multicast group)\n";
336 if (!
rt->isMulticastForwardingEnabled()) {
337 EV_WARN <<
"Skip forwarding of multicast datagram (forwarding disabled)\n";
340 else if (destAddr.isLinkLocalMulticast()) {
341 EV_WARN <<
"Skip forwarding of multicast datagram (packet is link-local)\n";
344 else if (ipv4Header->getTimeToLive() <= 1) {
345 EV_WARN <<
"Skip forwarding of multicast datagram (TTL reached 0)\n";
352 const NetworkInterface *broadcastIE =
nullptr;
356 if (
rt->isLocalAddress(destAddr) || fromIE->getProtocolData<Ipv4InterfaceData>()->getIPAddress().isUnspecified()) {
359 else if (destAddr.isLimitedBroadcastAddress() || (broadcastIE =
rt->findInterfaceByLocalBroadcastAddress(destAddr))) {
361 if (broadcastIE && fromIE != broadcastIE &&
rt->isForwardingEnabled()) {
366 packetCopy->addTagIfAbsent<
InterfaceReq>()->setInterfaceId(broadcastIE->getInterfaceId());
371 EV_INFO <<
"Forwarding of direct broadcast packets is disabled on interface " << broadcastIE->getInterfaceName() << std::endl;
374 EV_INFO <<
"Broadcast received\n";
377 else if (!
rt->isForwardingEnabled()) {
378 EV_WARN <<
"forwarding off, dropping packet\n";
380 PacketDropDetails details;
386 packet->addTagIfAbsent<NextHopAddressReq>()->setNextHopAddress(nextHopAddr);
Referenced by handleIncomingDatagram(), and reinjectQueuedDatagram().
◆ reassembleAndDeliver()
| void inet::Ipv4::reassembleAndDeliver |
( |
Packet * |
packet | ) |
|
|
protectedvirtual |
Perform reassembly of fragmented datagrams, then send them up to the higher layers using sendToHL().
713 EV_INFO <<
"Delivering " << packet <<
" locally.\n";
715 const auto& ipv4Header = packet->peekAtFront<Ipv4Header>();
716 if (ipv4Header->getSrcAddress().isUnspecified())
717 EV_WARN <<
"Received datagram '" << packet->getName() <<
"' without source address filled in\n";
720 if (ipv4Header->getFragmentOffset() != 0 || ipv4Header->getMoreFragments()) {
721 EV_DETAIL <<
"Datagram fragment: offset=" << ipv4Header->getFragmentOffset()
722 <<
", MORE=" << (ipv4Header->getMoreFragments() ?
"true" :
"false") <<
".\n";
732 EV_DETAIL <<
"No complete datagram yet.\n";
735 if (packet->peekAtFront<Ipv4Header>()->getCrcMode() ==
CRC_COMPUTED) {
736 auto ipv4Header = removeNetworkProtocolHeader<Ipv4Header>(packet);
740 EV_DETAIL <<
"This fragment completes the datagram.\n";
Referenced by preroutingFinish().
◆ reassembleAndDeliverFinish()
| void inet::Ipv4::reassembleAndDeliverFinish |
( |
Packet * |
packet | ) |
|
|
protectedvirtual |
749 auto ipv4HeaderPosition = packet->getFrontOffset();
750 const auto& ipv4Header = packet->peekAtFront<Ipv4Header>();
751 const Protocol *
protocol = ipv4Header->getProtocol();
752 auto remoteAddress(ipv4Header->getSrcAddress());
753 auto localAddress(ipv4Header->getDestAddress());
755 bool hasSocket =
false;
757 if (elem.second->protocolId ==
protocol->getId()
758 && (elem.second->localAddress.isUnspecified() || elem.second->localAddress == localAddress)
759 && (elem.second->remoteAddress.isUnspecified() || elem.second->remoteAddress == remoteAddress))
761 auto *packetCopy = packet->dup();
763 packetCopy->addTagIfAbsent<SocketInd>()->setSocketId(elem.second->socketId);
764 EV_INFO <<
"Passing up to socket " << elem.second->socketId <<
"\n";
766 send(packetCopy,
"transportOut");
771 EV_INFO <<
"Passing up to protocol " << *
protocol <<
"\n";
773 send(packet,
"transportOut");
776 else if (hasSocket) {
780 EV_ERROR <<
"Transport protocol '" <<
protocol->getName() <<
"' not connected, discarding packet\n";
781 packet->setFrontOffset(ipv4HeaderPosition);
Referenced by reassembleAndDeliver(), and reinjectQueuedDatagram().
◆ receiveSignal()
| void inet::Ipv4::receiveSignal |
( |
cComponent * |
source, |
|
|
simsignal_t |
signalID, |
|
|
cObject * |
obj, |
|
|
cObject * |
details |
|
) |
| |
|
overridevirtual |
cListener method
1402 Enter_Method(
"%s", cComponent::getSignalName(signalID));
◆ refreshDisplay()
| void inet::Ipv4::refreshDisplay |
( |
| ) |
const |
|
overrideprotectedvirtual |
140 sprintf(buf + strlen(buf),
"DROP:%d ",
numDropped);
143 getDisplayString().setTagArg(
"t", 0, buf);
◆ registerHook()
registers a Hook to be executed during datagram processing
Reimplemented from inet::NetfilterBase.
◆ reinjectQueuedDatagram()
| void inet::Ipv4::reinjectQueuedDatagram |
( |
const Packet * |
datagram | ) |
|
|
overridevirtual |
re-injects a previously queued datagram
Implements inet::INetfilter.
1187 if (iter->packet == packet) {
1188 auto *qPacket = iter->packet;
1190 switch (iter->hookType) {
1212 throw cRuntimeError(
"Unknown hook ID: %d", (
int)(iter->hookType));
◆ resolveNextHopMacAddress()
1122 if (nextHopAddr.isLimitedBroadcastAddress() || nextHopAddr == destIE->getProtocolData<Ipv4InterfaceData>()->getNetworkBroadcastAddress()) {
1123 EV_DETAIL <<
"destination address is broadcast, sending packet to broadcast MAC address\n";
1127 if (nextHopAddr.isMulticast()) {
1128 MacAddress macAddr = nextHopAddr.mapToMulticastMacAddress();
1129 EV_DETAIL <<
"destination address is multicast, sending packet to MAC address " << macAddr <<
"\n";
1133 return arp->resolveL3Address(nextHopAddr, destIE);
Referenced by sendDatagramToOutput().
◆ routeLocalBroadcastPacket()
| void inet::Ipv4::routeLocalBroadcastPacket |
( |
Packet * |
packet | ) |
|
|
protectedvirtual |
Broadcasts the datagram on the specified interface.
When destIE is nullptr, the datagram is broadcasted on each interface.
586 const auto& interfaceReq = packet->findTag<
InterfaceReq>();
587 const NetworkInterface *destIE = interfaceReq !=
nullptr ?
ift->getInterfaceById(interfaceReq->getInterfaceId()) :
nullptr;
591 if (destIE !=
nullptr) {
592 packet->addTagIfAbsent<
InterfaceReq>()->setInterfaceId(destIE->getInterfaceId());
597 auto destAddr = packet->peekAtFront<Ipv4Header>()->getDestAddress();
599 for (
int i = 0; i <
ift->getNumInterfaces(); i++) {
600 const NetworkInterface *ie =
ift->getInterface(i);
601 if (!destAddr.isLimitedBroadcastAddress()) {
602 Ipv4Address interfaceAddr = ie->getProtocolData<Ipv4InterfaceData>()->getIPAddress();
603 Ipv4Address broadcastAddr = interfaceAddr.makeBroadcastAddress(ie->getProtocolData<Ipv4InterfaceData>()->getNetmask());
604 if (destAddr != broadcastAddr)
607 auto packetCopy = packet->dup();
608 packetCopy->addTagIfAbsent<
InterfaceReq>()->setInterfaceId(ie->getInterfaceId());
616 PacketDropDetails details;
Referenced by datagramLocalOut().
◆ routeUnicastPacket()
| void inet::Ipv4::routeUnicastPacket |
( |
Packet * |
packet | ) |
|
|
protectedvirtual |
Performs unicast routing.
Based on the routing decision, it sends the datagram through the outgoing interface.
527 Ipv4Address nextHopAddress =
getNextHop(packet);
529 const auto& ipv4Header = packet->peekAtFront<Ipv4Header>();
530 Ipv4Address destAddr = ipv4Header->getDestAddress();
531 EV_INFO <<
"Routing " << packet <<
" with destination = " << destAddr <<
", ";
535 EV_DETAIL <<
"using manually specified output interface " << destIE->getInterfaceName() <<
"\n";
537 if (!nextHopAddress.isUnspecified()) {
541 else if (destIE->isBroadcast()) {
543 const Ipv4Route *re =
rt->findBestMatchingRoute(destAddr);
544 if (re && re->getInterface() == destIE) {
545 packet->addTagIfAbsent<NextHopAddressReq>()->setNextHopAddress(re->getGateway());
551 const Ipv4Route *re =
rt->findBestMatchingRoute(destAddr);
553 destIE = re->getInterface();
554 packet->addTagIfAbsent<
InterfaceReq>()->setInterfaceId(destIE->getInterfaceId());
555 packet->addTagIfAbsent<NextHopAddressReq>()->setNextHopAddress(re->getGateway());
560 EV_WARN <<
"unroutable, sending ICMP_DESTINATION_UNREACHABLE, dropping packet\n";
562 PacketDropDetails details;
568 if (fromIE !=
nullptr) {
Referenced by datagramLocalOut(), and preroutingFinish().
◆ routeUnicastPacketFinish()
| void inet::Ipv4::routeUnicastPacketFinish |
( |
Packet * |
packet | ) |
|
|
protected |
◆ sendDatagramToOutput()
| void inet::Ipv4::sendDatagramToOutput |
( |
Packet * |
packet | ) |
|
|
protectedvirtual |
Send datagram on the given interface.
1061 const NetworkInterface *ie =
ift->getInterfaceById(packet->getTag<
InterfaceReq>()->getInterfaceId());
1062 auto nextHopAddressReq = packet->removeTag<NextHopAddressReq>();
1063 Ipv4Address nextHopAddr = nextHopAddressReq->getNextHopAddress().toIpv4();
1064 if (!ie->isBroadcast() || ie->getMacAddress().isUnspecified())
1068 if (nextHopMacAddr.isUnspecified()) {
1069 EV_INFO <<
"Pending " << packet <<
" to ARP resolution.\n";
1073 ASSERT2(!
containsKey(
pendingPackets, nextHopAddr),
"Ipv4-ARP error: nextHopAddr found in ARP table, but Ipv4 queue for nextHopAddr not empty");
1074 packet->addTagIfAbsent<MacAddressReq>()->setDestAddress(nextHopMacAddr);
Referenced by fragmentAndSend().
◆ sendIcmpError()
◆ sendPacketToNIC()
| void inet::Ipv4::sendPacketToNIC |
( |
Packet * |
packet | ) |
|
|
protectedvirtual |
1138 auto networkInterface =
ift->getInterfaceById(packet->getTag<
InterfaceReq>()->getInterfaceId());
1139 EV_INFO <<
"Sending " << packet <<
" to output interface = " << networkInterface->getInterfaceName() <<
".\n";
1141 packet->addTagIfAbsent<DispatchProtocolInd>()->setProtocol(&
Protocol::ipv4);
1142 auto networkInterfaceProtocol = networkInterface->getProtocol();
1143 auto dispatchProtocol = networkInterfaceProtocol;
1144 if (
auto encapsulationProtocolReq = packet->findTagForUpdate<EncapsulationProtocolReq>()) {
1145 dispatchProtocol = encapsulationProtocolReq->getProtocol(0);
1146 encapsulationProtocolReq->eraseProtocol(0);
1147 encapsulationProtocolReq->insertProtocol(encapsulationProtocolReq->getProtocolArraySize(), networkInterfaceProtocol);
1149 if (dispatchProtocol ==
nullptr)
1154 send(packet,
"queueOut");
Referenced by arpResolutionCompleted(), and sendDatagramToOutput().
◆ setComputedCrc()
| void inet::Ipv4::setComputedCrc |
( |
Ptr< Ipv4Header > & |
ipv4Header | ) |
|
|
protected |
◆ start()
| void inet::Ipv4::start |
( |
| ) |
|
|
protectedvirtual |
◆ stop()
| void inet::Ipv4::stop |
( |
| ) |
|
|
protectedvirtual |
◆ unregisterHook()
unregisters a Hook to be executed during datagram processing
Reimplemented from inet::NetfilterBase.
◆ verifyCrc()
| bool inet::Ipv4::verifyCrc |
( |
const Ptr< const Ipv4Header > & |
ipv4Header | ) |
|
|
protected |
209 switch (ipv4Header->getCrcMode()) {
212 return ipv4Header->isCorrect();
218 if (ipv4Header->isCorrect()) {
220 MemoryOutputStream ipv4HeaderStream;
223 return computedCrc == 0;
230 throw cRuntimeError(
"Unknown CRC mode");
Referenced by handleIncomingDatagram().
◆ arp
◆ crcMode
◆ curFragmentId
| uint16_t inet::Ipv4::curFragmentId = -1 |
|
protected |
◆ defaultMCTimeToLive
| int inet::Ipv4::defaultMCTimeToLive = -1 |
|
protected |
◆ defaultTimeToLive
| int inet::Ipv4::defaultTimeToLive = -1 |
|
protected |
◆ directBroadcastInterfaceMatcher
| cPatternMatcher inet::Ipv4::directBroadcastInterfaceMatcher |
|
protected |
◆ directBroadcastInterfaces
| std::string inet::Ipv4::directBroadcastInterfaces = "" |
|
protected |
◆ fragbuf
◆ fragmentTimeoutTime
| simtime_t inet::Ipv4::fragmentTimeoutTime |
|
protected |
◆ icmp
◆ ift
Referenced by datagramLocalOut(), determineOutgoingInterfaceForMulticastDatagram(), forwardMulticastPacket(), fragmentAndSend(), fragmentPostRouting(), getDestInterface(), getSourceInterface(), handlePacketFromHL(), initialize(), preroutingFinish(), routeLocalBroadcastPacket(), sendDatagramToOutput(), and sendPacketToNIC().
◆ lastCheckTime
| simtime_t inet::Ipv4::lastCheckTime |
|
protected |
◆ limitedBroadcast
| bool inet::Ipv4::limitedBroadcast = false |
|
protected |
◆ numDropped
| int inet::Ipv4::numDropped = 0 |
|
protected |
◆ numForwarded
| int inet::Ipv4::numForwarded = 0 |
|
protected |
◆ numLocalDeliver
| int inet::Ipv4::numLocalDeliver = 0 |
|
protected |
◆ numMulticast
| int inet::Ipv4::numMulticast = 0 |
|
protected |
◆ numUnroutable
| int inet::Ipv4::numUnroutable = 0 |
|
protected |
◆ pendingPackets
◆ queuedDatagramsForHooks
◆ rt
◆ socketIdToSocketDescriptor
◆ transportInGateBaseId
| int inet::Ipv4::transportInGateBaseId = -1 |
|
protected |
◆ upperProtocols
| std::set<const Protocol *> inet::Ipv4::upperProtocols |
|
protected |
The documentation for this class was generated from the following files:
bool verifyCrc(const Ptr< const Ipv4Header > &ipv4Header)
Definition: Ipv4.cc:207
simsignal_t ipv4DataOnRpfSignal
Definition: Simsignals.cc:58
int defaultTimeToLive
Definition: Ipv4.h:73
int getProtocolNumber(const Protocol *protocol) const
Definition: ProtocolGroup.cc:46
virtual const NetworkInterface * determineOutgoingInterfaceForMulticastDatagram(const Ptr< const Ipv4Header > &ipv4Header, const NetworkInterface *multicastIFOption)
Determines the output interface for the given multicast datagram.
Definition: Ipv4.cc:496
removed DscpReq Ipv4ControlInfo Ipv6ControlInfo up L3AddressInd DispatchProtocolReq L4PortInd Ipv4ControlInfo Ipv6ControlInfo down protocol
Definition: IUdp-gates.txt:25
@ NO_INTERFACE_FOUND
Definition: Simsignals_m.h:74
@ ICMP_DESTINATION_UNREACHABLE
Definition: IcmpHeader_m.h:77
virtual void sendIcmpError(Packet *packet, int inputInterfaceId, IcmpType type, IcmpCode code)
Definition: Ipv4.cc:1412
virtual const NetworkInterface * getDestInterface(Packet *packet)
Definition: Ipv4.cc:240
@ ICMP_DU_PROTOCOL_UNREACHABLE
Definition: IcmpHeader_m.h:188
virtual void forwardMulticastPacket(Packet *packet)
Forwards packets to all multicast destinations, using fragmentAndSend().
Definition: Ipv4.cc:628
void setComputedCrc(Ptr< Ipv4Header > &ipv4Header)
Definition: Ipv4.cc:821
removed DscpReq Ipv4ControlInfo Ipv6ControlInfo up L3AddressInd DispatchProtocolReq L4PortInd Ipv4ControlInfo Ipv6ControlInfo down DscpReq
Definition: IUdp-gates.txt:25
@ STAGE_NETWORK_LAYER
Definition: ModuleOperations.h:53
@ INCORRECTLY_RECEIVED
Definition: Simsignals_m.h:71
static const Protocol ipv4
Definition: Protocol.h:93
virtual void handleIncomingDatagram(Packet *packet)
Handle Ipv4Header messages arriving from lower layer.
Definition: Ipv4.cc:252
IHook::Result datagramLocalInHook(Packet *datagram)
called before a packet arriving from the network is delivered locally
Definition: Ipv4.cc:1345
virtual void routeLocalBroadcastPacket(Packet *packet)
Broadcasts the datagram on the specified interface.
Definition: Ipv4.cc:584
simsignal_t packetReceivedFromUpperSignal
Definition: Simsignals.cc:88
@ STOLEN
doesn't allow datagram to pass to next hook, but won't be deleted
Definition: INetfilter.h:43
@ IP_PROT_IGMP
Definition: IpProtocolId_m.h:92
int numUnroutable
Definition: Ipv4.h:95
@ ICMP_PARAMETER_PROBLEM
Definition: IcmpHeader_m.h:84
ModuleRefByPar< IArp > arp
Definition: Ipv4.h:67
IHook::Result datagramForwardHook(Packet *datagram)
called before a packet arriving from the network is delivered via the network
Definition: Ipv4.cc:1247
virtual void initialize(int stage) override
Definition: OperationalMixinImpl.h:26
@ CRC_COMPUTED
Definition: CrcMode_m.h:59
@ STAGE_NETWORK_LAYER
Definition: ModuleOperations.h:29
removed InterfaceReq
Definition: IUdp-gates.txt:11
static void serialize(MemoryOutputStream &stream, const Ptr< const Chunk > &chunk, b offset=b(0), b length=b(-1))
Serializes a chunk into the given stream.
Definition: Chunk.cc:175
virtual void decapsulate(Packet *packet)
Decapsulate packet.
Definition: Ipv4.cc:787
const char * getInterfaceName() const
Definition: NetworkInterface.h:233
removed DscpReq Ipv4ControlInfo Ipv6ControlInfo up L3AddressInd DispatchProtocolReq L4PortInd Ipv4ControlInfo Ipv6ControlInfo down DispatchProtocolReq
Definition: IUdp-gates.txt:25
INET_API InitStage INITSTAGE_NETWORK_LAYER
Initialization of network layer protocols.
ModuleRefByPar< IIpv4RoutingTable > rt
Definition: Ipv4.h:65
removed DscpReq Ipv4ControlInfo Ipv6ControlInfo up L3AddressInd L3AddressInd
Definition: IUdp-gates.txt:20
virtual void reassembleAndDeliverFinish(Packet *packet)
Definition: Ipv4.cc:747
@ FORWARD
Definition: INetfilter.h:34
simtime_t fragmentTimeoutTime
Definition: Ipv4.h:75
virtual void handlePacketFromHL(Packet *packet)
Handle messages (typically packets to be send in Ipv4) from transport or ICMP.
Definition: Ipv4.cc:392
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
CrcMode parseCrcMode(const char *crcModeString, bool allowDisable)
Definition: CrcMode.cc:14
@ HOP_LIMIT_REACHED
Definition: Simsignals_m.h:70
int defaultMCTimeToLive
Definition: Ipv4.h:74
@ NO_ROUTE_FOUND
Definition: Simsignals_m.h:75
PendingPackets pendingPackets
Definition: Ipv4.h:89
@ IPv4
Definition: L3Address.h:35
void registerService(const Protocol &protocol, cGate *gate, ServicePrimitive servicePrimitive)
Registers a service primitive (SDU processing) at the given gate.
Definition: IProtocolRegistrationListener.cc:14
int transportInGateBaseId
Definition: Ipv4.h:69
Ipv4FragBuf fragbuf
Definition: Ipv4.h:83
@ FORWARDING_DISABLED
Definition: Simsignals_m.h:69
void insertNetworkProtocolHeader(Packet *packet, const Protocol &protocol, const Ptr< NetworkHeaderBase > &header)
Definition: L3Tools.cc:70
simsignal_t packetDroppedSignal
Definition: Simsignals.cc:85
virtual void sendDatagramToOutput(Packet *packet)
Send datagram on the given interface.
Definition: Ipv4.cc:1059
simtime_t lastCheckTime
Definition: Ipv4.h:84
uint16_t curFragmentId
Definition: Ipv4.h:82
removed DscpReq Ipv4ControlInfo Ipv6ControlInfo up L3AddressInd DispatchProtocolReq L4PortInd Ipv4ControlInfo Ipv6ControlInfo down PacketProtocolTag
Definition: IUdp-gates.txt:25
simsignal_t ipv4NewMulticastSignal
Definition: Simsignals.cc:56
static const Ipv4Address ALLONES_ADDRESS
255.255.255.255
Definition: Ipv4Address.h:94
virtual void routeUnicastPacket(Packet *packet)
Performs unicast routing.
Definition: Ipv4.cc:523
void handleRequest(Request *request)
Definition: Ipv4.cc:146
removed ctrl
Definition: IUdp-gates.txt:7
simsignal_t ipv4MdataRegisterSignal
Definition: Simsignals.cc:59
virtual void flush()
Definition: Ipv4.cc:1327
removed MulticastReq
Definition: IUdp-gates.txt:11
void purgeStaleFragments(Icmp *icmpModule, simtime_t lastupdate)
Throws out all fragments which are incomplete and their last update (last fragment arrival) was befor...
Definition: Ipv4FragBuf.cc:99
void flush()
Clear all state.
Definition: Ipv4FragBuf.cc:27
std::map< int, SocketDescriptor * > socketIdToSocketDescriptor
Definition: Ipv4.h:86
intscale< b, 1, 8 > B
Definition: Units.h:1168
@ ICMP_TIME_EXCEEDED
Definition: IcmpHeader_m.h:83
IHook::Result datagramPreRoutingHook(Packet *datagram)
called before a packet arriving from the network is routed
Definition: Ipv4.cc:1221
@ QUEUE
queues the datagram for later re-injection (e.g. when route discovery completes)
Definition: INetfilter.h:42
Result
Definition: INetfilter.h:39
bool contains(const std::vector< T > &v, const Tk &a)
Definition: stlutils.h:65
IHook::Result datagramPostRoutingHook(Packet *datagram)
called before a packet is delivered via the network
Definition: Ipv4.cc:1273
virtual void unregisterHook(INetfilter::IHook *hook) override
Removes the provided hook from the list of registered hooks.
Definition: INetfilter.h:142
int numForwarded
Definition: Ipv4.h:96
removed HopLimitReq
Definition: IUdp-gates.txt:11
virtual void stop()
Definition: Ipv4.cc:1319
virtual void start()
Definition: Ipv4.cc:1315
void routeUnicastPacketFinish(Packet *packet)
Definition: Ipv4.cc:577
removed type
Definition: IUdp-gates.txt:7
Packet * addFragment(Packet *packet, simtime_t now)
Takes a fragment and inserts it into the reassembly buffer.
Definition: Ipv4FragBuf.cc:34
void arpResolutionTimedOut(IArp::Notification *entry)
Definition: Ipv4.cc:1101
INET_API InitStage INITSTAGE_LOCAL
Initialization of local state that don't use or affect other modules includes:
virtual void datagramLocalOut(Packet *packet)
Routes and sends datagram received from higher layers.
Definition: Ipv4.cc:417
int numMulticast
Definition: Ipv4.h:92
bool limitedBroadcast
Definition: Ipv4.h:76
static const simsignal_t arpResolutionFailedSignal
Definition: IArp.h:43
CrcMode
Enum generated from inet/transportlayer/common/CrcMode.msg:12 by opp_msgtool.
Definition: CrcMode_m.h:54
int numLocalDeliver
Definition: Ipv4.h:93
#define NUM_INIT_STAGES
Definition: InitStageRegistry.h:73
simsignal_t packetReceivedFromLowerSignal
Definition: Simsignals.cc:91
simsignal_t ipv4DataOnNonrpfSignal
Definition: Simsignals.cc:57
@ IPv4_I_SOCKET_CLOSED
Definition: Ipv4SocketCommand_m.h:85
DatagramQueueForHooks queuedDatagramsForHooks
Definition: Ipv4.h:100
@ PREROUTING
Definition: INetfilter.h:32
void arpResolutionCompleted(IArp::Notification *entry)
Definition: Ipv4.cc:1080
static uint16_t checksum(const void *addr, unsigned int count)
Definition: TcpIpChecksum.h:33
virtual void reassembleAndDeliver(Packet *packet)
Perform reassembly of fragmented datagrams, then send them up to the higher layers using sendToHL().
Definition: Ipv4.cc:711
@ CRC_DECLARED_CORRECT
Definition: CrcMode_m.h:57
virtual const NetworkInterface * getShortestPathInterfaceToSource(const Ptr< const Ipv4Header > &ipv4Header) const
Definition: Ipv4.cc:623
virtual Packet * prepareForForwarding(Packet *packet) const
Definition: Ipv4.cc:304
@ IPv4_I_DATA
Definition: Ipv4SocketCommand_m.h:84
virtual void fragmentAndSend(Packet *packet)
Fragment packet if needed, then send it to the selected interface using sendDatagramToOutput().
Definition: Ipv4.cc:860
int numDropped
Definition: Ipv4.h:94
virtual void sendPacketToNIC(Packet *packet)
Definition: Ipv4.cc:1136
ModuleRefByPar< Icmp > icmp
Definition: Ipv4.h:68
@ CRC_DECLARED_INCORRECT
Definition: CrcMode_m.h:58
const B IPv4_MAX_HEADER_LENGTH
Definition: Ipv4Header_m.h:71
std::multimap< int, IHook * > hooks
Definition: INetfilter.h:129
static const Ipv4Address UNSPECIFIED_ADDRESS
0.0.0.0
Definition: Ipv4Address.h:91
@ DROP
doesn't allow the datagram to pass to the next hook, will be deleted
Definition: INetfilter.h:41
#define Enter_Method(...)
Definition: SelfDoc.h:71
std::string directBroadcastInterfaces
Definition: Ipv4.h:77
static const MacAddress BROADCAST_ADDRESS
The broadcast MAC address, ff:ff:ff:ff:ff:ff.
Definition: MacAddress.h:34
static const simsignal_t arpResolutionCompletedSignal
Definition: IArp.h:42
@ ACCEPT
allows the datagram to pass to the next hook
Definition: INetfilter.h:40
virtual void encapsulate(Packet *packet)
Encapsulate packet coming from higher layers into Ipv4Header, using the given control info.
Definition: Ipv4.cc:960
static ProtocolGroup ipprotocol
Definition: ProtocolGroup.h:42
@ ADDRESS_RESOLUTION_FAILED
Definition: Simsignals_m.h:68
simsignal_t packetSentToUpperSignal
Definition: Simsignals.cc:87
const Protocol * getProtocol(int protocolNumber) const
Definition: ProtocolGroup.cc:31
virtual MacAddress resolveNextHopMacAddress(cPacket *packet, Ipv4Address nextHopAddr, const NetworkInterface *destIE)
Definition: Ipv4.cc:1120
virtual const NetworkInterface * getSourceInterface(Packet *packet)
Definition: Ipv4.cc:234
IpProtocolId
Enum generated from inet/networklayer/common/IpProtocolId.msg:17 by opp_msgtool.
Definition: IpProtocolId_m.h:90
virtual void fragmentPostRouting(Packet *datagram)
Call PostRouting Hook and continue with fragmentAndSend() if accepted.
Definition: Ipv4.cc:808
virtual void refreshDisplay() const override
Definition: OperationalMixinImpl.h:200
void registerProtocol(const Protocol &protocol, cGate *gate, ServicePrimitive servicePrimitive)
Registers a protocol primitive (PDU processing) at the given gate.
Definition: IProtocolRegistrationListener.cc:83
cPatternMatcher directBroadcastInterfaceMatcher
Definition: Ipv4.h:79
std::set< const Protocol * > upperProtocols
Definition: Ipv4.h:85
@ LOCALIN
Definition: INetfilter.h:33
@ POSTROUTING
Definition: INetfilter.h:35
@ LOCALOUT
Definition: INetfilter.h:36
CrcMode crcMode
Definition: Ipv4.h:72
bool containsKey(const std::map< K, V, _C > &m, const Tk &a)
Definition: stlutils.h:80
IHook::Result datagramLocalOutHook(Packet *datagram)
called before a packet arriving locally is delivered
Definition: Ipv4.cc:1374
virtual void preroutingFinish(Packet *packet)
Definition: Ipv4.cc:312
ModuleRefByPar< IInterfaceTable > ift
Definition: Ipv4.h:66
virtual Ipv4Address getNextHop(Packet *packet)
Definition: Ipv4.cc:246