22 #include "ns3/packet.h"
25 #include "ns3/udp-header.h"
26 #include "ns3/tcp-header.h"
106 uint32_t *out_flowId, uint32_t *out_packetId)
119 if ((tuple.
protocol != UDP_PROT_NUMBER) && (tuple.
protocol != TCP_PROT_NUMBER))
138 uint16_t srcPort = 0;
143 uint16_t dstPort = 0;
152 std::pair<std::map<FiveTuple, FlowId>::iterator,
bool> insert
153 =
m_flowMap.insert (std::pair<FiveTuple, FlowId> (tuple, 0));
159 insert.first->second = newFlowId;
170 std::pair<std::map<Ipv6Header::DscpType, uint32_t>::iterator,
bool> dscpInserter
171 =
m_flowDscpMap[insert.first->second].insert (std::pair<Ipv6Header::DscpType, uint32_t> (dscp, 1));
174 if (!dscpInserter.second)
179 *out_flowId = insert.first->second;
189 for (std::map<FiveTuple, FlowId>::const_iterator
192 if (iter->second == flowId)
204 std::pair<Ipv6Header::DscpType, uint32_t> right)
206 return left.second > right.second;
209 std::vector<std::pair<Ipv6Header::DscpType, uint32_t> >
212 std::map<FlowId, std::map<Ipv6Header::DscpType, uint32_t> >::const_iterator flow
220 std::vector<std::pair<Ipv6Header::DscpType, uint32_t> > v (flow->second.begin (), flow->second.end ());
228 Indent (os, indent); os <<
"<Ipv6FlowClassifier>\n";
231 for (std::map<FiveTuple, FlowId>::const_iterator
235 os <<
"<Flow flowId=\"" << iter->second <<
"\""
236 <<
" sourceAddress=\"" << iter->first.sourceAddress <<
"\""
237 <<
" destinationAddress=\"" << iter->first.destinationAddress <<
"\""
238 <<
" protocol=\"" << int(iter->first.protocol) <<
"\""
239 <<
" sourcePort=\"" << iter->first.sourcePort <<
"\""
240 <<
" destinationPort=\"" << iter->first.destinationPort <<
"\">\n";
243 std::map<FlowId, std::map<Ipv6Header::DscpType, uint32_t> >::const_iterator flow
248 for (std::map<Ipv6Header::DscpType, uint32_t>::const_iterator i = flow->second.begin (); i != flow->second.end (); i++)
251 os <<
"<Dscp value=\"0x" << std::hex << static_cast<uint32_t> (i->first) <<
"\""
252 <<
" packets=\"" << std::dec << i->second <<
"\" />\n";
257 Indent (os, indent); os <<
"</Flow>\n";
261 Indent (os, indent); os <<
"</Ipv6FlowClassifier>\n";
FiveTuple FindFlow(FlowId flowId) const
Searches for the FiveTuple corresponding to the given flowId.
FlowId GetNewFlowId()
Returns a new, unique Flow Identifier.
DscpType
DiffServ Code Points Code Points defined in Assured Forwarding (AF) RFC 2597 Expedited Forwarding (EF...
Ipv6Address destinationAddress
Destination address.
const uint8_t TCP_PROT_NUMBER
TCP Protocol number.
uint32_t GetSize(void) const
Returns the the size in bytes of the packet (including the zero-filled initial payload).
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 ...
#define NS_FATAL_ERROR(msg)
Report a fatal error with a message and terminate.
void Indent(std::ostream &os, uint16_t level) const
Add a number of spaces for indentation purposes.
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
bool operator<(const EventId &a, const EventId &b)
def indent(source, debug, level)
static Ipv6Address GetZero()
Get the 0 (::) Ipv6Address.
std::map< FlowId, std::map< Ipv6Header::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 operator()(std::pair< Ipv6Header::DscpType, uint32_t > left, std::pair< Ipv6Header::DscpType, uint32_t > right)
Comparator function.
Ipv6Address sourceAddress
Source address.
std::map< FlowId, FlowPacketId > m_flowPktIdMap
Map to FlowIds to FlowPacketId.
Every class exported by the ns3 library is enclosed in the ns3 namespace.
uint8_t protocol
Protocol.
bool IsMulticast() const
If the IPv6 address is multicast (ff00::/8).
const uint8_t UDP_PROT_NUMBER
UDP Protocol number.
bool operator==(const EventId &a, const EventId &b)
uint32_t CopyData(uint8_t *buffer, uint32_t size) const
Copy the packet contents to a byte buffer.
virtual void SerializeToXmlStream(std::ostream &os, uint16_t indent) const
Serializes the results to an std::ostream in XML format.
Comparator used to sort the vector of DSCP values.
uint16_t destinationPort
Destination port.
uint16_t sourcePort
Source port.
Structure to classify a packet.
uint32_t FlowId
Abstract identifier of a packet flow.