A Discrete-Event Network Simulator
Home
Tutorials ▼
English
Documentation ▼
Installation
Manual
Models
Contributing
Wiki
Development ▼
API Docs
Issue Tracker
Merge Requests
API
ipcs-classifier.cc
Go to the documentation of this file.
1
/*
2
* Copyright (c) 2009 INRIA, UDcast
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
* Mohamed Amine Ismail <amine.ismail@sophia.inria.fr>
18
*
19
*/
20
21
#include "
ipcs-classifier.h
"
22
23
#include "
service-flow.h
"
24
25
#include "ns3/ipv4-header.h"
26
#include "ns3/llc-snap-header.h"
27
#include "ns3/log.h"
28
#include "ns3/packet.h"
29
#include "ns3/tcp-header.h"
30
#include "ns3/tcp-l4-protocol.h"
31
#include "ns3/udp-header.h"
32
#include "ns3/udp-l4-protocol.h"
33
34
#include <stdint.h>
35
36
namespace
ns3
37
{
38
39
NS_LOG_COMPONENT_DEFINE
(
"IpcsClassifier"
);
40
41
NS_OBJECT_ENSURE_REGISTERED
(IpcsClassifier);
42
43
TypeId
44
IpcsClassifier::GetTypeId
()
45
{
46
static
TypeId
tid =
TypeId
(
"ns3::IpcsClassifier"
).
SetParent
<
Object
>().SetGroupName(
"Wimax"
);
47
return
tid;
48
}
49
50
IpcsClassifier::IpcsClassifier
()
51
{
52
}
53
54
IpcsClassifier::~IpcsClassifier
()
55
{
56
}
57
58
ServiceFlow
*
59
IpcsClassifier::Classify
(
Ptr<const Packet>
packet,
60
Ptr<ServiceFlowManager>
sfm,
61
ServiceFlow::Direction
dir
)
62
{
63
Ptr<Packet>
C_Packet = packet->
Copy
();
64
65
LlcSnapHeader
llc;
66
C_Packet->
RemoveHeader
(llc);
67
68
Ipv4Header
ipv4Header;
69
C_Packet->
RemoveHeader
(ipv4Header);
70
Ipv4Address
source_address = ipv4Header.
GetSource
();
71
Ipv4Address
dest_address = ipv4Header.
GetDestination
();
72
uint8_t protocol = ipv4Header.
GetProtocol
();
73
74
uint16_t sourcePort = 0;
75
uint16_t destPort = 0;
76
if
(protocol ==
UdpL4Protocol::PROT_NUMBER
)
77
{
78
UdpHeader
udpHeader;
79
C_Packet->
RemoveHeader
(udpHeader);
80
sourcePort = udpHeader.
GetSourcePort
();
81
destPort = udpHeader.
GetDestinationPort
();
82
}
83
else
if
(protocol ==
TcpL4Protocol::PROT_NUMBER
)
84
{
85
TcpHeader
tcpHeader;
86
C_Packet->
RemoveHeader
(tcpHeader);
87
sourcePort = tcpHeader.
GetSourcePort
();
88
destPort = tcpHeader.
GetDestinationPort
();
89
}
90
else
91
{
92
NS_LOG_INFO
(
"\t\t\tUnknown protocol: "
<< protocol);
93
return
nullptr
;
94
}
95
96
NS_LOG_INFO
(
"Classifing packet: src_addr="
<< source_address <<
" dst_addr="
<< dest_address
97
<<
" src_port="
<< sourcePort <<
" dst_port="
98
<< destPort <<
" proto="
<< (uint16_t)protocol);
99
return
(sfm->DoClassify(source_address, dest_address, sourcePort, destPort, protocol,
dir
));
100
}
101
102
}
// namespace ns3
ns3::IpcsClassifier::Classify
ServiceFlow * Classify(Ptr< const Packet > packet, Ptr< ServiceFlowManager > sfm, ServiceFlow::Direction dir)
classify a packet in a service flow
Definition:
ipcs-classifier.cc:59
ns3::IpcsClassifier::GetTypeId
static TypeId GetTypeId()
Get the type ID.
Definition:
ipcs-classifier.cc:44
ns3::IpcsClassifier::IpcsClassifier
IpcsClassifier()
Definition:
ipcs-classifier.cc:50
ns3::IpcsClassifier::~IpcsClassifier
~IpcsClassifier() override
Definition:
ipcs-classifier.cc:54
ns3::Ipv4Address
Ipv4 addresses are stored in host order in this class.
Definition:
ipv4-address.h:42
ns3::Ipv4Header
Packet header for IPv4.
Definition:
ipv4-header.h:34
ns3::Ipv4Header::GetSource
Ipv4Address GetSource() const
Definition:
ipv4-header.cc:302
ns3::Ipv4Header::GetProtocol
uint8_t GetProtocol() const
Definition:
ipv4-header.cc:281
ns3::Ipv4Header::GetDestination
Ipv4Address GetDestination() const
Definition:
ipv4-header.cc:316
ns3::LlcSnapHeader
Header for the LLC/SNAP encapsulation.
Definition:
llc-snap-header.h:45
ns3::Object
A base class which provides memory management and object aggregation.
Definition:
object.h:89
ns3::Packet::RemoveHeader
uint32_t RemoveHeader(Header &header)
Deserialize and remove the header from the internal buffer.
Definition:
packet.cc:294
ns3::Packet::Copy
Ptr< Packet > Copy() const
performs a COW copy of the packet.
Definition:
packet.cc:131
ns3::Ptr< const Packet >
ns3::ServiceFlow
This class implements service flows as described by the IEEE-802.16 standard.
Definition:
service-flow.h:43
ns3::ServiceFlow::Direction
Direction
Direction enumeration.
Definition:
service-flow.h:47
ns3::TcpHeader
Header for the Transmission Control Protocol.
Definition:
tcp-header.h:47
ns3::TcpHeader::GetDestinationPort
uint16_t GetDestinationPort() const
Get the destination port.
Definition:
tcp-header.cc:112
ns3::TcpHeader::GetSourcePort
uint16_t GetSourcePort() const
Get the source port.
Definition:
tcp-header.cc:106
ns3::TcpL4Protocol::PROT_NUMBER
static const uint8_t PROT_NUMBER
protocol number (0x6)
Definition:
tcp-l4-protocol.h:88
ns3::TypeId
a unique identifier for an interface.
Definition:
type-id.h:59
ns3::TypeId::SetParent
TypeId SetParent(TypeId tid)
Set the parent TypeId.
Definition:
type-id.cc:931
ns3::UdpHeader
Packet header for UDP packets.
Definition:
udp-header.h:41
ns3::UdpHeader::GetDestinationPort
uint16_t GetDestinationPort() const
Definition:
udp-header.cc:54
ns3::UdpHeader::GetSourcePort
uint16_t GetSourcePort() const
Definition:
udp-header.cc:48
ns3::UdpL4Protocol::PROT_NUMBER
static const uint8_t PROT_NUMBER
protocol number (0x11)
Definition:
udp-l4-protocol.h:71
NS_LOG_COMPONENT_DEFINE
#define NS_LOG_COMPONENT_DEFINE(name)
Define a Log component with a specific name.
Definition:
log.h:202
NS_LOG_INFO
#define NS_LOG_INFO(msg)
Use NS_LOG to output a message of level LOG_INFO.
Definition:
log.h:275
NS_OBJECT_ENSURE_REGISTERED
#define NS_OBJECT_ENSURE_REGISTERED(type)
Register an Object subclass with the TypeId system.
Definition:
object-base.h:46
ipcs-classifier.h
ns3
Every class exported by the ns3 library is enclosed in the ns3 namespace.
service-flow.h
dir
std::string dir
Definition:
tcp-bbr-example.cc:68
src
wimax
model
ipcs-classifier.cc
Generated on Sun Mar 3 2024 17:11:14 for ns-3 by
1.9.1