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
ipcs-classifier.cc
Go to the documentation of this file.
1
/*
2
* Copyright (c) 2009 INRIA, UDcast
3
*
4
* SPDX-License-Identifier: GPL-2.0-only
5
*
6
* Mohamed Amine Ismail <amine.ismail@sophia.inria.fr>
7
*
8
*/
9
10
#include "
ipcs-classifier.h
"
11
12
#include "
service-flow.h
"
13
14
#include "ns3/ipv4-header.h"
15
#include "ns3/llc-snap-header.h"
16
#include "ns3/log.h"
17
#include "ns3/packet.h"
18
#include "ns3/tcp-header.h"
19
#include "ns3/tcp-l4-protocol.h"
20
#include "ns3/udp-header.h"
21
#include "ns3/udp-l4-protocol.h"
22
23
#include <stdint.h>
24
25
namespace
ns3
26
{
27
28
NS_LOG_COMPONENT_DEFINE
(
"IpcsClassifier"
);
29
30
NS_OBJECT_ENSURE_REGISTERED
(IpcsClassifier);
31
32
TypeId
33
IpcsClassifier::GetTypeId
()
34
{
35
static
TypeId
tid =
TypeId
(
"ns3::IpcsClassifier"
).
SetParent
<
Object
>().SetGroupName(
"Wimax"
);
36
return
tid;
37
}
38
39
IpcsClassifier::IpcsClassifier
()
40
{
41
}
42
43
IpcsClassifier::~IpcsClassifier
()
44
{
45
}
46
47
ServiceFlow
*
48
IpcsClassifier::Classify
(
Ptr<const Packet>
packet,
49
Ptr<ServiceFlowManager>
sfm,
50
ServiceFlow::Direction
dir
)
51
{
52
Ptr<Packet>
C_Packet = packet->Copy();
53
54
LlcSnapHeader
llc;
55
C_Packet->RemoveHeader(llc);
56
57
Ipv4Header
ipv4Header;
58
C_Packet->RemoveHeader(ipv4Header);
59
Ipv4Address
source_address = ipv4Header.
GetSource
();
60
Ipv4Address
dest_address = ipv4Header.
GetDestination
();
61
uint8_t protocol = ipv4Header.
GetProtocol
();
62
63
uint16_t sourcePort = 0;
64
uint16_t destPort = 0;
65
if
(protocol ==
UdpL4Protocol::PROT_NUMBER
)
66
{
67
UdpHeader
udpHeader;
68
C_Packet->RemoveHeader(udpHeader);
69
sourcePort = udpHeader.
GetSourcePort
();
70
destPort = udpHeader.
GetDestinationPort
();
71
}
72
else
if
(protocol ==
TcpL4Protocol::PROT_NUMBER
)
73
{
74
TcpHeader
tcpHeader;
75
C_Packet->RemoveHeader(tcpHeader);
76
sourcePort = tcpHeader.
GetSourcePort
();
77
destPort = tcpHeader.
GetDestinationPort
();
78
}
79
else
80
{
81
NS_LOG_INFO
(
"\t\t\tUnknown protocol: "
<< protocol);
82
return
nullptr
;
83
}
84
85
NS_LOG_INFO
(
"Classifing packet: src_addr="
<< source_address <<
" dst_addr="
<< dest_address
86
<<
" src_port="
<< sourcePort <<
" dst_port="
87
<< destPort <<
" proto="
<< (uint16_t)protocol);
88
return
(sfm->DoClassify(source_address, dest_address, sourcePort, destPort, protocol,
dir
));
89
}
90
91
}
// 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:48
ns3::IpcsClassifier::GetTypeId
static TypeId GetTypeId()
Get the type ID.
Definition
ipcs-classifier.cc:33
ns3::IpcsClassifier::IpcsClassifier
IpcsClassifier()
Definition
ipcs-classifier.cc:39
ns3::IpcsClassifier::~IpcsClassifier
~IpcsClassifier() override
Definition
ipcs-classifier.cc:43
ns3::Ipv4Address
Ipv4 addresses are stored in host order in this class.
Definition
ipv4-address.h:31
ns3::Ipv4Header
Packet header for IPv4.
Definition
ipv4-header.h:23
ns3::Ipv4Header::GetSource
Ipv4Address GetSource() const
Definition
ipv4-header.cc:291
ns3::Ipv4Header::GetProtocol
uint8_t GetProtocol() const
Definition
ipv4-header.cc:270
ns3::Ipv4Header::GetDestination
Ipv4Address GetDestination() const
Definition
ipv4-header.cc:305
ns3::LlcSnapHeader
Header for the LLC/SNAP encapsulation.
Definition
llc-snap-header.h:34
ns3::Object
A base class which provides memory management and object aggregation.
Definition
object.h:78
ns3::Ptr
Smart pointer class similar to boost::intrusive_ptr.
Definition
mpi-test-fixtures.h:37
ns3::ServiceFlow
This class implements service flows as described by the IEEE-802.16 standard.
Definition
service-flow.h:32
ns3::ServiceFlow::Direction
Direction
Direction enumeration.
Definition
service-flow.h:36
ns3::TcpHeader
Header for the Transmission Control Protocol.
Definition
tcp-header.h:36
ns3::TcpHeader::GetDestinationPort
uint16_t GetDestinationPort() const
Get the destination port.
Definition
tcp-header.cc:101
ns3::TcpHeader::GetSourcePort
uint16_t GetSourcePort() const
Get the source port.
Definition
tcp-header.cc:95
ns3::TcpL4Protocol::PROT_NUMBER
static const uint8_t PROT_NUMBER
protocol number (0x6)
Definition
tcp-l4-protocol.h:77
ns3::TypeId
a unique identifier for an interface.
Definition
type-id.h:48
ns3::TypeId::SetParent
TypeId SetParent(TypeId tid)
Set the parent TypeId.
Definition
type-id.cc:1001
ns3::UdpHeader
Packet header for UDP packets.
Definition
udp-header.h:30
ns3::UdpHeader::GetDestinationPort
uint16_t GetDestinationPort() const
Definition
udp-header.cc:43
ns3::UdpHeader::GetSourcePort
uint16_t GetSourcePort() const
Definition
udp-header.cc:37
ns3::UdpL4Protocol::PROT_NUMBER
static const uint8_t PROT_NUMBER
protocol number (0x11)
Definition
udp-l4-protocol.h:60
NS_LOG_COMPONENT_DEFINE
#define NS_LOG_COMPONENT_DEFINE(name)
Define a Log component with a specific name.
Definition
log.h:191
NS_LOG_INFO
#define NS_LOG_INFO(msg)
Use NS_LOG to output a message of level LOG_INFO.
Definition
log.h:264
NS_OBJECT_ENSURE_REGISTERED
#define NS_OBJECT_ENSURE_REGISTERED(type)
Register an Object subclass with the TypeId system.
Definition
object-base.h:35
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:57
src
wimax
model
ipcs-classifier.cc
Generated on Fri Nov 8 2024 13:59:09 for ns-3 by
1.11.0