A Discrete-Event Network Simulator
Home
Tutorials ▼
English
Portuguese
Docs ▼
Wiki
Manual
Models
Develop ▼
API
Bugs
API
Main Page
Related Pages
Modules
Namespaces
Classes
Files
File List
File Members
All
Classes
Namespaces
Files
Functions
Variables
Typedefs
Enumerations
Enumerator
Properties
Friends
Macros
Groups
Pages
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
NS_LOG_COMPONENT_DEFINE
(
"IpcsClassifier"
);
35
36
namespace
ns3 {
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
return
tid;
45
}
46
47
IpcsClassifier::IpcsClassifier
(
void
)
48
{
49
}
50
51
IpcsClassifier::~IpcsClassifier
(
void
)
52
{
53
}
54
55
ServiceFlow
*
56
IpcsClassifier::Classify
(
Ptr<const Packet>
packet,
57
Ptr<ServiceFlowManager>
sfm,
ServiceFlow::Direction
dir)
58
{
59
Ptr<Packet>
C_Packet = packet->
Copy
();
60
61
LlcSnapHeader
llc;
62
C_Packet->
RemoveHeader
(llc);
63
64
Ipv4Header
ipv4Header;
65
C_Packet->
RemoveHeader
(ipv4Header);
66
Ipv4Address
source_address = ipv4Header.
GetSource
();
67
Ipv4Address
dest_address = ipv4Header.
GetDestination
();
68
uint8_t protocol = ipv4Header.
GetProtocol
();
69
70
uint16_t sourcePort = 0;
71
uint16_t destPort = 0;
72
if
(protocol ==
UdpL4Protocol::PROT_NUMBER
)
73
{
74
UdpHeader
udpHeader;
75
C_Packet->
RemoveHeader
(udpHeader);
76
sourcePort = udpHeader.
GetSourcePort
();
77
destPort = udpHeader.
GetDestinationPort
();
78
}
79
else
if
(protocol ==
TcpL4Protocol::PROT_NUMBER
)
80
{
81
TcpHeader
tcpHeader;
82
C_Packet->
RemoveHeader
(tcpHeader);
83
sourcePort = tcpHeader.
GetSourcePort
();
84
destPort = tcpHeader.
GetDestinationPort
();
85
}
86
else
87
{
88
NS_LOG_INFO
(
"\t\t\tUnknown protocol: "
<< protocol);
89
return
0;
90
}
91
92
NS_LOG_INFO
(
"Classifing packet: src_addr="
<< source_address <<
" dst_addr="
93
<< dest_address <<
" src_port="
<< sourcePort <<
" dst_port="
94
<< destPort <<
" proto="
<< (uint16_t) protocol);
95
return
(sfm->DoClassify (source_address,
96
dest_address,
97
sourcePort,
98
destPort,
99
protocol,dir));
100
}
101
102
}
src
wimax
model
ipcs-classifier.cc
Generated on Tue Oct 9 2012 16:45:50 for ns-3 by
1.8.1.2