author | Vedran Mileti? <rivanvx@gmail.com> |
Sat, 01 Sep 2012 20:57:21 +0200 | |
changeset 9063 | 32755d0516f4 |
parent 8996 | d0e0a162a990 |
child 9070 | 0d6be2f9c438 |
permissions | -rw-r--r-- |
1820
736919bd4874
Add src/common/error-model implementation and example script, and add to NetDevices
Tom Henderson <tomh@tomh.org>
parents:
diff
changeset
|
1 |
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */ |
736919bd4874
Add src/common/error-model implementation and example script, and add to NetDevices
Tom Henderson <tomh@tomh.org>
parents:
diff
changeset
|
2 |
/* |
736919bd4874
Add src/common/error-model implementation and example script, and add to NetDevices
Tom Henderson <tomh@tomh.org>
parents:
diff
changeset
|
3 |
* Copyright (c) 2007 University of Washington |
736919bd4874
Add src/common/error-model implementation and example script, and add to NetDevices
Tom Henderson <tomh@tomh.org>
parents:
diff
changeset
|
4 |
* |
736919bd4874
Add src/common/error-model implementation and example script, and add to NetDevices
Tom Henderson <tomh@tomh.org>
parents:
diff
changeset
|
5 |
* This program is free software; you can redistribute it and/or modify |
736919bd4874
Add src/common/error-model implementation and example script, and add to NetDevices
Tom Henderson <tomh@tomh.org>
parents:
diff
changeset
|
6 |
* it under the terms of the GNU General Public License version 2 as |
736919bd4874
Add src/common/error-model implementation and example script, and add to NetDevices
Tom Henderson <tomh@tomh.org>
parents:
diff
changeset
|
7 |
* published by the Free Software Foundation; |
736919bd4874
Add src/common/error-model implementation and example script, and add to NetDevices
Tom Henderson <tomh@tomh.org>
parents:
diff
changeset
|
8 |
* |
736919bd4874
Add src/common/error-model implementation and example script, and add to NetDevices
Tom Henderson <tomh@tomh.org>
parents:
diff
changeset
|
9 |
* This program is distributed in the hope that it will be useful, |
736919bd4874
Add src/common/error-model implementation and example script, and add to NetDevices
Tom Henderson <tomh@tomh.org>
parents:
diff
changeset
|
10 |
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
736919bd4874
Add src/common/error-model implementation and example script, and add to NetDevices
Tom Henderson <tomh@tomh.org>
parents:
diff
changeset
|
11 |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
736919bd4874
Add src/common/error-model implementation and example script, and add to NetDevices
Tom Henderson <tomh@tomh.org>
parents:
diff
changeset
|
12 |
* GNU General Public License for more details. |
736919bd4874
Add src/common/error-model implementation and example script, and add to NetDevices
Tom Henderson <tomh@tomh.org>
parents:
diff
changeset
|
13 |
* |
736919bd4874
Add src/common/error-model implementation and example script, and add to NetDevices
Tom Henderson <tomh@tomh.org>
parents:
diff
changeset
|
14 |
* You should have received a copy of the GNU General Public License |
736919bd4874
Add src/common/error-model implementation and example script, and add to NetDevices
Tom Henderson <tomh@tomh.org>
parents:
diff
changeset
|
15 |
* along with this program; if not, write to the Free Software |
736919bd4874
Add src/common/error-model implementation and example script, and add to NetDevices
Tom Henderson <tomh@tomh.org>
parents:
diff
changeset
|
16 |
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA |
736919bd4874
Add src/common/error-model implementation and example script, and add to NetDevices
Tom Henderson <tomh@tomh.org>
parents:
diff
changeset
|
17 |
* |
7876
6689d37e36e0
Align licenses according to SFLC recommendations
Tom Henderson <tomh@tomh.org>
parents:
7871
diff
changeset
|
18 |
* |
6689d37e36e0
Align licenses according to SFLC recommendations
Tom Henderson <tomh@tomh.org>
parents:
7871
diff
changeset
|
19 |
* This file incorporates work covered by the following copyright and |
6689d37e36e0
Align licenses according to SFLC recommendations
Tom Henderson <tomh@tomh.org>
parents:
7871
diff
changeset
|
20 |
* permission notice: |
6689d37e36e0
Align licenses according to SFLC recommendations
Tom Henderson <tomh@tomh.org>
parents:
7871
diff
changeset
|
21 |
* |
6689d37e36e0
Align licenses according to SFLC recommendations
Tom Henderson <tomh@tomh.org>
parents:
7871
diff
changeset
|
22 |
* Copyright (c) 1997 Regents of the University of California. |
6689d37e36e0
Align licenses according to SFLC recommendations
Tom Henderson <tomh@tomh.org>
parents:
7871
diff
changeset
|
23 |
* All rights reserved. |
6689d37e36e0
Align licenses according to SFLC recommendations
Tom Henderson <tomh@tomh.org>
parents:
7871
diff
changeset
|
24 |
* |
6689d37e36e0
Align licenses according to SFLC recommendations
Tom Henderson <tomh@tomh.org>
parents:
7871
diff
changeset
|
25 |
* Redistribution and use in source and binary forms, with or without |
6689d37e36e0
Align licenses according to SFLC recommendations
Tom Henderson <tomh@tomh.org>
parents:
7871
diff
changeset
|
26 |
* modification, are permitted provided that the following conditions |
6689d37e36e0
Align licenses according to SFLC recommendations
Tom Henderson <tomh@tomh.org>
parents:
7871
diff
changeset
|
27 |
* are met: |
6689d37e36e0
Align licenses according to SFLC recommendations
Tom Henderson <tomh@tomh.org>
parents:
7871
diff
changeset
|
28 |
* 1. Redistributions of source code must retain the above copyright |
6689d37e36e0
Align licenses according to SFLC recommendations
Tom Henderson <tomh@tomh.org>
parents:
7871
diff
changeset
|
29 |
* notice, this list of conditions and the following disclaimer. |
6689d37e36e0
Align licenses according to SFLC recommendations
Tom Henderson <tomh@tomh.org>
parents:
7871
diff
changeset
|
30 |
* 2. Redistributions in binary form must reproduce the above copyright |
6689d37e36e0
Align licenses according to SFLC recommendations
Tom Henderson <tomh@tomh.org>
parents:
7871
diff
changeset
|
31 |
* notice, this list of conditions and the following disclaimer in the |
6689d37e36e0
Align licenses according to SFLC recommendations
Tom Henderson <tomh@tomh.org>
parents:
7871
diff
changeset
|
32 |
* documentation and/or other materials provided with the distribution. |
6689d37e36e0
Align licenses according to SFLC recommendations
Tom Henderson <tomh@tomh.org>
parents:
7871
diff
changeset
|
33 |
* 3. Neither the name of the University nor of the Laboratory may be used |
6689d37e36e0
Align licenses according to SFLC recommendations
Tom Henderson <tomh@tomh.org>
parents:
7871
diff
changeset
|
34 |
* to endorse or promote products derived from this software without |
6689d37e36e0
Align licenses according to SFLC recommendations
Tom Henderson <tomh@tomh.org>
parents:
7871
diff
changeset
|
35 |
* specific prior written permission. |
6689d37e36e0
Align licenses according to SFLC recommendations
Tom Henderson <tomh@tomh.org>
parents:
7871
diff
changeset
|
36 |
* |
6689d37e36e0
Align licenses according to SFLC recommendations
Tom Henderson <tomh@tomh.org>
parents:
7871
diff
changeset
|
37 |
* THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND |
6689d37e36e0
Align licenses according to SFLC recommendations
Tom Henderson <tomh@tomh.org>
parents:
7871
diff
changeset
|
38 |
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE |
6689d37e36e0
Align licenses according to SFLC recommendations
Tom Henderson <tomh@tomh.org>
parents:
7871
diff
changeset
|
39 |
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE |
6689d37e36e0
Align licenses according to SFLC recommendations
Tom Henderson <tomh@tomh.org>
parents:
7871
diff
changeset
|
40 |
* ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE |
6689d37e36e0
Align licenses according to SFLC recommendations
Tom Henderson <tomh@tomh.org>
parents:
7871
diff
changeset
|
41 |
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL |
6689d37e36e0
Align licenses according to SFLC recommendations
Tom Henderson <tomh@tomh.org>
parents:
7871
diff
changeset
|
42 |
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS |
6689d37e36e0
Align licenses according to SFLC recommendations
Tom Henderson <tomh@tomh.org>
parents:
7871
diff
changeset
|
43 |
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) |
6689d37e36e0
Align licenses according to SFLC recommendations
Tom Henderson <tomh@tomh.org>
parents:
7871
diff
changeset
|
44 |
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT |
6689d37e36e0
Align licenses according to SFLC recommendations
Tom Henderson <tomh@tomh.org>
parents:
7871
diff
changeset
|
45 |
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY |
6689d37e36e0
Align licenses according to SFLC recommendations
Tom Henderson <tomh@tomh.org>
parents:
7871
diff
changeset
|
46 |
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF |
6689d37e36e0
Align licenses according to SFLC recommendations
Tom Henderson <tomh@tomh.org>
parents:
7871
diff
changeset
|
47 |
* SUCH DAMAGE. |
6689d37e36e0
Align licenses according to SFLC recommendations
Tom Henderson <tomh@tomh.org>
parents:
7871
diff
changeset
|
48 |
* |
6689d37e36e0
Align licenses according to SFLC recommendations
Tom Henderson <tomh@tomh.org>
parents:
7871
diff
changeset
|
49 |
* Contributed by the Daedalus Research Group, UC Berkeley |
6689d37e36e0
Align licenses according to SFLC recommendations
Tom Henderson <tomh@tomh.org>
parents:
7871
diff
changeset
|
50 |
* (http://daedalus.cs.berkeley.edu) |
6689d37e36e0
Align licenses according to SFLC recommendations
Tom Henderson <tomh@tomh.org>
parents:
7871
diff
changeset
|
51 |
* |
1820
736919bd4874
Add src/common/error-model implementation and example script, and add to NetDevices
Tom Henderson <tomh@tomh.org>
parents:
diff
changeset
|
52 |
* This code has been ported from ns-2 (queue/errmodel.{cc,h} |
736919bd4874
Add src/common/error-model implementation and example script, and add to NetDevices
Tom Henderson <tomh@tomh.org>
parents:
diff
changeset
|
53 |
*/ |
736919bd4874
Add src/common/error-model implementation and example script, and add to NetDevices
Tom Henderson <tomh@tomh.org>
parents:
diff
changeset
|
54 |
|
9063
32755d0516f4
Bug 1237 - code cleanups related to includes
Vedran Mileti? <rivanvx@gmail.com>
parents:
8996
diff
changeset
|
55 |
#include <cmath> |
1820
736919bd4874
Add src/common/error-model implementation and example script, and add to NetDevices
Tom Henderson <tomh@tomh.org>
parents:
diff
changeset
|
56 |
|
736919bd4874
Add src/common/error-model implementation and example script, and add to NetDevices
Tom Henderson <tomh@tomh.org>
parents:
diff
changeset
|
57 |
#include "error-model.h" |
736919bd4874
Add src/common/error-model implementation and example script, and add to NetDevices
Tom Henderson <tomh@tomh.org>
parents:
diff
changeset
|
58 |
|
736919bd4874
Add src/common/error-model implementation and example script, and add to NetDevices
Tom Henderson <tomh@tomh.org>
parents:
diff
changeset
|
59 |
#include "ns3/packet.h" |
736919bd4874
Add src/common/error-model implementation and example script, and add to NetDevices
Tom Henderson <tomh@tomh.org>
parents:
diff
changeset
|
60 |
#include "ns3/assert.h" |
736919bd4874
Add src/common/error-model implementation and example script, and add to NetDevices
Tom Henderson <tomh@tomh.org>
parents:
diff
changeset
|
61 |
#include "ns3/log.h" |
2481
8db62d9a69fd
use Attributes in ErrorModel.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2402
diff
changeset
|
62 |
#include "ns3/boolean.h" |
8db62d9a69fd
use Attributes in ErrorModel.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2402
diff
changeset
|
63 |
#include "ns3/enum.h" |
8db62d9a69fd
use Attributes in ErrorModel.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2402
diff
changeset
|
64 |
#include "ns3/double.h" |
8986
3391f6a7fb3b
Replace src/network usage of RandomVariable with RandomVariableStream
Mitch Watrous
parents:
7876
diff
changeset
|
65 |
#include "ns3/string.h" |
3391f6a7fb3b
Replace src/network usage of RandomVariable with RandomVariableStream
Mitch Watrous
parents:
7876
diff
changeset
|
66 |
#include "ns3/pointer.h" |
1820
736919bd4874
Add src/common/error-model implementation and example script, and add to NetDevices
Tom Henderson <tomh@tomh.org>
parents:
diff
changeset
|
67 |
|
736919bd4874
Add src/common/error-model implementation and example script, and add to NetDevices
Tom Henderson <tomh@tomh.org>
parents:
diff
changeset
|
68 |
NS_LOG_COMPONENT_DEFINE ("ErrorModel"); |
736919bd4874
Add src/common/error-model implementation and example script, and add to NetDevices
Tom Henderson <tomh@tomh.org>
parents:
diff
changeset
|
69 |
|
736919bd4874
Add src/common/error-model implementation and example script, and add to NetDevices
Tom Henderson <tomh@tomh.org>
parents:
diff
changeset
|
70 |
namespace ns3 { |
736919bd4874
Add src/common/error-model implementation and example script, and add to NetDevices
Tom Henderson <tomh@tomh.org>
parents:
diff
changeset
|
71 |
|
2249
3a1da26d61dc
replace ComponentManager::Create and ClassId with InterfaceId::CreateObjest and InterfaceId
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2238
diff
changeset
|
72 |
NS_OBJECT_ENSURE_REGISTERED (ErrorModel); |
1820
736919bd4874
Add src/common/error-model implementation and example script, and add to NetDevices
Tom Henderson <tomh@tomh.org>
parents:
diff
changeset
|
73 |
|
2251
04963d8cca51
iid (void) -> GetTypeId (void)
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2250
diff
changeset
|
74 |
TypeId ErrorModel::GetTypeId (void) |
2232
9abd038ee588
replace static const Interface iid; with static InterfaceId iid (void);
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2230
diff
changeset
|
75 |
{ |
2602
d9262bff6df2
add back support for introspected doxygen.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2503
diff
changeset
|
76 |
static TypeId tid = TypeId ("ns3::ErrorModel") |
2481
8db62d9a69fd
use Attributes in ErrorModel.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2402
diff
changeset
|
77 |
.SetParent<Object> () |
8db62d9a69fd
use Attributes in ErrorModel.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2402
diff
changeset
|
78 |
.AddAttribute ("IsEnabled", "Whether this ErrorModel is enabled or not.", |
2965
4b28e9740e3b
get rid of Attribute class. Use AttributeValue subclasses directly.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2602
diff
changeset
|
79 |
BooleanValue (true), |
2481
8db62d9a69fd
use Attributes in ErrorModel.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2402
diff
changeset
|
80 |
MakeBooleanAccessor (&ErrorModel::m_enable), |
8db62d9a69fd
use Attributes in ErrorModel.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2402
diff
changeset
|
81 |
MakeBooleanChecker ()) |
7182
5ecfee5d17de
network coding style changes
Josh Pelkey <jpelkey@gatech.edu>
parents:
6823
diff
changeset
|
82 |
; |
2252
80595448707a
iid -> tid
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2251
diff
changeset
|
83 |
return tid; |
2232
9abd038ee588
replace static const Interface iid; with static InterfaceId iid (void);
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2230
diff
changeset
|
84 |
} |
1820
736919bd4874
Add src/common/error-model implementation and example script, and add to NetDevices
Tom Henderson <tomh@tomh.org>
parents:
diff
changeset
|
85 |
|
736919bd4874
Add src/common/error-model implementation and example script, and add to NetDevices
Tom Henderson <tomh@tomh.org>
parents:
diff
changeset
|
86 |
ErrorModel::ErrorModel () : |
736919bd4874
Add src/common/error-model implementation and example script, and add to NetDevices
Tom Henderson <tomh@tomh.org>
parents:
diff
changeset
|
87 |
m_enable (true) |
736919bd4874
Add src/common/error-model implementation and example script, and add to NetDevices
Tom Henderson <tomh@tomh.org>
parents:
diff
changeset
|
88 |
{ |
2983
e3a416fe9dd5
NS_LOG_FUNCTION -> NS_LOG_FUNCTION_NOARGS and NS_LOG_PARAMS -> NS_LOG_FUNCTION
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2602
diff
changeset
|
89 |
NS_LOG_FUNCTION_NOARGS (); |
1820
736919bd4874
Add src/common/error-model implementation and example script, and add to NetDevices
Tom Henderson <tomh@tomh.org>
parents:
diff
changeset
|
90 |
} |
736919bd4874
Add src/common/error-model implementation and example script, and add to NetDevices
Tom Henderson <tomh@tomh.org>
parents:
diff
changeset
|
91 |
|
736919bd4874
Add src/common/error-model implementation and example script, and add to NetDevices
Tom Henderson <tomh@tomh.org>
parents:
diff
changeset
|
92 |
ErrorModel::~ErrorModel () |
736919bd4874
Add src/common/error-model implementation and example script, and add to NetDevices
Tom Henderson <tomh@tomh.org>
parents:
diff
changeset
|
93 |
{ |
2983
e3a416fe9dd5
NS_LOG_FUNCTION -> NS_LOG_FUNCTION_NOARGS and NS_LOG_PARAMS -> NS_LOG_FUNCTION
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2602
diff
changeset
|
94 |
NS_LOG_FUNCTION_NOARGS (); |
1820
736919bd4874
Add src/common/error-model implementation and example script, and add to NetDevices
Tom Henderson <tomh@tomh.org>
parents:
diff
changeset
|
95 |
} |
736919bd4874
Add src/common/error-model implementation and example script, and add to NetDevices
Tom Henderson <tomh@tomh.org>
parents:
diff
changeset
|
96 |
|
736919bd4874
Add src/common/error-model implementation and example script, and add to NetDevices
Tom Henderson <tomh@tomh.org>
parents:
diff
changeset
|
97 |
bool |
1870 | 98 |
ErrorModel::IsCorrupt (Ptr<Packet> p) |
1820
736919bd4874
Add src/common/error-model implementation and example script, and add to NetDevices
Tom Henderson <tomh@tomh.org>
parents:
diff
changeset
|
99 |
{ |
2983
e3a416fe9dd5
NS_LOG_FUNCTION -> NS_LOG_FUNCTION_NOARGS and NS_LOG_PARAMS -> NS_LOG_FUNCTION
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2602
diff
changeset
|
100 |
NS_LOG_FUNCTION_NOARGS (); |
1820
736919bd4874
Add src/common/error-model implementation and example script, and add to NetDevices
Tom Henderson <tomh@tomh.org>
parents:
diff
changeset
|
101 |
bool result; |
736919bd4874
Add src/common/error-model implementation and example script, and add to NetDevices
Tom Henderson <tomh@tomh.org>
parents:
diff
changeset
|
102 |
// Insert any pre-conditions here |
736919bd4874
Add src/common/error-model implementation and example script, and add to NetDevices
Tom Henderson <tomh@tomh.org>
parents:
diff
changeset
|
103 |
result = DoCorrupt (p); |
736919bd4874
Add src/common/error-model implementation and example script, and add to NetDevices
Tom Henderson <tomh@tomh.org>
parents:
diff
changeset
|
104 |
// Insert any post-conditions here |
736919bd4874
Add src/common/error-model implementation and example script, and add to NetDevices
Tom Henderson <tomh@tomh.org>
parents:
diff
changeset
|
105 |
return result; |
736919bd4874
Add src/common/error-model implementation and example script, and add to NetDevices
Tom Henderson <tomh@tomh.org>
parents:
diff
changeset
|
106 |
} |
736919bd4874
Add src/common/error-model implementation and example script, and add to NetDevices
Tom Henderson <tomh@tomh.org>
parents:
diff
changeset
|
107 |
|
736919bd4874
Add src/common/error-model implementation and example script, and add to NetDevices
Tom Henderson <tomh@tomh.org>
parents:
diff
changeset
|
108 |
void |
736919bd4874
Add src/common/error-model implementation and example script, and add to NetDevices
Tom Henderson <tomh@tomh.org>
parents:
diff
changeset
|
109 |
ErrorModel::Reset (void) |
736919bd4874
Add src/common/error-model implementation and example script, and add to NetDevices
Tom Henderson <tomh@tomh.org>
parents:
diff
changeset
|
110 |
{ |
2983
e3a416fe9dd5
NS_LOG_FUNCTION -> NS_LOG_FUNCTION_NOARGS and NS_LOG_PARAMS -> NS_LOG_FUNCTION
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2602
diff
changeset
|
111 |
NS_LOG_FUNCTION_NOARGS (); |
1820
736919bd4874
Add src/common/error-model implementation and example script, and add to NetDevices
Tom Henderson <tomh@tomh.org>
parents:
diff
changeset
|
112 |
DoReset (); |
736919bd4874
Add src/common/error-model implementation and example script, and add to NetDevices
Tom Henderson <tomh@tomh.org>
parents:
diff
changeset
|
113 |
} |
736919bd4874
Add src/common/error-model implementation and example script, and add to NetDevices
Tom Henderson <tomh@tomh.org>
parents:
diff
changeset
|
114 |
|
736919bd4874
Add src/common/error-model implementation and example script, and add to NetDevices
Tom Henderson <tomh@tomh.org>
parents:
diff
changeset
|
115 |
void |
736919bd4874
Add src/common/error-model implementation and example script, and add to NetDevices
Tom Henderson <tomh@tomh.org>
parents:
diff
changeset
|
116 |
ErrorModel::Enable (void) |
736919bd4874
Add src/common/error-model implementation and example script, and add to NetDevices
Tom Henderson <tomh@tomh.org>
parents:
diff
changeset
|
117 |
{ |
2983
e3a416fe9dd5
NS_LOG_FUNCTION -> NS_LOG_FUNCTION_NOARGS and NS_LOG_PARAMS -> NS_LOG_FUNCTION
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2602
diff
changeset
|
118 |
NS_LOG_FUNCTION_NOARGS (); |
1820
736919bd4874
Add src/common/error-model implementation and example script, and add to NetDevices
Tom Henderson <tomh@tomh.org>
parents:
diff
changeset
|
119 |
m_enable = true; |
736919bd4874
Add src/common/error-model implementation and example script, and add to NetDevices
Tom Henderson <tomh@tomh.org>
parents:
diff
changeset
|
120 |
} |
736919bd4874
Add src/common/error-model implementation and example script, and add to NetDevices
Tom Henderson <tomh@tomh.org>
parents:
diff
changeset
|
121 |
|
736919bd4874
Add src/common/error-model implementation and example script, and add to NetDevices
Tom Henderson <tomh@tomh.org>
parents:
diff
changeset
|
122 |
void |
736919bd4874
Add src/common/error-model implementation and example script, and add to NetDevices
Tom Henderson <tomh@tomh.org>
parents:
diff
changeset
|
123 |
ErrorModel::Disable (void) |
736919bd4874
Add src/common/error-model implementation and example script, and add to NetDevices
Tom Henderson <tomh@tomh.org>
parents:
diff
changeset
|
124 |
{ |
2983
e3a416fe9dd5
NS_LOG_FUNCTION -> NS_LOG_FUNCTION_NOARGS and NS_LOG_PARAMS -> NS_LOG_FUNCTION
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2602
diff
changeset
|
125 |
NS_LOG_FUNCTION_NOARGS (); |
1820
736919bd4874
Add src/common/error-model implementation and example script, and add to NetDevices
Tom Henderson <tomh@tomh.org>
parents:
diff
changeset
|
126 |
m_enable = false; |
736919bd4874
Add src/common/error-model implementation and example script, and add to NetDevices
Tom Henderson <tomh@tomh.org>
parents:
diff
changeset
|
127 |
} |
736919bd4874
Add src/common/error-model implementation and example script, and add to NetDevices
Tom Henderson <tomh@tomh.org>
parents:
diff
changeset
|
128 |
|
736919bd4874
Add src/common/error-model implementation and example script, and add to NetDevices
Tom Henderson <tomh@tomh.org>
parents:
diff
changeset
|
129 |
bool |
736919bd4874
Add src/common/error-model implementation and example script, and add to NetDevices
Tom Henderson <tomh@tomh.org>
parents:
diff
changeset
|
130 |
ErrorModel::IsEnabled (void) const |
736919bd4874
Add src/common/error-model implementation and example script, and add to NetDevices
Tom Henderson <tomh@tomh.org>
parents:
diff
changeset
|
131 |
{ |
2983
e3a416fe9dd5
NS_LOG_FUNCTION -> NS_LOG_FUNCTION_NOARGS and NS_LOG_PARAMS -> NS_LOG_FUNCTION
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2602
diff
changeset
|
132 |
NS_LOG_FUNCTION_NOARGS (); |
1820
736919bd4874
Add src/common/error-model implementation and example script, and add to NetDevices
Tom Henderson <tomh@tomh.org>
parents:
diff
changeset
|
133 |
return m_enable; |
736919bd4874
Add src/common/error-model implementation and example script, and add to NetDevices
Tom Henderson <tomh@tomh.org>
parents:
diff
changeset
|
134 |
} |
736919bd4874
Add src/common/error-model implementation and example script, and add to NetDevices
Tom Henderson <tomh@tomh.org>
parents:
diff
changeset
|
135 |
|
736919bd4874
Add src/common/error-model implementation and example script, and add to NetDevices
Tom Henderson <tomh@tomh.org>
parents:
diff
changeset
|
136 |
// |
736919bd4874
Add src/common/error-model implementation and example script, and add to NetDevices
Tom Henderson <tomh@tomh.org>
parents:
diff
changeset
|
137 |
// RateErrorModel |
736919bd4874
Add src/common/error-model implementation and example script, and add to NetDevices
Tom Henderson <tomh@tomh.org>
parents:
diff
changeset
|
138 |
// |
736919bd4874
Add src/common/error-model implementation and example script, and add to NetDevices
Tom Henderson <tomh@tomh.org>
parents:
diff
changeset
|
139 |
|
2249
3a1da26d61dc
replace ComponentManager::Create and ClassId with InterfaceId::CreateObjest and InterfaceId
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2238
diff
changeset
|
140 |
NS_OBJECT_ENSURE_REGISTERED (RateErrorModel); |
3a1da26d61dc
replace ComponentManager::Create and ClassId with InterfaceId::CreateObjest and InterfaceId
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2238
diff
changeset
|
141 |
|
2251
04963d8cca51
iid (void) -> GetTypeId (void)
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2250
diff
changeset
|
142 |
TypeId RateErrorModel::GetTypeId (void) |
2232
9abd038ee588
replace static const Interface iid; with static InterfaceId iid (void);
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2230
diff
changeset
|
143 |
{ |
2602
d9262bff6df2
add back support for introspected doxygen.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2503
diff
changeset
|
144 |
static TypeId tid = TypeId ("ns3::RateErrorModel") |
2249
3a1da26d61dc
replace ComponentManager::Create and ClassId with InterfaceId::CreateObjest and InterfaceId
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2238
diff
changeset
|
145 |
.SetParent<ErrorModel> () |
2481
8db62d9a69fd
use Attributes in ErrorModel.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2402
diff
changeset
|
146 |
.AddConstructor<RateErrorModel> () |
2493
2cd8723ece97
use names closer to those used in the previous DefaultValues.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2481
diff
changeset
|
147 |
.AddAttribute ("ErrorUnit", "The error unit", |
7871
94986f4b94b1
Use longer names for QueueMode and ErrorUnit enums and move them to Queue and RateErrorModel classes respectively.
Vedran Mileti? <rivanvx@gmail.com>
parents:
7386
diff
changeset
|
148 |
EnumValue (ERROR_UNIT_BYTE), |
2481
8db62d9a69fd
use Attributes in ErrorModel.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2402
diff
changeset
|
149 |
MakeEnumAccessor (&RateErrorModel::m_unit), |
7871
94986f4b94b1
Use longer names for QueueMode and ErrorUnit enums and move them to Queue and RateErrorModel classes respectively.
Vedran Mileti? <rivanvx@gmail.com>
parents:
7386
diff
changeset
|
150 |
MakeEnumChecker (ERROR_UNIT_BIT, "ERROR_UNIT_BIT", |
94986f4b94b1
Use longer names for QueueMode and ErrorUnit enums and move them to Queue and RateErrorModel classes respectively.
Vedran Mileti? <rivanvx@gmail.com>
parents:
7386
diff
changeset
|
151 |
ERROR_UNIT_BYTE, "ERROR_UNIT_BYTE", |
94986f4b94b1
Use longer names for QueueMode and ErrorUnit enums and move them to Queue and RateErrorModel classes respectively.
Vedran Mileti? <rivanvx@gmail.com>
parents:
7386
diff
changeset
|
152 |
ERROR_UNIT_PACKET, "ERROR_UNIT_PACKET")) |
2493
2cd8723ece97
use names closer to those used in the previous DefaultValues.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2481
diff
changeset
|
153 |
.AddAttribute ("ErrorRate", "The error rate.", |
2965
4b28e9740e3b
get rid of Attribute class. Use AttributeValue subclasses directly.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2602
diff
changeset
|
154 |
DoubleValue (0.0), |
2481
8db62d9a69fd
use Attributes in ErrorModel.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2402
diff
changeset
|
155 |
MakeDoubleAccessor (&RateErrorModel::m_rate), |
8db62d9a69fd
use Attributes in ErrorModel.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2402
diff
changeset
|
156 |
MakeDoubleChecker<double> ()) |
8db62d9a69fd
use Attributes in ErrorModel.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2402
diff
changeset
|
157 |
.AddAttribute ("RanVar", "The decision variable attached to this error model.", |
8986
3391f6a7fb3b
Replace src/network usage of RandomVariable with RandomVariableStream
Mitch Watrous
parents:
7876
diff
changeset
|
158 |
StringValue ("ns3::UniformRandomVariable[Min=0.0|Max=1.0]"), |
3391f6a7fb3b
Replace src/network usage of RandomVariable with RandomVariableStream
Mitch Watrous
parents:
7876
diff
changeset
|
159 |
MakePointerAccessor (&RateErrorModel::m_ranvar), |
3391f6a7fb3b
Replace src/network usage of RandomVariable with RandomVariableStream
Mitch Watrous
parents:
7876
diff
changeset
|
160 |
MakePointerChecker<RandomVariableStream> ()) |
7182
5ecfee5d17de
network coding style changes
Josh Pelkey <jpelkey@gatech.edu>
parents:
6823
diff
changeset
|
161 |
; |
2252
80595448707a
iid -> tid
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2251
diff
changeset
|
162 |
return tid; |
2232
9abd038ee588
replace static const Interface iid; with static InterfaceId iid (void);
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2230
diff
changeset
|
163 |
} |
9abd038ee588
replace static const Interface iid; with static InterfaceId iid (void);
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2230
diff
changeset
|
164 |
|
9abd038ee588
replace static const Interface iid; with static InterfaceId iid (void);
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2230
diff
changeset
|
165 |
|
2481
8db62d9a69fd
use Attributes in ErrorModel.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2402
diff
changeset
|
166 |
RateErrorModel::RateErrorModel () |
1820
736919bd4874
Add src/common/error-model implementation and example script, and add to NetDevices
Tom Henderson <tomh@tomh.org>
parents:
diff
changeset
|
167 |
{ |
2983
e3a416fe9dd5
NS_LOG_FUNCTION -> NS_LOG_FUNCTION_NOARGS and NS_LOG_PARAMS -> NS_LOG_FUNCTION
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2602
diff
changeset
|
168 |
NS_LOG_FUNCTION_NOARGS (); |
1820
736919bd4874
Add src/common/error-model implementation and example script, and add to NetDevices
Tom Henderson <tomh@tomh.org>
parents:
diff
changeset
|
169 |
} |
736919bd4874
Add src/common/error-model implementation and example script, and add to NetDevices
Tom Henderson <tomh@tomh.org>
parents:
diff
changeset
|
170 |
|
736919bd4874
Add src/common/error-model implementation and example script, and add to NetDevices
Tom Henderson <tomh@tomh.org>
parents:
diff
changeset
|
171 |
RateErrorModel::~RateErrorModel () |
736919bd4874
Add src/common/error-model implementation and example script, and add to NetDevices
Tom Henderson <tomh@tomh.org>
parents:
diff
changeset
|
172 |
{ |
2983
e3a416fe9dd5
NS_LOG_FUNCTION -> NS_LOG_FUNCTION_NOARGS and NS_LOG_PARAMS -> NS_LOG_FUNCTION
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2602
diff
changeset
|
173 |
NS_LOG_FUNCTION_NOARGS (); |
1820
736919bd4874
Add src/common/error-model implementation and example script, and add to NetDevices
Tom Henderson <tomh@tomh.org>
parents:
diff
changeset
|
174 |
} |
736919bd4874
Add src/common/error-model implementation and example script, and add to NetDevices
Tom Henderson <tomh@tomh.org>
parents:
diff
changeset
|
175 |
|
7871
94986f4b94b1
Use longer names for QueueMode and ErrorUnit enums and move them to Queue and RateErrorModel classes respectively.
Vedran Mileti? <rivanvx@gmail.com>
parents:
7386
diff
changeset
|
176 |
RateErrorModel::ErrorUnit |
1820
736919bd4874
Add src/common/error-model implementation and example script, and add to NetDevices
Tom Henderson <tomh@tomh.org>
parents:
diff
changeset
|
177 |
RateErrorModel::GetUnit (void) const |
736919bd4874
Add src/common/error-model implementation and example script, and add to NetDevices
Tom Henderson <tomh@tomh.org>
parents:
diff
changeset
|
178 |
{ |
2983
e3a416fe9dd5
NS_LOG_FUNCTION -> NS_LOG_FUNCTION_NOARGS and NS_LOG_PARAMS -> NS_LOG_FUNCTION
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2602
diff
changeset
|
179 |
NS_LOG_FUNCTION_NOARGS (); |
1820
736919bd4874
Add src/common/error-model implementation and example script, and add to NetDevices
Tom Henderson <tomh@tomh.org>
parents:
diff
changeset
|
180 |
return m_unit; |
736919bd4874
Add src/common/error-model implementation and example script, and add to NetDevices
Tom Henderson <tomh@tomh.org>
parents:
diff
changeset
|
181 |
} |
736919bd4874
Add src/common/error-model implementation and example script, and add to NetDevices
Tom Henderson <tomh@tomh.org>
parents:
diff
changeset
|
182 |
|
736919bd4874
Add src/common/error-model implementation and example script, and add to NetDevices
Tom Henderson <tomh@tomh.org>
parents:
diff
changeset
|
183 |
void |
736919bd4874
Add src/common/error-model implementation and example script, and add to NetDevices
Tom Henderson <tomh@tomh.org>
parents:
diff
changeset
|
184 |
RateErrorModel::SetUnit (enum ErrorUnit error_unit) |
736919bd4874
Add src/common/error-model implementation and example script, and add to NetDevices
Tom Henderson <tomh@tomh.org>
parents:
diff
changeset
|
185 |
{ |
2983
e3a416fe9dd5
NS_LOG_FUNCTION -> NS_LOG_FUNCTION_NOARGS and NS_LOG_PARAMS -> NS_LOG_FUNCTION
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2602
diff
changeset
|
186 |
NS_LOG_FUNCTION_NOARGS (); |
1820
736919bd4874
Add src/common/error-model implementation and example script, and add to NetDevices
Tom Henderson <tomh@tomh.org>
parents:
diff
changeset
|
187 |
m_unit = error_unit; |
736919bd4874
Add src/common/error-model implementation and example script, and add to NetDevices
Tom Henderson <tomh@tomh.org>
parents:
diff
changeset
|
188 |
} |
736919bd4874
Add src/common/error-model implementation and example script, and add to NetDevices
Tom Henderson <tomh@tomh.org>
parents:
diff
changeset
|
189 |
|
736919bd4874
Add src/common/error-model implementation and example script, and add to NetDevices
Tom Henderson <tomh@tomh.org>
parents:
diff
changeset
|
190 |
double |
736919bd4874
Add src/common/error-model implementation and example script, and add to NetDevices
Tom Henderson <tomh@tomh.org>
parents:
diff
changeset
|
191 |
RateErrorModel::GetRate (void) const |
736919bd4874
Add src/common/error-model implementation and example script, and add to NetDevices
Tom Henderson <tomh@tomh.org>
parents:
diff
changeset
|
192 |
{ |
2983
e3a416fe9dd5
NS_LOG_FUNCTION -> NS_LOG_FUNCTION_NOARGS and NS_LOG_PARAMS -> NS_LOG_FUNCTION
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2602
diff
changeset
|
193 |
NS_LOG_FUNCTION_NOARGS (); |
1820
736919bd4874
Add src/common/error-model implementation and example script, and add to NetDevices
Tom Henderson <tomh@tomh.org>
parents:
diff
changeset
|
194 |
return m_rate; |
736919bd4874
Add src/common/error-model implementation and example script, and add to NetDevices
Tom Henderson <tomh@tomh.org>
parents:
diff
changeset
|
195 |
} |
736919bd4874
Add src/common/error-model implementation and example script, and add to NetDevices
Tom Henderson <tomh@tomh.org>
parents:
diff
changeset
|
196 |
|
736919bd4874
Add src/common/error-model implementation and example script, and add to NetDevices
Tom Henderson <tomh@tomh.org>
parents:
diff
changeset
|
197 |
void |
736919bd4874
Add src/common/error-model implementation and example script, and add to NetDevices
Tom Henderson <tomh@tomh.org>
parents:
diff
changeset
|
198 |
RateErrorModel::SetRate (double rate) |
736919bd4874
Add src/common/error-model implementation and example script, and add to NetDevices
Tom Henderson <tomh@tomh.org>
parents:
diff
changeset
|
199 |
{ |
2983
e3a416fe9dd5
NS_LOG_FUNCTION -> NS_LOG_FUNCTION_NOARGS and NS_LOG_PARAMS -> NS_LOG_FUNCTION
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2602
diff
changeset
|
200 |
NS_LOG_FUNCTION_NOARGS (); |
1820
736919bd4874
Add src/common/error-model implementation and example script, and add to NetDevices
Tom Henderson <tomh@tomh.org>
parents:
diff
changeset
|
201 |
m_rate = rate; |
736919bd4874
Add src/common/error-model implementation and example script, and add to NetDevices
Tom Henderson <tomh@tomh.org>
parents:
diff
changeset
|
202 |
} |
736919bd4874
Add src/common/error-model implementation and example script, and add to NetDevices
Tom Henderson <tomh@tomh.org>
parents:
diff
changeset
|
203 |
|
736919bd4874
Add src/common/error-model implementation and example script, and add to NetDevices
Tom Henderson <tomh@tomh.org>
parents:
diff
changeset
|
204 |
void |
8986
3391f6a7fb3b
Replace src/network usage of RandomVariable with RandomVariableStream
Mitch Watrous
parents:
7876
diff
changeset
|
205 |
RateErrorModel::SetRandomVariable (Ptr<RandomVariableStream> ranvar) |
1820
736919bd4874
Add src/common/error-model implementation and example script, and add to NetDevices
Tom Henderson <tomh@tomh.org>
parents:
diff
changeset
|
206 |
{ |
2983
e3a416fe9dd5
NS_LOG_FUNCTION -> NS_LOG_FUNCTION_NOARGS and NS_LOG_PARAMS -> NS_LOG_FUNCTION
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2602
diff
changeset
|
207 |
NS_LOG_FUNCTION_NOARGS (); |
2383
a0e0ec096169
bug 133: automate RandomVariable memory management.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2254
diff
changeset
|
208 |
m_ranvar = ranvar; |
1820
736919bd4874
Add src/common/error-model implementation and example script, and add to NetDevices
Tom Henderson <tomh@tomh.org>
parents:
diff
changeset
|
209 |
} |
736919bd4874
Add src/common/error-model implementation and example script, and add to NetDevices
Tom Henderson <tomh@tomh.org>
parents:
diff
changeset
|
210 |
|
8986
3391f6a7fb3b
Replace src/network usage of RandomVariable with RandomVariableStream
Mitch Watrous
parents:
7876
diff
changeset
|
211 |
int64_t |
3391f6a7fb3b
Replace src/network usage of RandomVariable with RandomVariableStream
Mitch Watrous
parents:
7876
diff
changeset
|
212 |
RateErrorModel::AssignStreams (int64_t stream) |
3391f6a7fb3b
Replace src/network usage of RandomVariable with RandomVariableStream
Mitch Watrous
parents:
7876
diff
changeset
|
213 |
{ |
3391f6a7fb3b
Replace src/network usage of RandomVariable with RandomVariableStream
Mitch Watrous
parents:
7876
diff
changeset
|
214 |
m_ranvar->SetStream (stream); |
3391f6a7fb3b
Replace src/network usage of RandomVariable with RandomVariableStream
Mitch Watrous
parents:
7876
diff
changeset
|
215 |
return 1; |
3391f6a7fb3b
Replace src/network usage of RandomVariable with RandomVariableStream
Mitch Watrous
parents:
7876
diff
changeset
|
216 |
} |
3391f6a7fb3b
Replace src/network usage of RandomVariable with RandomVariableStream
Mitch Watrous
parents:
7876
diff
changeset
|
217 |
|
1820
736919bd4874
Add src/common/error-model implementation and example script, and add to NetDevices
Tom Henderson <tomh@tomh.org>
parents:
diff
changeset
|
218 |
bool |
1870 | 219 |
RateErrorModel::DoCorrupt (Ptr<Packet> p) |
1820
736919bd4874
Add src/common/error-model implementation and example script, and add to NetDevices
Tom Henderson <tomh@tomh.org>
parents:
diff
changeset
|
220 |
{ |
2983
e3a416fe9dd5
NS_LOG_FUNCTION -> NS_LOG_FUNCTION_NOARGS and NS_LOG_PARAMS -> NS_LOG_FUNCTION
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2602
diff
changeset
|
221 |
NS_LOG_FUNCTION_NOARGS (); |
3371
e472358ea634
do not make m_enable protected
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2989
diff
changeset
|
222 |
if (!IsEnabled ()) |
1820
736919bd4874
Add src/common/error-model implementation and example script, and add to NetDevices
Tom Henderson <tomh@tomh.org>
parents:
diff
changeset
|
223 |
{ |
7182
5ecfee5d17de
network coding style changes
Josh Pelkey <jpelkey@gatech.edu>
parents:
6823
diff
changeset
|
224 |
return false; |
1820
736919bd4874
Add src/common/error-model implementation and example script, and add to NetDevices
Tom Henderson <tomh@tomh.org>
parents:
diff
changeset
|
225 |
} |
736919bd4874
Add src/common/error-model implementation and example script, and add to NetDevices
Tom Henderson <tomh@tomh.org>
parents:
diff
changeset
|
226 |
switch (m_unit) |
736919bd4874
Add src/common/error-model implementation and example script, and add to NetDevices
Tom Henderson <tomh@tomh.org>
parents:
diff
changeset
|
227 |
{ |
7871
94986f4b94b1
Use longer names for QueueMode and ErrorUnit enums and move them to Queue and RateErrorModel classes respectively.
Vedran Mileti? <rivanvx@gmail.com>
parents:
7386
diff
changeset
|
228 |
case ERROR_UNIT_PACKET: |
1820
736919bd4874
Add src/common/error-model implementation and example script, and add to NetDevices
Tom Henderson <tomh@tomh.org>
parents:
diff
changeset
|
229 |
return DoCorruptPkt (p); |
7871
94986f4b94b1
Use longer names for QueueMode and ErrorUnit enums and move them to Queue and RateErrorModel classes respectively.
Vedran Mileti? <rivanvx@gmail.com>
parents:
7386
diff
changeset
|
230 |
case ERROR_UNIT_BYTE: |
1820
736919bd4874
Add src/common/error-model implementation and example script, and add to NetDevices
Tom Henderson <tomh@tomh.org>
parents:
diff
changeset
|
231 |
return DoCorruptByte (p); |
7871
94986f4b94b1
Use longer names for QueueMode and ErrorUnit enums and move them to Queue and RateErrorModel classes respectively.
Vedran Mileti? <rivanvx@gmail.com>
parents:
7386
diff
changeset
|
232 |
case ERROR_UNIT_BIT: |
1820
736919bd4874
Add src/common/error-model implementation and example script, and add to NetDevices
Tom Henderson <tomh@tomh.org>
parents:
diff
changeset
|
233 |
return DoCorruptBit (p); |
736919bd4874
Add src/common/error-model implementation and example script, and add to NetDevices
Tom Henderson <tomh@tomh.org>
parents:
diff
changeset
|
234 |
default: |
736919bd4874
Add src/common/error-model implementation and example script, and add to NetDevices
Tom Henderson <tomh@tomh.org>
parents:
diff
changeset
|
235 |
NS_ASSERT_MSG (false, "m_unit not supported yet"); |
736919bd4874
Add src/common/error-model implementation and example script, and add to NetDevices
Tom Henderson <tomh@tomh.org>
parents:
diff
changeset
|
236 |
break; |
736919bd4874
Add src/common/error-model implementation and example script, and add to NetDevices
Tom Henderson <tomh@tomh.org>
parents:
diff
changeset
|
237 |
} |
736919bd4874
Add src/common/error-model implementation and example script, and add to NetDevices
Tom Henderson <tomh@tomh.org>
parents:
diff
changeset
|
238 |
return false; |
736919bd4874
Add src/common/error-model implementation and example script, and add to NetDevices
Tom Henderson <tomh@tomh.org>
parents:
diff
changeset
|
239 |
} |
736919bd4874
Add src/common/error-model implementation and example script, and add to NetDevices
Tom Henderson <tomh@tomh.org>
parents:
diff
changeset
|
240 |
|
736919bd4874
Add src/common/error-model implementation and example script, and add to NetDevices
Tom Henderson <tomh@tomh.org>
parents:
diff
changeset
|
241 |
bool |
1870 | 242 |
RateErrorModel::DoCorruptPkt (Ptr<Packet> p) |
1820
736919bd4874
Add src/common/error-model implementation and example script, and add to NetDevices
Tom Henderson <tomh@tomh.org>
parents:
diff
changeset
|
243 |
{ |
2983
e3a416fe9dd5
NS_LOG_FUNCTION -> NS_LOG_FUNCTION_NOARGS and NS_LOG_PARAMS -> NS_LOG_FUNCTION
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2602
diff
changeset
|
244 |
NS_LOG_FUNCTION_NOARGS (); |
8986
3391f6a7fb3b
Replace src/network usage of RandomVariable with RandomVariableStream
Mitch Watrous
parents:
7876
diff
changeset
|
245 |
return (m_ranvar->GetValue () < m_rate); |
1820
736919bd4874
Add src/common/error-model implementation and example script, and add to NetDevices
Tom Henderson <tomh@tomh.org>
parents:
diff
changeset
|
246 |
} |
736919bd4874
Add src/common/error-model implementation and example script, and add to NetDevices
Tom Henderson <tomh@tomh.org>
parents:
diff
changeset
|
247 |
|
736919bd4874
Add src/common/error-model implementation and example script, and add to NetDevices
Tom Henderson <tomh@tomh.org>
parents:
diff
changeset
|
248 |
bool |
1870 | 249 |
RateErrorModel::DoCorruptByte (Ptr<Packet> p) |
1820
736919bd4874
Add src/common/error-model implementation and example script, and add to NetDevices
Tom Henderson <tomh@tomh.org>
parents:
diff
changeset
|
250 |
{ |
2983
e3a416fe9dd5
NS_LOG_FUNCTION -> NS_LOG_FUNCTION_NOARGS and NS_LOG_PARAMS -> NS_LOG_FUNCTION
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2602
diff
changeset
|
251 |
NS_LOG_FUNCTION_NOARGS (); |
1820
736919bd4874
Add src/common/error-model implementation and example script, and add to NetDevices
Tom Henderson <tomh@tomh.org>
parents:
diff
changeset
|
252 |
// compute pkt error rate, assume uniformly distributed byte error |
9063
32755d0516f4
Bug 1237 - code cleanups related to includes
Vedran Mileti? <rivanvx@gmail.com>
parents:
8996
diff
changeset
|
253 |
double per = 1 - std::pow (1.0 - m_rate, p->GetSize ()); |
8986
3391f6a7fb3b
Replace src/network usage of RandomVariable with RandomVariableStream
Mitch Watrous
parents:
7876
diff
changeset
|
254 |
return (m_ranvar->GetValue () < per); |
1820
736919bd4874
Add src/common/error-model implementation and example script, and add to NetDevices
Tom Henderson <tomh@tomh.org>
parents:
diff
changeset
|
255 |
} |
736919bd4874
Add src/common/error-model implementation and example script, and add to NetDevices
Tom Henderson <tomh@tomh.org>
parents:
diff
changeset
|
256 |
|
736919bd4874
Add src/common/error-model implementation and example script, and add to NetDevices
Tom Henderson <tomh@tomh.org>
parents:
diff
changeset
|
257 |
bool |
7256
b04ba6772f8c
rerun check-style.py at default level to enforce space after function name
Tom Henderson <tomh@tomh.org>
parents:
7182
diff
changeset
|
258 |
RateErrorModel::DoCorruptBit (Ptr<Packet> p) |
1820
736919bd4874
Add src/common/error-model implementation and example script, and add to NetDevices
Tom Henderson <tomh@tomh.org>
parents:
diff
changeset
|
259 |
{ |
2983
e3a416fe9dd5
NS_LOG_FUNCTION -> NS_LOG_FUNCTION_NOARGS and NS_LOG_PARAMS -> NS_LOG_FUNCTION
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2602
diff
changeset
|
260 |
NS_LOG_FUNCTION_NOARGS (); |
1820
736919bd4874
Add src/common/error-model implementation and example script, and add to NetDevices
Tom Henderson <tomh@tomh.org>
parents:
diff
changeset
|
261 |
// compute pkt error rate, assume uniformly distributed bit error |
9063
32755d0516f4
Bug 1237 - code cleanups related to includes
Vedran Mileti? <rivanvx@gmail.com>
parents:
8996
diff
changeset
|
262 |
double per = 1 - std::pow (1.0 - m_rate, (8 * p->GetSize ()) ); |
8986
3391f6a7fb3b
Replace src/network usage of RandomVariable with RandomVariableStream
Mitch Watrous
parents:
7876
diff
changeset
|
263 |
return (m_ranvar->GetValue () < per); |
1820
736919bd4874
Add src/common/error-model implementation and example script, and add to NetDevices
Tom Henderson <tomh@tomh.org>
parents:
diff
changeset
|
264 |
} |
736919bd4874
Add src/common/error-model implementation and example script, and add to NetDevices
Tom Henderson <tomh@tomh.org>
parents:
diff
changeset
|
265 |
|
736919bd4874
Add src/common/error-model implementation and example script, and add to NetDevices
Tom Henderson <tomh@tomh.org>
parents:
diff
changeset
|
266 |
void |
736919bd4874
Add src/common/error-model implementation and example script, and add to NetDevices
Tom Henderson <tomh@tomh.org>
parents:
diff
changeset
|
267 |
RateErrorModel::DoReset (void) |
736919bd4874
Add src/common/error-model implementation and example script, and add to NetDevices
Tom Henderson <tomh@tomh.org>
parents:
diff
changeset
|
268 |
{ |
2983
e3a416fe9dd5
NS_LOG_FUNCTION -> NS_LOG_FUNCTION_NOARGS and NS_LOG_PARAMS -> NS_LOG_FUNCTION
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2602
diff
changeset
|
269 |
NS_LOG_FUNCTION_NOARGS (); |
1820
736919bd4874
Add src/common/error-model implementation and example script, and add to NetDevices
Tom Henderson <tomh@tomh.org>
parents:
diff
changeset
|
270 |
/* re-initialize any state; no-op for now */ |
736919bd4874
Add src/common/error-model implementation and example script, and add to NetDevices
Tom Henderson <tomh@tomh.org>
parents:
diff
changeset
|
271 |
} |
736919bd4874
Add src/common/error-model implementation and example script, and add to NetDevices
Tom Henderson <tomh@tomh.org>
parents:
diff
changeset
|
272 |
|
736919bd4874
Add src/common/error-model implementation and example script, and add to NetDevices
Tom Henderson <tomh@tomh.org>
parents:
diff
changeset
|
273 |
// |
736919bd4874
Add src/common/error-model implementation and example script, and add to NetDevices
Tom Henderson <tomh@tomh.org>
parents:
diff
changeset
|
274 |
// ListErrorModel |
736919bd4874
Add src/common/error-model implementation and example script, and add to NetDevices
Tom Henderson <tomh@tomh.org>
parents:
diff
changeset
|
275 |
// |
736919bd4874
Add src/common/error-model implementation and example script, and add to NetDevices
Tom Henderson <tomh@tomh.org>
parents:
diff
changeset
|
276 |
|
2249
3a1da26d61dc
replace ComponentManager::Create and ClassId with InterfaceId::CreateObjest and InterfaceId
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2238
diff
changeset
|
277 |
NS_OBJECT_ENSURE_REGISTERED (ListErrorModel); |
1820
736919bd4874
Add src/common/error-model implementation and example script, and add to NetDevices
Tom Henderson <tomh@tomh.org>
parents:
diff
changeset
|
278 |
|
2251
04963d8cca51
iid (void) -> GetTypeId (void)
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2250
diff
changeset
|
279 |
TypeId ListErrorModel::GetTypeId (void) |
2232
9abd038ee588
replace static const Interface iid; with static InterfaceId iid (void);
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2230
diff
changeset
|
280 |
{ |
2602
d9262bff6df2
add back support for introspected doxygen.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2503
diff
changeset
|
281 |
static TypeId tid = TypeId ("ns3::ListErrorModel") |
2249
3a1da26d61dc
replace ComponentManager::Create and ClassId with InterfaceId::CreateObjest and InterfaceId
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2238
diff
changeset
|
282 |
.SetParent<ErrorModel> () |
2481
8db62d9a69fd
use Attributes in ErrorModel.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2402
diff
changeset
|
283 |
.AddConstructor<ListErrorModel> () |
7182
5ecfee5d17de
network coding style changes
Josh Pelkey <jpelkey@gatech.edu>
parents:
6823
diff
changeset
|
284 |
; |
2252
80595448707a
iid -> tid
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2251
diff
changeset
|
285 |
return tid; |
2232
9abd038ee588
replace static const Interface iid; with static InterfaceId iid (void);
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2230
diff
changeset
|
286 |
} |
1820
736919bd4874
Add src/common/error-model implementation and example script, and add to NetDevices
Tom Henderson <tomh@tomh.org>
parents:
diff
changeset
|
287 |
|
7182
5ecfee5d17de
network coding style changes
Josh Pelkey <jpelkey@gatech.edu>
parents:
6823
diff
changeset
|
288 |
ListErrorModel::ListErrorModel () |
1820
736919bd4874
Add src/common/error-model implementation and example script, and add to NetDevices
Tom Henderson <tomh@tomh.org>
parents:
diff
changeset
|
289 |
{ |
2983
e3a416fe9dd5
NS_LOG_FUNCTION -> NS_LOG_FUNCTION_NOARGS and NS_LOG_PARAMS -> NS_LOG_FUNCTION
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2602
diff
changeset
|
290 |
NS_LOG_FUNCTION_NOARGS (); |
1820
736919bd4874
Add src/common/error-model implementation and example script, and add to NetDevices
Tom Henderson <tomh@tomh.org>
parents:
diff
changeset
|
291 |
} |
736919bd4874
Add src/common/error-model implementation and example script, and add to NetDevices
Tom Henderson <tomh@tomh.org>
parents:
diff
changeset
|
292 |
|
736919bd4874
Add src/common/error-model implementation and example script, and add to NetDevices
Tom Henderson <tomh@tomh.org>
parents:
diff
changeset
|
293 |
ListErrorModel::~ListErrorModel () |
736919bd4874
Add src/common/error-model implementation and example script, and add to NetDevices
Tom Henderson <tomh@tomh.org>
parents:
diff
changeset
|
294 |
{ |
2983
e3a416fe9dd5
NS_LOG_FUNCTION -> NS_LOG_FUNCTION_NOARGS and NS_LOG_PARAMS -> NS_LOG_FUNCTION
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2602
diff
changeset
|
295 |
NS_LOG_FUNCTION_NOARGS (); |
1820
736919bd4874
Add src/common/error-model implementation and example script, and add to NetDevices
Tom Henderson <tomh@tomh.org>
parents:
diff
changeset
|
296 |
} |
736919bd4874
Add src/common/error-model implementation and example script, and add to NetDevices
Tom Henderson <tomh@tomh.org>
parents:
diff
changeset
|
297 |
|
736919bd4874
Add src/common/error-model implementation and example script, and add to NetDevices
Tom Henderson <tomh@tomh.org>
parents:
diff
changeset
|
298 |
std::list<uint32_t> |
736919bd4874
Add src/common/error-model implementation and example script, and add to NetDevices
Tom Henderson <tomh@tomh.org>
parents:
diff
changeset
|
299 |
ListErrorModel::GetList (void) const |
736919bd4874
Add src/common/error-model implementation and example script, and add to NetDevices
Tom Henderson <tomh@tomh.org>
parents:
diff
changeset
|
300 |
{ |
2983
e3a416fe9dd5
NS_LOG_FUNCTION -> NS_LOG_FUNCTION_NOARGS and NS_LOG_PARAMS -> NS_LOG_FUNCTION
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2602
diff
changeset
|
301 |
NS_LOG_FUNCTION_NOARGS (); |
1820
736919bd4874
Add src/common/error-model implementation and example script, and add to NetDevices
Tom Henderson <tomh@tomh.org>
parents:
diff
changeset
|
302 |
return m_packetList; |
736919bd4874
Add src/common/error-model implementation and example script, and add to NetDevices
Tom Henderson <tomh@tomh.org>
parents:
diff
changeset
|
303 |
} |
736919bd4874
Add src/common/error-model implementation and example script, and add to NetDevices
Tom Henderson <tomh@tomh.org>
parents:
diff
changeset
|
304 |
|
736919bd4874
Add src/common/error-model implementation and example script, and add to NetDevices
Tom Henderson <tomh@tomh.org>
parents:
diff
changeset
|
305 |
void |
736919bd4874
Add src/common/error-model implementation and example script, and add to NetDevices
Tom Henderson <tomh@tomh.org>
parents:
diff
changeset
|
306 |
ListErrorModel::SetList (const std::list<uint32_t> &packetlist) |
736919bd4874
Add src/common/error-model implementation and example script, and add to NetDevices
Tom Henderson <tomh@tomh.org>
parents:
diff
changeset
|
307 |
{ |
2983
e3a416fe9dd5
NS_LOG_FUNCTION -> NS_LOG_FUNCTION_NOARGS and NS_LOG_PARAMS -> NS_LOG_FUNCTION
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2602
diff
changeset
|
308 |
NS_LOG_FUNCTION_NOARGS (); |
1820
736919bd4874
Add src/common/error-model implementation and example script, and add to NetDevices
Tom Henderson <tomh@tomh.org>
parents:
diff
changeset
|
309 |
m_packetList = packetlist; |
736919bd4874
Add src/common/error-model implementation and example script, and add to NetDevices
Tom Henderson <tomh@tomh.org>
parents:
diff
changeset
|
310 |
} |
736919bd4874
Add src/common/error-model implementation and example script, and add to NetDevices
Tom Henderson <tomh@tomh.org>
parents:
diff
changeset
|
311 |
|
736919bd4874
Add src/common/error-model implementation and example script, and add to NetDevices
Tom Henderson <tomh@tomh.org>
parents:
diff
changeset
|
312 |
// When performance becomes a concern, the list provided could be |
736919bd4874
Add src/common/error-model implementation and example script, and add to NetDevices
Tom Henderson <tomh@tomh.org>
parents:
diff
changeset
|
313 |
// converted to a dynamically-sized array of uint32_t to avoid |
736919bd4874
Add src/common/error-model implementation and example script, and add to NetDevices
Tom Henderson <tomh@tomh.org>
parents:
diff
changeset
|
314 |
// list iteration below. |
736919bd4874
Add src/common/error-model implementation and example script, and add to NetDevices
Tom Henderson <tomh@tomh.org>
parents:
diff
changeset
|
315 |
bool |
1870 | 316 |
ListErrorModel::DoCorrupt (Ptr<Packet> p) |
1820
736919bd4874
Add src/common/error-model implementation and example script, and add to NetDevices
Tom Henderson <tomh@tomh.org>
parents:
diff
changeset
|
317 |
{ |
2983
e3a416fe9dd5
NS_LOG_FUNCTION -> NS_LOG_FUNCTION_NOARGS and NS_LOG_PARAMS -> NS_LOG_FUNCTION
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2602
diff
changeset
|
318 |
NS_LOG_FUNCTION_NOARGS (); |
3371
e472358ea634
do not make m_enable protected
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2989
diff
changeset
|
319 |
if (!IsEnabled ()) |
1820
736919bd4874
Add src/common/error-model implementation and example script, and add to NetDevices
Tom Henderson <tomh@tomh.org>
parents:
diff
changeset
|
320 |
{ |
7182
5ecfee5d17de
network coding style changes
Josh Pelkey <jpelkey@gatech.edu>
parents:
6823
diff
changeset
|
321 |
return false; |
1820
736919bd4874
Add src/common/error-model implementation and example script, and add to NetDevices
Tom Henderson <tomh@tomh.org>
parents:
diff
changeset
|
322 |
} |
1870 | 323 |
uint32_t uid = p->GetUid (); |
1820
736919bd4874
Add src/common/error-model implementation and example script, and add to NetDevices
Tom Henderson <tomh@tomh.org>
parents:
diff
changeset
|
324 |
for (PacketListCI i = m_packetList.begin (); |
7182
5ecfee5d17de
network coding style changes
Josh Pelkey <jpelkey@gatech.edu>
parents:
6823
diff
changeset
|
325 |
i != m_packetList.end (); i++) |
1820
736919bd4874
Add src/common/error-model implementation and example script, and add to NetDevices
Tom Henderson <tomh@tomh.org>
parents:
diff
changeset
|
326 |
{ |
736919bd4874
Add src/common/error-model implementation and example script, and add to NetDevices
Tom Henderson <tomh@tomh.org>
parents:
diff
changeset
|
327 |
if (uid == *i) |
7182
5ecfee5d17de
network coding style changes
Josh Pelkey <jpelkey@gatech.edu>
parents:
6823
diff
changeset
|
328 |
{ |
5ecfee5d17de
network coding style changes
Josh Pelkey <jpelkey@gatech.edu>
parents:
6823
diff
changeset
|
329 |
return true; |
5ecfee5d17de
network coding style changes
Josh Pelkey <jpelkey@gatech.edu>
parents:
6823
diff
changeset
|
330 |
} |
1820
736919bd4874
Add src/common/error-model implementation and example script, and add to NetDevices
Tom Henderson <tomh@tomh.org>
parents:
diff
changeset
|
331 |
} |
736919bd4874
Add src/common/error-model implementation and example script, and add to NetDevices
Tom Henderson <tomh@tomh.org>
parents:
diff
changeset
|
332 |
return false; |
736919bd4874
Add src/common/error-model implementation and example script, and add to NetDevices
Tom Henderson <tomh@tomh.org>
parents:
diff
changeset
|
333 |
} |
736919bd4874
Add src/common/error-model implementation and example script, and add to NetDevices
Tom Henderson <tomh@tomh.org>
parents:
diff
changeset
|
334 |
|
736919bd4874
Add src/common/error-model implementation and example script, and add to NetDevices
Tom Henderson <tomh@tomh.org>
parents:
diff
changeset
|
335 |
void |
736919bd4874
Add src/common/error-model implementation and example script, and add to NetDevices
Tom Henderson <tomh@tomh.org>
parents:
diff
changeset
|
336 |
ListErrorModel::DoReset (void) |
736919bd4874
Add src/common/error-model implementation and example script, and add to NetDevices
Tom Henderson <tomh@tomh.org>
parents:
diff
changeset
|
337 |
{ |
2983
e3a416fe9dd5
NS_LOG_FUNCTION -> NS_LOG_FUNCTION_NOARGS and NS_LOG_PARAMS -> NS_LOG_FUNCTION
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2602
diff
changeset
|
338 |
NS_LOG_FUNCTION_NOARGS (); |
7256
b04ba6772f8c
rerun check-style.py at default level to enforce space after function name
Tom Henderson <tomh@tomh.org>
parents:
7182
diff
changeset
|
339 |
m_packetList.clear (); |
1820
736919bd4874
Add src/common/error-model implementation and example script, and add to NetDevices
Tom Henderson <tomh@tomh.org>
parents:
diff
changeset
|
340 |
} |
736919bd4874
Add src/common/error-model implementation and example script, and add to NetDevices
Tom Henderson <tomh@tomh.org>
parents:
diff
changeset
|
341 |
|
6288
1bc85b014aaf
move receive-list-error-model to src/common/error-model
Josh Pelkey <jpelkey@gatech.edu>
parents:
3371
diff
changeset
|
342 |
// |
1bc85b014aaf
move receive-list-error-model to src/common/error-model
Josh Pelkey <jpelkey@gatech.edu>
parents:
3371
diff
changeset
|
343 |
// ReceiveListErrorModel |
1bc85b014aaf
move receive-list-error-model to src/common/error-model
Josh Pelkey <jpelkey@gatech.edu>
parents:
3371
diff
changeset
|
344 |
// |
1bc85b014aaf
move receive-list-error-model to src/common/error-model
Josh Pelkey <jpelkey@gatech.edu>
parents:
3371
diff
changeset
|
345 |
|
1bc85b014aaf
move receive-list-error-model to src/common/error-model
Josh Pelkey <jpelkey@gatech.edu>
parents:
3371
diff
changeset
|
346 |
NS_OBJECT_ENSURE_REGISTERED (ReceiveListErrorModel); |
1bc85b014aaf
move receive-list-error-model to src/common/error-model
Josh Pelkey <jpelkey@gatech.edu>
parents:
3371
diff
changeset
|
347 |
|
1bc85b014aaf
move receive-list-error-model to src/common/error-model
Josh Pelkey <jpelkey@gatech.edu>
parents:
3371
diff
changeset
|
348 |
TypeId ReceiveListErrorModel::GetTypeId (void) |
1bc85b014aaf
move receive-list-error-model to src/common/error-model
Josh Pelkey <jpelkey@gatech.edu>
parents:
3371
diff
changeset
|
349 |
{ |
1bc85b014aaf
move receive-list-error-model to src/common/error-model
Josh Pelkey <jpelkey@gatech.edu>
parents:
3371
diff
changeset
|
350 |
static TypeId tid = TypeId ("ns3::ReceiveListErrorModel") |
1bc85b014aaf
move receive-list-error-model to src/common/error-model
Josh Pelkey <jpelkey@gatech.edu>
parents:
3371
diff
changeset
|
351 |
.SetParent<ErrorModel> () |
1bc85b014aaf
move receive-list-error-model to src/common/error-model
Josh Pelkey <jpelkey@gatech.edu>
parents:
3371
diff
changeset
|
352 |
.AddConstructor<ReceiveListErrorModel> () |
7182
5ecfee5d17de
network coding style changes
Josh Pelkey <jpelkey@gatech.edu>
parents:
6823
diff
changeset
|
353 |
; |
6288
1bc85b014aaf
move receive-list-error-model to src/common/error-model
Josh Pelkey <jpelkey@gatech.edu>
parents:
3371
diff
changeset
|
354 |
return tid; |
1bc85b014aaf
move receive-list-error-model to src/common/error-model
Josh Pelkey <jpelkey@gatech.edu>
parents:
3371
diff
changeset
|
355 |
} |
1bc85b014aaf
move receive-list-error-model to src/common/error-model
Josh Pelkey <jpelkey@gatech.edu>
parents:
3371
diff
changeset
|
356 |
|
1bc85b014aaf
move receive-list-error-model to src/common/error-model
Josh Pelkey <jpelkey@gatech.edu>
parents:
3371
diff
changeset
|
357 |
|
1bc85b014aaf
move receive-list-error-model to src/common/error-model
Josh Pelkey <jpelkey@gatech.edu>
parents:
3371
diff
changeset
|
358 |
ReceiveListErrorModel::ReceiveListErrorModel () : |
1bc85b014aaf
move receive-list-error-model to src/common/error-model
Josh Pelkey <jpelkey@gatech.edu>
parents:
3371
diff
changeset
|
359 |
m_timesInvoked (0) |
1bc85b014aaf
move receive-list-error-model to src/common/error-model
Josh Pelkey <jpelkey@gatech.edu>
parents:
3371
diff
changeset
|
360 |
{ |
1bc85b014aaf
move receive-list-error-model to src/common/error-model
Josh Pelkey <jpelkey@gatech.edu>
parents:
3371
diff
changeset
|
361 |
NS_LOG_FUNCTION_NOARGS (); |
1bc85b014aaf
move receive-list-error-model to src/common/error-model
Josh Pelkey <jpelkey@gatech.edu>
parents:
3371
diff
changeset
|
362 |
} |
1bc85b014aaf
move receive-list-error-model to src/common/error-model
Josh Pelkey <jpelkey@gatech.edu>
parents:
3371
diff
changeset
|
363 |
|
1bc85b014aaf
move receive-list-error-model to src/common/error-model
Josh Pelkey <jpelkey@gatech.edu>
parents:
3371
diff
changeset
|
364 |
ReceiveListErrorModel::~ReceiveListErrorModel () |
1bc85b014aaf
move receive-list-error-model to src/common/error-model
Josh Pelkey <jpelkey@gatech.edu>
parents:
3371
diff
changeset
|
365 |
{ |
1bc85b014aaf
move receive-list-error-model to src/common/error-model
Josh Pelkey <jpelkey@gatech.edu>
parents:
3371
diff
changeset
|
366 |
NS_LOG_FUNCTION_NOARGS (); |
1bc85b014aaf
move receive-list-error-model to src/common/error-model
Josh Pelkey <jpelkey@gatech.edu>
parents:
3371
diff
changeset
|
367 |
} |
1bc85b014aaf
move receive-list-error-model to src/common/error-model
Josh Pelkey <jpelkey@gatech.edu>
parents:
3371
diff
changeset
|
368 |
|
1bc85b014aaf
move receive-list-error-model to src/common/error-model
Josh Pelkey <jpelkey@gatech.edu>
parents:
3371
diff
changeset
|
369 |
std::list<uint32_t> |
1bc85b014aaf
move receive-list-error-model to src/common/error-model
Josh Pelkey <jpelkey@gatech.edu>
parents:
3371
diff
changeset
|
370 |
ReceiveListErrorModel::GetList (void) const |
1bc85b014aaf
move receive-list-error-model to src/common/error-model
Josh Pelkey <jpelkey@gatech.edu>
parents:
3371
diff
changeset
|
371 |
{ |
1bc85b014aaf
move receive-list-error-model to src/common/error-model
Josh Pelkey <jpelkey@gatech.edu>
parents:
3371
diff
changeset
|
372 |
NS_LOG_FUNCTION_NOARGS (); |
1bc85b014aaf
move receive-list-error-model to src/common/error-model
Josh Pelkey <jpelkey@gatech.edu>
parents:
3371
diff
changeset
|
373 |
return m_packetList; |
1bc85b014aaf
move receive-list-error-model to src/common/error-model
Josh Pelkey <jpelkey@gatech.edu>
parents:
3371
diff
changeset
|
374 |
} |
1bc85b014aaf
move receive-list-error-model to src/common/error-model
Josh Pelkey <jpelkey@gatech.edu>
parents:
3371
diff
changeset
|
375 |
|
1bc85b014aaf
move receive-list-error-model to src/common/error-model
Josh Pelkey <jpelkey@gatech.edu>
parents:
3371
diff
changeset
|
376 |
void |
1bc85b014aaf
move receive-list-error-model to src/common/error-model
Josh Pelkey <jpelkey@gatech.edu>
parents:
3371
diff
changeset
|
377 |
ReceiveListErrorModel::SetList (const std::list<uint32_t> &packetlist) |
1bc85b014aaf
move receive-list-error-model to src/common/error-model
Josh Pelkey <jpelkey@gatech.edu>
parents:
3371
diff
changeset
|
378 |
{ |
1bc85b014aaf
move receive-list-error-model to src/common/error-model
Josh Pelkey <jpelkey@gatech.edu>
parents:
3371
diff
changeset
|
379 |
NS_LOG_FUNCTION_NOARGS (); |
1bc85b014aaf
move receive-list-error-model to src/common/error-model
Josh Pelkey <jpelkey@gatech.edu>
parents:
3371
diff
changeset
|
380 |
m_packetList = packetlist; |
1bc85b014aaf
move receive-list-error-model to src/common/error-model
Josh Pelkey <jpelkey@gatech.edu>
parents:
3371
diff
changeset
|
381 |
} |
1bc85b014aaf
move receive-list-error-model to src/common/error-model
Josh Pelkey <jpelkey@gatech.edu>
parents:
3371
diff
changeset
|
382 |
|
1bc85b014aaf
move receive-list-error-model to src/common/error-model
Josh Pelkey <jpelkey@gatech.edu>
parents:
3371
diff
changeset
|
383 |
bool |
1bc85b014aaf
move receive-list-error-model to src/common/error-model
Josh Pelkey <jpelkey@gatech.edu>
parents:
3371
diff
changeset
|
384 |
ReceiveListErrorModel::DoCorrupt (Ptr<Packet> p) |
1bc85b014aaf
move receive-list-error-model to src/common/error-model
Josh Pelkey <jpelkey@gatech.edu>
parents:
3371
diff
changeset
|
385 |
{ |
1bc85b014aaf
move receive-list-error-model to src/common/error-model
Josh Pelkey <jpelkey@gatech.edu>
parents:
3371
diff
changeset
|
386 |
NS_LOG_FUNCTION_NOARGS (); |
1bc85b014aaf
move receive-list-error-model to src/common/error-model
Josh Pelkey <jpelkey@gatech.edu>
parents:
3371
diff
changeset
|
387 |
if (!IsEnabled ()) |
1bc85b014aaf
move receive-list-error-model to src/common/error-model
Josh Pelkey <jpelkey@gatech.edu>
parents:
3371
diff
changeset
|
388 |
{ |
7182
5ecfee5d17de
network coding style changes
Josh Pelkey <jpelkey@gatech.edu>
parents:
6823
diff
changeset
|
389 |
return false; |
6288
1bc85b014aaf
move receive-list-error-model to src/common/error-model
Josh Pelkey <jpelkey@gatech.edu>
parents:
3371
diff
changeset
|
390 |
} |
1bc85b014aaf
move receive-list-error-model to src/common/error-model
Josh Pelkey <jpelkey@gatech.edu>
parents:
3371
diff
changeset
|
391 |
m_timesInvoked += 1; |
1bc85b014aaf
move receive-list-error-model to src/common/error-model
Josh Pelkey <jpelkey@gatech.edu>
parents:
3371
diff
changeset
|
392 |
for (PacketListCI i = m_packetList.begin (); |
7182
5ecfee5d17de
network coding style changes
Josh Pelkey <jpelkey@gatech.edu>
parents:
6823
diff
changeset
|
393 |
i != m_packetList.end (); i++) |
6288
1bc85b014aaf
move receive-list-error-model to src/common/error-model
Josh Pelkey <jpelkey@gatech.edu>
parents:
3371
diff
changeset
|
394 |
{ |
1bc85b014aaf
move receive-list-error-model to src/common/error-model
Josh Pelkey <jpelkey@gatech.edu>
parents:
3371
diff
changeset
|
395 |
if (m_timesInvoked - 1 == *i) |
7182
5ecfee5d17de
network coding style changes
Josh Pelkey <jpelkey@gatech.edu>
parents:
6823
diff
changeset
|
396 |
{ |
5ecfee5d17de
network coding style changes
Josh Pelkey <jpelkey@gatech.edu>
parents:
6823
diff
changeset
|
397 |
return true; |
5ecfee5d17de
network coding style changes
Josh Pelkey <jpelkey@gatech.edu>
parents:
6823
diff
changeset
|
398 |
} |
6288
1bc85b014aaf
move receive-list-error-model to src/common/error-model
Josh Pelkey <jpelkey@gatech.edu>
parents:
3371
diff
changeset
|
399 |
} |
1bc85b014aaf
move receive-list-error-model to src/common/error-model
Josh Pelkey <jpelkey@gatech.edu>
parents:
3371
diff
changeset
|
400 |
return false; |
1bc85b014aaf
move receive-list-error-model to src/common/error-model
Josh Pelkey <jpelkey@gatech.edu>
parents:
3371
diff
changeset
|
401 |
} |
1bc85b014aaf
move receive-list-error-model to src/common/error-model
Josh Pelkey <jpelkey@gatech.edu>
parents:
3371
diff
changeset
|
402 |
|
1bc85b014aaf
move receive-list-error-model to src/common/error-model
Josh Pelkey <jpelkey@gatech.edu>
parents:
3371
diff
changeset
|
403 |
void |
1bc85b014aaf
move receive-list-error-model to src/common/error-model
Josh Pelkey <jpelkey@gatech.edu>
parents:
3371
diff
changeset
|
404 |
ReceiveListErrorModel::DoReset (void) |
1bc85b014aaf
move receive-list-error-model to src/common/error-model
Josh Pelkey <jpelkey@gatech.edu>
parents:
3371
diff
changeset
|
405 |
{ |
1bc85b014aaf
move receive-list-error-model to src/common/error-model
Josh Pelkey <jpelkey@gatech.edu>
parents:
3371
diff
changeset
|
406 |
NS_LOG_FUNCTION_NOARGS (); |
7256
b04ba6772f8c
rerun check-style.py at default level to enforce space after function name
Tom Henderson <tomh@tomh.org>
parents:
7182
diff
changeset
|
407 |
m_packetList.clear (); |
6288
1bc85b014aaf
move receive-list-error-model to src/common/error-model
Josh Pelkey <jpelkey@gatech.edu>
parents:
3371
diff
changeset
|
408 |
} |
1bc85b014aaf
move receive-list-error-model to src/common/error-model
Josh Pelkey <jpelkey@gatech.edu>
parents:
3371
diff
changeset
|
409 |
|
1820
736919bd4874
Add src/common/error-model implementation and example script, and add to NetDevices
Tom Henderson <tomh@tomh.org>
parents:
diff
changeset
|
410 |
|
7386
2310ed220a61
standardize ns-3 namespace declaration format
Vedran Mileti? <rivanvx@gmail.com>
parents:
7256
diff
changeset
|
411 |
} // namespace ns3 |