A Discrete-Event Network Simulator
API
tcp-error-model.h
Go to the documentation of this file.
1/*
2 * Copyright (c) 2015 Natale Patriciello <natale.patriciello@gmail.com>
3 *
4 * This program is free software; you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License version 2 as
6 * published by the Free Software Foundation;
7 *
8 * This program is distributed in the hope that it will be useful,
9 * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 * GNU General Public License for more details.
12 *
13 * You should have received a copy of the GNU General Public License
14 * along with this program; if not, write to the Free Software
15 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
16 *
17 */
18#ifndef TCPERRORCHANNEL_H
19#define TCPERRORCHANNEL_H
20
21#include "ns3/error-model.h"
22#include "ns3/ipv4-header.h"
23#include "ns3/tcp-header.h"
24
25namespace ns3
26{
27
39{
40 public:
45 static TypeId GetTypeId();
47
53 {
54 m_dropCallback = cb;
55 }
56
57 protected:
65 virtual bool ShouldDrop(const Ipv4Header& ipHeader,
66 const TcpHeader& tcpHeader,
68
69 private:
70 bool DoCorrupt(Ptr<Packet> p) override;
73};
74
84{
85 public:
90 static TypeId GetTypeId();
91
94 {
95 }
96
106 {
107 m_seqToKill.insert(m_seqToKill.end(), seq);
108 }
109
110 protected:
111 bool ShouldDrop(const Ipv4Header& ipHeader,
112 const TcpHeader& tcpHeader,
113 uint32_t packetSize) override;
114
115 protected:
116 std::list<SequenceNumber32> m_seqToKill;
117
118 private:
119 void DoReset() override;
120};
121
136{
137 public:
142 static TypeId GetTypeId();
144
151 {
152 m_flagsToKill = flags;
153 }
154
166 void SetKillRepeat(int16_t killNumber)
167 {
168 m_killNumber = killNumber;
169 }
170
171 protected:
172 bool ShouldDrop(const Ipv4Header& ipHeader,
173 const TcpHeader& tcpHeader,
174 uint32_t packetSize) override;
175
176 protected:
178 int16_t m_killNumber;
179
180 private:
181 void DoReset() override;
182};
183
184} // namespace ns3
185
186#endif // TCPERRORCHANNEL_H
Callback template class.
Definition: callback.h:443
General error model that can be used to corrupt packets.
Definition: error-model.h:117
Packet header for IPv4.
Definition: ipv4-header.h:34
Error model which drop packets with specified TCP flags.
TcpHeader::Flags_t m_flagsToKill
Flags a packet should have to be dropped.
void SetFlagToKill(TcpHeader::Flags_t flags)
Set the flags of the segment that should be killed.
bool ShouldDrop(const Ipv4Header &ipHeader, const TcpHeader &tcpHeader, uint32_t packetSize) override
Check if the packet should be dropped.
void DoReset() override
Re-initialize any state.
void SetKillRepeat(int16_t killNumber)
Set how many packets should be killed.
int16_t m_killNumber
The number of times the packet should be killed.
static TypeId GetTypeId()
Get the type ID.
A general (TCP-aware) error model.
void SetDropCallback(Callback< void, const Ipv4Header &, const TcpHeader &, Ptr< const Packet > > cb)
Set the drop callback.
bool DoCorrupt(Ptr< Packet > p) override
Corrupt a packet according to the specified model.
Callback< void, const Ipv4Header &, const TcpHeader &, Ptr< const Packet > > m_dropCallback
Drop callback.
virtual bool ShouldDrop(const Ipv4Header &ipHeader, const TcpHeader &tcpHeader, uint32_t packetSize)=0
Check if the packet should be dropped.
static TypeId GetTypeId()
Get the type ID.
Header for the Transmission Control Protocol.
Definition: tcp-header.h:46
Flags_t
TCP flag field values.
Definition: tcp-header.h:279
An error model TCP aware: it drops the sequence number declared.
static TypeId GetTypeId()
Get the type ID.
bool ShouldDrop(const Ipv4Header &ipHeader, const TcpHeader &tcpHeader, uint32_t packetSize) override
Check if the packet should be dropped.
void AddSeqToKill(const SequenceNumber32 &seq)
Add the sequence number to the list of segments to be killed.
void DoReset() override
Re-initialize any state.
std::list< SequenceNumber32 > m_seqToKill
List of the sequence numbers to be dropped.
a unique identifier for an interface.
Definition: type-id.h:60
Every class exported by the ns3 library is enclosed in the ns3 namespace.
static const uint32_t packetSize
Packet size generated at the AP.