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
tcp-header.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_HEADER_H
22
#define TCP_HEADER_H
23
24
#include <stdint.h>
25
#include "ns3/header.h"
26
#include "ns3/tcp-option.h"
27
#include "ns3/buffer.h"
28
#include "ns3/tcp-socket-factory.h"
29
#include "ns3/ipv4-address.h"
30
#include "ns3/ipv6-address.h"
31
#include "ns3/sequence-number.h"
32
33
namespace
ns3
{
34
44
class
TcpHeader
:
public
Header
45
{
46
public
:
47
TcpHeader
();
48
virtual
~TcpHeader
();
49
65
static
std::string
FlagsToString
(uint8_t flags,
const
std::string& delimiter =
"|"
);
66
72
void
EnableChecksums
(
void
);
73
74
//Setters
75
80
void
SetSourcePort
(uint16_t
port
);
81
86
void
SetDestinationPort
(uint16_t port);
87
92
void
SetSequenceNumber
(
SequenceNumber32
sequenceNumber);
93
98
void
SetAckNumber
(
SequenceNumber32
ackNumber);
99
104
void
SetFlags
(uint8_t flags);
105
110
void
SetWindowSize
(uint16_t windowSize);
111
116
void
SetUrgentPointer
(uint16_t urgentPointer);
117
118
//Getters
119
124
uint16_t
GetSourcePort
()
const
;
125
130
uint16_t
GetDestinationPort
()
const
;
131
136
SequenceNumber32
GetSequenceNumber
()
const
;
137
142
SequenceNumber32
GetAckNumber
()
const
;
143
152
uint8_t
GetLength
()
const
;
153
158
uint8_t
GetFlags
()
const
;
159
164
uint16_t
GetWindowSize
()
const
;
165
170
uint16_t
GetUrgentPointer
()
const
;
171
177
Ptr<TcpOption>
GetOption
(uint8_t kind)
const
;
178
184
bool
HasOption
(uint8_t kind)
const
;
185
191
bool
AppendOption
(
Ptr<TcpOption>
option);
192
207
void
InitializeChecksum
(
Ipv4Address
source,
208
Ipv4Address
destination,
209
uint8_t protocol);
210
225
void
InitializeChecksum
(
Ipv6Address
source,
226
Ipv6Address
destination,
227
uint8_t protocol);
228
243
void
InitializeChecksum
(
Address
source,
244
Address
destination,
245
uint8_t protocol);
246
250
typedef
enum
251
{
252
NONE
= 0,
253
FIN
= 1,
254
SYN
= 2,
255
RST
= 4,
256
PSH
= 8,
257
ACK
= 16,
258
URG
= 32,
259
ECE
= 64,
260
CWR
= 128
261
}
Flags_t
;
262
267
static
TypeId
GetTypeId
(
void
);
268
virtual
TypeId
GetInstanceTypeId
(
void
)
const
;
269
virtual
void
Print
(std::ostream &os)
const
;
270
virtual
uint32_t
GetSerializedSize
(
void
)
const
;
271
virtual
void
Serialize
(
Buffer::Iterator
start
)
const
;
272
virtual
uint32_t
Deserialize
(
Buffer::Iterator
start
);
273
278
bool
IsChecksumOk
(
void
)
const
;
279
286
friend
bool
operator==
(
const
TcpHeader
&lhs,
const
TcpHeader
&rhs);
287
288
private
:
294
uint16_t
CalculateHeaderChecksum
(uint16_t size)
const
;
295
304
uint8_t
CalculateHeaderLength
()
const
;
305
306
uint16_t
m_sourcePort
;
307
uint16_t
m_destinationPort
;
308
SequenceNumber32
m_sequenceNumber
;
309
SequenceNumber32
m_ackNumber
;
310
uint8_t
m_length
;
311
uint8_t
m_flags
;
312
uint16_t
m_windowSize
;
313
uint16_t
m_urgentPointer
;
314
315
Address
m_source
;
316
Address
m_destination
;
317
uint8_t
m_protocol
;
318
319
bool
m_calcChecksum
;
320
bool
m_goodChecksum
;
321
322
323
typedef
std::list< Ptr<TcpOption> >
TcpOptionList
;
324
TcpOptionList
m_options
;
325
uint8_t
m_optionsLen
;
326
static
const
uint8_t
m_maxOptionsLen
= 40;
327
};
328
329
}
// namespace ns3
330
331
#endif
/* TCP_HEADER */
ns3::Header
Protocol header serialization and deserialization.
Definition:
header.h:42
ns3::TcpHeader::RST
Reset.
Definition:
tcp-header.h:255
ns3::TcpHeader::FlagsToString
static std::string FlagsToString(uint8_t flags, const std::string &delimiter="|")
Converts an integer into a human readable list of Tcp flags.
Definition:
tcp-header.cc:55
ns3::Ptr< TcpOption >
ns3::TcpHeader::GetDestinationPort
uint16_t GetDestinationPort() const
Get the destination port.
Definition:
tcp-header.cc:137
ns3::TcpHeader::GetSequenceNumber
SequenceNumber32 GetSequenceNumber() const
Get the sequence number.
Definition:
tcp-header.cc:143
ns3::TcpHeader::InitializeChecksum
void InitializeChecksum(Ipv4Address source, Ipv4Address destination, uint8_t protocol)
Initialize the TCP checksum.
Definition:
tcp-header.cc:179
ns3::TcpHeader::GetFlags
uint8_t GetFlags() const
Get the flags.
Definition:
tcp-header.cc:161
ns3::TcpHeader::GetAckNumber
SequenceNumber32 GetAckNumber() const
Get the ACK number.
Definition:
tcp-header.cc:149
ns3::TcpHeader::m_maxOptionsLen
static const uint8_t m_maxOptionsLen
Maximum options length.
Definition:
tcp-header.h:326
visualizer.core.start
def start()
Definition:
core.py:1482
ns3::TcpHeader::ACK
Ack.
Definition:
tcp-header.h:257
ns3::TcpHeader::m_source
Address m_source
Source IP address.
Definition:
tcp-header.h:315
ns3::TcpHeader::CWR
CWR.
Definition:
tcp-header.h:260
ns3::TcpHeader::TcpHeader
TcpHeader()
Definition:
tcp-header.cc:35
ns3::TcpHeader::m_destinationPort
uint16_t m_destinationPort
Destination port.
Definition:
tcp-header.h:307
ns3::TcpHeader::CalculateHeaderLength
uint8_t CalculateHeaderLength() const
Calculates the header length (in words)
Definition:
tcp-header.cc:430
ns3::TcpHeader::m_calcChecksum
bool m_calcChecksum
Flag to calculate checksum.
Definition:
tcp-header.h:319
port
uint16_t port
Definition:
dsdv-manet.cc:44
ns3::Buffer::Iterator
iterator in a Buffer instance
Definition:
buffer.h:98
ns3::Address
a polymophic address class
Definition:
address.h:90
ns3::TcpHeader::Print
virtual void Print(std::ostream &os) const
Definition:
tcp-header.cc:275
ns3::TcpHeader::AppendOption
bool AppendOption(Ptr< TcpOption > option)
Append an option to the TCP header.
Definition:
tcp-header.cc:448
ns3::TcpHeader::SetSequenceNumber
void SetSequenceNumber(SequenceNumber32 sequenceNumber)
Set the sequence Number.
Definition:
tcp-header.cc:101
ns3::TcpHeader::GetWindowSize
uint16_t GetWindowSize() const
Get the window size.
Definition:
tcp-header.cc:167
ns3::TcpHeader::TcpOptionList
std::list< Ptr< TcpOption > > TcpOptionList
List of TcpOption.
Definition:
tcp-header.h:323
ns3::TcpHeader::Flags_t
Flags_t
TCP flag field values.
Definition:
tcp-header.h:250
ns3::TcpHeader::GetInstanceTypeId
virtual TypeId GetInstanceTypeId(void) const
Get the most derived TypeId for this Object.
Definition:
tcp-header.cc:269
ns3::TcpHeader::CalculateHeaderChecksum
uint16_t CalculateHeaderChecksum(uint16_t size) const
Calculate the header checksum.
Definition:
tcp-header.cc:209
ns3::TcpHeader::SYN
SYN.
Definition:
tcp-header.h:254
ns3::TcpHeader::PSH
Push.
Definition:
tcp-header.h:256
ns3::TcpHeader::m_goodChecksum
bool m_goodChecksum
Flag to indicate that checksum is correct.
Definition:
tcp-header.h:320
ns3::TcpHeader::SetDestinationPort
void SetDestinationPort(uint16_t port)
Set the destination port.
Definition:
tcp-header.cc:95
ns3::TcpHeader::SetFlags
void SetFlags(uint8_t flags)
Set flags of the header.
Definition:
tcp-header.cc:113
ns3::TcpHeader::m_windowSize
uint16_t m_windowSize
Window size.
Definition:
tcp-header.h:312
ns3
Every class exported by the ns3 library is enclosed in the ns3 namespace.
ns3::TcpHeader::m_sourcePort
uint16_t m_sourcePort
Source port.
Definition:
tcp-header.h:306
ns3::TcpHeader::m_optionsLen
uint8_t m_optionsLen
Tcp options length.
Definition:
tcp-header.h:325
ns3::SequenceNumber< uint32_t, int32_t >
ns3::TcpHeader
Header for the Transmission Control Protocol.
Definition:
tcp-header.h:44
ns3::TcpHeader::SetSourcePort
void SetSourcePort(uint16_t port)
Set the source port.
Definition:
tcp-header.cc:89
ns3::TcpHeader::URG
Urgent.
Definition:
tcp-header.h:258
ns3::TcpHeader::~TcpHeader
virtual ~TcpHeader()
Definition:
tcp-header.cc:50
ns3::TcpHeader::m_destination
Address m_destination
Destination IP address.
Definition:
tcp-header.h:316
ns3::TcpHeader::SetUrgentPointer
void SetUrgentPointer(uint16_t urgentPointer)
Set the urgent pointer.
Definition:
tcp-header.cc:125
ns3::TcpHeader::FIN
FIN.
Definition:
tcp-header.h:253
ns3::TcpHeader::GetSerializedSize
virtual uint32_t GetSerializedSize(void) const
Definition:
tcp-header.cc:297
ns3::TcpHeader::GetLength
uint8_t GetLength() const
Get the length in words.
Definition:
tcp-header.cc:155
ns3::TcpHeader::m_protocol
uint8_t m_protocol
Protocol number.
Definition:
tcp-header.h:317
ns3::TcpHeader::GetOption
Ptr< TcpOption > GetOption(uint8_t kind) const
Get the option specified.
Definition:
tcp-header.cc:474
ns3::TcpHeader::Deserialize
virtual uint32_t Deserialize(Buffer::Iterator start)
Definition:
tcp-header.cc:348
ns3::TcpHeader::m_urgentPointer
uint16_t m_urgentPointer
Urgent pointer.
Definition:
tcp-header.h:313
ns3::Ipv6Address
Describes an IPv6 address.
Definition:
ipv6-address.h:47
ns3::Ipv4Address
Ipv4 addresses are stored in host order in this class.
Definition:
ipv4-address.h:40
ns3::TcpHeader::m_ackNumber
SequenceNumber32 m_ackNumber
ACK number.
Definition:
tcp-header.h:309
ns3::TcpHeader::m_flags
uint8_t m_flags
Flags (really a uint6_t)
Definition:
tcp-header.h:311
ns3::TcpHeader::m_length
uint8_t m_length
Length (really a uint4_t) in words.
Definition:
tcp-header.h:310
ns3::TcpHeader::operator==
friend bool operator==(const TcpHeader &lhs, const TcpHeader &rhs)
Comparison operator.
Definition:
tcp-header.cc:506
ns3::TcpHeader::SetAckNumber
void SetAckNumber(SequenceNumber32 ackNumber)
Set the ACK number.
Definition:
tcp-header.cc:107
ns3::TcpHeader::GetSourcePort
uint16_t GetSourcePort() const
Get the source port.
Definition:
tcp-header.cc:131
ns3::TcpHeader::IsChecksumOk
bool IsChecksumOk(void) const
Is the TCP checksum correct ?
Definition:
tcp-header.cc:252
ns3::TcpHeader::ECE
ECE.
Definition:
tcp-header.h:259
ns3::TcpHeader::EnableChecksums
void EnableChecksums(void)
Enable checksum calculation for TCP.
Definition:
tcp-header.cc:83
ns3::TcpHeader::m_options
TcpOptionList m_options
TcpOption present in the header.
Definition:
tcp-header.h:324
ns3::TcpHeader::HasOption
bool HasOption(uint8_t kind) const
Check if the header has the option specified.
Definition:
tcp-header.cc:490
ns3::TcpHeader::SetWindowSize
void SetWindowSize(uint16_t windowSize)
Set the window size.
Definition:
tcp-header.cc:119
ns3::TypeId
a unique identifier for an interface.
Definition:
type-id.h:57
ns3::TcpHeader::GetUrgentPointer
uint16_t GetUrgentPointer() const
Get the urgent pointer.
Definition:
tcp-header.cc:173
ns3::TcpHeader::Serialize
virtual void Serialize(Buffer::Iterator start) const
Definition:
tcp-header.cc:303
ns3::TcpHeader::NONE
No flags.
Definition:
tcp-header.h:252
ns3::TcpHeader::GetTypeId
static TypeId GetTypeId(void)
Get the type ID.
Definition:
tcp-header.cc:258
ns3::TcpHeader::m_sequenceNumber
SequenceNumber32 m_sequenceNumber
Sequence number.
Definition:
tcp-header.h:308
src
internet
model
tcp-header.h
Generated on Thu Aug 13 2015 14:27:56 for ns-3 by
1.8.9.1