21 #include "ns3/packet.h"
24 #include "ns3/udp-header.h"
25 #include "ns3/tcp-header.h"
105 uint32_t *out_flowId, uint32_t *out_packetId)
137 uint16_t srcPort = 0;
142 uint16_t dstPort = 0;
151 std::pair<std::map<FiveTuple, FlowId>::iterator,
bool> insert
152 =
m_flowMap.insert (std::pair<FiveTuple, FlowId> (tuple, 0));
158 insert.first->second = newFlowId;
169 std::pair<std::map<Ipv4Header::DscpType, uint32_t>::iterator,
bool> dscpInserter
170 =
m_flowDscpMap[insert.first->second].insert (std::pair<Ipv4Header::DscpType, uint32_t> (dscp, 1));
173 if (!dscpInserter.second)
178 *out_flowId = insert.first->second;
188 for (std::map<FiveTuple, FlowId>::const_iterator
191 if (iter->second == flowId)
203 std::pair<Ipv4Header::DscpType, uint32_t> right)
205 return left.second > right.second;
208 std::vector<std::pair<Ipv4Header::DscpType, uint32_t> >
211 std::map<FlowId, std::map<Ipv4Header::DscpType, uint32_t> >::const_iterator flow
219 std::vector<std::pair<Ipv4Header::DscpType, uint32_t> > v (flow->second.begin (), flow->second.end ());
230 for (std::map<FiveTuple, FlowId>::const_iterator
234 os <<
"<Flow flowId=\"" << iter->second <<
"\""
235 <<
" sourceAddress=\"" << iter->first.sourceAddress <<
"\""
236 <<
" destinationAddress=\"" << iter->first.destinationAddress <<
"\""
237 <<
" protocol=\"" << int(iter->first.protocol) <<
"\""
238 <<
" sourcePort=\"" << iter->first.sourcePort <<
"\""
239 <<
" destinationPort=\"" << iter->first.destinationPort <<
"\">\n";
242 std::map<FlowId, std::map<Ipv4Header::DscpType, uint32_t> >::const_iterator flow
247 for (std::map<Ipv4Header::DscpType, uint32_t>::const_iterator i = flow->second.begin (); i != flow->second.end (); i++)
250 os <<
"<Dscp value=\"0x" << std::hex << static_cast<uint32_t> (i->first) <<
"\""
251 <<
" packets=\"" << std::dec << i->second <<
"\" />\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(void)
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.
virtual void SerializeToXmlStream(std::ostream &os, uint16_t indent) const
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 CopyData(uint8_t *buffer, uint32_t size) const
Copy the packet contents to a byte buffer.
uint32_t GetSize(void) const
Returns the the size in bytes of the packet (including the zero-filled initial payload).
#define NS_FATAL_ERROR(msg)
Report a fatal error with a message and terminate.
uint32_t FlowId
Abstract identifier of a packet flow.
def indent(source, debug, level)
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.