Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018 #ifndef __INET_IP_H
00019 #define __INET_IP_H
00020
00021 #include "QueueBase.h"
00022 #include "InterfaceTableAccess.h"
00023 #include "RoutingTableAccess.h"
00024 #include "IRoutingTable.h"
00025 #include "ICMPAccess.h"
00026 #include "IPControlInfo.h"
00027 #include "IPDatagram.h"
00028 #include "IPFragBuf.h"
00029 #include "ProtocolMap.h"
00030
00031
00032 class ARPPacket;
00033 class ICMPMessage;
00034
00035
00036 const int ICMP_FRAGMENTATION_ERROR_CODE = 4;
00037
00038
00042 class INET_API IP : public QueueBase
00043 {
00044 protected:
00045 IRoutingTable *rt;
00046 IInterfaceTable *ift;
00047 ICMPAccess icmpAccess;
00048 cGate *queueOutGate;
00049
00050
00051 int defaultTimeToLive;
00052 int defaultMCTimeToLive;
00053 simtime_t fragmentTimeoutTime;
00054
00055
00056 long curFragmentId;
00057 IPFragBuf fragbuf;
00058 simtime_t lastCheckTime;
00059 ProtocolMapping mapping;
00060
00061
00062 int numMulticast;
00063 int numLocalDeliver;
00064 int numDropped;
00065 int numUnroutable;
00066 int numForwarded;
00067
00068 protected:
00069
00070 virtual InterfaceEntry *getSourceInterfaceFrom(cPacket *msg);
00071
00072
00073 virtual void updateDisplayString();
00074
00079 virtual IPDatagram *encapsulate(cPacket *transportPacket, InterfaceEntry *&destIE);
00080
00086 virtual IPDatagram *encapsulate(cPacket *transportPacket, InterfaceEntry *&destIE, IPControlInfo *controlInfo);
00087
00091 virtual IPDatagram *createIPDatagram(const char *name);
00092
00097 virtual void handlePacketFromNetwork(IPDatagram *datagram);
00098
00103 virtual void handleMessageFromHL(cPacket *msg);
00104
00108 virtual void handleARP(ARPPacket *msg);
00109
00113 virtual void handleReceivedICMP(ICMPMessage *msg);
00114
00121 virtual void routePacket(IPDatagram *datagram, InterfaceEntry *destIE, bool fromHL);
00122
00126 virtual void routeMulticastPacket(IPDatagram *datagram, InterfaceEntry *destIE, InterfaceEntry *fromIE);
00127
00132 virtual void reassembleAndDeliver(IPDatagram *datagram);
00133
00137 virtual cPacket *decapsulateIP(IPDatagram *datagram);
00138
00143 virtual void fragmentAndSend(IPDatagram *datagram, InterfaceEntry *ie, IPAddress nextHopAddr);
00144
00148 virtual void sendDatagramToOutput(IPDatagram *datagram, InterfaceEntry *ie, IPAddress nextHopAddr);
00149
00150 public:
00151 IP() {}
00152
00153 protected:
00157 virtual void initialize();
00158
00163 virtual void endService(cPacket *msg);
00164 };
00165
00166 #endif
00167