11#include "ns3/packet.h"
12#include "ns3/tcp-header.h"
13#include "ns3/udp-header.h"
109 if (ipPayload->GetSize() < 4)
121 ipPayload->CopyData(
data, 4);
123 uint16_t srcPort = 0;
128 uint16_t dstPort = 0;
137 auto insert =
m_flowMap.insert(std::pair<FiveTuple, FlowId>(tuple, 0));
143 insert.first->second = newFlowId;
154 auto dscpInserter =
m_flowDscpMap[insert.first->second].insert(
155 std::pair<Ipv4Header::DscpType, uint32_t>(dscp, 1));
158 if (!dscpInserter.second)
163 *out_flowId = insert.first->second;
174 if (iter->second == flowId)
186 std::pair<Ipv4Header::DscpType, uint32_t> right)
188 return left.second > right.second;
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";
void Indent(std::ostream &os, uint16_t level) const
Add a number of spaces for indentation purposes.
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.
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.
Structure to classify a packet.
uint16_t destinationPort
Destination port.
Ipv4Address sourceAddress
Source address.
Ipv4Address destinationAddress
Destination address.
uint8_t protocol
Protocol.
uint16_t sourcePort
Source port.