|
INET Framework for OMNeT++/OMNEST
|
#include <BasicDSCPClassifier.h>
Public Member Functions | |
| virtual int | getNumQueues () |
| virtual int | classifyPacket (cMessage *msg) |
Private Member Functions | |
| virtual int | classifyByDSCP (int dscp) |
Just an example for packet classifiers, based on IPv4 DSCP/IPv6 Traffic class. You'll probably need to implement others if your research interest lies in QoS.
| int BasicDSCPClassifier::classifyByDSCP | ( | int | dscp | ) | [private, virtual] |
Referenced by classifyPacket().
{
// DSCP is 6 bits, mask out all others
dscp = (dscp & 0x3f);
// DSCP format:
// xxxxx0: used by standards; see RFC 2474
// xxxxx1: experimental or local use
// source: Stallings, High-Speed Networks, 2nd Ed, p494
// all-zero DSCP maps to Best Effort (lowest priority)
if (dscp==0)
return BEST_EFFORT;
// assume Best Effort service for experimental or local DSCP's too
if (dscp & 1)
return BEST_EFFORT;
// from here on, we deal with non-zero standardized DSCP values only
int upper3bits = (dscp & 0x3c) >> 3;
//int lower3bits = (dscp & 0x07); -- we'll ignore this
// rfc 2474, section 4.2.2: at least two independently forwarded classes of traffic have to be created
if (upper3bits & 0x04)
return 0; // highest priority
else
return 1; // low priority (best effort)
}
| int BasicDSCPClassifier::classifyPacket | ( | cMessage * | msg | ) | [virtual] |
The method should return the priority (the index of subqueue) for the given packet, a value between 0 and getNumQueues()-1 (inclusive).
Implements IQoSClassifier.
{
if (dynamic_cast<IPDatagram *>(msg))
{
// IPv4 QoS: map DSCP to queue number
IPDatagram *datagram = (IPDatagram *)msg;
int dscp = datagram->getDiffServCodePoint();
return classifyByDSCP(dscp);
}
#ifndef WITHOUT_IPv6
else if (dynamic_cast<IPv6Datagram *>(msg))
{
// IPv6 QoS: map Traffic Class to queue number
IPv6Datagram *datagram = (IPv6Datagram *)msg;
int dscp = datagram->getTrafficClass();
return classifyByDSCP(dscp);
}
#endif
else
{
return BEST_EFFORT; // lowest priority ("best effort")
}
}
| int BasicDSCPClassifier::getNumQueues | ( | ) | [virtual] |
Returns the largest value plus one classifyPacket() returns.
Implements IQoSClassifier.
{
return 2;
}