Classifies packets by looking at their IP and TCP/UDP headers. More...
#include "ipv4-flow-classifier.h"
Classes | |
struct | FiveTuple |
Structure to classify a packet. More... | |
class | SortByCount |
Comparator used to sort the vector of DSCP values. More... | |
Public Member Functions | |
Ipv4FlowClassifier () | |
bool | Classify (const Ipv4Header &ipHeader, Ptr< const Packet > ipPayload, uint32_t *out_flowId, uint32_t *out_packetId) |
try to classify the packet into flow-id and packet-id | |
FiveTuple | FindFlow (FlowId flowId) const |
Searches for the FiveTuple corresponding to the given flowId. | |
std::vector< std::pair< Ipv4Header::DscpType, uint32_t > > | GetDscpCounts (FlowId flowId) const |
get the DSCP values of the packets belonging to the flow with the given FlowId, sorted in decreasing order of number of packets seen with that DSCP value | |
void | SerializeToXmlStream (std::ostream &os, uint16_t indent) const override |
Serializes the results to an std::ostream in XML format. | |
Public Member Functions inherited from ns3::FlowClassifier | |
FlowClassifier () | |
FlowClassifier (const FlowClassifier &)=delete | |
virtual | ~FlowClassifier () |
FlowClassifier & | operator= (const FlowClassifier &)=delete |
Public Member Functions inherited from ns3::SimpleRefCount< FlowClassifier > | |
SimpleRefCount () | |
Default constructor. | |
SimpleRefCount (const SimpleRefCount &o) | |
Copy constructor. | |
uint32_t | GetReferenceCount () const |
Get the reference count of the object. | |
SimpleRefCount & | operator= (const SimpleRefCount &o) |
Assignment operator. | |
void | Ref () const |
Increment the reference count. | |
void | Unref () const |
Decrement the reference count. | |
Private Attributes | |
std::map< FlowId, std::map< Ipv4Header::DscpType, uint32_t > > | m_flowDscpMap |
Map FlowIds to (DSCP value, packet count) pairs. | |
std::map< FiveTuple, FlowId > | m_flowMap |
Map to Flows Identifiers to FlowIds. | |
std::map< FlowId, FlowPacketId > | m_flowPktIdMap |
Map to FlowIds to FlowPacketId. | |
Additional Inherited Members | |
Protected Member Functions inherited from ns3::FlowClassifier | |
FlowId | GetNewFlowId () |
Returns a new, unique Flow Identifier. | |
void | Indent (std::ostream &os, uint16_t level) const |
Add a number of spaces for indentation purposes. | |
Classifies packets by looking at their IP and TCP/UDP headers.
From these packet headers, a tuple (source-ip, destination-ip, protocol, source-port, destination-port) is created, and a unique flow identifier is assigned for each different tuple combination
Definition at line 28 of file ipv4-flow-classifier.h.
ns3::Ipv4FlowClassifier::Ipv4FlowClassifier | ( | ) |
Definition at line 83 of file ipv4-flow-classifier.cc.
bool ns3::Ipv4FlowClassifier::Classify | ( | const Ipv4Header & | ipHeader, |
Ptr< const Packet > | ipPayload, | ||
uint32_t * | out_flowId, | ||
uint32_t * | out_packetId ) |
try to classify the packet into flow-id and packet-id
ipHeader | packet's IP header |
ipPayload | packet's IP payload |
out_flowId | packet's FlowId |
out_packetId | packet's identifier |
Definition at line 88 of file ipv4-flow-classifier.cc.
References data, ns3::Ipv4FlowClassifier::FiveTuple::destinationAddress, ns3::Ipv4FlowClassifier::FiveTuple::destinationPort, ns3::Ipv4Header::GetDestination(), ns3::Ipv4Header::GetDscp(), ns3::Ipv4Header::GetFragmentOffset(), ns3::FlowClassifier::GetNewFlowId(), ns3::Ipv4Header::GetProtocol(), ns3::Ipv4Header::GetSource(), m_flowDscpMap, m_flowMap, m_flowPktIdMap, ns3::Ipv4FlowClassifier::FiveTuple::protocol, ns3::Ipv4FlowClassifier::FiveTuple::sourceAddress, ns3::Ipv4FlowClassifier::FiveTuple::sourcePort, ns3::TCP_PROT_NUMBER, and ns3::UDP_PROT_NUMBER.
Ipv4FlowClassifier::FiveTuple ns3::Ipv4FlowClassifier::FindFlow | ( | FlowId | flowId | ) | const |
Searches for the FiveTuple corresponding to the given flowId.
flowId | the FlowId to search for |
Definition at line 170 of file ipv4-flow-classifier.cc.
References ns3::Ipv4Address::GetZero(), m_flowMap, and NS_FATAL_ERROR.
std::vector< std::pair< Ipv4Header::DscpType, uint32_t > > ns3::Ipv4FlowClassifier::GetDscpCounts | ( | FlowId | flowId | ) | const |
get the DSCP values of the packets belonging to the flow with the given FlowId, sorted in decreasing order of number of packets seen with that DSCP value
flowId | the identifier of the flow of interest |
Definition at line 192 of file ipv4-flow-classifier.cc.
References m_flowDscpMap, and NS_FATAL_ERROR.
|
overridevirtual |
Serializes the results to an std::ostream in XML format.
os | the output stream |
indent | number of spaces to use as base indentation level |
Implements ns3::FlowClassifier.
Definition at line 208 of file ipv4-flow-classifier.cc.
References ns3::FlowClassifier::Indent(), m_flowDscpMap, and m_flowMap.
|
private |
Map FlowIds to (DSCP value, packet count) pairs.
Definition at line 90 of file ipv4-flow-classifier.h.
Referenced by Classify(), GetDscpCounts(), and SerializeToXmlStream().
Map to Flows Identifiers to FlowIds.
Definition at line 86 of file ipv4-flow-classifier.h.
Referenced by Classify(), FindFlow(), and SerializeToXmlStream().
|
private |
Map to FlowIds to FlowPacketId.
Definition at line 88 of file ipv4-flow-classifier.h.
Referenced by Classify().