11#include "ns3/packet.h"
12#include "ns3/tcp-header.h"
13#include "ns3/udp-header.h"
27 if (
t1.sourceAddress <
t2.sourceAddress)
31 if (
t1.sourceAddress !=
t2.sourceAddress)
36 if (
t1.destinationAddress <
t2.destinationAddress)
40 if (
t1.destinationAddress !=
t2.destinationAddress)
45 if (
t1.protocol <
t2.protocol)
49 if (
t1.protocol !=
t2.protocol)
54 if (
t1.sourcePort <
t2.sourcePort)
58 if (
t1.sourcePort !=
t2.sourcePort)
63 if (
t1.destinationPort <
t2.destinationPort)
67 if (
t1.destinationPort !=
t2.destinationPort)
78 return (
t1.sourceAddress ==
t2.sourceAddress &&
79 t1.destinationAddress ==
t2.destinationAddress &&
t1.protocol ==
t2.protocol &&
80 t1.sourcePort ==
t2.sourcePort &&
t1.destinationPort ==
t2.destinationPort);
93 if (
ipHeader.GetFragmentOffset() > 0)
137 auto insert =
m_flowMap.insert(std::pair<FiveTuple, FlowId>(
tuple, 0));
155 std::pair<Ipv4Header::DscpType, uint32_t>(
dscp, 1));
174 if (
iter->second == flowId)
186 std::pair<Ipv4Header::DscpType, uint32_t>
right)
191std::vector<std::pair<Ipv4Header::DscpType, uint32_t>>
201 std::vector<std::pair<Ipv4Header::DscpType, uint32_t>> v(
flow->second.begin(),
211 os <<
"<Ipv4FlowClassifier>\n";
217 os <<
"<Flow flowId=\"" <<
iter->second <<
"\""
218 <<
" sourceAddress=\"" <<
iter->first.sourceAddress <<
"\""
219 <<
" destinationAddress=\"" <<
iter->first.destinationAddress <<
"\""
220 <<
" protocol=\"" << int(
iter->first.protocol) <<
"\""
221 <<
" sourcePort=\"" <<
iter->first.sourcePort <<
"\""
222 <<
" destinationPort=\"" <<
iter->first.destinationPort <<
"\">\n";
229 for (
auto i =
flow->second.begin();
i !=
flow->second.end();
i++)
232 os <<
"<Dscp value=\"0x" << std::hex << static_cast<uint32_t>(
i->first) <<
"\""
233 <<
" packets=\"" << std::dec <<
i->second <<
"\" />\n";
244 os <<
"</Ipv4FlowClassifier>\n";
FlowId GetNewFlowId()
Returns a new, unique Flow Identifier.
static Ipv4Address GetZero()
Comparator used to sort the vector of DSCP values.
bool operator()(std::pair< Ipv4Header::DscpType, uint32_t > left, std::pair< Ipv4Header::DscpType, uint32_t > right)
Comparator function.
std::map< FlowId, FlowPacketId > m_flowPktIdMap
Map to FlowIds to FlowPacketId.
void SerializeToXmlStream(std::ostream &os, uint16_t indent) const override
Serializes the results to an std::ostream in XML format.
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 ...
FiveTuple FindFlow(FlowId flowId) const
Searches for the FiveTuple corresponding to the given flowId.
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.
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
Smart pointer class similar to boost::intrusive_ptr.
#define NS_FATAL_ERROR(msg)
Report a fatal error with a message and terminate.
Ptr< T > Create(Ts &&... args)
Create class instances by constructors with varying numbers of arguments and return them by Ptr.
Every class exported by the ns3 library is enclosed in the ns3 namespace.
const uint8_t TCP_PROT_NUMBER
TCP Protocol number.
bool operator==(const EventId &a, const EventId &b)
bool operator<(const EventId &a, const EventId &b)
const uint8_t UDP_PROT_NUMBER
UDP Protocol number.
Helper to indent output a specified number of steps.
Structure to classify a packet.
Ipv4Address sourceAddress
Source address.