A Discrete-Event Network Simulator
Home
Tutorials ▼
English
Documentation ▼
Installation
Manual
Models
Contributing
Wiki
Development ▼
API Docs
Issue Tracker
Merge Requests
API
Loading...
Searching...
No Matches
ipv6-flow-classifier.h
Go to the documentation of this file.
1
//
2
// Copyright (c) 2009 INESC Porto
3
//
4
// SPDX-License-Identifier: GPL-2.0-only
5
//
6
// Author: Gustavo J. A. M. Carneiro <gjc@inescporto.pt> <gjcarneiro@gmail.com>
7
// Modifications: Tommaso Pecorella <tommaso.pecorella@unifi.it>
8
//
9
10
#ifndef IPV6_FLOW_CLASSIFIER_H
11
#define IPV6_FLOW_CLASSIFIER_H
12
13
#include "
flow-classifier.h
"
14
15
#include "ns3/ipv6-header.h"
16
17
#include <map>
18
#include <stdint.h>
19
20
namespace
ns3
21
{
22
23
class
Packet;
24
25
/// Classifies packets by looking at their IP and TCP/UDP headers.
26
/// From these packet headers, a tuple (source-ip, destination-ip,
27
/// protocol, source-port, destination-port) is created, and a unique
28
/// flow identifier is assigned for each different tuple combination
29
class
Ipv6FlowClassifier
:
public
FlowClassifier
30
{
31
public
:
32
/// Structure to classify a packet
33
struct
FiveTuple
34
{
35
Ipv6Address
sourceAddress
;
//!< Source address
36
Ipv6Address
destinationAddress
;
//!< Destination address
37
uint8_t
protocol
;
//!< Protocol
38
uint16_t
sourcePort
;
//!< Source port
39
uint16_t
destinationPort
;
//!< Destination port
40
};
41
42
Ipv6FlowClassifier
();
43
44
/// \brief try to classify the packet into flow-id and packet-id
45
///
46
/// \warning: it must be called only once per packet, from SendOutgoingLogger.
47
///
48
/// \return true if the packet was classified, false if not (i.e. it
49
/// does not appear to be part of a flow).
50
/// \param ipHeader packet's IP header
51
/// \param ipPayload packet's IP payload
52
/// \param out_flowId packet's FlowId
53
/// \param out_packetId packet's identifier
54
bool
Classify
(
const
Ipv6Header
& ipHeader,
55
Ptr<const Packet>
ipPayload,
56
uint32_t
* out_flowId,
57
uint32_t
* out_packetId);
58
59
/// Searches for the FiveTuple corresponding to the given flowId
60
/// \param flowId the FlowId to search for
61
/// \returns the FiveTuple corresponding to flowId
62
FiveTuple
FindFlow
(
FlowId
flowId)
const
;
63
64
/// Comparator used to sort the vector of DSCP values
65
class
SortByCount
66
{
67
public
:
68
/// Comparator function
69
/// \param left left operand
70
/// \param right right operand
71
/// \return true if left DSCP is greater than right DSCP
72
bool
operator()
(std::pair<Ipv6Header::DscpType, uint32_t> left,
73
std::pair<Ipv6Header::DscpType, uint32_t> right);
74
};
75
76
/// \brief get the DSCP values of the packets belonging to the flow with the
77
/// given FlowId, sorted in decreasing order of number of packets seen with
78
/// that DSCP value
79
/// \param flowId the identifier of the flow of interest
80
/// \returns the vector of DSCP values
81
std::vector<std::pair<Ipv6Header::DscpType, uint32_t>>
GetDscpCounts
(
FlowId
flowId)
const
;
82
83
void
SerializeToXmlStream
(std::ostream& os, uint16_t indent)
const override
;
84
85
private
:
86
/// Map to Flows Identifiers to FlowIds
87
std::map<FiveTuple, FlowId>
m_flowMap
;
88
/// Map to FlowIds to FlowPacketId
89
std::map<FlowId, FlowPacketId>
m_flowPktIdMap
;
90
/// Map FlowIds to (DSCP value, packet count) pairs
91
std::map<FlowId, std::map<Ipv6Header::DscpType, uint32_t>>
m_flowDscpMap
;
92
};
93
94
/**
95
* \brief Less than operator.
96
*
97
* \param t1 the first operand
98
* \param t2 the first operand
99
* \returns true if the operands are equal
100
*/
101
bool
operator<
(
const
Ipv6FlowClassifier::FiveTuple
& t1,
const
Ipv6FlowClassifier::FiveTuple
& t2);
102
103
/**
104
* \brief Equal to operator.
105
*
106
* \param t1 the first operand
107
* \param t2 the first operand
108
* \returns true if the operands are equal
109
*/
110
bool
operator==
(
const
Ipv6FlowClassifier::FiveTuple
& t1,
const
Ipv6FlowClassifier::FiveTuple
& t2);
111
112
}
// namespace ns3
113
114
#endif
/* IPV6_FLOW_CLASSIFIER_H */
ns3::FlowClassifier
Provides a method to translate raw packet data into abstract flow identifier and packet identifier pa...
Definition
flow-classifier.h:43
ns3::Ipv6Address
Describes an IPv6 address.
Definition
ipv6-address.h:38
ns3::Ipv6FlowClassifier::SortByCount
Comparator used to sort the vector of DSCP values.
Definition
ipv6-flow-classifier.h:66
ns3::Ipv6FlowClassifier::SortByCount::operator()
bool operator()(std::pair< Ipv6Header::DscpType, uint32_t > left, std::pair< Ipv6Header::DscpType, uint32_t > right)
Comparator function.
Definition
ipv6-flow-classifier.cc:186
ns3::Ipv6FlowClassifier
Classifies packets by looking at their IP and TCP/UDP headers.
Definition
ipv6-flow-classifier.h:30
ns3::Ipv6FlowClassifier::m_flowMap
std::map< FiveTuple, FlowId > m_flowMap
Map to Flows Identifiers to FlowIds.
Definition
ipv6-flow-classifier.h:87
ns3::Ipv6FlowClassifier::SerializeToXmlStream
void SerializeToXmlStream(std::ostream &os, uint16_t indent) const override
Serializes the results to an std::ostream in XML format.
Definition
ipv6-flow-classifier.cc:209
ns3::Ipv6FlowClassifier::GetDscpCounts
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 ...
Definition
ipv6-flow-classifier.cc:193
ns3::Ipv6FlowClassifier::Ipv6FlowClassifier
Ipv6FlowClassifier()
Definition
ipv6-flow-classifier.cc:84
ns3::Ipv6FlowClassifier::FindFlow
FiveTuple FindFlow(FlowId flowId) const
Searches for the FiveTuple corresponding to the given flowId.
Definition
ipv6-flow-classifier.cc:171
ns3::Ipv6FlowClassifier::Classify
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
Definition
ipv6-flow-classifier.cc:89
ns3::Ipv6FlowClassifier::m_flowPktIdMap
std::map< FlowId, FlowPacketId > m_flowPktIdMap
Map to FlowIds to FlowPacketId.
Definition
ipv6-flow-classifier.h:89
ns3::Ipv6FlowClassifier::m_flowDscpMap
std::map< FlowId, std::map< Ipv6Header::DscpType, uint32_t > > m_flowDscpMap
Map FlowIds to (DSCP value, packet count) pairs.
Definition
ipv6-flow-classifier.h:91
ns3::Ipv6Header
Packet header for IPv6.
Definition
ipv6-header.h:24
ns3::Ptr
Smart pointer class similar to boost::intrusive_ptr.
Definition
mpi-test-fixtures.h:37
uint32_t
flow-classifier.h
ns3
Every class exported by the ns3 library is enclosed in the ns3 namespace.
ns3::operator==
bool operator==(const EventId &a, const EventId &b)
Definition
event-id.h:155
ns3::operator<
bool operator<(const EventId &a, const EventId &b)
Definition
event-id.h:168
ns3::Ipv6FlowClassifier::FiveTuple
Structure to classify a packet.
Definition
ipv6-flow-classifier.h:34
ns3::Ipv6FlowClassifier::FiveTuple::destinationPort
uint16_t destinationPort
Destination port.
Definition
ipv6-flow-classifier.h:39
ns3::Ipv6FlowClassifier::FiveTuple::destinationAddress
Ipv6Address destinationAddress
Destination address.
Definition
ipv6-flow-classifier.h:36
ns3::Ipv6FlowClassifier::FiveTuple::sourcePort
uint16_t sourcePort
Source port.
Definition
ipv6-flow-classifier.h:38
ns3::Ipv6FlowClassifier::FiveTuple::protocol
uint8_t protocol
Protocol.
Definition
ipv6-flow-classifier.h:37
ns3::Ipv6FlowClassifier::FiveTuple::sourceAddress
Ipv6Address sourceAddress
Source address.
Definition
ipv6-flow-classifier.h:35
src
flow-monitor
model
ipv6-flow-classifier.h
Generated on Fri Nov 8 2024 13:59:00 for ns-3 by
1.11.0