A Discrete-Event Network Simulator
API
ipv4-flow-classifier.h
Go to the documentation of this file.
1 //
2 // Copyright (c) 2009 INESC Porto
3 //
4 // This program is free software; you can redistribute it and/or modify
5 // it under the terms of the GNU General Public License version 2 as
6 // published by the Free Software Foundation;
7 //
8 // This program is distributed in the hope that it will be useful,
9 // but WITHOUT ANY WARRANTY; without even the implied warranty of
10 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 // GNU General Public License for more details.
12 //
13 // You should have received a copy of the GNU General Public License
14 // along with this program; if not, write to the Free Software
15 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
16 //
17 // Author: Gustavo J. A. M. Carneiro <gjc@inescporto.pt> <gjcarneiro@gmail.com>
18 //
19 
20 #ifndef IPV4_FLOW_CLASSIFIER_H
21 #define IPV4_FLOW_CLASSIFIER_H
22 
23 #include "flow-classifier.h"
24 
25 #include "ns3/ipv4-header.h"
26 
27 #include <map>
28 #include <stdint.h>
29 
30 namespace ns3
31 {
32 
33 class Packet;
34 
40 {
41  public:
43  struct FiveTuple
44  {
47  uint8_t protocol;
48  uint16_t sourcePort;
49  uint16_t destinationPort;
50  };
51 
53 
64  bool Classify(const Ipv4Header& ipHeader,
65  Ptr<const Packet> ipPayload,
66  uint32_t* out_flowId,
67  uint32_t* out_packetId);
68 
72  FiveTuple FindFlow(FlowId flowId) const;
73 
76  {
77  public:
82  bool operator()(std::pair<Ipv4Header::DscpType, uint32_t> left,
83  std::pair<Ipv4Header::DscpType, uint32_t> right);
84  };
85 
91  std::vector<std::pair<Ipv4Header::DscpType, uint32_t>> GetDscpCounts(FlowId flowId) const;
92 
93  void SerializeToXmlStream(std::ostream& os, uint16_t indent) const override;
94 
95  private:
97  std::map<FiveTuple, FlowId> m_flowMap;
99  std::map<FlowId, FlowPacketId> m_flowPktIdMap;
101  std::map<FlowId, std::map<Ipv4Header::DscpType, uint32_t>> m_flowDscpMap;
102 };
103 
112 
121 
122 } // namespace ns3
123 
124 #endif /* IPV4_FLOW_CLASSIFIER_H */
Provides a method to translate raw packet data into abstract flow identifier and packet identifier pa...
Ipv4 addresses are stored in host order in this class.
Definition: ipv4-address.h:42
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.
Classifies packets by looking at their IP and TCP/UDP headers.
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
Packet header for IPv4.
Definition: ipv4-header.h:34
uint32_t FlowId
Abstract identifier of a packet flow.
Every class exported by the ns3 library is enclosed in the ns3 namespace.
bool operator==(const EventId &a, const EventId &b)
Definition: event-id.h:157
bool operator<(const EventId &a, const EventId &b)
Definition: event-id.h:170
Structure to classify a packet.
uint16_t destinationPort
Destination port.
Ipv4Address sourceAddress
Source address.
Ipv4Address destinationAddress
Destination address.