23#include "ns3/packet.h"
24#include "ns3/tcp-header.h"
25#include "ns3/udp-header.h"
121 if (ipPayload->GetSize() < 4)
133 ipPayload->CopyData(
data, 4);
135 uint16_t srcPort = 0;
140 uint16_t dstPort = 0;
149 std::pair<std::map<FiveTuple, FlowId>::iterator,
bool> insert =
150 m_flowMap.insert(std::pair<FiveTuple, FlowId>(tuple, 0));
156 insert.first->second = newFlowId;
167 std::pair<std::map<Ipv6Header::DscpType, uint32_t>::iterator,
bool> dscpInserter =
169 std::pair<Ipv6Header::DscpType, uint32_t>(dscp, 1));
172 if (!dscpInserter.second)
177 *out_flowId = insert.first->second;
186 for (std::map<FiveTuple, FlowId>::const_iterator iter =
m_flowMap.begin();
190 if (iter->second == flowId)
202 std::pair<Ipv6Header::DscpType, uint32_t> right)
204 return left.second > right.second;
207std::vector<std::pair<Ipv6Header::DscpType, uint32_t>>
210 std::map<FlowId, std::map<Ipv6Header::DscpType, uint32_t>>::const_iterator flow =
218 std::vector<std::pair<Ipv6Header::DscpType, uint32_t>> v(flow->second.begin(),
228 os <<
"<Ipv6FlowClassifier>\n";
231 for (std::map<FiveTuple, FlowId>::const_iterator iter =
m_flowMap.begin();
236 os <<
"<Flow flowId=\"" << iter->second <<
"\""
237 <<
" sourceAddress=\"" << iter->first.sourceAddress <<
"\""
238 <<
" destinationAddress=\"" << iter->first.destinationAddress <<
"\""
239 <<
" protocol=\"" << int(iter->first.protocol) <<
"\""
240 <<
" sourcePort=\"" << iter->first.sourcePort <<
"\""
241 <<
" destinationPort=\"" << iter->first.destinationPort <<
"\">\n";
244 std::map<FlowId, std::map<Ipv6Header::DscpType, uint32_t>>::const_iterator flow =
249 for (std::map<Ipv6Header::DscpType, uint32_t>::const_iterator i = flow->second.begin();
250 i != flow->second.end();
254 os <<
"<Dscp value=\"0x" << std::hex << static_cast<uint32_t>(i->first) <<
"\""
255 <<
" packets=\"" << std::dec << i->second <<
"\" />\n";
266 os <<
"</Ipv6FlowClassifier>\n";
FlowId GetNewFlowId()
Returns a new, unique Flow Identifier.
static Ipv6Address GetZero()
Get the 0 (::) Ipv6Address.
bool IsMulticast() const
If the IPv6 address is multicast (ff00::/8).
Comparator used to sort the vector of DSCP values.
bool operator()(std::pair< Ipv6Header::DscpType, uint32_t > left, std::pair< Ipv6Header::DscpType, uint32_t > right)
Comparator function.
std::map< FiveTuple, FlowId > m_flowMap
Map to Flows Identifiers to FlowIds.
void SerializeToXmlStream(std::ostream &os, uint16_t indent) const override
Serializes the results to an std::ostream in XML format.
std::vector< std::pair< Ipv6Header::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.
bool Classify(const Ipv6Header &ipHeader, Ptr< const Packet > ipPayload, uint32_t *out_flowId, uint32_t *out_packetId)
try to classify the packet into flow-id and packet-id
std::map< FlowId, FlowPacketId > m_flowPktIdMap
Map to FlowIds to FlowPacketId.
std::map< FlowId, std::map< Ipv6Header::DscpType, uint32_t > > m_flowDscpMap
Map FlowIds to (DSCP value, packet count) pairs.
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.
Helper to indent output a specified number of steps.
Structure to classify a packet.
uint16_t destinationPort
Destination port.
Ipv6Address destinationAddress
Destination address.
uint16_t sourcePort
Source port.
uint8_t protocol
Protocol.
Ipv6Address sourceAddress
Source address.