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
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) 2007 University of Washington
4
* Copyright (c) 2013 ResiliNets, ITTC, University of Kansas
5
*
6
* This program is free software; you can redistribute it and/or modify
7
* it under the terms of the GNU General Public License version 2 as
8
* published by the Free Software Foundation;
9
*
10
* This program is distributed in the hope that it will be useful,
11
* but WITHOUT ANY WARRANTY; without even the implied warranty of
12
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13
* GNU General Public License for more details.
14
*
15
* You should have received a copy of the GNU General Public License
16
* along with this program; if not, write to the Free Software
17
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
18
*
19
*
20
* This file incorporates work covered by the following copyright and
21
* permission notice:
22
*
23
* Copyright (c) 1997 Regents of the University of California.
24
* All rights reserved.
25
*
26
* Redistribution and use in source and binary forms, with or without
27
* modification, are permitted provided that the following conditions
28
* are met:
29
* 1. Redistributions of source code must retain the above copyright
30
* notice, this list of conditions and the following disclaimer.
31
* 2. Redistributions in binary form must reproduce the above copyright
32
* notice, this list of conditions and the following disclaimer in the
33
* documentation and/or other materials provided with the distribution.
34
* 3. Neither the name of the University nor of the Laboratory may be used
35
* to endorse or promote products derived from this software without
36
* specific prior written permission.
37
*
38
* THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
39
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
40
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
41
* ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
42
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
43
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
44
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
45
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
46
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
47
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
48
* SUCH DAMAGE.
49
*
50
* Contributed by the Daedalus Research Group, UC Berkeley
51
* (http://daedalus.cs.berkeley.edu)
52
*
53
* This code has been ported from ns-2 (queue/errmodel.{cc,h}
54
*/
55
56
/* BurstErrorModel additions
57
*
58
* Author: Truc Anh N. Nguyen <annguyen@ittc.ku.edu>
59
* ResiliNets Research Group http://wiki.ittc.ku.edu/resilinets
60
* James P.G. Sterbenz <jpgs@ittc.ku.edu>, director
61
*/
62
63
#ifndef ERROR_MODEL_H
64
#define ERROR_MODEL_H
65
66
#include <list>
67
#include "ns3/object.h"
68
#include "ns3/random-variable-stream.h"
69
70
namespace
ns3 {
71
72
class
Packet;
73
115
class
ErrorModel
:
public
Object
116
{
117
public
:
118
static
TypeId
GetTypeId
(
void
);
119
120
ErrorModel
();
121
virtual
~ErrorModel
();
122
130
bool
IsCorrupt
(
Ptr<Packet>
pkt);
134
void
Reset
(
void
);
138
void
Enable
(
void
);
142
void
Disable
(
void
);
146
bool
IsEnabled
(
void
)
const
;
147
148
private
:
149
/*
150
* These methods must be implemented by subclasses
151
*/
152
virtual
bool
DoCorrupt
(
Ptr<Packet>
) = 0;
153
virtual
void
DoReset
(
void
) = 0;
154
155
bool
m_enable
;
156
};
157
173
class
RateErrorModel
:
public
ErrorModel
174
{
175
public
:
176
static
TypeId
GetTypeId
(
void
);
177
178
RateErrorModel
();
179
virtual
~RateErrorModel
();
180
181
enum
ErrorUnit
182
{
183
ERROR_UNIT_BIT
,
184
ERROR_UNIT_BYTE
,
185
ERROR_UNIT_PACKET
186
};
187
191
RateErrorModel::ErrorUnit
GetUnit
(
void
)
const
;
195
void
SetUnit
(
enum
ErrorUnit
error_unit);
196
200
double
GetRate
(
void
)
const
;
204
void
SetRate
(
double
rate);
205
209
void
SetRandomVariable
(
Ptr<RandomVariableStream>
);
210
219
int64_t
AssignStreams
(int64_t stream);
220
221
private
:
222
virtual
bool
DoCorrupt
(
Ptr<Packet>
p);
223
virtual
bool
DoCorruptPkt
(
Ptr<Packet>
p);
224
virtual
bool
DoCorruptByte
(
Ptr<Packet>
p);
225
virtual
bool
DoCorruptBit
(
Ptr<Packet>
p);
226
virtual
void
DoReset
(
void
);
227
228
enum
ErrorUnit
m_unit
;
229
double
m_rate
;
230
231
Ptr<RandomVariableStream>
m_ranvar
;
232
};
233
234
267
class
BurstErrorModel
:
public
ErrorModel
268
{
269
public
:
270
static
TypeId
GetTypeId
(
void
);
271
272
BurstErrorModel
();
273
virtual
~BurstErrorModel
();
274
278
double
GetBurstRate
(
void
)
const
;
282
void
SetBurstRate
(
double
rate);
283
287
void
SetRandomVariable
(
Ptr<RandomVariableStream>
);
288
292
void
SetRandomBurstSize
(
Ptr<RandomVariableStream>
);
293
302
int64_t
AssignStreams
(int64_t stream);
303
304
private
:
305
virtual
bool
DoCorrupt
(
Ptr<Packet>
p);
306
virtual
void
DoReset
(
void
);
307
308
double
m_burstRate
;
//the burst error event
309
310
Ptr<RandomVariableStream>
m_burstStart
;
//the error decision variable
311
312
Ptr<RandomVariableStream>
m_burstSize
;
//the number of packets being flagged as errored
313
314
uint32_t
m_counter
;
//keep track of the number of packets being errored
315
//until it reaches m_burstSize
316
317
uint32_t
m_currentBurstSz
;
//the current burst size
318
319
};
320
321
344
class
ListErrorModel
:
public
ErrorModel
345
{
346
public
:
347
static
TypeId
GetTypeId
(
void
);
348
ListErrorModel
();
349
virtual
~ListErrorModel
();
350
354
std::list<uint32_t>
GetList
(
void
)
const
;
360
void
SetList
(
const
std::list<uint32_t> &packetlist);
361
362
private
:
363
virtual
bool
DoCorrupt
(
Ptr<Packet>
p);
364
virtual
void
DoReset
(
void
);
365
366
typedef
std::list<uint32_t>
PacketList
;
367
typedef
std::list<uint32_t>::const_iterator
PacketListCI
;
368
369
PacketList
m_packetList
;
370
371
};
372
385
class
ReceiveListErrorModel
:
public
ErrorModel
386
{
387
public
:
388
static
TypeId
GetTypeId
(
void
);
389
ReceiveListErrorModel
();
390
virtual
~ReceiveListErrorModel
();
391
395
std::list<uint32_t>
GetList
(
void
)
const
;
401
void
SetList
(
const
std::list<uint32_t> &packetlist);
402
403
private
:
404
virtual
bool
DoCorrupt
(
Ptr<Packet>
p);
405
virtual
void
DoReset
(
void
);
406
407
typedef
std::list<uint32_t>
PacketList
;
408
typedef
std::list<uint32_t>::const_iterator
PacketListCI
;
409
410
PacketList
m_packetList
;
411
uint32_t
m_timesInvoked
;
412
413
};
414
415
416
}
// namespace ns3
417
#endif
src
network
utils
error-model.h
Generated on Tue May 14 2013 11:08:30 for ns-3 by
1.8.1.2