A Discrete-Event Network Simulator
API
ipv4-flow-classifier.h
Go to the documentation of this file.
1 /* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
2 //
3 // Copyright (c) 2009 INESC Porto
4 //
5 // This program is free software; you can redistribute it and/or modify
6 // it under the terms of the GNU General Public License version 2 as
7 // published by the Free Software Foundation;
8 //
9 // This program is distributed in the hope that it will be useful,
10 // but WITHOUT ANY WARRANTY; without even the implied warranty of
11 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 // GNU General Public License for more details.
13 //
14 // You should have received a copy of the GNU General Public License
15 // along with this program; if not, write to the Free Software
16 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
17 //
18 // Author: Gustavo J. A. M. Carneiro <gjc@inescporto.pt> <gjcarneiro@gmail.com>
19 //
20 
21 #ifndef IPV4_FLOW_CLASSIFIER_H
22 #define IPV4_FLOW_CLASSIFIER_H
23 
24 #include <stdint.h>
25 #include <map>
26 
27 #include "ns3/ipv4-header.h"
28 #include "ns3/flow-classifier.h"
29 
30 namespace ns3 {
31 
32 class Packet;
33 
39 {
40 public:
41 
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, Ptr<const Packet> ipPayload,
65  uint32_t *out_flowId, uint32_t *out_packetId);
66 
70  FiveTuple FindFlow (FlowId flowId) const;
71 
74  {
75  public:
80  bool operator() (std::pair<Ipv4Header::DscpType, uint32_t> left,
81  std::pair<Ipv4Header::DscpType, uint32_t> right);
82  };
83 
89  std::vector<std::pair<Ipv4Header::DscpType, uint32_t> > GetDscpCounts (FlowId flowId) const;
90 
91  virtual void SerializeToXmlStream (std::ostream &os, uint16_t indent) const;
92 
93 private:
94 
96  std::map<FiveTuple, FlowId> m_flowMap;
98  std::map<FlowId, FlowPacketId> m_flowPktIdMap;
100  std::map<FlowId, std::map<Ipv4Header::DscpType, uint32_t> > m_flowDscpMap;
101 
102 };
103 
112 
121 
122 
123 } // namespace ns3
124 
125 #endif /* IPV4_FLOW_CLASSIFIER_H */
Ipv4Address destinationAddress
Destination address.
Classifies packets by looking at their IP and TCP/UDP headers.
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 ...
uint16_t destinationPort
Destination port.
std::map< FlowId, FlowPacketId > m_flowPktIdMap
Map to FlowIds to FlowPacketId.
bool operator<(const EventId &a, const EventId &b)
Definition: event-id.h:153
def indent(source, debug, level)
Definition: check-style.py:424
Packet header for IPv4.
Definition: ipv4-header.h:33
bool operator()(std::pair< Ipv4Header::DscpType, uint32_t > left, std::pair< Ipv4Header::DscpType, uint32_t > right)
Comparator function.
Every class exported by the ns3 library is enclosed in the ns3 namespace.
Structure to classify a packet.
Comparator used to sort the vector of DSCP values.
FiveTuple FindFlow(FlowId flowId) const
Searches for the FiveTuple corresponding to the given flowId.
Ipv4 addresses are stored in host order in this class.
Definition: ipv4-address.h:41
bool operator==(const EventId &a, const EventId &b)
Definition: event-id.h:135
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
virtual void SerializeToXmlStream(std::ostream &os, uint16_t indent) const
Serializes the results to an std::ostream in XML format.
std::map< FiveTuple, FlowId > m_flowMap
Map to Flows Identifiers to FlowIds.
Ipv4Address sourceAddress
Source address.
uint32_t FlowId
Abstract identifier of a packet flow.
std::map< FlowId, std::map< Ipv4Header::DscpType, uint32_t > > m_flowDscpMap
Map FlowIds to (DSCP value, packet count) pairs.
Provides a method to translate raw packet data into abstract flow identifier and packet identifier pa...