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

An example packet classifier based on the UDP/TCP port number. More...

#include <ExampleQoSClassifier.h>

Inheritance diagram for inet::ExampleQoSClassifier:

Public Member Functions

 ExampleQoSClassifier ()
 
virtual void initialize () override
 
virtual void handleMessage (cMessage *msg) override
 

Protected Member Functions

virtual int getUserPriority (cMessage *msg)
 

Detailed Description

An example packet classifier based on the UDP/TCP port number.

Constructor & Destructor Documentation

inet::ExampleQoSClassifier::ExampleQoSClassifier ( )
inline
34 {}

Member Function Documentation

int inet::ExampleQoSClassifier::getUserPriority ( cMessage *  msg)
protectedvirtual

Referenced by handleMessage().

55 {
56  cPacket *ipData = nullptr;
57 
58 #ifdef WITH_IPv4
59  ipData = dynamic_cast<IPv4Datagram *>(msg);
60  if (ipData && dynamic_cast<ICMPMessage *>(ipData->getEncapsulatedPacket()))
61  return UP_BE; // ICMP class
62 #endif
63 
64 #ifdef WITH_IPv6
65  if (!ipData) {
66  ipData = dynamic_cast<IPv6Datagram *>(msg);
67  if (ipData && dynamic_cast<ICMPv6Message *>(ipData->getEncapsulatedPacket()))
68  return UP_BE; // ICMPv6 class
69  }
70 #endif
71 
72  if (!ipData)
73  return UP_BE;
74 
75 #ifdef WITH_UDP
76  UDPPacket *udp = dynamic_cast<UDPPacket *>(ipData->getEncapsulatedPacket());
77  if (udp) {
78  if (udp->getDestinationPort() == 21 || udp->getSourcePort() == 21)
79  return UP_BK;
80  if (udp->getDestinationPort() == 80 || udp->getSourcePort() == 80)
81  return UP_BE;
82  if (udp->getDestinationPort() == 4000 || udp->getSourcePort() == 4000)
83  return UP_VI;
84  if (udp->getDestinationPort() == 5000 || udp->getSourcePort() == 5000)
85  return UP_VO;
86  if (udp->getDestinationPort() == 6000 || udp->getSourcePort() == 6000) // not classified
87  return -1;
88  }
89 #endif
90 
91 #ifdef WITH_TCP_COMMON
92  tcp::TCPSegment *tcp = dynamic_cast<tcp::TCPSegment *>(ipData->getEncapsulatedPacket());
93  if (tcp) {
94  if (tcp->getDestPort() == 21 || tcp->getSrcPort() == 21)
95  return UP_BK;
96  if (tcp->getDestPort() == 80 || tcp->getSrcPort() == 80)
97  return UP_BE;
98  if (tcp->getDestPort() == 4000 || tcp->getSrcPort() == 4000)
99  return UP_VI;
100  if (tcp->getDestPort() == 5000 || tcp->getSrcPort() == 5000)
101  return UP_VO;
102  if (tcp->getDestinationPort() == 6000 || tcp->getSourcePort() == 6000) // not classified
103  return -1;
104  }
105 #endif
106 
107  return UP_BE;
108 }
Definition: UserPriority.h:33
Definition: UserPriority.h:31
Definition: UserPriority.h:36
Definition: UserPriority.h:37
void inet::ExampleQoSClassifier::handleMessage ( cMessage *  msg)
overridevirtual
47 {
48  Ieee802Ctrl *ctrl = check_and_cast<Ieee802Ctrl*>(msg->getControlInfo());
49  int userPriority = getUserPriority(msg);
50  ctrl->setUserPriority(userPriority);
51  send(msg, "out");
52 }
virtual int getUserPriority(cMessage *msg)
Definition: ExampleQoSClassifier.cc:54
void inet::ExampleQoSClassifier::initialize ( )
overridevirtual
42 {
43  //TODO parameters
44 }

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