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
tcp-l4-protocol.h
Go to the documentation of this file.
1
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
2
/*
3
* Copyright (c) 2007 Georgia Tech Research Corporation
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
* Author: Raj Bhattacharjea <raj.b@gatech.edu>
19
*/
20
21
#ifndef TCP_L4_PROTOCOL_H
22
#define TCP_L4_PROTOCOL_H
23
24
#include <stdint.h>
25
26
#include "ns3/packet.h"
27
#include "ns3/ipv4-address.h"
28
#include "ns3/ipv6-address.h"
29
#include "ns3/ptr.h"
30
#include "ns3/object-factory.h"
31
#include "
ip-l4-protocol.h
"
32
#include "ns3/net-device.h"
33
34
namespace
ns3 {
35
36
class
Node;
37
class
Socket;
38
class
TcpHeader;
39
class
Ipv4EndPointDemux;
40
class
Ipv6EndPointDemux;
41
class
Ipv4Interface;
42
class
TcpSocketBase;
43
class
Ipv4EndPoint;
44
class
Ipv6EndPoint;
45
56
class
TcpL4Protocol
:
public
IpL4Protocol
{
57
public
:
58
static
TypeId
GetTypeId
(
void
);
59
static
const
uint8_t
PROT_NUMBER
;
63
TcpL4Protocol
();
64
virtual
~TcpL4Protocol
();
65
66
void
SetNode
(
Ptr<Node>
node);
67
68
virtual
int
GetProtocolNumber
(
void
)
const
;
69
74
Ptr<Socket>
CreateSocket
(
void
);
75
Ptr<Socket>
CreateSocket
(
TypeId
socketTypeId);
76
77
Ipv4EndPoint
*
Allocate
(
void
);
78
Ipv4EndPoint
*
Allocate
(
Ipv4Address
address);
79
Ipv4EndPoint
*
Allocate
(uint16_t
port
);
80
Ipv4EndPoint
*
Allocate
(
Ipv4Address
address, uint16_t
port
);
81
Ipv4EndPoint
*
Allocate
(
Ipv4Address
localAddress, uint16_t localPort,
82
Ipv4Address
peerAddress, uint16_t peerPort);
83
Ipv6EndPoint
*
Allocate6
(
void
);
84
Ipv6EndPoint
*
Allocate6
(
Ipv6Address
address);
85
Ipv6EndPoint
*
Allocate6
(uint16_t
port
);
86
Ipv6EndPoint
*
Allocate6
(
Ipv6Address
address, uint16_t
port
);
87
Ipv6EndPoint
*
Allocate6
(
Ipv6Address
localAddress, uint16_t localPort,
88
Ipv6Address
peerAddress, uint16_t peerPort);
89
90
void
DeAllocate
(
Ipv4EndPoint
*endPoint);
91
void
DeAllocate
(
Ipv6EndPoint
*endPoint);
92
102
void
Send
(
Ptr<Packet>
packet,
103
Ipv4Address
saddr,
Ipv4Address
daddr,
104
uint16_t sport, uint16_t dport,
Ptr<NetDevice>
oif = 0);
105
void
Send
(
Ptr<Packet>
packet,
106
Ipv6Address
saddr,
Ipv6Address
daddr,
107
uint16_t sport, uint16_t dport,
Ptr<NetDevice>
oif = 0);
114
virtual
enum
IpL4Protocol::RxStatus
Receive
(
Ptr<Packet>
p,
115
Ipv4Header
const
&header,
116
Ptr<Ipv4Interface>
incomingInterface);
117
virtual
enum
IpL4Protocol::RxStatus
Receive
(
Ptr<Packet>
p,
118
Ipv6Header
const
&header,
119
Ptr<Ipv6Interface>
interface);
120
132
virtual
void
ReceiveIcmp
(
Ipv4Address
icmpSource, uint8_t icmpTtl,
133
uint8_t icmpType, uint8_t icmpCode, uint32_t icmpInfo,
134
Ipv4Address
payloadSource,
Ipv4Address
payloadDestination,
135
const
uint8_t payload[8]);
136
virtual
void
ReceiveIcmp
(
Ipv6Address
icmpSource, uint8_t icmpTtl,
137
uint8_t icmpType, uint8_t icmpCode, uint32_t icmpInfo,
138
Ipv6Address
payloadSource,
Ipv6Address
payloadDestination,
139
const
uint8_t payload[8]);
140
141
// From IpL4Protocol
142
virtual
void
SetDownTarget
(
IpL4Protocol::DownTargetCallback
cb);
143
virtual
void
SetDownTarget6
(
IpL4Protocol::DownTargetCallback6
cb);
144
// From IpL4Protocol
145
virtual
IpL4Protocol::DownTargetCallback
GetDownTarget
(
void
)
const
;
146
virtual
IpL4Protocol::DownTargetCallback6
GetDownTarget6
(
void
)
const
;
147
148
protected
:
149
virtual
void
DoDispose
(
void
);
150
/*
151
* This function will notify other components connected to the node that a new stack member is now connected
152
* This will be used to notify Layer 3 protocol of layer 4 protocol stack to connect them together.
153
*/
154
virtual
void
NotifyNewAggregate
();
155
private
:
156
Ptr<Node>
m_node
;
157
Ipv4EndPointDemux
*
m_endPoints
;
158
Ipv6EndPointDemux
*
m_endPoints6
;
159
TypeId
m_rttTypeId
;
160
TypeId
m_socketTypeId
;
161
private
:
162
friend
class
TcpSocketBase
;
163
void
SendPacket
(
Ptr<Packet>
,
const
TcpHeader
&,
164
Ipv4Address
,
Ipv4Address
,
Ptr<NetDevice>
oif = 0);
165
void
SendPacket
(
Ptr<Packet>
,
const
TcpHeader
&,
166
Ipv6Address
,
Ipv6Address
,
Ptr<NetDevice>
oif = 0);
167
TcpL4Protocol
(
const
TcpL4Protocol
&o);
168
TcpL4Protocol
&
operator =
(
const
TcpL4Protocol
&o);
169
170
std::vector<Ptr<TcpSocketBase> >
m_sockets
;
171
IpL4Protocol::DownTargetCallback
m_downTarget
;
172
IpL4Protocol::DownTargetCallback6
m_downTarget6
;
173
};
174
175
}
// namespace ns3
176
177
#endif
/* TCP_L4_PROTOCOL_H */
src
internet
model
tcp-l4-protocol.h
Generated on Fri Dec 21 2012 19:00:38 for ns-3 by
1.8.1.2