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

DSCP Marker. More...

#include <DSCPMarker.h>

Inheritance diagram for inet::DSCPMarker:

Public Member Functions

 DSCPMarker ()
 

Protected Member Functions

virtual void initialize () override
 
virtual void handleMessage (cMessage *msg) override
 
virtual void refreshDisplay () const override
 
virtual bool markPacket (cPacket *msg, int dscp)
 

Protected Attributes

std::vector< int > dscps
 
int numRcvd = 0
 
int numMarked = 0
 

Static Protected Attributes

static simsignal_t markPkSignal = registerSignal("markPk")
 

Detailed Description

DSCP Marker.

Constructor & Destructor Documentation

inet::DSCPMarker::DSCPMarker ( )
inline
39 {}

Member Function Documentation

void inet::DSCPMarker::handleMessage ( cMessage *  msg)
overrideprotectedvirtual
56 {
57  cPacket *packet = dynamic_cast<cPacket *>(msg);
58  if (packet) {
59  numRcvd++;
60  int dscp = dscps.at(msg->getArrivalGate()->getIndex());
61  if (markPacket(packet, dscp)) {
62  emit(markPkSignal, packet);
63  numMarked++;
64  }
65 
66  send(packet, "out");
67  }
68  else
69  throw cRuntimeError("DSCPMarker expects cPackets");
70 }
int numRcvd
Definition: DSCPMarker.h:33
virtual bool markPacket(cPacket *msg, int dscp)
Definition: DSCPMarker.cc:81
int numMarked
Definition: DSCPMarker.h:34
std::vector< int > dscps
Definition: DSCPMarker.h:31
static simsignal_t markPkSignal
Definition: DSCPMarker.h:36
void inet::DSCPMarker::initialize ( )
overrideprotectedvirtual
42 {
43  parseDSCPs(par("dscps"), "dscps", dscps);
44  if (dscps.empty())
45  dscps.push_back(DSCP_BE);
46  while ((int)dscps.size() < gateSize("in"))
47  dscps.push_back(dscps.back());
48 
49  numRcvd = 0;
50  numMarked = 0;
51  WATCH(numRcvd);
52  WATCH(numMarked);
53 }
int numRcvd
Definition: DSCPMarker.h:33
int numMarked
Definition: DSCPMarker.h:34
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::vector< int > dscps
Definition: DSCPMarker.h:31
Definition: DSCP_m.h:84
bool inet::DSCPMarker::markPacket ( cPacket *  msg,
int  dscp 
)
protectedvirtual
82 {
83  EV_DETAIL << "Marking packet with dscp=" << dscpToString(dscp) << "\n";
84 
85  for ( ; packet; packet = packet->getEncapsulatedPacket()) {
86 #ifdef WITH_IPv4
87  IPv4Datagram *ipv4Datagram = dynamic_cast<IPv4Datagram *>(packet);
88  if (ipv4Datagram) {
89  ipv4Datagram->setDiffServCodePoint(dscp);
90  return true;
91  }
92 #endif // ifdef WITH_IPv4
93 #ifdef WITH_IPv6
94  IPv6Datagram *ipv6Datagram = dynamic_cast<IPv6Datagram *>(packet);
95  if (ipv6Datagram) {
96  ipv6Datagram->setDiffServCodePoint(dscp);
97  return true;
98  }
99 #endif // ifdef WITH_IPv6
100  }
101 
102  return false;
103 }
std::string dscpToString(int dscp)
Returns the string representation of the given DSCP value.
Definition: DiffservUtil.cc:162
void inet::DSCPMarker::refreshDisplay ( ) const
overrideprotectedvirtual
72 {
73  char buf[50] = "";
74  if (numRcvd > 0)
75  sprintf(buf + strlen(buf), "rcvd: %d ", numRcvd);
76  if (numMarked > 0)
77  sprintf(buf + strlen(buf), "mark:%d ", numMarked);
78  getDisplayString().setTagArg("t", 0, buf);
79 }
int numRcvd
Definition: DSCPMarker.h:33
int numMarked
Definition: DSCPMarker.h:34

Member Data Documentation

std::vector<int> inet::DSCPMarker::dscps
protected
simsignal_t inet::DSCPMarker::markPkSignal = registerSignal("markPk")
staticprotected
int inet::DSCPMarker::numMarked = 0
protected
int inet::DSCPMarker::numRcvd = 0
protected

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