|
INET Framework for OMNeT++/OMNEST
|
This module classifies and assigns User Priority to packets.
More...
#include <QosClassifier.h>
This module classifies and assigns User Priority to packets.
◆ QosClassifier()
| inet::QosClassifier::QosClassifier |
( |
| ) |
|
|
inline |
◆ getUserPriority()
| int inet::QosClassifier::getUserPriority |
( |
cMessage * |
msg | ) |
|
|
protectedvirtual |
96 #if defined(INET_WITH_ETHERNET) || defined(INET_WITH_IPv4) || defined(INET_WITH_IPv6) || defined(INET_WITH_UDP) || defined(INET_WITH_TCP_COMMON)
97 auto packet = check_and_cast<Packet *>(msg);
99 int ethernetMacProtocol = -1;
100 b ethernetMacHeaderLength =
b(0);
101 b ipHeaderLength =
b(-1);
104 #ifdef INET_WITH_ETHERNET
106 const auto& ethernetMacHeader = packet->peekAtFront<EthernetMacHeader>();
107 ethernetMacProtocol = ethernetMacHeader->getTypeOrLength();
108 ethernetMacHeaderLength = ethernetMacHeader->getChunkLength();
112 #ifdef INET_WITH_IPv4
114 const auto& ipv4Header = packet->peekDataAt<Ipv4Header>(ethernetMacHeaderLength);
115 ipProtocol = ipv4Header->getProtocolId();
116 ipHeaderLength = ipv4Header->getChunkLength();
120 #ifdef INET_WITH_IPv6
122 const auto& ipv6Header = packet->peekDataAt<Ipv6Header>(ethernetMacHeaderLength);
123 ipProtocol = ipv6Header->getProtocolId();
124 ipHeaderLength = ipv6Header->getChunkLength();
128 if (ipProtocol == -1)
136 const auto& udpHeader = packet->peekDataAt<UdpHeader>(ethernetMacHeaderLength + ipHeaderLength);
137 unsigned int srcPort = udpHeader->getSourcePort();
138 unsigned int destPort = udpHeader->getDestinationPort();
148 #ifdef INET_WITH_TCP_COMMON
150 const auto& tcpHeader = packet->peekDataAt<tcp::TcpHeader>(ethernetMacHeaderLength + ipHeaderLength);
151 unsigned int srcPort = tcpHeader->getSourcePort();
152 unsigned int destPort = tcpHeader->getDestinationPort();
Referenced by handleMessage().
◆ handleMessage()
| void inet::QosClassifier::handleMessage |
( |
cMessage * |
msg | ) |
|
|
overridevirtual |
51 auto packet = check_and_cast<Packet *>(msg);
52 packet->addTagIfAbsent<UserPriorityReq>()->setUserPriority(
getUserPriority(msg));
◆ handleRegisterProtocol()
| void inet::QosClassifier::handleRegisterProtocol |
( |
const Protocol & |
protocol, |
|
|
cGate * |
gate, |
|
|
ServicePrimitive |
servicePrimitive |
|
) |
| |
|
overrideprotectedvirtual |
◆ handleRegisterService()
| void inet::QosClassifier::handleRegisterService |
( |
const Protocol & |
protocol, |
|
|
cGate * |
gate, |
|
|
ServicePrimitive |
servicePrimitive |
|
) |
| |
|
overrideprotectedvirtual |
◆ initialize()
| void inet::QosClassifier::initialize |
( |
int |
stage | ) |
|
|
overridevirtual |
◆ numInitStages()
| virtual int inet::QosClassifier::numInitStages |
( |
| ) |
const |
|
inlineoverridevirtual |
◆ parseUserPriority()
| int inet::QosClassifier::parseUserPriority |
( |
const char * |
text | ) |
|
|
protectedvirtual |
58 if (!strcmp(text,
"BE"))
60 else if (!strcmp(text,
"BK"))
62 else if (!strcmp(text,
"BK2"))
64 else if (!strcmp(text,
"EE"))
66 else if (!strcmp(text,
"CL"))
68 else if (!strcmp(text,
"VI"))
70 else if (!strcmp(text,
"VO"))
72 else if (!strcmp(text,
"NC"))
75 throw cRuntimeError(
"Unknown user priority: '%s'", text);
Referenced by initialize(), and parseUserPriorityMap().
◆ parseUserPriorityMap()
| void inet::QosClassifier::parseUserPriorityMap |
( |
const char * |
text, |
|
|
std::map< int, int > & |
upMap |
|
) |
| |
|
protectedvirtual |
80 cStringTokenizer tokenizer(text);
81 while (tokenizer.hasMoreTokens()) {
82 const char *keyString = tokenizer.nextToken();
83 const char *upString = tokenizer.nextToken();
84 if (!keyString || !upString)
85 throw cRuntimeError(
"Insufficient number of values in: '%s'", text);
86 int key = std::atoi(keyString);
88 upMap.insert(std::pair<int, int>(key,
up));
Referenced by initialize().
◆ defaultUp
| int inet::QosClassifier::defaultUp |
|
protected |
◆ ipProtocolUpMap
| std::map<int, int> inet::QosClassifier::ipProtocolUpMap |
|
protected |
◆ tcpPortUpMap
| std::map<int, int> inet::QosClassifier::tcpPortUpMap |
|
protected |
◆ udpPortUpMap
| std::map<int, int> inet::QosClassifier::udpPortUpMap |
|
protected |
The documentation for this class was generated from the following files:
std::map< int, int > tcpPortUpMap
Definition: QosClassifier.h:24
removed DscpReq Ipv4ControlInfo Ipv6ControlInfo up L3AddressInd DispatchProtocolReq L4PortInd Ipv4ControlInfo Ipv6ControlInfo down protocol
Definition: IUdp-gates.txt:25
int defaultUp
Definition: QosClassifier.h:21
static const Protocol ipv4
Definition: Protocol.h:93
@ UP_BE
Definition: UserPriority.h:21
static const Protocol ipv6
Definition: Protocol.h:94
@ UP_BK
Definition: UserPriority.h:19
@ UP_CL
Definition: UserPriority.h:23
void registerService(const Protocol &protocol, cGate *gate, ServicePrimitive servicePrimitive)
Registers a service primitive (SDU processing) at the given gate.
Definition: IProtocolRegistrationListener.cc:14
virtual int parseUserPriority(const char *text)
Definition: QosClassifier.cc:56
removed DscpReq Ipv4ControlInfo Ipv6ControlInfo up L3AddressInd DispatchProtocolReq L4PortInd Ipv4ControlInfo Ipv6ControlInfo down PacketProtocolTag
Definition: IUdp-gates.txt:25
milli< kg >::type g
Definition: Units.h:1071
@ IP_PROT_UDP
Definition: IpProtocolId_m.h:97
if(cwndVector) cwndVector -> record(state->snd_cwnd)
static const Protocol ethernetMac
Definition: Protocol.h:65
#define INET_WITH_UDP
Definition: features.h:193
@ UP_EE
Definition: UserPriority.h:22
INET_API InitStage INITSTAGE_LOCAL
Initialization of local state that don't use or affect other modules includes:
value< int64_t, units::b > b
Definition: Units.h:1241
#define NUM_INIT_STAGES
Definition: InitStageRegistry.h:73
@ UP_VI
Definition: UserPriority.h:24
@ IP_PROT_TCP
Definition: IpProtocolId_m.h:94
#define Enter_Method(...)
Definition: SelfDoc.h:71
virtual int getUserPriority(cMessage *msg)
Definition: QosClassifier.cc:92
@ UP_NC
Definition: UserPriority.h:26
@ ETHERTYPE_IPv4
Definition: EtherType_m.h:77
@ UP_BK2
Definition: UserPriority.h:20
void registerProtocol(const Protocol &protocol, cGate *gate, ServicePrimitive servicePrimitive)
Registers a protocol primitive (PDU processing) at the given gate.
Definition: IProtocolRegistrationListener.cc:83
virtual void parseUserPriorityMap(const char *text, std::map< int, int > &upMap)
Definition: QosClassifier.cc:78
std::map< int, int > udpPortUpMap
Definition: QosClassifier.h:23
@ UP_VO
Definition: UserPriority.h:25
std::map< int, int > ipProtocolUpMap
Definition: QosClassifier.h:22
removed DscpReq Ipv4ControlInfo up
Definition: IUdp-gates.txt:14
@ ETHERTYPE_IPv6
Definition: EtherType_m.h:87