22 #include "ns3/packet.h"
23 #include "ns3/tcp-header.h"
24 #include "ns3/udp-header.h"
101 uint32_t* out_flowId,
102 uint32_t* out_packetId)
134 uint16_t srcPort = 0;
139 uint16_t dstPort = 0;
148 auto insert =
m_flowMap.insert(std::pair<FiveTuple, FlowId>(tuple, 0));
154 insert.first->second = newFlowId;
165 auto dscpInserter =
m_flowDscpMap[insert.first->second].insert(
166 std::pair<Ipv4Header::DscpType, uint32_t>(dscp, 1));
169 if (!dscpInserter.second)
174 *out_flowId = insert.first->second;
185 if (iter->second == flowId)
197 std::pair<Ipv4Header::DscpType, uint32_t> right)
199 return left.second > right.second;
202 std::vector<std::pair<Ipv4Header::DscpType, uint32_t>>
212 std::vector<std::pair<Ipv4Header::DscpType, uint32_t>> v(flow->second.begin(),
222 os <<
"<Ipv4FlowClassifier>\n";
228 os <<
"<Flow flowId=\"" << iter->second <<
"\""
229 <<
" sourceAddress=\"" << iter->first.sourceAddress <<
"\""
230 <<
" destinationAddress=\"" << iter->first.destinationAddress <<
"\""
231 <<
" protocol=\"" << int(iter->first.protocol) <<
"\""
232 <<
" sourcePort=\"" << iter->first.sourcePort <<
"\""
233 <<
" destinationPort=\"" << iter->first.destinationPort <<
"\">\n";
240 for (
auto i = flow->second.begin(); i != flow->second.end(); i++)
243 os <<
"<Dscp value=\"0x" << std::hex << static_cast<uint32_t>(i->first) <<
"\""
244 <<
" packets=\"" << std::dec << i->second <<
"\" />\n";
255 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
uint32_t GetSize() const
Returns the the size in bytes of the packet (including the zero-filled initial payload).
uint32_t CopyData(uint8_t *buffer, uint32_t size) const
Copy the packet contents to a byte buffer.
#define NS_FATAL_ERROR(msg)
Report a fatal error with a message and terminate.
uint32_t FlowId
Abstract identifier of a packet flow.
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.