A Discrete-Event Network Simulator
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 
36 {
37 public:
38  static TypeId GetTypeId (void);
40 
42  {
43  m_dropCallback = cb;
44  }
45 
46 protected:
47  virtual bool ShouldDrop (const Ipv4Header &ipHeader, const TcpHeader &tcpHeader,
48  uint32_t packetSize) = 0;
49 
50 
51 private:
52  virtual bool DoCorrupt (Ptr<Packet> p);
54 };
55 
62 {
63 public:
64  static TypeId GetTypeId (void);
66 
75  void AddSeqToKill (const SequenceNumber32 &seq)
76  {
77  m_seqToKill.insert(m_seqToKill.end(), seq);
78  }
79 
80 protected:
81  virtual bool ShouldDrop (const Ipv4Header &ipHeader, const TcpHeader &tcpHeader,
82  uint32_t packetSize);
83 
84 protected:
85  std::list<SequenceNumber32> m_seqToKill;
86 
87 private:
88  virtual void DoReset (void);
89 };
90 
102 {
103 public:
104  static TypeId GetTypeId (void);
106 
113  {
114  m_flagsToKill = flags;
115  }
116 
128  void SetKillRepeat (int killNumber)
129  {
130  m_killNumber = killNumber;
131  }
132 
133 protected:
134  virtual bool ShouldDrop (const Ipv4Header &ipHeader, const TcpHeader &tcpHeader,
135  uint32_t packetSize);
136 
137 protected:
140 
141 private:
142  virtual void DoReset (void);
143 };
144 
145 } // namespace ns3
146 
147 #endif // TCPERRORCHANNEL_H
virtual void DoReset(void)
Re-initialize any state.
static TypeId GetTypeId(void)
Callback template class.
Definition: callback.h:1176
void SetDropCallback(Callback< void, const Ipv4Header &, const TcpHeader &, Ptr< const Packet > > cb)
A general (TCP-aware) error model.
General error model that can be used to corrupt packets.
Definition: error-model.h:115
An error model TCP aware: it drops the sequence number declared.
Packet header for IPv4.
Definition: ipv4-header.h:33
void SetKillRepeat(int killNumber)
Set how many packets should be killed.
Flags_t
TCP flag field values.
Definition: tcp-header.h:271
TcpHeader::Flags_t m_flagsToKill
static TypeId GetTypeId(void)
Every class exported by the ns3 library is enclosed in the ns3 namespace.
Header for the Transmission Control Protocol.
Definition: tcp-header.h:44
virtual bool ShouldDrop(const Ipv4Header &ipHeader, const TcpHeader &tcpHeader, uint32_t packetSize)
void AddSeqToKill(const SequenceNumber32 &seq)
Add the sequence number to the list of segments to be killed.
std::list< SequenceNumber32 > m_seqToKill
static TypeId GetTypeId(void)
Error model which drop packets with specified TCP flags.
virtual bool DoCorrupt(Ptr< Packet > p)
Corrupt a packet according to the specified model.
static const uint32_t packetSize
virtual bool ShouldDrop(const Ipv4Header &ipHeader, const TcpHeader &tcpHeader, uint32_t packetSize)
virtual void DoReset(void)
Re-initialize any state.
a unique identifier for an interface.
Definition: type-id.h:58
Callback< void, const Ipv4Header &, const TcpHeader &, Ptr< const Packet > > m_dropCallback
void SetFlagToKill(TcpHeader::Flags_t flags)
Set the flags of the segment that should be killed.
virtual bool ShouldDrop(const Ipv4Header &ipHeader, const TcpHeader &tcpHeader, uint32_t packetSize)=0