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