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

ARP implementation. More...

#include <ARP.h>

Inheritance diagram for inet::ARP:
inet::IARP inet::ILifecycle

Classes

class  ARPCacheEntry
 

Public Types

typedef std::map< IPv4Address, ARPCacheEntry * > ARPCache
 
typedef std::vector< cMessage * > MsgPtrVector
 

Public Member Functions

 ARP ()
 
virtual ~ARP ()
 
virtual int numInitStages () const override
 
virtual MACAddress resolveL3Address (const L3Address &address, const InterfaceEntry *ie) override
 IARP implementation. More...
 
virtual L3Address getL3AddressFor (const MACAddress &addr) const override
 Returns the Layer 3 address for the given MAC address. More...
 
- Public Member Functions inherited from inet::IARP
virtual ~IARP ()
 
- Public Member Functions inherited from inet::ILifecycle
virtual ~ILifecycle ()
 

Protected Member Functions

MACAddress mapMulticastAddress (IPv4Address addr)
 
virtual void initialize (int stage) override
 
virtual void handleMessage (cMessage *msg) override
 
virtual void handleMessageWhenDown (cMessage *msg)
 
virtual bool handleOperationStage (LifecycleOperation *operation, int stage, IDoneCallback *doneCallback) override
 Perform one stage of a lifecycle operation. More...
 
virtual void finish () override
 
virtual bool isNodeUp ()
 
virtual void stop ()
 
virtual void start ()
 
virtual void flush ()
 
virtual void sendPacketToNIC (cMessage *msg, const InterfaceEntry *ie, const MACAddress &macAddress, int etherType)
 
virtual void initiateARPResolution (ARPCacheEntry *entry)
 
virtual void sendARPRequest (const InterfaceEntry *ie, IPv4Address ipAddress)
 
virtual void requestTimedOut (cMessage *selfmsg)
 
virtual bool addressRecognized (IPv4Address destAddr, InterfaceEntry *ie)
 
virtual void processARPPacket (ARPPacket *arp)
 
virtual void updateARPCache (ARPCacheEntry *entry, const MACAddress &macAddress)
 
virtual void dumpARPPacket (ARPPacket *arp)
 
virtual void refreshDisplay () const override
 

Protected Attributes

simtime_t retryTimeout
 
int retryCount = 0
 
simtime_t cacheTimeout
 
bool respondToProxyARP = false
 
bool isUp = false
 
long numResolutions = 0
 
long numFailedResolutions = 0
 
long numRequestsSent = 0
 
long numRepliesSent = 0
 
ARPCache arpCache
 
cGate * netwOutGate = nullptr
 
IInterfaceTableift = nullptr
 
IIPv4RoutingTablert = nullptr
 

Static Protected Attributes

static simsignal_t sentReqSignal = registerSignal("sentReq")
 
static simsignal_t sentReplySignal = registerSignal("sentReply")
 

Additional Inherited Members

- Static Public Attributes inherited from inet::IARP
static const simsignal_t initiatedARPResolutionSignal = cComponent::registerSignal("initiatedARPResolution")
 Signals used to publish ARP state changes. More...
 
static const simsignal_t completedARPResolutionSignal = cComponent::registerSignal("completedARPResolution")
 
static const simsignal_t failedARPResolutionSignal = cComponent::registerSignal("failedARPResolution")
 

Detailed Description

ARP implementation.

Member Typedef Documentation

typedef std::vector<cMessage *> inet::ARP::MsgPtrVector

Constructor & Destructor Documentation

inet::ARP::ARP ( )
55 {
56 }
inet::ARP::~ARP ( )
virtual
93 {
94  for (auto & elem : arpCache)
95  delete elem.second;
96 }
ARPCache arpCache
Definition: ARP.h:81

Member Function Documentation

bool inet::ARP::addressRecognized ( IPv4Address  destAddr,
InterfaceEntry ie 
)
protectedvirtual

Referenced by processARPPacket().

266 {
267  if (rt->isLocalAddress(destAddr)) {
268  return true;
269  }
270  else if (respondToProxyARP) {
271  // respond to Proxy ARP request: if we can route this packet (and the
272  // output port is different from this one), say yes
273  InterfaceEntry *rtie = rt->getInterfaceForDestAddr(destAddr);
274  return rtie != nullptr && rtie != ie;
275  }
276  else {
277  return false;
278  }
279 }
IIPv4RoutingTable * rt
Definition: ARP.h:86
virtual InterfaceEntry * getInterfaceForDestAddr(const IPv4Address &dest) const =0
Convenience function based on findBestMatchingRoute().
bool respondToProxyARP
Definition: ARP.h:69
virtual bool isLocalAddress(const IPv4Address &dest) const =0
Checks if the address is a local one, i.e.
void inet::ARP::dumpARPPacket ( ARPPacket arp)
protectedvirtual

Referenced by processARPPacket().

282 {
283  EV_DETAIL << (arp->getOpcode() == ARP_REQUEST ? "ARP_REQ" : arp->getOpcode() == ARP_REPLY ? "ARP_REPLY" : "unknown type")
284  << " src=" << arp->getSrcIPAddress() << " / " << arp->getSrcMACAddress()
285  << " dest=" << arp->getDestIPAddress() << " / " << arp->getDestMACAddress() << "\n";
286 }
Definition: ARPPacket_m.h:61
Definition: ARPPacket_m.h:60
void inet::ARP::finish ( )
overrideprotectedvirtual
89 {
90 }
void inet::ARP::flush ( )
protectedvirtual

Referenced by stop().

157 {
158  while (!arpCache.empty()) {
159  auto i = arpCache.begin();
160  ARPCacheEntry *entry = i->second;
161  cancelAndDelete(entry->timer);
162  entry->timer = nullptr;
163  delete entry;
164  arpCache.erase(i);
165  }
166 }
ARPCache arpCache
Definition: ARP.h:81
L3Address inet::ARP::getL3AddressFor ( const MACAddress ) const
overridevirtual

Returns the Layer 3 address for the given MAC address.

If it is not available (not in the cache, pending resolution, or already expired), UNSPECIFIED_ADDRESS is returned.

Implements inet::IARP.

467 {
468  Enter_Method_Silent();
469 
470  if (macAddr.isUnspecified())
472 
473  simtime_t now = simTime();
474  for (const auto & elem : arpCache)
475  if (elem.second->macAddress == macAddr && elem.second->lastUpdate + cacheTimeout >= now)
476  return elem.first;
477 
478 
480 }
ARPCache arpCache
Definition: ARP.h:81
simtime_t cacheTimeout
Definition: ARP.h:68
static const IPv4Address UNSPECIFIED_ADDRESS
0.0.0.0
Definition: IPv4Address.h:102
void inet::ARP::handleMessage ( cMessage *  msg)
overrideprotectedvirtual
99 {
100  if (!isUp) {
102  return;
103  }
104 
105  if (msg->isSelfMessage()) {
106  requestTimedOut(msg);
107  }
108  else {
109  ARPPacket *arp = check_and_cast<ARPPacket *>(msg);
110  processARPPacket(arp);
111  }
112 }
virtual void handleMessageWhenDown(cMessage *msg)
Definition: ARP.cc:114
virtual void processARPPacket(ARPPacket *arp)
Definition: ARP.cc:288
virtual void requestTimedOut(cMessage *selfmsg)
Definition: ARP.cc:240
bool isUp
Definition: ARP.h:71
void inet::ARP::handleMessageWhenDown ( cMessage *  msg)
protectedvirtual

Referenced by handleMessage().

115 {
116  if (msg->isSelfMessage())
117  throw cRuntimeError("Model error: self msg '%s' received when protocol is down", msg->getName());
118  EV_WARN << "Protocol is turned off, dropping '" << msg->getName() << "' message\n";
119  delete msg;
120 }
bool inet::ARP::handleOperationStage ( LifecycleOperation operation,
int  stage,
IDoneCallback doneCallback 
)
overrideprotectedvirtual

Perform one stage of a lifecycle operation.

Processing may be done entirely within this method, or may be a longer process that involves nonzero simulation time or several events, and is triggered by this method call.

Return value: true = "done"; false = "not yet done, will invoke doneCallback when done"

Implements inet::ILifecycle.

123 {
124  Enter_Method_Silent();
125 
126  if (dynamic_cast<NodeStartOperation *>(operation)) {
128  start();
129  }
130  else if (dynamic_cast<NodeShutdownOperation *>(operation)) {
132  stop();
133  }
134  else if (dynamic_cast<NodeCrashOperation *>(operation)) {
136  stop();
137  }
138  else {
139  throw cRuntimeError("Unsupported operation '%s'", operation->getClassName());
140  }
141  return true;
142 }
Definition: NodeOperations.h:50
virtual void start()
Definition: ARP.cc:144
virtual void stop()
Definition: ARP.cc:150
Stage
Definition: NodeOperations.h:71
Stage
Definition: NodeOperations.h:126
Stage
Definition: NodeOperations.h:46
Definition: NodeOperations.h:127
void inet::ARP::initialize ( int  stage)
overrideprotectedvirtual
59 {
60  cSimpleModule::initialize(stage);
61 
62  if (stage == INITSTAGE_LOCAL) {
63  retryTimeout = par("retryTimeout");
64  retryCount = par("retryCount");
65  cacheTimeout = par("cacheTimeout");
66  respondToProxyARP = par("respondToProxyARP");
67 
68  netwOutGate = gate("netwOut");
69 
70  // init statistics
73  WATCH(numRequestsSent);
74  WATCH(numRepliesSent);
75  WATCH(numResolutions);
76  WATCH(numFailedResolutions);
77 
78  WATCH_PTRMAP(arpCache);
79  }
80  else if (stage == INITSTAGE_NETWORK_LAYER_3) { // IP addresses should be available
81  ift = getModuleFromPar<IInterfaceTable>(par("interfaceTableModule"), this);
82  rt = getModuleFromPar<IIPv4RoutingTable>(par("routingTableModule"), this);
83 
84  isUp = isNodeUp();
85  }
86 }
IInterfaceTable * ift
Definition: ARP.h:85
int retryCount
Definition: ARP.h:67
long numResolutions
Definition: ARP.h:73
IIPv4RoutingTable * rt
Definition: ARP.h:86
virtual bool isNodeUp()
Definition: ARP.cc:168
long numFailedResolutions
Definition: ARP.h:74
ARPCache arpCache
Definition: ARP.h:81
long numRequestsSent
Definition: ARP.h:75
simtime_t cacheTimeout
Definition: ARP.h:68
simtime_t retryTimeout
Definition: ARP.h:66
Initialization of network-layer protocols, stage 3.
Definition: InitStages.h:84
cGate * netwOutGate
Definition: ARP.h:83
bool respondToProxyARP
Definition: ARP.h:69
long numRepliesSent
Definition: ARP.h:76
Local initializations.
Definition: InitStages.h:35
bool isUp
Definition: ARP.h:71
void inet::ARP::initiateARPResolution ( ARPCacheEntry entry)
protectedvirtual

Referenced by resolveL3Address().

185 {
186  IPv4Address nextHopAddr = entry->myIter->first;
187  entry->pending = true;
188  entry->numRetries = 0;
189  entry->lastUpdate = SIMTIME_ZERO;
190  entry->macAddress = MACAddress::UNSPECIFIED_ADDRESS;
191  sendARPRequest(entry->ie, nextHopAddr);
192 
193  // start timer
194  cMessage *msg = entry->timer = new cMessage("ARP timeout");
195  msg->setContextPointer(entry);
196  scheduleAt(simTime() + retryTimeout, msg);
197 
198  numResolutions++;
199  Notification signal(nextHopAddr, MACAddress::UNSPECIFIED_ADDRESS, entry->ie);
200  emit(initiatedARPResolutionSignal, &signal);
201 }
long numResolutions
Definition: ARP.h:73
static const simsignal_t initiatedARPResolutionSignal
Signals used to publish ARP state changes.
Definition: IARP.h:55
simtime_t retryTimeout
Definition: ARP.h:66
virtual void sendARPRequest(const InterfaceEntry *ie, IPv4Address ipAddress)
Definition: ARP.cc:217
static const MACAddress UNSPECIFIED_ADDRESS
The unspecified MAC address, 00:00:00:00:00:00.
Definition: MACAddress.h:57
bool inet::ARP::isNodeUp ( )
protectedvirtual

Referenced by initialize().

169 {
170  NodeStatus *nodeStatus = dynamic_cast<NodeStatus *>(findContainingNode(this)->getSubmodule("status"));
171  return !nodeStatus || nodeStatus->getState() == NodeStatus::UP;
172 }
cModule * findContainingNode(const cModule *from)
Find the node containing the given module.
Definition: ModuleAccess.cc:56
Definition: NodeStatus.h:40
MACAddress inet::ARP::mapMulticastAddress ( IPv4Address  addr)
protected
virtual int inet::ARP::numInitStages ( ) const
inlineoverridevirtual
95 { return NUM_INIT_STAGES; }
The number of initialization stages.
Definition: InitStages.h:116
void inet::ARP::processARPPacket ( ARPPacket arp)
protectedvirtual

Referenced by handleMessage().

289 {
290  EV_INFO << "Received " << arp << " from network protocol.\n";
291  dumpARPPacket(arp);
292 
293  // extract input port
294  IMACProtocolControlInfo *ctrl = check_and_cast<IMACProtocolControlInfo *>(arp->removeControlInfo());
295  InterfaceEntry *ie = ift->getInterfaceById(ctrl->getInterfaceId());
296  delete ctrl;
297 
298  //
299  // Recipe a'la RFC 826:
300  //
301  // ?Do I have the hardware type in ar$hrd?
302  // Yes: (almost definitely)
303  // [optionally check the hardware length ar$hln]
304  // ?Do I speak the protocol in ar$pro?
305  // Yes:
306  // [optionally check the protocol length ar$pln]
307  // Merge_flag := false
308  // If the pair <protocol type, sender protocol address> is
309  // already in my translation table, update the sender
310  // hardware address field of the entry with the new
311  // information in the packet and set Merge_flag to true.
312  // ?Am I the target protocol address?
313  // Yes:
314  // If Merge_flag is false, add the triplet <protocol type,
315  // sender protocol address, sender hardware address> to
316  // the translation table.
317  // ?Is the opcode ares_op$REQUEST? (NOW look at the opcode!!)
318  // Yes:
319  // Swap hardware and protocol fields, putting the local
320  // hardware and protocol addresses in the sender fields.
321  // Set the ar$op field to ares_op$REPLY
322  // Send the packet to the (new) target hardware address on
323  // the same hardware on which the request was received.
324  //
325 
326  MACAddress srcMACAddress = arp->getSrcMACAddress();
327  IPv4Address srcIPAddress = arp->getSrcIPAddress();
328 
329  if (srcMACAddress.isUnspecified())
330  throw cRuntimeError("wrong ARP packet: source MAC address is empty");
331  if (srcIPAddress.isUnspecified())
332  throw cRuntimeError("wrong ARP packet: source IPv4 address is empty");
333 
334  bool mergeFlag = false;
335  // "If ... sender protocol address is already in my translation table"
336  auto it = arpCache.find(srcIPAddress);
337  if (it != arpCache.end()) {
338  // "update the sender hardware address field"
339  ARPCacheEntry *entry = it->second;
340  updateARPCache(entry, srcMACAddress);
341  mergeFlag = true;
342  }
343 
344  // "?Am I the target protocol address?"
345  // if Proxy ARP is enabled, we also have to reply if we're a router to the dest IPv4 address
346  if (addressRecognized(arp->getDestIPAddress(), ie)) {
347  // "If Merge_flag is false, add the triplet protocol type, sender
348  // protocol address, sender hardware address to the translation table"
349  if (!mergeFlag) {
350  ARPCacheEntry *entry;
351  if (it != arpCache.end()) {
352  entry = it->second;
353  }
354  else {
355  entry = new ARPCacheEntry();
356  auto where = arpCache.insert(arpCache.begin(), std::make_pair(srcIPAddress, entry));
357  entry->myIter = where;
358  entry->ie = ie;
359 
360  entry->pending = false;
361  entry->timer = nullptr;
362  entry->numRetries = 0;
363  }
364  updateARPCache(entry, srcMACAddress);
365  }
366 
367  // "?Is the opcode ares_op$REQUEST? (NOW look at the opcode!!)"
368  switch (arp->getOpcode()) {
369  case ARP_REQUEST: {
370  EV_DETAIL << "Packet was ARP REQUEST, sending REPLY\n";
371 
372  // find our own IPv4 address and MAC address on the given interface
373  MACAddress myMACAddress = ie->getMacAddress();
374  IPv4Address myIPAddress = ie->ipv4Data()->getIPAddress();
375 
376  // "Swap hardware and protocol fields", etc.
377  arp->setName("arpREPLY");
378  IPv4Address origDestAddress = arp->getDestIPAddress();
379  arp->setDestIPAddress(srcIPAddress);
380  arp->setDestMACAddress(srcMACAddress);
381  arp->setSrcIPAddress(origDestAddress);
382  arp->setSrcMACAddress(myMACAddress);
383  arp->setOpcode(ARP_REPLY);
384  delete arp->removeControlInfo();
385  sendPacketToNIC(arp, ie, srcMACAddress, ETHERTYPE_ARP);
386  numRepliesSent++;
387  emit(sentReplySignal, 1L);
388  break;
389  }
390 
391  case ARP_REPLY: {
392  EV_DETAIL << "Discarding packet\n";
393  delete arp;
394  break;
395  }
396 
397  case ARP_RARP_REQUEST:
398  throw cRuntimeError("RARP request received: RARP is not supported");
399 
400  case ARP_RARP_REPLY:
401  throw cRuntimeError("RARP reply received: RARP is not supported");
402 
403  default:
404  throw cRuntimeError("Unsupported opcode %d in received ARP packet", arp->getOpcode());
405  }
406  }
407  else {
408  // address not recognized
409  EV_INFO << "IPv4 address " << arp->getDestIPAddress() << " not recognized, dropping ARP packet\n";
410  delete arp;
411  }
412 }
virtual void dumpARPPacket(ARPPacket *arp)
Definition: ARP.cc:281
IInterfaceTable * ift
Definition: ARP.h:85
virtual InterfaceEntry * getInterfaceById(int id) const =0
Returns an interface by its Id.
virtual bool addressRecognized(IPv4Address destAddr, InterfaceEntry *ie)
Definition: ARP.cc:265
Definition: ARPPacket_m.h:62
Definition: ARPPacket_m.h:61
ARPCache arpCache
Definition: ARP.h:81
virtual void updateARPCache(ARPCacheEntry *entry, const MACAddress &macAddress)
Definition: ARP.cc:414
virtual void sendPacketToNIC(cMessage *msg, const InterfaceEntry *ie, const MACAddress &macAddress, int etherType)
Definition: ARP.cc:203
static simsignal_t sentReplySignal
Definition: ARP.h:79
long numRepliesSent
Definition: ARP.h:76
Definition: ARPPacket_m.h:60
Definition: ARPPacket_m.h:63
Definition: Ieee802Ctrl_m.h:116
void inet::ARP::refreshDisplay ( ) const
overrideprotectedvirtual
175 {
176  std::stringstream os;
177 
178  os << arpCache.size() << " cache entries\nsent req:" << numRequestsSent
179  << " repl:" << numRepliesSent << " fail:" << numFailedResolutions;
180 
181  getDisplayString().setTagArg("t", 0, os.str().c_str());
182 }
long numFailedResolutions
Definition: ARP.h:74
ARPCache arpCache
Definition: ARP.h:81
long numRequestsSent
Definition: ARP.h:75
long numRepliesSent
Definition: ARP.h:76
void inet::ARP::requestTimedOut ( cMessage *  selfmsg)
protectedvirtual

Referenced by handleMessage().

241 {
242  ARPCacheEntry *entry = (ARPCacheEntry *)selfmsg->getContextPointer();
243  entry->numRetries++;
244  if (entry->numRetries < retryCount) {
245  // retry
246  IPv4Address nextHopAddr = entry->myIter->first;
247  EV_INFO << "ARP request for " << nextHopAddr << " timed out, resending\n";
248  sendARPRequest(entry->ie, nextHopAddr);
249  scheduleAt(simTime() + retryTimeout, selfmsg);
250  return;
251  }
252 
253  delete selfmsg;
254 
255  // max retry count reached: ARP failure.
256  // throw out entry from cache
257  EV << "ARP timeout, max retry count " << retryCount << " for " << entry->myIter->first << " reached.\n";
258  Notification signal(entry->myIter->first, MACAddress::UNSPECIFIED_ADDRESS, entry->ie);
259  emit(failedARPResolutionSignal, &signal);
260  arpCache.erase(entry->myIter);
261  delete entry;
263 }
int retryCount
Definition: ARP.h:67
long numFailedResolutions
Definition: ARP.h:74
ARPCache arpCache
Definition: ARP.h:81
simtime_t retryTimeout
Definition: ARP.h:66
virtual void sendARPRequest(const InterfaceEntry *ie, IPv4Address ipAddress)
Definition: ARP.cc:217
static const simsignal_t failedARPResolutionSignal
Definition: IARP.h:57
static const MACAddress UNSPECIFIED_ADDRESS
The unspecified MAC address, 00:00:00:00:00:00.
Definition: MACAddress.h:57
MACAddress inet::ARP::resolveL3Address ( const L3Address address,
const InterfaceEntry ie 
)
overridevirtual

IARP implementation.

Implements inet::IARP.

432 {
433  Enter_Method("resolveMACAddress(%s,%s)", address.str().c_str(), ie->getName());
434 
435  IPv4Address addr = address.toIPv4();
436  ARPCache::const_iterator it = arpCache.find(addr);
437  if (it == arpCache.end()) {
438  // no cache entry: launch ARP request
439  ARPCacheEntry *entry = new ARPCacheEntry();
440  entry->owner = this;
441  auto where = arpCache.insert(arpCache.begin(), std::make_pair(addr, entry));
442  entry->myIter = where; // note: "inserting a new element into a map does not invalidate iterators that point to existing elements"
443  entry->ie = ie;
444 
445  EV << "Starting ARP resolution for " << addr << "\n";
446  initiateARPResolution(entry);
448  }
449  else if (it->second->pending) {
450  // an ARP request is already pending for this address
451  EV << "ARP resolution for " << addr << " is already pending\n";
453  }
454  else if (it->second->lastUpdate + cacheTimeout >= simTime()) {
455  return it->second->macAddress;
456  }
457  else {
458  EV << "ARP cache entry for " << addr << " expired, starting new ARP resolution\n";
459  ARPCacheEntry *entry = it->second;
460  entry->ie = ie; // routing table may have changed
461  initiateARPResolution(entry);
462  }
464 }
ARPCache arpCache
Definition: ARP.h:81
simtime_t cacheTimeout
Definition: ARP.h:68
virtual void initiateARPResolution(ARPCacheEntry *entry)
Definition: ARP.cc:184
static const MACAddress UNSPECIFIED_ADDRESS
The unspecified MAC address, 00:00:00:00:00:00.
Definition: MACAddress.h:57
void inet::ARP::sendARPRequest ( const InterfaceEntry ie,
IPv4Address  ipAddress 
)
protectedvirtual

Referenced by initiateARPResolution(), and requestTimedOut().

218 {
219  // find our own IPv4 address and MAC address on the given interface
220  MACAddress myMACAddress = ie->getMacAddress();
221  IPv4Address myIPAddress = ie->ipv4Data()->getIPAddress();
222 
223  // both must be set
224  ASSERT(!myMACAddress.isUnspecified());
225  ASSERT(!myIPAddress.isUnspecified());
226 
227  // fill out everything in ARP Request packet except dest MAC address
228  ARPPacket *arp = new ARPPacket("arpREQ");
229  arp->setByteLength(ARP_HEADER_BYTES);
230  arp->setOpcode(ARP_REQUEST);
231  arp->setSrcMACAddress(myMACAddress);
232  arp->setSrcIPAddress(myIPAddress);
233  arp->setDestIPAddress(ipAddress);
234 
236  numRequestsSent++;
237  emit(sentReqSignal, 1L);
238 }
long numRequestsSent
Definition: ARP.h:75
virtual void sendPacketToNIC(cMessage *msg, const InterfaceEntry *ie, const MACAddress &macAddress, int etherType)
Definition: ARP.cc:203
Definition: ARPPacket_m.h:60
static simsignal_t sentReqSignal
Definition: ARP.h:78
Definition: Ieee802Ctrl_m.h:116
#define ARP_HEADER_BYTES
Definition: ARPPacket_m.h:40
static const MACAddress BROADCAST_ADDRESS
The broadcast MAC address, ff:ff:ff:ff:ff:ff.
Definition: MACAddress.h:60
void inet::ARP::sendPacketToNIC ( cMessage *  msg,
const InterfaceEntry ie,
const MACAddress macAddress,
int  etherType 
)
protectedvirtual

Referenced by processARPPacket(), and sendARPRequest().

204 {
205  // add control info with MAC address
206  Ieee802Ctrl *controlInfo = new Ieee802Ctrl();
207  controlInfo->setDest(macAddress);
208  controlInfo->setEtherType(etherType);
209  controlInfo->setInterfaceId(ie->getInterfaceId());
210  msg->setControlInfo(controlInfo);
211 
212  // send out
213  EV_INFO << "Sending " << msg << " to network protocol.\n";
214  send(msg, netwOutGate);
215 }
cGate * netwOutGate
Definition: ARP.h:83
void inet::ARP::start ( )
protectedvirtual

Referenced by handleOperationStage().

145 {
146  ASSERT(arpCache.empty());
147  isUp = true;
148 }
ARPCache arpCache
Definition: ARP.h:81
bool isUp
Definition: ARP.h:71
void inet::ARP::stop ( )
protectedvirtual

Referenced by handleOperationStage().

151 {
152  isUp = false;
153  flush();
154 }
virtual void flush()
Definition: ARP.cc:156
bool isUp
Definition: ARP.h:71
void inet::ARP::updateARPCache ( ARPCacheEntry entry,
const MACAddress macAddress 
)
protectedvirtual

Referenced by processARPPacket().

415 {
416  EV_DETAIL << "Updating ARP cache entry: " << entry->myIter->first << " <--> " << macAddress << "\n";
417 
418  // update entry
419  if (entry->pending) {
420  entry->pending = false;
421  delete cancelEvent(entry->timer);
422  entry->timer = nullptr;
423  entry->numRetries = 0;
424  }
425  entry->macAddress = macAddress;
426  entry->lastUpdate = simTime();
427  Notification signal(entry->myIter->first, macAddress, entry->ie);
428  emit(completedARPResolutionSignal, &signal);
429 }
static const simsignal_t completedARPResolutionSignal
Definition: IARP.h:56

Member Data Documentation

simtime_t inet::ARP::cacheTimeout
protected
IInterfaceTable* inet::ARP::ift = nullptr
protected

Referenced by initialize(), and processARPPacket().

bool inet::ARP::isUp = false
protected

Referenced by handleMessage(), initialize(), start(), and stop().

cGate* inet::ARP::netwOutGate = nullptr
protected

Referenced by initialize(), and sendPacketToNIC().

long inet::ARP::numFailedResolutions = 0
protected
long inet::ARP::numRepliesSent = 0
protected
long inet::ARP::numRequestsSent = 0
protected
long inet::ARP::numResolutions = 0
protected
bool inet::ARP::respondToProxyARP = false
protected

Referenced by addressRecognized(), and initialize().

int inet::ARP::retryCount = 0
protected

Referenced by initialize(), and requestTimedOut().

simtime_t inet::ARP::retryTimeout
protected
IIPv4RoutingTable* inet::ARP::rt = nullptr
protected

Referenced by addressRecognized(), and initialize().

simsignal_t inet::ARP::sentReplySignal = registerSignal("sentReply")
staticprotected

Referenced by processARPPacket().

simsignal_t inet::ARP::sentReqSignal = registerSignal("sentReq")
staticprotected

Referenced by sendARPRequest().


The documentation for this class was generated from the following files: