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

Error Handling: print out received error. More...

#include <ErrorHandling.h>

Inheritance diagram for inet::ErrorHandling:

Protected Member Functions

virtual void initialize () override
 
virtual void handleMessage (cMessage *msg) override
 
virtual void refreshDisplay () const override
 

Protected Attributes

long numReceived
 
long numHostUnreachable
 
long numTimeExceeded
 

Detailed Description

Error Handling: print out received error.

Member Function Documentation

void inet::ErrorHandling::handleMessage ( cMessage *  msg)
overrideprotectedvirtual
42 {
43  numReceived++;
44 
45  ICMPMessage *icmpMsg = check_and_cast<ICMPMessage *>(msg);
46  // Note: we must NOT use decapsulate() because payload in ICMP is conceptually truncated
47  IPv4Datagram *d = check_and_cast<IPv4Datagram *>(icmpMsg->getEncapsulatedPacket());
48 
49  EV_WARN << "Error Handler: ICMP message received:\n";
50  EV_WARN << " Type: " << (int)icmpMsg->getType()
51  << " Code: " << (int)icmpMsg->getCode()
52  << " Bytelength: " << d->getByteLength()
53  << " Src: " << d->getSrcAddress()
54  << " Dest: " << d->getDestAddress()
55  << " Time: " << simTime()
56  << "\n";
57 
58  switch (icmpMsg->getType()) {
61  break;
62 
63  case ICMP_TIME_EXCEEDED:
65  break;
66  }
67 
68  delete icmpMsg;
69 }
Definition: ICMPMessage_m.h:66
long numReceived
Definition: ErrorHandling.h:35
long numHostUnreachable
Definition: ErrorHandling.h:36
Definition: ICMPMessage_m.h:72
long numTimeExceeded
Definition: ErrorHandling.h:37
void inet::ErrorHandling::initialize ( )
overrideprotectedvirtual
31 {
32  numReceived = 0;
34  numTimeExceeded = 0;
35 
36  WATCH(numReceived);
37  WATCH(numHostUnreachable);
38  WATCH(numTimeExceeded);
39 }
long numReceived
Definition: ErrorHandling.h:35
long numHostUnreachable
Definition: ErrorHandling.h:36
long numTimeExceeded
Definition: ErrorHandling.h:37
void inet::ErrorHandling::refreshDisplay ( ) const
overrideprotectedvirtual
72 {
73  char buf[80];
74  sprintf(buf, "errors: %ld", numReceived);
75  getDisplayString().setTagArg("t", 0, buf);
76 }
long numReceived
Definition: ErrorHandling.h:35

Member Data Documentation

long inet::ErrorHandling::numHostUnreachable
protected

Referenced by handleMessage(), and initialize().

long inet::ErrorHandling::numReceived
protected
long inet::ErrorHandling::numTimeExceeded
protected

Referenced by handleMessage(), and initialize().


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