A Discrete-Event Network Simulator
Home
Tutorials ▼
English
Docs ▼
Wiki
Manual
Models
Develop ▼
API
Bugs
API
tcp-error-model.h
Go to the documentation of this file.
1
/* -*- Mode: C++; c-file-style: "gnu"; indent-tabs-mode:nil; -*- */
2
/*
3
* Copyright (c) 2015 Natale Patriciello <natale.patriciello@gmail.com>
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
*/
19
#ifndef TCPERRORCHANNEL_H
20
#define TCPERRORCHANNEL_H
21
22
#include "ns3/error-model.h"
23
#include "ns3/tcp-header.h"
24
#include "ns3/ipv4-header.h"
25
26
namespace
ns3
{
27
38
class
TcpGeneralErrorModel
:
public
ErrorModel
39
{
40
public
:
45
static
TypeId
GetTypeId
(
void
);
46
TcpGeneralErrorModel
();
47
52
void
SetDropCallback
(
Callback
<
void
,
const
Ipv4Header
&,
const
TcpHeader
&,
Ptr<const Packet>
> cb)
53
{
54
m_dropCallback
= cb;
55
}
56
57
protected
:
65
virtual
bool
ShouldDrop
(
const
Ipv4Header
&ipHeader,
const
TcpHeader
&tcpHeader,
66
uint32_t
packetSize
) = 0;
67
68
69
private
:
70
virtual
bool
DoCorrupt
(
Ptr<Packet>
p);
71
Callback<void, const Ipv4Header&, const TcpHeader&, Ptr<const Packet>
>
m_dropCallback
;
72
};
73
82
class
TcpSeqErrorModel
:
public
TcpGeneralErrorModel
83
{
84
public
:
89
static
TypeId
GetTypeId
(
void
);
90
TcpSeqErrorModel
() :
TcpGeneralErrorModel
() { }
91
100
void
AddSeqToKill
(
const
SequenceNumber32
&seq)
101
{
102
m_seqToKill
.insert(
m_seqToKill
.end(), seq);
103
}
104
105
protected
:
106
virtual
bool
ShouldDrop
(
const
Ipv4Header
&ipHeader,
const
TcpHeader
&tcpHeader,
107
uint32_t
packetSize
);
108
109
protected
:
110
std::list<SequenceNumber32>
m_seqToKill
;
111
112
private
:
113
virtual
void
DoReset
(
void
);
114
};
115
129
class
TcpFlagErrorModel
:
public
TcpGeneralErrorModel
130
{
131
public
:
136
static
TypeId
GetTypeId
(
void
);
137
TcpFlagErrorModel
();
138
144
void
SetFlagToKill
(
TcpHeader::Flags_t
flags)
145
{
146
m_flagsToKill
= flags;
147
}
148
160
void
SetKillRepeat
(int16_t killNumber)
161
{
162
m_killNumber
= killNumber;
163
}
164
165
protected
:
166
virtual
bool
ShouldDrop
(
const
Ipv4Header
&ipHeader,
const
TcpHeader
&tcpHeader,
167
uint32_t
packetSize
);
168
169
protected
:
170
TcpHeader::Flags_t
m_flagsToKill
;
171
int16_t
m_killNumber
;
172
173
private
:
174
virtual
void
DoReset
(
void
);
175
};
176
177
}
// namespace ns3
178
179
#endif // TCPERRORCHANNEL_H
ns3::TcpFlagErrorModel::SetKillRepeat
void SetKillRepeat(int16_t killNumber)
Set how many packets should be killed.
Definition:
tcp-error-model.h:160
ns3::TypeId
a unique identifier for an interface.
Definition:
type-id.h:59
ns3::Ipv4Header
Packet header for IPv4.
Definition:
ipv4-header.h:34
ns3::TcpFlagErrorModel::TcpFlagErrorModel
TcpFlagErrorModel()
Definition:
tcp-error-model.cc:126
ns3::TcpGeneralErrorModel::TcpGeneralErrorModel
TcpGeneralErrorModel()
Definition:
tcp-error-model.cc:38
ns3::TcpGeneralErrorModel::ShouldDrop
virtual bool ShouldDrop(const Ipv4Header &ipHeader, const TcpHeader &tcpHeader, uint32_t packetSize)=0
Check if the packet should be dropped.
ns3::TcpSeqErrorModel::GetTypeId
static TypeId GetTypeId(void)
Get the type ID.
Definition:
tcp-error-model.cc:75
ns3::Callback
Callback template class.
Definition:
callback.h:1279
ns3
Every class exported by the ns3 library is enclosed in the ns3 namespace.
ns3::TcpFlagErrorModel::m_flagsToKill
TcpHeader::Flags_t m_flagsToKill
Flags a packet should have to be dropped.
Definition:
tcp-error-model.h:170
ns3::ErrorModel
General error model that can be used to corrupt packets.
Definition:
error-model.h:116
ns3::TcpFlagErrorModel::m_killNumber
int16_t m_killNumber
The number of times the packet should be killed.
Definition:
tcp-error-model.h:171
ns3::TcpSeqErrorModel::ShouldDrop
virtual bool ShouldDrop(const Ipv4Header &ipHeader, const TcpHeader &tcpHeader, uint32_t packetSize)
Check if the packet should be dropped.
Definition:
tcp-error-model.cc:85
ns3::TcpFlagErrorModel::ShouldDrop
virtual bool ShouldDrop(const Ipv4Header &ipHeader, const TcpHeader &tcpHeader, uint32_t packetSize)
Check if the packet should be dropped.
Definition:
tcp-error-model.cc:134
ns3::TcpSeqErrorModel::m_seqToKill
std::list< SequenceNumber32 > m_seqToKill
List of the sequence numbers to be dropped.
Definition:
tcp-error-model.h:110
ns3::TcpHeader::Flags_t
Flags_t
TCP flag field values.
Definition:
tcp-header.h:280
ns3::TcpGeneralErrorModel::GetTypeId
static TypeId GetTypeId(void)
Get the type ID.
Definition:
tcp-error-model.cc:30
ns3::TcpGeneralErrorModel::SetDropCallback
void SetDropCallback(Callback< void, const Ipv4Header &, const TcpHeader &, Ptr< const Packet > > cb)
Set the drop callback.
Definition:
tcp-error-model.h:52
ns3::Ptr< const Packet >
ns3::TcpSeqErrorModel
An error model TCP aware: it drops the sequence number declared.
Definition:
tcp-error-model.h:83
ns3::TcpFlagErrorModel
Error model which drop packets with specified TCP flags.
Definition:
tcp-error-model.h:130
ns3::TcpFlagErrorModel::GetTypeId
static TypeId GetTypeId(void)
Get the type ID.
Definition:
tcp-error-model.cc:117
ns3::TcpSeqErrorModel::DoReset
virtual void DoReset(void)
Re-initialize any state.
Definition:
tcp-error-model.cc:109
ns3::TcpHeader
Header for the Transmission Control Protocol.
Definition:
tcp-header.h:45
ns3::TcpFlagErrorModel::DoReset
virtual void DoReset(void)
Re-initialize any state.
Definition:
tcp-error-model.cc:163
packetSize
static const uint32_t packetSize
Definition:
wifi-power-adaptation-distance.cc:113
ns3::TcpFlagErrorModel::SetFlagToKill
void SetFlagToKill(TcpHeader::Flags_t flags)
Set the flags of the segment that should be killed.
Definition:
tcp-error-model.h:144
ns3::TcpGeneralErrorModel::m_dropCallback
Callback< void, const Ipv4Header &, const TcpHeader &, Ptr< const Packet > > m_dropCallback
Drop callback.
Definition:
tcp-error-model.h:71
ns3::TcpGeneralErrorModel::DoCorrupt
virtual bool DoCorrupt(Ptr< Packet > p)
Corrupt a packet according to the specified model.
Definition:
tcp-error-model.cc:44
ns3::TcpSeqErrorModel::AddSeqToKill
void AddSeqToKill(const SequenceNumber32 &seq)
Add the sequence number to the list of segments to be killed.
Definition:
tcp-error-model.h:100
ns3::TcpGeneralErrorModel
A general (TCP-aware) error model.
Definition:
tcp-error-model.h:39
ns3::SequenceNumber< uint32_t, int32_t >
ns3::TcpSeqErrorModel::TcpSeqErrorModel
TcpSeqErrorModel()
Definition:
tcp-error-model.h:90
src
internet
test
tcp-error-model.h
Generated on Fri Oct 1 2021 17:03:12 for ns-3 by
1.8.20