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

Behavior Aggregate Classifier. More...

#include <BehaviorAggregateClassifier.h>

Inheritance diagram for inet::BehaviorAggregateClassifier:

Public Member Functions

 BehaviorAggregateClassifier ()
 

Protected Member Functions

virtual void initialize () override
 
virtual void handleMessage (cMessage *msg) override
 
virtual void refreshDisplay () const override
 
virtual int classifyPacket (cPacket *packet)
 
int getDscpFromPacket (cPacket *packet)
 

Protected Attributes

int numOutGates = 0
 
std::map< int, int > dscpToGateIndexMap
 
int numRcvd = 0
 

Static Protected Attributes

static simsignal_t pkClassSignal = registerSignal("pkClass")
 

Detailed Description

Behavior Aggregate Classifier.

Constructor & Destructor Documentation

inet::BehaviorAggregateClassifier::BehaviorAggregateClassifier ( )
inline
40 {}

Member Function Documentation

int inet::BehaviorAggregateClassifier::classifyPacket ( cPacket *  packet)
protectedvirtual
88 {
89  int dscp = getDscpFromPacket(packet);
90  if (dscp >= 0) {
91  auto it = dscpToGateIndexMap.find(dscp);
92  if (it != dscpToGateIndexMap.end())
93  return it->second;
94  }
95  return -1;
96 }
int getDscpFromPacket(cPacket *packet)
Definition: BehaviorAggregateClassifier.cc:98
std::map< int, int > dscpToGateIndexMap
Definition: BehaviorAggregateClassifier.h:33
int inet::BehaviorAggregateClassifier::getDscpFromPacket ( cPacket *  packet)
protected
99 {
100  for ( ; packet; packet = packet->getEncapsulatedPacket()) {
101 #ifdef WITH_IPv4
102  IPv4Datagram *ipv4Datagram = dynamic_cast<IPv4Datagram *>(packet);
103  if (ipv4Datagram)
104  return ipv4Datagram->getDiffServCodePoint();
105 #endif // ifdef WITH_IPv4
106 #ifdef WITH_IPv6
107  IPv6Datagram *ipv6Datagram = dynamic_cast<IPv6Datagram *>(packet);
108  if (ipv6Datagram)
109  return ipv6Datagram->getDiffServCodePoint();
110 #endif // ifdef WITH_IPv6
111  }
112  return -1;
113 }
void inet::BehaviorAggregateClassifier::handleMessage ( cMessage *  msg)
overrideprotectedvirtual
67 {
68  cPacket *packet = check_and_cast<cPacket *>(msg);
69  numRcvd++;
70  int clazz = classifyPacket(packet);
71  emit(pkClassSignal, clazz);
72 
73  if (clazz >= 0)
74  send(packet, "outs", clazz);
75  else
76  send(packet, "defaultOut");
77 }
int numRcvd
Definition: BehaviorAggregateClassifier.h:35
virtual int classifyPacket(cPacket *packet)
Definition: BehaviorAggregateClassifier.cc:87
static simsignal_t pkClassSignal
Definition: BehaviorAggregateClassifier.h:37
void inet::BehaviorAggregateClassifier::initialize ( )
overrideprotectedvirtual
51 {
52  numOutGates = gateSize("outs");
53  std::vector<int> dscps;
54  parseDSCPs(par("dscps"), "dscps", dscps);
55  int numDscps = (int)dscps.size();
56  if (numDscps > numOutGates)
57  throw cRuntimeError("%s dscp values are given, but the module has only %d out gates",
58  numDscps, numOutGates);
59  for (int i = 0; i < numDscps; ++i)
60  dscpToGateIndexMap[dscps[i]] = i;
61 
62  numRcvd = 0;
63  WATCH(numRcvd);
64 }
int numRcvd
Definition: BehaviorAggregateClassifier.h:35
void parseDSCPs(const char *attrValue, const char *attrName, std::vector< int > &result)
Parses a space separated list of DSCP values and puts them into the result vector.
Definition: DiffservUtil.cc:147
std::map< int, int > dscpToGateIndexMap
Definition: BehaviorAggregateClassifier.h:33
int numOutGates
Definition: BehaviorAggregateClassifier.h:32
void inet::BehaviorAggregateClassifier::refreshDisplay ( ) const
overrideprotectedvirtual
80 {
81  char buf[20] = "";
82  if (numRcvd > 0)
83  sprintf(buf + strlen(buf), "rcvd:%d ", numRcvd);
84  getDisplayString().setTagArg("t", 0, buf);
85 }
int numRcvd
Definition: BehaviorAggregateClassifier.h:35

Member Data Documentation

std::map<int, int> inet::BehaviorAggregateClassifier::dscpToGateIndexMap
protected
int inet::BehaviorAggregateClassifier::numOutGates = 0
protected
int inet::BehaviorAggregateClassifier::numRcvd = 0
protected
simsignal_t inet::BehaviorAggregateClassifier::pkClassSignal = registerSignal("pkClass")
staticprotected

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