A Discrete-Event Network Simulator
API
ipv6-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 // Modifications: Tommaso Pecorella <tommaso.pecorella@unifi.it>
19 //
20 
21 #ifndef IPV6_FLOW_CLASSIFIER_H
22 #define IPV6_FLOW_CLASSIFIER_H
23 
24 #include "flow-classifier.h"
25 
26 #include "ns3/ipv6-header.h"
27 
28 #include <map>
29 #include <stdint.h>
30 
31 namespace ns3
32 {
33 
34 class Packet;
35 
41 {
42  public:
44  struct FiveTuple
45  {
48  uint8_t protocol;
49  uint16_t sourcePort;
50  uint16_t destinationPort;
51  };
52 
54 
65  bool Classify(const Ipv6Header& ipHeader,
66  Ptr<const Packet> ipPayload,
67  uint32_t* out_flowId,
68  uint32_t* out_packetId);
69 
73  FiveTuple FindFlow(FlowId flowId) const;
74 
77  {
78  public:
83  bool operator()(std::pair<Ipv6Header::DscpType, uint32_t> left,
84  std::pair<Ipv6Header::DscpType, uint32_t> right);
85  };
86 
92  std::vector<std::pair<Ipv6Header::DscpType, uint32_t>> GetDscpCounts(FlowId flowId) const;
93 
94  void SerializeToXmlStream(std::ostream& os, uint16_t indent) const override;
95 
96  private:
98  std::map<FiveTuple, FlowId> m_flowMap;
100  std::map<FlowId, FlowPacketId> m_flowPktIdMap;
102  std::map<FlowId, std::map<Ipv6Header::DscpType, uint32_t>> m_flowDscpMap;
103 };
104 
113 
122 
123 } // namespace ns3
124 
125 #endif /* IPV6_FLOW_CLASSIFIER_H */
Provides a method to translate raw packet data into abstract flow identifier and packet identifier pa...
Describes an IPv6 address.
Definition: ipv6-address.h:49
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.
Classifies packets by looking at their IP and TCP/UDP headers.
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.
Packet header for IPv6.
Definition: ipv6-header.h:35
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.
Ipv6Address destinationAddress
Destination address.
Ipv6Address sourceAddress
Source address.