INET Framework for OMNeT++/OMNEST
AnsaQosClassifiers.h
Go to the documentation of this file.
00001 //
00002 // Copyright (C) 2011 Martin Danko
00003 //
00004 // This program is free software; you can redistribute it and/or
00005 // modify it under the terms of the GNU General Public License
00006 // as published by the Free Software Foundation; either version 2
00007 // of the License, or (at your option) any later version.
00008 //
00009 // This program is distributed in the hope that it will be useful,
00010 // but WITHOUT ANY WARRANTY; without even the implied warranty of
00011 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00012 // GNU General Public License for more details.
00013 //
00014 // You should have received a copy of the GNU General Public License
00015 // along with this program; if not, write to the Free Software
00016 // Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
00017 //
00018 
00019 
00020 #ifndef __ANSA_QOS_CLASSIFIERS_H
00021 #define __ANSA_QOS_CLASSIFIERS_H
00022 
00023 #include "IPDatagram.h"
00024 #include "TCPSegment.h"
00025 #include "UDPPacket.h"
00026 #include "AclContainerAccess.h"
00027 
00028 namespace ANSAQOS {
00029 
00030 /*
00031  * Trieda reprezentuje tok definovany 6-ticou:
00032  * - zdrojova IP adresa
00033  * - cielova IP adresa
00034  * - transportny protokol
00035  * - IP precedence
00036  * - zdrojovy port
00037  * - cielovy port      
00038  */
00039   
00040 class Flow {
00041 
00042 public:
00043     IPAddress srcAddress;
00044     IPAddress destAddress;
00045     int transportProtocol;
00046     short ipPrec;
00047     int srcPort;
00048     int destPort;
00049     
00050     Flow() {}
00051     Flow(cMessage *msg) {this->parseFromMsg(msg);}
00052 
00053     void parseFromMsg(cMessage *msg);
00054 
00055     bool operator==(const Flow& flow) const;
00056 
00057 };
00058 
00059 /*
00060  * Trieda definuje rozhranie klasifikatora     
00061  */
00062 
00063 class Classifier
00064 {
00065 public:
00066     virtual bool classifyPacket(cMessage *msg) = 0; // rozhodne o klasifikacii
00067     virtual std::string info() = 0; // vrati string pre graficke rozhranie
00068 }; 
00069 
00070 /*
00071  * Trieda klasifikatora pre WFQ frontu na zaklade toku     
00072  */
00073 
00074 class WFQClassifier : public Classifier
00075 {
00076 private: 
00077     Flow flowID;
00078     std::string infoString;
00079         
00080 public:
00081     WFQClassifier(cMessage *msg);   
00082     virtual bool classifyPacket(cMessage *msg);
00083     virtual std::string info() {return infoString;}
00084 };
00085 
00086 /*
00087  * Trieda klasifikatora na zaklade ACL     
00088  */
00089 
00090 class ACLClassifier : public Classifier
00091 {
00092 private: 
00093     std::vector<std::string> acls;
00094     AclContainer* aclAccess;
00095     std::string infoString;     
00096 public:
00097     ACLClassifier(cXMLElement& clsfrConfig);   
00098     virtual bool classifyPacket(cMessage *msg);
00099     virtual std::string info() {return infoString;}
00100 };
00101 
00102 /*
00103  * Trieda klasifikatora na zaklade DSCP     
00104  */
00105 
00106 class DSCPClassifier : public Classifier
00107 {
00108 private: 
00109     std::vector<unsigned char> values;
00110     std::string infoString; 
00111         
00112 public:
00113     DSCPClassifier(cXMLElement& clsfrConfig);
00114     unsigned char readDscp(std::string dscpString);   
00115     virtual bool classifyPacket(cMessage *msg);
00116     virtual std::string info() {return infoString;}
00117 };
00118 
00119 /*
00120  * Trieda klasifikatora na zaklade IP precedence     
00121  */
00122 
00123 class PRECClassifier : public Classifier
00124 {
00125 private: 
00126     std::vector<short> values;
00127     std::string infoString; 
00128         
00129 public:
00130     PRECClassifier(cXMLElement& clsfrConfig);   
00131     virtual bool classifyPacket(cMessage *msg);
00132     virtual std::string info() {return infoString;}
00133 };
00134 
00135 /*
00136  * Trieda klasifikatora, ktory klasifikuje kazdy paket     
00137  */
00138 
00139 class MatchAnyClassifier : public Classifier
00140 {
00141         
00142 public:
00143     virtual bool classifyPacket(cMessage *msg) {return true;}
00144     virtual std::string info() {return "Match any";}
00145 };
00146 
00147 /*
00148  * Trieda klasifikatora, ktory neklasifikuje ziadny paket     
00149  */
00150 
00151 class MatchNoneClassifier : public Classifier
00152 {
00153         
00154 public:
00155     virtual bool classifyPacket(cMessage *msg) {return false;}
00156     virtual std::string info() {return "Match none";}
00157 };
00158 
00159 }
00160 
00161 #endif
00162