Permalink
Browse files

ieee802.11: classifier now puts mgmnt frames correctly to class 3. De…

…fault class is 0 otherwise.
  • Loading branch information...
1 parent 65502e5 commit 5f3818b71e0e2d5902c3e833374be2977a3de34b @rhornig rhornig committed Feb 23, 2012
@@ -38,11 +38,10 @@
Register_Class(Ieee80211eClassifier);
-#define DEFAULT 3
-
Ieee80211eClassifier::Ieee80211eClassifier()
{
- defaultAC = DEFAULT;
+ defaultAC = 0;
+ defaultManagement = 3;
}
@@ -56,46 +55,54 @@ int Ieee80211eClassifier::classifyPacket(cMessage *frame)
ASSERT(check_and_cast<Ieee80211DataOrMgmtFrame *>(frame));
cPacket *ipData = NULL; // must be initialized in case neither IPv4 nor IPv6 is present
+ // if this is a management type, use a pre-configured default class
+ if (dynamic_cast<Ieee80211ManagementFrame *>(frame))
+ return defaultManagement;
+
+ // we have a data packet
+ cPacket *encapsulatedNetworkPacket = PK(frame)->getEncapsulatedPacket();
+ ASSERT(encapsulatedNetworkPacket); // frame must contain an encapsulated network data frame
+
#ifdef WITH_IPv4
- ipData = dynamic_cast<IPv4Datagram *>(PK(frame)->getEncapsulatedPacket());
+ ipData = dynamic_cast<IPv4Datagram *>(encapsulatedNetworkPacket);
if (ipData && dynamic_cast<ICMPMessage *>(ipData->getEncapsulatedPacket()))
return 1; // ICMP class
#endif
#ifdef WITH_IPv6
if (!ipData) {
- ipData = dynamic_cast<IPv6Datagram *>(PK(frame)->getEncapsulatedPacket());
+ ipData = dynamic_cast<IPv6Datagram *>(encapsulatedNetworkPacket);
if (ipData && dynamic_cast<ICMPv6Message *>(ipData->getEncapsulatedPacket()))
return 1; // ICMPv6 class
}
#endif
if (!ipData)
- return defaultAC; // neither IPv4 nor IPv6 packet = default
+ return defaultAC; // neither IPv4 nor IPv6 packet (unknown protocol) = default AC
#ifdef WITH_UDP
UDPPacket *udp = dynamic_cast<UDPPacket *>(ipData->getEncapsulatedPacket());
if (udp)
{
- if (udp->getDestinationPort() == 5000 || udp->getSourcePort() == 5000) //voice
- return 3;
- if (udp->getDestinationPort() == 4000 || udp->getSourcePort() == 4000) //video
- return 2;
- if (udp->getDestinationPort() == 80 || udp->getSourcePort() == 80) //voice
- return 1;
- if (udp->getDestinationPort() == 21 || udp->getSourcePort() == 21) //voice
+ if (udp->getDestinationPort() == 21 || udp->getSourcePort() == 21)
return 0;
+ if (udp->getDestinationPort() == 80 || udp->getSourcePort() == 80)
+ return 1;
+ if (udp->getDestinationPort() == 4000 || udp->getSourcePort() == 4000)
+ return 2;
+ if (udp->getDestinationPort() == 5000 || udp->getSourcePort() == 5000)
+ return 3;
}
#endif
#ifdef WITH_TCP_COMMON
TCPSegment *tcp = dynamic_cast<TCPSegment *>(ipData->getEncapsulatedPacket());
if (tcp)
{
- if (tcp->getDestPort() == 80 || tcp->getSrcPort() == 80)
- return 1;
if (tcp->getDestPort() == 21 || tcp->getSrcPort() == 21)
return 0;
+ if (tcp->getDestPort() == 80 || tcp->getSrcPort() == 80)
+ return 1;
if (tcp->getDestPort() == 4000 || tcp->getSrcPort() == 4000)
return 2;
if (tcp->getDestPort() == 5000 || tcp->getSrcPort() == 5000)
@@ -106,4 +113,3 @@ int Ieee80211eClassifier::classifyPacket(cMessage *frame)
return defaultAC;
}
-
@@ -22,22 +22,27 @@
#include "IQoSClassifier.h"
/**
- * 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.
+ * An example packet classifier based on the UDP/TCP port number.
+ * Access point management frames are classified into the 'defaultManagement' class (3 by default).
+ * ICMP messages are classified to: 1
+ * Traffic on TCP/UDP port 21: class 0
+ * Traffic on TCP/UDP port 80: class 1
+ * Traffic on TCP/UDP port 4000: class 2
+ * Traffic on TCP/UDP port 5000: class 3
+ * All other traffic is classified as 'defaultAC' (0 by default)
*/
class INET_API Ieee80211eClassifier : public IQoSClassifier
{
private:
int defaultAC;
+ int defaultManagement;
public:
- /**
- * Returns the largest value plus one classifyPacket() returns.
- */
Ieee80211eClassifier();
virtual int getNumQueues();
virtual void setDefaultClass(int i) { defaultAC = i; }
virtual int getDefaultClass() { return defaultAC; }
+ virtual void setDefaultManagementClass(int i) { defaultManagement = i; }
+ virtual int getDefaultManagementClass() { return defaultManagement; }
/**
* The method should return the priority (the index of subqueue)

0 comments on commit 5f3818b

Please sign in to comment.